:root {
    --bg: #0b0b0c;
    --surface: #141416;
    --surface-2: #1b1b1e;
    --border: #2c2c30;
    --border-strong: #444448;
    --text: #f4f4f5;
    --text-dim: #a1a1aa;
    --accent: #3ee07f;          /* the single colour accent */
    --accent-dim: rgba(62, 224, 127, 0.14);
    --accent-ink: #06140c;       /* text on accent */
    --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
    font-family: 'Manrope', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* ---------- HUD ---------- */
.hud {
    position: fixed; top: 0; left: 0; right: 0; z-index: 30;
    display: flex; align-items: center; gap: 10px;
    padding: 14px 18px;
}
.hud-stat {
    display: flex; align-items: baseline; gap: 8px;
    background: var(--surface); border: 1px solid var(--border);
    padding: 7px 14px; border-radius: 10px;
}
.hud-label { font-size: .74rem; color: var(--text-dim); letter-spacing: .02em; }
.hud-value { font-weight: 800; font-size: 1.05rem; min-width: 1.2ch; text-align: center; transition: transform .2s, color .2s; }
.hud-value.bump { transform: scale(1.45); color: var(--accent); }

#dev-menu-toggle {
    margin-left: auto; width: 38px; height: 38px; border-radius: 10px;
    background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
    font-size: 1.05rem; cursor: pointer; transition: .2s;
}
#dev-menu-toggle:hover { color: var(--text); border-color: var(--border-strong); }

#dev-menu {
    position: fixed; top: 64px; right: 18px; z-index: 40;
    background: var(--surface); border: 1px solid var(--border);
    padding: 18px; border-radius: var(--radius); width: 250px;
    box-shadow: 0 16px 40px rgba(0,0,0,.5);
}
#dev-menu h3 { font-size: .95rem; margin-bottom: 12px; }
#dev-menu label { display: block; margin-top: 14px; font-size: .8rem; color: var(--text-dim); }
#dev-menu input, #dev-menu select {
    margin-top: 6px; width: 100%; padding: 9px 10px; border-radius: 9px;
    border: 1px solid var(--border); background: var(--bg); color: var(--text);
    font-family: inherit; font-size: .95rem;
}
#dev-menu input:focus, #dev-menu select:focus { outline: none; border-color: var(--accent); }

/* ---------- Stage / screens ---------- */
#game-container { position: relative; width: 100%; max-width: 560px; min-height: 540px; }
.screen {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    text-align: center;
    background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
    padding: 40px 34px;
    opacity: 0; pointer-events: none;
    transform: translateY(10px);
    transition: opacity .3s ease, transform .3s ease;
}
.screen.wide { justify-content: flex-start; }
.screen.active { opacity: 1; pointer-events: auto; transform: translateY(0); }
.hidden { display: none !important; }

/* ---------- Typography ---------- */
.brand { font-size: clamp(2.4rem, 8vw, 3.2rem); font-weight: 800; letter-spacing: -.02em; margin-bottom: 14px; }
h1 { font-weight: 800; line-height: 1.05; }
h2 { font-weight: 700; font-size: 1.35rem; }
p { color: var(--text-dim); line-height: 1.55; }
.lead { max-width: 30rem; margin: 0 auto 28px; font-size: 1rem; }
.small-text { font-size: .9rem; color: var(--text-dim); margin-top: 14px; }

.field-label { font-size: .74rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 12px; }
.danger-label { color: var(--text); }

/* ---------- Buttons ---------- */
.btn {
    font-family: inherit; font-weight: 700; font-size: 1rem; cursor: pointer;
    border-radius: 11px; padding: 13px 30px; transition: .18s; border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; transform: none; filter: none; }
.btn-primary.slim { padding: 11px 20px; font-size: .92rem; }

.btn-ghost { margin-top: 18px; background: transparent; color: var(--text-dim); border: 1px solid var(--border-strong); padding: 10px 24px; }
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); }

/* ---------- Difficulty selector ---------- */
.difficulty-select { display: flex; gap: 10px; margin-bottom: 30px; flex-wrap: wrap; justify-content: center; }
.diff-btn {
    display: flex; flex-direction: column; gap: 3px; align-items: center;
    min-width: 100px; padding: 12px 14px; cursor: pointer;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px;
    color: var(--text); font-family: inherit; transition: .18s;
}
.diff-btn span { font-weight: 700; font-size: 1rem; }
.diff-btn small { font-size: .72rem; color: var(--text-dim); }
.diff-btn:hover { border-color: var(--border-strong); }
.diff-btn.active { border-color: var(--accent); background: var(--accent-dim); }
.diff-btn.active span { color: var(--accent); }

/* ---------- Word card / taboo ---------- */
.word-card {
    position: relative; width: 100%;
    background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius);
    padding: 26px 20px; margin-bottom: 22px;
}
.word-card.compact { padding: 18px; margin-bottom: 14px; }
.card-tag {
    position: absolute; top: -10px; left: 16px;
    font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 700;
    color: var(--accent-ink); background: var(--accent); padding: 3px 11px; border-radius: 6px;
}
.word-card h1 { font-size: clamp(1.7rem, 5vw, 2.2rem); }
.word-card.compact h1 { font-size: 1.4rem; }

.taboo-section { width: 100%; margin-bottom: 24px; }
.taboo-list { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.taboo-list.compact { font-size: .88rem; }
.taboo-list li {
    background: var(--surface-2); color: var(--text);
    padding: 6px 14px; border-radius: 8px; font-weight: 600;
    border: 1px solid var(--border-strong);
    text-decoration: line-through; text-decoration-color: var(--text-dim);
    animation: pop .35s backwards;
}
.taboo-list li::before { content: "✕"; margin-right: 6px; text-decoration: none; display: inline-block; color: var(--text-dim); }
@keyframes pop { from { opacity: 0; transform: scale(.85) } to { opacity: 1; transform: scale(1) } }

/* ---------- Ring timer ---------- */
.ring-timer { position: relative; width: 86px; height: 86px; margin: 6px auto; }
.ring-timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--border); stroke-width: 6; }
.ring-fg {
    fill: none; stroke: var(--accent); stroke-width: 6; stroke-linecap: round;
    stroke-dasharray: 327; stroke-dashoffset: 0; transition: stroke-dashoffset 1s linear;
}
.ring-timer span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.8rem; }

/* ---------- Explaining ---------- */
.rec-row { display: flex; align-items: center; gap: 10px; }
.rec-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.25} }
.explain-timer { width: 100%; display: flex; align-items: center; gap: 14px; margin: 16px 0; }
.timer-bar-container { flex: 1; height: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; transition: border-color .3s, box-shadow .3s; }
#explain-timer-bar { height: 100%; width: 100%; background: var(--accent); transition: background .3s; }
.timer-count {
    flex: none; min-width: 2.4ch; text-align: right; line-height: 1;
    font-weight: 800; font-size: 1.5rem; color: var(--accent);
    font-variant-numeric: tabular-nums; transition: color .3s;
}
/* low-time warning: bar + counter go red and the number pulses */
.explain-timer.low #explain-timer-bar { background: #f87171; }
.explain-timer.low .timer-bar-container { border-color: #f87171; box-shadow: 0 0 0 1px rgba(248,113,113,.35); }
.explain-timer.low .timer-count { color: #f87171; animation: timer-pulse .7s ease-in-out infinite; }
@keyframes timer-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.22); } }
.live-transcript {
    width: 100%; min-height: 54px; max-height: 120px; overflow-y: auto;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px;
    padding: 12px 14px; color: var(--text); font-size: .95rem; text-align: left;
}
.live-transcript:empty::before { content: "Слушаю…"; color: var(--text-dim); }
textarea {
    width: 100%; height: 110px; background: var(--surface-2);
    border: 1px solid var(--border-strong); border-radius: 11px; color: var(--text);
    padding: 13px; font-family: inherit; font-size: 1rem; resize: none;
}
textarea:focus { outline: none; border-color: var(--accent); }

/* ---------- Loader ---------- */
.loader { display: flex; gap: 8px; margin-bottom: 22px; }
.loader span { width: 11px; height: 11px; border-radius: 50%; background: var(--text-dim); animation: bounce 1.2s infinite; }
.loader span:nth-child(2){ animation-delay: .15s; } .loader span:nth-child(3){ animation-delay: .3s; }
@keyframes bounce { 0%,100%{ transform: translateY(0); opacity:.4 } 50%{ transform: translateY(-7px); opacity:1; background: var(--accent) } }

/* ---------- AI avatar ---------- */
.ai-avatar {
    width: 52px; height: 52px; border-radius: 12px; flex: none;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface-2); border: 1px solid var(--accent);
    color: var(--accent); font-weight: 800; font-size: .95rem; letter-spacing: .02em;
}

/* ---------- Verdict + chat ---------- */
.verdict-head { display: flex; align-items: center; gap: 16px; width: 100%; margin-bottom: 18px; text-align: left; }
.verdict-titles { flex: 1; }
.verdict-title { font-size: 1.6rem; }
.verdict-title.win::before  { content: "✓ "; color: var(--accent); }
.verdict-title.lose::before { content: "✕ "; color: var(--text-dim); }
.verdict-points { font-weight: 800; font-size: 1.15rem; margin-top: 4px; }
.verdict-points .pos { color: var(--accent); }
.verdict-points .neg { color: var(--text); }
.verdict-points small { font-weight: 500; font-size: .8rem; color: var(--text-dim); margin-left: 8px; }

.dossier { width: 100%; display: grid; gap: 8px; margin-bottom: 16px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 15px; }
.dossier-row { display: flex; gap: 12px; justify-content: space-between; align-items: baseline; text-align: left; }
.dossier-row span { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-dim); flex: none; }
.dossier-row b { color: var(--text); font-weight: 600; text-align: right; }
.res-phrase-highlight { color: var(--accent) !important; font-size: 1rem; }
.res-taboo-highlight { color: #f87171 !important; font-size: .88rem; font-weight: 500 !important; }

.chat-log { width: 100%; flex: 1; min-height: 80px; max-height: 220px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 10px; padding-right: 4px; margin-bottom: 14px; }
.chat-log::-webkit-scrollbar { width: 6px; }
.chat-log::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
.bubble { max-width: 86%; padding: 10px 14px; border-radius: 13px; line-height: 1.45; font-size: .96rem; animation: rise .3s backwards; }
@keyframes rise { from{opacity:0; transform:translateY(6px)} to{opacity:1; transform:translateY(0)} }
.bubble.ai { align-self: flex-start; border-top-left-radius: 4px; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text); }
.bubble.ai .who { font-size: .64rem; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); display: block; margin-bottom: 3px; }
.bubble.player { align-self: flex-end; border-top-right-radius: 4px; background: var(--accent-dim); border: 1px solid var(--accent); color: var(--text); }
.bubble.typing { color: var(--text-dim); }
.bubble.typing .dot { animation: blink 1.2s infinite; }
.bubble.typing .dot:nth-child(2){animation-delay:.2s} .bubble.typing .dot:nth-child(3){animation-delay:.4s}

.dispute-zone { width: 100%; margin-bottom: 14px; }
.dispute-row { display: flex; gap: 10px; }
#dispute-input { flex: 1; padding: 12px 15px; border-radius: 10px;
    background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text); font-family: inherit; font-size: .96rem; }
#dispute-input::placeholder { color: var(--text-dim); }
#dispute-input:focus { outline: none; border-color: var(--accent); }
.dispute-hint { font-size: .82rem; color: var(--text-dim); margin-top: 9px; text-align: center; }
.dispute-hint b { color: var(--text); }

/* ---------- Game over ---------- */
.final-score { font-size: 1.1rem; color: var(--text-dim); margin: 4px 0 26px; }
.final-score b { color: var(--text); font-size: 1.5rem; font-weight: 800; }
.gameover-mode {
    display: inline-block; margin-bottom: 22px;
    font-size: .88rem; font-weight: 600; color: var(--accent) !important;
    background: var(--accent-dim); padding: 6px 16px; border-radius: 8px;
    border: 1px solid var(--accent);
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
    body { padding: 0; }
    #game-container { max-width: 100%; min-height: 100vh; }
    .screen { border-radius: 0; padding: 64px 18px 28px; }
    .verdict-head { flex-direction: row; }
    .hud-label { display: none; }
}
