:root {
    --paper: #f6ead2;
    --ink: #f8f1e3;
    --muted: #a7b0ad;
    --bg: #090b0f;
    --panel: rgba(20, 24, 29, 0.92);
    --line: rgba(246, 234, 210, 0.16);
    --line-strong: rgba(246, 234, 210, 0.34);
    --cyan: #2df7ef;
    --cyan-soft: rgba(45, 247, 239, 0.22);
    --gold: #ffd76a;
    --red: #ff5d55;
    --green: #66f2a2;
    --shadow: 0 24px 90px rgba(0, 0, 0, 0.45);
    --radius: 8px;
}

* { box-sizing: border-box; }

html, body { width: 100%; min-height: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    overflow: hidden;
    color: var(--ink);
    cursor: none;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(45, 247, 239, 0.14), transparent 34rem),
        radial-gradient(circle at bottom right, rgba(255, 215, 106, 0.08), transparent 30rem),
        linear-gradient(135deg, #07080b, #111418 54%, #090b0f);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.22;
    background-image:
        linear-gradient(rgba(246, 234, 210, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(246, 234, 210, 0.06) 1px, transparent 1px);
    background-size: 32px 32px;
    mask-image: linear-gradient(to bottom, #000, transparent 88%);
}

button { font: inherit; }
h1, h2, p { margin: 0; }

.app-shell {
    width: min(1480px, calc(100vw - 32px));
    height: min(900px, calc(100vh - 32px));
    margin: 16px auto;
    display: grid;
    grid-template-columns: minmax(230px, 292px) minmax(0, 1fr);
    gap: 16px;
}

.mission-panel, .game-panel {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent), var(--panel);
    box-shadow: var(--shadow);
}

.mission-panel::before, .game-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(246, 234, 210, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(246, 234, 210, 0.035) 1px, transparent 1px);
    background-size: 18px 18px;
}

.mission-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
}

.brand-lockup, .mission-card, .recognition-card, .clear-button, .drawing-hint {
    position: relative;
    z-index: 1;
}

.brand-lockup {
    padding-bottom: 14px;
    border-bottom: 1px dashed var(--line-strong);
}

.eyebrow, .section-heading, .target-label, .stat-label {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.eyebrow { color: var(--cyan); }

.brand-lockup h1 {
    margin-top: 8px;
    font-size: clamp(1.8rem, 2.8vw, 2.5rem);
    line-height: 0.95;
}

.brand-lockup p, .drawing-hint {
    margin-top: 10px;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.45;
}

.mission-card, .recognition-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    background: rgba(255, 255, 255, 0.035);
}

.mission-card {
    border-left: 3px solid var(--gold);
    background: linear-gradient(135deg, rgba(255, 215, 106, 0.12), transparent 48%), rgba(255, 255, 255, 0.035);
}

.section-heading, .confidence-heading, .recognizer-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.section-heading { color: var(--paper); }

.tier-chip {
    padding: 4px 8px;
    border: 1px solid rgba(255, 215, 106, 0.52);
    border-radius: 999px;
    color: var(--gold);
    letter-spacing: 0.06em;
}

.target-label { margin-top: 20px; color: var(--muted); }

#targetPrompt {
    margin-top: 5px;
    color: var(--cyan);
    font-size: 1.65rem;
    line-height: 1.1;
    text-transform: capitalize;
    text-shadow: 0 0 22px rgba(45, 247, 239, 0.34);
}

.mission-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 16px;
    color: var(--muted);
    font-size: 0.72rem;
}

.mission-meta span:first-child { grid-column: 1 / -1; }
.mission-meta strong { color: var(--ink); }

.recognition-card.close {
    border-color: rgba(45, 247, 239, 0.72);
    box-shadow: 0 0 28px rgba(45, 247, 239, 0.15);
    animation: close-pulse 1.1s ease-in-out infinite alternate;
}

@keyframes close-pulse { to { box-shadow: 0 0 36px rgba(45, 247, 239, 0.28); } }

.recognizer-status {
    justify-content: flex-start;
    color: var(--muted);
    font-size: 0.78rem;
    min-height: 20px;
}

.thinking-dot {
    width: 7px;
    height: 7px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--muted);
}

.thinking-dot.active {
    background: var(--cyan);
    box-shadow: 0 0 12px var(--cyan);
    animation: think 0.65s ease-in-out infinite alternate;
}

@keyframes think { to { opacity: 0.3; transform: scale(0.65); } }

.guess-list {
    display: grid;
    gap: 6px;
    margin: 12px 0 15px;
    padding: 0;
    list-style: none;
    counter-reset: guesses;
}

.guess-list li {
    display: flex;
    justify-content: space-between;
    padding: 7px 9px;
    border: 1px solid rgba(246, 234, 210, 0.1);
    border-radius: 5px;
    color: var(--muted);
    background: rgba(9, 11, 15, 0.42);
    font-size: 0.8rem;
    text-transform: capitalize;
}

.guess-list li:first-child { color: var(--ink); border-color: rgba(45, 247, 239, 0.25); }
.guess-list strong { color: var(--cyan); }

.confidence-heading {
    color: var(--muted);
    font-size: 0.7rem;
}

.confidence-heading strong { color: var(--gold); }

.confidence-track {
    height: 7px;
    margin-top: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(246, 234, 210, 0.1);
}

.confidence-track span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--cyan), var(--gold));
    box-shadow: 0 0 16px var(--cyan);
    transition: width 0.3s ease;
}

.drawing-hint {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px dashed var(--line-strong);
}

.game-panel {
    min-width: 0;
    display: grid;
    grid-template-rows: auto 1fr;
}

.top-hud {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(9, 11, 15, 0.52);
}

#instructions, .game-over {
    color: var(--paper);
    font-size: clamp(0.92rem, 1.4vw, 1.06rem);
    font-weight: 700;
    line-height: 1.35;
}

.game-over { color: var(--red); }

.hud-stats, .controls {
    display: flex;
    align-items: center;
    gap: 9px;
}

.stat-card {
    min-width: 112px;
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.035);
}

.stat-label { display: block; color: var(--muted); }

.stat-value {
    display: block;
    margin-top: 3px;
    font-size: 1.25rem;
    font-weight: 900;
    line-height: 1;
}

.green { color: var(--green); }
.gold { color: var(--gold); }

.button {
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid rgba(45, 247, 239, 0.45);
    border-radius: 999px;
    color: #031515;
    cursor: pointer;
    font-weight: 900;
    background: linear-gradient(135deg, var(--cyan), #9dfff8);
    box-shadow: 0 0 24px var(--cyan-soft);
    transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 0 34px rgba(45, 247, 239, 0.34); }
.button:disabled { cursor: not-allowed; opacity: 0.4; }

.button.secondary {
    color: var(--paper);
    border-color: var(--line-strong);
    background: rgba(246, 234, 210, 0.06);
    box-shadow: none;
}

.clear-button { width: 100%; }

.arena-wrap {
    position: relative;
    z-index: 1;
    min-height: 0;
    display: grid;
    padding: 16px;
}

#gameContainer {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 460px;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    border: 1px solid rgba(45, 247, 239, 0.34);
    border-radius: var(--radius);
    background:
        radial-gradient(circle at center, rgba(45, 247, 239, 0.08), transparent 30%),
        linear-gradient(rgba(246, 234, 210, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(246, 234, 210, 0.04) 1px, transparent 1px),
        #191d20;
    background-size: auto, 28px 28px, 28px 28px, auto;
    box-shadow: inset 0 0 0 1px rgba(246, 234, 210, 0.05), 0 0 40px rgba(45, 247, 239, 0.14);
}

#gameContainer::before {
    content: "";
    position: absolute;
    inset: 10px;
    z-index: 1;
    pointer-events: none;
    border: 1px dashed rgba(246, 234, 210, 0.12);
    border-radius: 6px;
}

#drawingCanvas {
    position: absolute;
    inset: 0;
    z-index: 20;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#playerCursor {
    position: absolute;
    z-index: 100;
    width: 16px;
    height: 16px;
    pointer-events: none;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(255, 255, 255, 0.78);
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 18px var(--cyan), 0 0 4px var(--cyan) inset;
}

.bullet, .orb {
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
}

.bullet {
    z-index: 50;
    width: 9px;
    height: 9px;
    background: var(--red);
    box-shadow: 0 0 12px rgba(255, 93, 85, 0.92), 0 0 2px var(--red) inset;
}

.orb {
    z-index: 30;
    width: 14px;
    height: 14px;
    opacity: 0;
    background: var(--green);
    box-shadow: 0 0 16px rgba(102, 242, 162, 0.86);
    transition: opacity 0.5s ease, transform 0.2s ease;
}

.orb.visible { opacity: 1; }

.mission-flash {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 120;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.85);
    color: var(--green);
    font-size: clamp(1.5rem, 5vw, 3.4rem);
    font-weight: 950;
    text-align: center;
    text-shadow: 0 0 26px rgba(102, 242, 162, 0.8);
}

.mission-flash.show { animation: flash 1.15s ease; }

@keyframes flash {
    20%, 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -60%) scale(1.08); }
}

@media (max-width: 980px) {
    body { overflow: auto; cursor: default; }
    .app-shell {
        width: min(100vw - 24px, 760px);
        height: auto;
        min-height: calc(100vh - 24px);
        margin: 12px auto;
        grid-template-columns: 1fr;
    }
    .mission-panel { min-height: 420px; }
    .top-hud { grid-template-columns: 1fr; }
    #gameContainer { height: min(64vh, 560px); min-height: 360px; }
}

@media (max-width: 560px) {
    .app-shell { width: calc(100vw - 16px); margin: 8px auto; gap: 10px; }
    .mission-panel, .top-hud, .arena-wrap { padding: 12px; }
    .hud-stats { align-items: stretch; flex-wrap: wrap; }
    .stat-card { flex: 1 1 100px; }
    .controls { width: 100%; }
    .controls .button { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
