@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap');
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #0f0c29;
    --secondary-color: #302b63;
    --accent-color: #24243e;
    --text-color: #e0e0e0;
    --highlight-color: #ff0055;
    --bg-dark: #050505;
    --card-bg: rgba(255, 255, 255, 0.05);
}

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    background: radial-gradient(circle at center, var(--secondary-color) 0%, var(--bg-dark) 100%);
    color: var(--text-color);
    font-size: 2vh;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

#app {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 2vw;
    position: relative;
    z-index: 1;
}

/* Background elements */
.floating-element {
    position: fixed;
    width: 30vw;
    height: 30vw;
    background: radial-gradient(circle, var(--highlight-color) 0%, transparent 70%);
    filter: blur(100px);
    opacity: 0.1;
    pointer-events: none;
    animation: float 25s infinite alternate;
    z-index: 0;
}

@keyframes float {
    from { transform: translate(-20%, -20%); }
    to { transform: translate(120%, 120%); }
}

header {
    width: 100%;
    min-height: 10vh;
    height: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2vh 5vw;
    background: rgba(15, 12, 41, 0.9);
    backdrop-filter: blur(15px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100;
    position: relative;
}

#site-logo {
    height: auto !important;
    display: block;
    transition: transform 0.3s ease;
}

/* Global Button & Link Styling */
button, .btn, .btn-play, nav button, nav a, .sidebar button, .form-section button, table button, .modal-content button, .cms-card button {
    padding: 1.2vh 2vw;
    margin: 0.5vh;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 0.8vh;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
    color: white;
    text-decoration: none !important;
    font-size: 1.6vh;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-block;
    outline: none;
    font-weight: 600;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
}

button:hover, .btn:hover, .btn-play:hover, nav button:hover, nav a:hover, .sidebar button:hover, .form-section button:hover, table button:hover, .modal-content button:hover, .cms-card button:hover {
    background: var(--highlight-color);
    border-color: var(--highlight-color);
    box-shadow: 0 0 25px rgba(255, 0, 85, 0.6);
    transform: translateY(-3px) scale(1.02);
}

a {
    color: var(--highlight-color);
    text-decoration: none !important;
    transition: all 0.3s;
}

a:hover {
    opacity: 0.8;
    text-decoration: none !important;
}

/* Forms */
input, select, textarea {
    display: block;
    width: 100%;
    padding: 1.5vh;
    margin: 1vh 0 2vh 0;
    font-size: 1.8vh;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.8vh;
    outline: none;
    transition: border-color 0.3s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--highlight-color);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 15px rgba(255, 0, 85, 0.2);
}

label {
    display: block;
    margin-bottom: 0.5vh;
    font-size: 1.5vh;
    color: #aaa;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.92);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(12px);
}

.modal-content {
    background: linear-gradient(160deg, var(--primary-color) 0%, #050505 100%);
    padding: 6vh;
    border-radius: 2.5vh;
    width: 95%;
    max-width: 550px;
    border: 1px solid rgba(255, 0, 85, 0.4);
    box-shadow: 0 0 60px rgba(0, 0, 0, 1), 0 0 30px rgba(255, 0, 85, 0.2);
    position: relative;
    animation: modalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-content h2 {
    margin-bottom: 4vh;
    color: var(--highlight-color);
    text-transform: uppercase;
    letter-spacing: 4px;
    text-align: center;
    font-size: 3vh;
}

/* Rooms.php Layout Swap */
.rooms-layout {
    display: flex;
    flex-direction: row;
    gap: 3vw;
    margin: 0 auto;
    align-items: flex-start;
    justify-content: center;
    width: 90%;
    max-width: 1600px;
}

.room-list { flex: 0 0 50vw; order: 1; min-width: 0; }
.sidebar { flex: 0 0 25vw; order: 2; min-width: 300px; }

/* Vertical centering for main content areas */
main.container, main#app {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: calc(100vh - 80px - 100px); /* Subtract header and footer approx height */
    padding: 2vh 0;
}

.sidebar, .room-list, .form-section, .cms-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px);
    padding: 5vh;
    border-radius: 2.5vh;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

/* Footer Improvements */
footer {
    width: 100%;
    min-height: 12vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #000;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: auto;
    padding: 2vh 0;
    z-index: 10;
}

footer p {
    font-size: 1.4vh;
    color: #666;
    margin-bottom: 1vh;
}

footer .footer-links a {
    font-size: 1.5vh;
    color: #888 !important;
    text-decoration: none !important;
    margin: 0 1.5vw;
    transition: all 0.3s;
}

footer .footer-links a:hover {
    color: var(--highlight-color) !important;
    text-shadow: 0 0 10px var(--highlight-color);
}

/* CMS Dashboard */
.admin-container {
    padding: 6vh 5vw;
    max-width: 1400px;
    margin: 0 auto;
}

.cms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 3vh;
}

.cms-card h3 {
    margin-bottom: 3vh;
    color: var(--highlight-color);
    text-transform: uppercase;
    font-size: 2vh;
    border-bottom: 1px solid rgba(255, 0, 85, 0.2);
    padding-bottom: 1vh;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 1.5vh;
}

th {
    padding: 1.5vh 2vh;
    text-align: left;
    color: #666;
    text-transform: uppercase;
    font-size: 1.3vh;
    letter-spacing: 1px;
}

td {
    background: rgba(255, 255, 255, 0.02);
    padding: 2vh;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

tr:hover td {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

.table-responsive table {
    min-width: 600px;
}

td:first-child { border-radius: 1vh 0 0 1vh; border-left: 1px solid rgba(255, 255, 255, 0.03); }
td:last-child { border-radius: 0 1vh 1vh 0; border-right: 1px solid rgba(255, 255, 255, 0.03); }


/* Hero Section */
#hero {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    min-height: 70vh;
}

#hero p {
    font-size: 2.5vh;
    color: #aaa;
    margin-bottom: 4vh;
}

.btn-play {
    background: var(--highlight-color) !important;
    border-color: var(--highlight-color) !important;
    box-shadow: 0 0 20px rgba(255, 0, 85, 0.4);
    padding: 2vh 4vw !important;
    font-size: 2.2vh !important;
}

.btn-play:hover {
    box-shadow: 0 0 40px rgba(255, 0, 85, 0.8) !important;
    transform: translateY(-5px) scale(1.05) !important;
}

/* Responsive */
@media (max-width: 1100px) {
    .rooms-layout { flex-direction: column; }
    .sidebar { width: 100%; order: 1; margin-bottom: 3vh; }
    .room-list { width: 100%; order: 2; }
}

/* Lobby Styling */
.lobby-frame {
    border: 3px solid var(--highlight-color);
    border-radius: 2.5vh;
    padding: 4vh;
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 30px rgba(255, 0, 85, 0.2);
    margin-bottom: 5vh;
    width: 90vw;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

.lobby-top-bar {
    margin-bottom: 2vh;
    display: flex;
    justify-content: flex-start;
}

.btn-leave {
    background: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    font-size: 1.4vh !important;
    padding: 1vh 1.5vw !important;
}

.btn-leave:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: #fff !important;
    box-shadow: none !important;
}

.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3vh;
    padding-bottom: 2vh;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.lobby-content {
    display: flex;
    gap: 2vw;
    align-items: flex-start;
    flex-wrap: wrap;
}

#player-list {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 2vh;
}

/* Game Layout with Side Ranking */
.game-layout {
    display: flex;
    flex-direction: row;
    gap: 20px;
    align-items: stretch;
    width: 95%;
    max-width: 1400px;
    margin: 0 auto 3vh auto;
}

.game-frame {
    flex: 3;
    min-width: 0;
    border: 3px solid var(--highlight-color);
    border-radius: 2vh;
    padding: 0;
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 30px rgba(255, 0, 85, 0.2);
    display: flex;
    flex-direction: column;
    min-height: 50vh;
    max-height: 75vh;
    overflow: hidden;
}

.game-side-ranking {
    flex: 0 0 280px;
    background: rgba(15, 12, 41, 0.95);
    border: 1px solid rgba(255, 0, 85, 0.3);
    border-radius: 1.5vh;
    padding: 1vh;
    display: flex;
    flex-direction: column;
    max-height: 75vh;
    backdrop-filter: blur(10px);
}

.side-ranking-header {
    font-weight: bold;
    color: var(--highlight-color);
    border-bottom: 1px solid rgba(255, 0, 85, 0.2);
    padding-bottom: 1vh;
    margin-bottom: 2vh;
    display: flex;
    justify-content: space-between;
    align-items: center;
    letter-spacing: 2px;
}

.side-ranking-list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1vh;
}

.side-ranking-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1vh 1.5vh;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 1vh;
    transition: all 0.3s;
}

.side-ranking-item.masked {
    background: rgba(255, 0, 85, 0.2);
    border: 1px solid var(--highlight-color);
}

.side-player-info {
    display: flex;
    gap: 10px;
    align-items: center;
}

.rank-pos {
    opacity: 0.5;
    font-weight: bold;
    font-size: 1.4vh;
}

.rank-name {
    font-weight: 500;
}

.rank-points {
    color: var(--highlight-color);
    font-weight: bold;
}

/* Mobile specific podium and sidebar */
.mobile-only-podium {
    display: none;
    margin-left: auto !important;
    background: var(--highlight-color) !important;
    padding: 1vh 2vh !important;
}

.mobile-only {
    display: none;
}

@media (max-width: 992px) {
    .game-side-ranking {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        height: 100vh;
        max-height: 100vh;
        z-index: 1000;
        transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        border-radius: 0;
        border-left: 2px solid var(--highlight-color);
    }
    
    .game-side-ranking.open {
        right: 0;
    }
    
    .mobile-only-podium {
        display: block;
    }
    
    .mobile-only {
        display: block;
    }
    
    #close-mobile-ranking {
        background: transparent !important;
        border: none !important;
        color: #fff !important;
        font-size: 2.5vh !important;
        padding: 0 !important;
        margin: 0 !important;
        width: auto !important;
    }
}

.password-section {
    padding: 1vh 2vh;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.password-box {
    background: rgba(255, 0, 85, 0.1);
    border: 1px solid var(--highlight-color);
    padding: 0.5vh 1.5vw;
    border-radius: 0.8vh;
    font-weight: bold;
    font-size: 1.8vh;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1vh;
    overflow: hidden;
    position: relative;
}

.message-list {
    flex: 1;
    overflow-y: auto;
    padding: 1vh;
    display: flex;
    flex-direction: column;
    gap: 1vh;
}

.message {
    max-width: 75%;
    padding: 1vh 2vh;
    border-radius: 1.5vh;
    font-size: 1.6vh;
    line-height: 1.3;
    position: relative;
    word-break: break-word;
}

.message-other {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.07);
    border-bottom-left-radius: 0.5vh;
    color: #fff;
}

.message-own {
    align-self: flex-end;
    background: var(--highlight-color);
    border-bottom-right-radius: 0.5vh;
    color: #fff;
}

.message-info {
    font-size: 1.2vh;
    margin-bottom: 0.5vh;
    opacity: 0.6;
    font-weight: bold;
}

.message-own .message-info {
    text-align: right;
}

.game-input-area {
    padding: 1.5vh 2.5vh;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 1.5vw;
    align-items: center;
}

.game-input-area input {
    margin: 0;
    flex: 1;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.game-input-area.active-turn {
    background: rgba(0, 255, 136, 0.05);
}

.game-input-area.active-turn input {
    border-color: #00ff88;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.2);
}

.turn-timer {
    font-size: 3vh;
    font-weight: bold;
    color: var(--highlight-color);
    min-width: 60px;
    text-align: center;
}

.pre-game-overlay {
    text-align: center;
    padding: 4vh;
}

#understand-btn {
    background: var(--highlight-color);
    font-size: 2vh;
    padding: 1.5vh 4vw;
}

#pre-game-timer {
    font-size: 4vh;
    margin-top: 2vh;
    color: var(--highlight-color);
}

.player-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 2.5vh;
    border-radius: 1.5vh;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s;
}

.player-name {
    font-weight: bold;
    font-size: 2vh;
    margin-bottom: 0.5vh;
}

.player-points {
    font-size: 1.6vh;
    color: var(--highlight-color);
}

.player-item.ready {
    border-color: #00ff88;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.2);
    background: rgba(0, 255, 136, 0.05);
}

.settings-panel {
    width: 320px;
    background: rgba(255, 255, 255, 0.03);
    padding: 3vh;
    border-radius: 2vh;
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.settings-panel .form-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5vh;
}

.settings-panel label {
    margin-bottom: 0;
    font-size: 1.3vh;
}

.input-tiny {
    width: 80px !important;
    margin: 0 !important;
    padding: 0.8vh !important;
    text-align: center;
    font-size: 1.6vh !important;
}

.btn-small {
    padding: 1.2vh !important;
    font-size: 1.4vh !important;
    width: 100%;
    margin-top: 1vh;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1) !important;
}

#share-url {
    background: #000;
    color: var(--highlight-color);
    font-family: monospace;
    text-align: center;
}

@media (max-width: 768px) {
    .lobby-content { flex-direction: column; }
    .settings-panel { width: 100%; }
    .lobby-header { flex-direction: column; gap: 2vh; text-align: center; }
}

/* Tiles Grid */
.tiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 3vh;
    padding: 4vh;
    justify-content: center;
    width: 100%;
}

.tile {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 2vh;
    padding: 4vh 2vh;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    font-weight: bold;
    font-size: 2.2vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5vh;
    min-height: 18vh;
    justify-content: center;
}

.tile:hover {
    background: rgba(255, 0, 85, 0.1);
    border-color: var(--highlight-color);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(255, 0, 85, 0.2);
}

.tile.selected {
    background: rgba(255, 0, 85, 0.2);
    border-color: var(--highlight-color);
    box-shadow: 0 0 20px var(--highlight-color);
}

.tile .voter-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5vh;
    justify-content: center;
    margin-top: 1vh;
}

.tile .voter-badge {
    font-size: 1.1vh;
    background: var(--highlight-color);
    color: white;
    padding: 0.3vh 0.8vw;
    border-radius: 0.4vh;
    font-weight: normal;
    animation: badgePop 0.3s ease-out;
}

@keyframes badgePop {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Results view */
#ranking-list {
    display: flex;
    flex-direction: column;
    gap: 2vh;
    margin: 4vh 0;
}

.ranking-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 3vh;
    border-radius: 1.5vh;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 2vh;
}

.ranking-item.masked {
    border-color: var(--highlight-color);
    background: rgba(255, 0, 85, 0.05);
}

.ranking-item .points {
    color: var(--highlight-color);
    font-weight: bold;
    font-size: 2.2vh;
}

@media (max-width: 768px) {
    .tiles-grid { grid-template-columns: 1fr; }
    .password-section { flex-direction: column; gap: 2vh; text-align: center; }
    .game-input-area { flex-direction: column; gap: 1vh; }
    #move-timer { font-size: 4vh; }
}
