/* ── Variables ──────────────────────────────────────────────────── */
:root {
    --gold:          #d4af37;
    --gold-glow:     rgba(212,175,55,0.35);
    --dark:          #050508;
    --panel-bg:      #0d0d14;
    --panel-border:  rgba(255,255,255,0.11);
    --accent-blue:   #00c3ff;
    --accent-truth:  #7b5cfa;
    --accent-dare:   #ff5c7a;
    --transition:    0.25s;
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body, html {
    height: 100%; width: 100%;
    font-family: 'Montserrat', 'Arial', sans-serif;
    background: var(--dark);
    color: #fff;
    overflow: hidden;
    display: flex; justify-content: center; align-items: center; flex-direction: column;
}

/* ── Stars layer (canvas injected by JS) ────────────────────────── */
.stars {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0; pointer-events: none;
}

/* ── Splash screen ──────────────────────────────────────────────── */
.content {
    position: relative; z-index: 1; text-align: center;
    opacity: 0; animation: fadeIn 3s ease-in-out 1s forwards;
}
.line {
    width: 1px; height: 80px;
    background: linear-gradient(to bottom, var(--gold), transparent);
    margin: 40px auto; transform: scaleY(0); transform-origin: top;
    animation: growLine 2s ease-in-out 2s forwards;
}

/* ── Layouts ────────────────────────────────────────────────────── */
.container-centered {
    height: 100%; display: flex; flex-direction: column;
    justify-content: center; align-items: center; text-align: center;
    padding: 20px; position: relative; z-index: 1;
}

/* ── Lobby ──────────────────────────────────────────────────────── */
.lobby-content { color: #fff; }
.lobby-title {
    font-family: 'Cinzel', serif;
    font-size: clamp(2rem, 8vw, 3.8rem);
    font-weight: 400; color: var(--gold);
    letter-spacing: 10px; text-transform: uppercase;
    text-shadow: 0 0 30px var(--gold-glow);
    margin-bottom: 0.4rem;
}
.lobby-content h2 {
    font-size: 1rem; font-weight: 300;
    color: rgba(255,255,255,0.65); margin-bottom: 0.2rem; letter-spacing: 2px;
}
.lobby-content h3 {
    font-size: 0.8rem; color: rgba(255,255,255,0.35);
    letter-spacing: 3px; text-transform: uppercase; margin-bottom: 1.4rem;
}
#playerName { color: var(--accent-blue); font-weight: 700; }

/* ── Buttons ────────────────────────────────────────────────────── */
.menu-btn {
    display: block; width: 260px; padding: 13px; margin: 8px auto;
    font-size: 0.95rem; color: #fff; font-weight: 600; letter-spacing: 1.5px;
    background: rgba(255,255,255,0.04);
    border: 1.5px solid rgba(255,255,255,0.2);
    border-radius: 10px; cursor: pointer;
    transition: background var(--transition), border-color var(--transition), transform var(--transition);
    /* NO backdrop-filter — was causing GPU pressure */
}
.menu-btn:hover {
    background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.55);
    transform: translateY(-2px);
}
.menu-btn:active { transform: translateY(0); }

/* ── Leave ──────────────────────────────────────────────────────── */
.leave-btn {
    position: absolute; top: 16px; right: 16px;
    padding: 8px 15px;
    background: rgba(255,50,50,0.1); border: 1.5px solid rgba(255,50,50,0.35);
    color: #ffbaba; border-radius: 8px; cursor: pointer;
    z-index: 50; font-weight: 700; font-size: 0.82rem;
    transition: background var(--transition);
}
.leave-btn:hover { background: rgba(255,50,50,0.3); color: #fff; }

/* ── Name overlay ───────────────────────────────────────────────── */
#nameOverlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.88);
    display: flex; justify-content: center; align-items: center; z-index: 1000;
}
.nameBox {
    background: var(--panel-bg); padding: 44px 36px; border-radius: 16px;
    text-align: center; width: 320px;
    border: 1px solid var(--panel-border);
    box-shadow: 0 0 60px rgba(0,195,255,0.1);
    animation: popup 0.45s cubic-bezier(0.34,1.56,0.64,1);
}
.nameBox h2 { color: #fff; margin-bottom: 22px; font-size: 1.3rem; font-weight: 400; letter-spacing: 2px; }
.nameBox input {
    width: 100%; padding: 13px 15px; border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.06);
    outline: none; font-size: 16px; margin-bottom: 14px; color: #fff;
    font-family: inherit; letter-spacing: 1px; transition: border-color var(--transition);
    /* No transform animations on focus — keeps input snappy */
}
.nameBox input:focus { border-color: var(--accent-blue); }
.nameBox button {
    width: 100%; padding: 13px; border: none; border-radius: 10px;
    background: var(--accent-blue); color: #fff; font-size: 16px;
    cursor: pointer; font-weight: 700; letter-spacing: 1px;
    transition: background var(--transition);
}
.nameBox button:hover { background: #0099cc; }

/* ── History button ─────────────────────────────────────────────── */
.history-btn {
    position: absolute; top: 16px; left: 16px;
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.13);
    border-radius: 50%; width: 42px; height: 42px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 50; transition: background var(--transition);
}
.history-btn:hover { background: rgba(255,255,255,0.15); }
.history-btn svg { width: 20px; height: 20px; }

/* ── Modals ─────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    /* Removed backdrop-filter:blur — was causing GPU lag */
    display: flex; justify-content: center; align-items: center; z-index: 100;
}
.modal-box {
    background: var(--panel-bg); padding: 28px;
    border: 1px solid var(--panel-border); border-radius: 16px;
    width: 88%; max-width: 420px; text-align: center;
}
.history-box {
    max-height: 80vh; overflow-y: auto;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.history-box::-webkit-scrollbar { width: 4px; }
.history-box::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 4px; }
.history-box button {
    width: 100%; padding: 11px; border: none; border-radius: 10px;
    background: var(--accent-blue); color: #fff; font-size: 14px;
    cursor: pointer; font-weight: 700; margin-top: 9px;
    font-family: inherit; transition: background var(--transition);
}
.history-box button:hover { background: #0099cc; }
.history-box button.danger { background: #c0392b; }
.history-box button.danger:hover { background: #e74c3c; }
.history-item {
    border-bottom: 1px solid rgba(255,255,255,0.07);
    padding: 12px 0; text-align: left; font-size: 0.88rem;
}
.history-item:last-child { border-bottom: none; }
.hi-name  { color: var(--accent-blue); font-weight: 700; }
.hi-badge {
    display: inline-block; padding: 2px 8px; border-radius: 20px;
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; margin-left: 5px;
}
.hi-badge.truth { background: rgba(123,92,250,0.25); color: #b8a4ff; }
.hi-badge.dare  { background: rgba(255,92,122,0.25); color: #ffaab9; }
.history-item p { margin: 3px 0 0; color: #bbb; font-size: 0.82rem; }
.hi-date { color: rgba(255,255,255,0.3) !important; font-size: 0.72rem !important; margin-top: 5px !important; }

/* ── Game room layout ───────────────────────────────────────────── */
.game-container {
    position: relative; width: 100vw; height: 100vh;
    display: flex; align-items: center; justify-content: center;
}
.player {
    position: absolute; font-size: 1.1rem; font-weight: 700; text-align: center;
    color: #fff; letter-spacing: 0.5px; width: 150px;
}
.player .slot-label {
    font-size: 0.62rem; color: rgba(255,255,255,0.3);
    letter-spacing: 3px; text-transform: uppercase;
    display: block; margin-bottom: 3px;
}
/* Player accent colours */
.player.p-color-1 span:not(.slot-label) { color: #ff7eb3; }
.player.p-color-2 span:not(.slot-label) { color: #7eb3ff; }
.player.p-color-3 span:not(.slot-label) { color: #7effb3; }
.player.p-color-4 span:not(.slot-label) { color: #ffb37e; }
/* Active/current turn highlight */
.player.is-target {
    text-shadow: 0 0 14px currentColor;
    animation: pulsePlayer 1.5s ease-in-out infinite;
}
@keyframes pulsePlayer {
    0%,100% { opacity: 1; } 50% { opacity: 0.6; }
}

.bottle-container {
    position: absolute; top: 50%; left: 50%;
    width: 140px; transform: translate(-50%,-50%);
    cursor: pointer; z-index: 10;
    /* Use will-change only on bottle — it actually rotates */
    will-change: contents;
}
.bottle-container img {
    width: 100%;
    transition: transform 4s cubic-bezier(0.2,0,0.1,1);
    /* GPU layer for the spinning image only */
    will-change: transform;
}

#game-log {
    position: absolute; bottom: 90px;
    left: 50%; transform: translateX(-50%);
    width: 80%; font-size: 0.88rem; text-align: center;
    color: rgba(255,255,255,0.5); padding: 8px 18px;
    background: rgba(0,0,0,0.25); border-radius: 30px;
    border: 1px solid rgba(255,255,255,0.07);
}

/* ── Score bar ──────────────────────────────────────────────────── */
#scoreBar {
    position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 10px; z-index: 20;
}
.score-chip {
    padding: 5px 14px; border-radius: 30px;
    font-size: 0.8rem; font-weight: 700; letter-spacing: 1px;
    border: 1.5px solid rgba(255,255,255,0.15);
    background: rgba(0,0,0,0.35);
    transition: box-shadow 0.4s, transform 0.2s;
    white-space: nowrap;
}
.score-chip.just-scored {
    box-shadow: 0 0 16px var(--gold);
    transform: scale(1.12);
}

/* ── Round counter ──────────────────────────────────────────────── */
#roundBadge {
    position: absolute; bottom: 130px;
    left: 50%; transform: translateX(-50%);
    font-size: 0.7rem; letter-spacing: 3px; text-transform: uppercase;
    color: rgba(255,255,255,0.25);
}

/* ── Game popups ────────────────────────────────────────────────── */
.game-popup {
    display: none; position: fixed;
    top: 50%; left: 50%; transform: translate(-50%,-50%);
    width: 88%; max-width: 420px;
    background: var(--panel-bg); border: 1px solid var(--panel-border);
    border-radius: 18px; padding: 26px 22px; z-index: 100;
    text-align: center; color: #fff;
    box-shadow: 0 20px 60px rgba(0,0,0,0.65);
    animation: popupIn 0.28s cubic-bezier(0.34,1.56,0.64,1);
}
.game-popup h2 { font-size: 1.2rem; font-weight: 600; margin-bottom: 16px; letter-spacing: 0.5px; }
.game-popup textarea {
    width: 100%; height: 86px; margin: 10px 0;
    border: 1px solid rgba(255,255,255,0.14); border-radius: 10px;
    padding: 11px; background: rgba(255,255,255,0.05);
    color: #fff; font-family: inherit; font-size: 0.93rem;
    resize: none; outline: none; line-height: 1.5;
    transition: border-color var(--transition);
    /* Explicit layer for text input areas — avoids repaint bleed from background */
}
.game-popup textarea:focus { border-color: var(--accent-blue); }
.btn-group { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.game-popup button {
    padding: 10px 20px; border: 1.5px solid rgba(255,255,255,0.22);
    background: transparent; color: #fff; border-radius: 10px;
    cursor: pointer; font-weight: 700; font-size: 0.88rem;
    font-family: inherit; transition: background var(--transition), border-color var(--transition);
    flex: 1; min-width: 90px;
}
.game-popup button:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.45); }

/* Truth/Dare choice */
#choosePopup button.truth-btn {
    background: rgba(123,92,250,0.13); border-color: var(--accent-truth);
    color: #c4b4ff; font-size: 1.05rem; padding: 15px;
}
#choosePopup button.truth-btn:hover { background: rgba(123,92,250,0.28); }
#choosePopup button.dare-btn {
    background: rgba(255,92,122,0.13); border-color: var(--accent-dare);
    color: #ffaab9; font-size: 1.05rem; padding: 15px;
}
#choosePopup button.dare-btn:hover { background: rgba(255,92,122,0.28); }

/* Answerer popup skip */
#skipBtn {
    background: rgba(255,50,50,0.1) !important;
    border-color: rgba(255,80,80,0.4) !important;
    color: #ffaaaa !important;
    font-size: 0.8rem !important;
}
#skipBtn:hover { background: rgba(255,50,50,0.25) !important; }

/* Result popup */
#resultPopup .result-answer {
    background: rgba(0,195,255,0.06); border: 1px solid rgba(0,195,255,0.18);
    border-radius: 10px; padding: 12px 14px; margin: 10px 0;
    color: #cceeff; font-size: 0.95rem; line-height: 1.55; text-align: left;
    min-height: 44px;
}
#nextTurnBtn {
    background: var(--gold) !important; border-color: var(--gold) !important;
    color: #000 !important; font-weight: 800 !important;
}
#nextTurnBtn:hover { background: #e8c94a !important; border-color: #e8c94a !important; }

/* Emoji reactions ── */
#reactionRow {
    display: flex; justify-content: center; gap: 10px;
    margin: 10px 0 4px;
}
.reaction-btn {
    font-size: 1.4rem; background: rgba(255,255,255,0.06);
    border: 1.5px solid rgba(255,255,255,0.13); border-radius: 50%;
    width: 44px; height: 44px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.15s, background 0.15s;
    flex: unset !important; min-width: unset !important;
    padding: 0 !important;
}
.reaction-btn:hover { transform: scale(1.25); background: rgba(255,255,255,0.15); }
.reaction-btn.popped { animation: reactionPop 0.4s ease; }
@keyframes reactionPop { 0%{transform:scale(1)} 50%{transform:scale(1.6)} 100%{transform:scale(1)} }

.reaction-float {
    position: fixed; font-size: 2.2rem;
    pointer-events: none; z-index: 200;
    animation: floatUp 1.4s ease-out forwards;
}
@keyframes floatUp {
    0%   { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-120px) scale(1.5); }
}

/* Waiting room ─────────────────────────────────────────────────── */
.waiting-container {
    text-align: center; width: 90%; max-width: 400px;
    position: relative; z-index: 1;
}
.waiting-container h1 {
    font-family: 'Cinzel', serif;
    text-transform: uppercase; letter-spacing: 4px;
    font-size: 1.5rem; color: var(--gold); margin-bottom: 1.8rem;
    font-weight: 400;
}
.player-list { text-align: left; display: inline-block; width: 100%; }
.player-entry {
    font-size: 1.2rem; margin: 14px 0;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    padding-bottom: 10px;
    display: flex; align-items: center; gap: 12px;
}
.status-dot {
    height: 11px; width: 11px; min-width: 11px;
    background: rgba(255,255,255,0.15); border-radius: 50%;
    transition: background 0.4s, box-shadow 0.4s;
}
.status-online { background: #4CAF50; box-shadow: 0 0 10px #4CAF50; }
.loading-text {
    margin-top: 24px; color: rgba(255,255,255,0.4);
    font-size: 0.85rem; letter-spacing: 0.5px;
}
.room-pin {
    display: inline-block; color: var(--gold); font-weight: 700;
    letter-spacing: 5px; font-size: 1.05rem;
    background: rgba(212,175,55,0.08); border: 1px solid rgba(212,175,55,0.28);
    border-radius: 8px; padding: 4px 14px; margin-top: 8px;
}

/* ── Keyframes ──────────────────────────────────────────────────── */
@keyframes fadeIn  { from{opacity:0;transform:translateY(18px)} to{opacity:1;transform:none} }
@keyframes growLine{ from{transform:scaleY(0)} to{transform:scaleY(1)} }
@keyframes popup   { from{opacity:0;transform:scale(0.65)} to{opacity:1;transform:scale(1)} }
@keyframes popupIn {
    from { opacity:0; transform:translate(-50%,-46%) scale(0.9); }
    to   { opacity:1; transform:translate(-50%,-50%) scale(1); }
}
