:root {
    --bg: #0d0f11;
    --bg-soft: #14171a;
    --panel: #191d20;
    --panel-2: #202529;
    --line: rgba(255, 255, 255, 0.10);
    --line-strong: rgba(255, 255, 255, 0.18);
    --text: #f2f3f4;
    --muted: #9da4aa;
    --accent: #d62f2f;
    --accent-strong: #ef3b35;
    --accent-soft: rgba(214, 47, 47, 0.14);
    --paper: #e8e2d5;
    --paper-ink: #1a1d1f;
    --ok: #62b58c;
    --warn: #d6a34a;
    --danger: #e45555;
    --radius: 22px;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

* { box-sizing: border-box; }
html { color-scheme: dark; background: var(--bg); }
body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 15% -10%, rgba(214, 47, 47, 0.15), transparent 38%),
        radial-gradient(circle at 110% 85%, rgba(255, 255, 255, 0.055), transparent 35%),
        var(--bg);
    -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
textarea { resize: vertical; }

.noise {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: .045;
    z-index: 1000;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.9'/%3E%3C/svg%3E");
}

.screen { width: min(100%, 760px); margin: 0 auto; padding: 20px; }
.screen--centered { min-height: 100dvh; display: grid; place-items: center; }
.screen--quest { padding-bottom: 118px; }

.case-card {
    position: relative;
    overflow: hidden;
    width: 100%;
    padding: 28px 24px;
    background: linear-gradient(145deg, rgba(31, 36, 40, .96), rgba(19, 22, 25, .98));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.case-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), transparent 74%);
}
.auth-card { max-width: 460px; }
.case-mark {
    position: absolute;
    right: -12px;
    top: 10px;
    font-size: 148px;
    line-height: 1;
    font-weight: 900;
    color: rgba(255,255,255,.025);
    transform: rotate(8deg);
}

a { color: inherit; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 14px; font-size: clamp(30px, 8vw, 48px); line-height: 1.02; letter-spacing: -.045em; }
h2 { margin-bottom: 8px; font-size: 24px; letter-spacing: -.03em; }
.lead { color: var(--muted); font-size: 16px; line-height: 1.65; }

.eyebrow, .section-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
    color: #c5c9cc;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
}
.section-label { margin-bottom: 7px; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 999px; background: var(--accent); box-shadow: 0 0 0 4px rgba(214,47,47,.12); }
.dot--pulse { animation: pulse 1.7s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(214,47,47,0); } }

.form-stack { display: grid; gap: 15px; margin-top: 24px; }
.field { display: grid; gap: 8px; }
.field > span { color: #c8cdd0; font-size: 12px; font-weight: 700; letter-spacing: .025em; }
.field input, .field textarea {
    width: 100%;
    color: var(--text);
    background: #101315;
    border: 1px solid var(--line-strong);
    border-radius: 13px;
    outline: none;
    padding: 14px 15px;
    line-height: 1.45;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.field input { min-height: 50px; }
.field textarea { min-height: 92px; }
.field input:focus, .field textarea:focus {
    border-color: rgba(239, 59, 53, .78);
    box-shadow: 0 0 0 4px rgba(214,47,47,.10);
    background: #121619;
}
.field--compact { flex: 1; }

.button {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border-radius: 13px;
    border: 1px solid transparent;
    padding: 0 18px;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
    transition: transform .12s ease, background .15s ease, border-color .15s ease;
}
.button:active { transform: translateY(1px) scale(.995); }
.button--wide { width: 100%; }
.button--primary { color: white; background: linear-gradient(135deg, var(--accent-strong), #b91f24); box-shadow: 0 10px 26px rgba(214,47,47,.22); }
.button--primary:hover { background: linear-gradient(135deg, #f0443e, #c42227); }
.button--ghost { color: var(--text); background: transparent; border-color: var(--line-strong); }
.button--danger { color: #ffdede; background: rgba(228,85,85,.10); border-color: rgba(228,85,85,.34); }
.text-button { padding: 8px 0; border: 0; color: var(--muted); background: transparent; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: rgba(255,255,255,.035); font-size: 18px; cursor: pointer; }

.inline-alert { margin: 18px 0 0; padding: 13px 14px; border-radius: 12px; font-size: 14px; line-height: 1.45; }
.inline-alert--error { color: #ffd4d4; background: rgba(228,85,85,.10); border: 1px solid rgba(228,85,85,.25); }
.microcopy { margin: 18px 0 0; color: #6f777c; font-size: 11px; line-height: 1.5; text-align: center; }

.flash {
    position: fixed;
    z-index: 2000;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: min(calc(100% - 28px), 640px);
    padding: 13px 16px;
    border-radius: 13px;
    background: #202529;
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow);
    font-size: 13px;
    line-height: 1.4;
    transition: opacity .25s ease, transform .25s ease;
}
.flash--ok { border-color: rgba(98,181,140,.34); }
.flash--error { border-color: rgba(228,85,85,.4); }
.flash--hide { opacity: 0; transform: translate(-50%, -8px); pointer-events: none; }

.waiting-card { max-width: 520px; text-align: center; }
.waiting-card .eyebrow { justify-content: center; }
.loader-ring { width: 74px; height: 74px; margin: 8px auto 30px; border-radius: 50%; border: 1px solid var(--line-strong); position: relative; }
.loader-ring::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; border: 2px solid transparent; border-top-color: var(--accent); animation: spin 1.3s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.identity-chip { display: inline-flex; margin: 14px 0 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 12px; background: rgba(255,255,255,.025); }
.identity-chip strong { color: var(--text); margin-left: 5px; }

.mobile-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 8px 0 30px; }
.mobile-header .eyebrow { margin-bottom: 7px; }
.header-login { color: var(--muted); font-size: 12px; }
.quest-hero { position: relative; padding: 18px 0 10px; }
.quest-hero h1 { max-width: 560px; margin-bottom: 16px; }
.quest-hero > p { max-width: 620px; color: var(--muted); line-height: 1.7; font-size: 15px; }
.case-index { position: absolute; right: 0; top: 0; color: rgba(255,255,255,.08); font-size: 12px; font-weight: 900; letter-spacing: .13em; }

.hint-card { display: flex; gap: 14px; align-items: flex-start; margin: 26px 0 34px; padding: 17px; border: 1px solid rgba(214,47,47,.26); border-radius: 17px; background: linear-gradient(135deg, rgba(214,47,47,.11), rgba(255,255,255,.025)); }
.hint-icon { display: grid; place-items: center; flex: 0 0 38px; width: 38px; height: 38px; border-radius: 11px; color: #ff8a83; background: rgba(214,47,47,.14); font-size: 22px; }
.hint-card p { margin: 0; line-height: 1.55; font-size: 15px; }

.mission-block { margin-top: 6px; }
.section-heading, .panel-title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.evidence-count { color: #70777c; font-size: 11px; }
.evidence-card { display: flex; gap: 16px; padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(145deg, rgba(32,37,41,.86), rgba(20,23,26,.9)); box-shadow: 0 16px 36px rgba(0,0,0,.18); }
.evidence-number { flex: 0 0 37px; padding-top: 2px; color: var(--accent); font-size: 12px; font-weight: 900; letter-spacing: .08em; }
.evidence-content > span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.evidence-content p { margin: 0; font-size: 17px; line-height: 1.55; }
.connector { height: 32px; margin-left: 38px; border-left: 1px dashed rgba(255,255,255,.18); position: relative; }
.connector span { position: absolute; bottom: 3px; left: -3px; width: 5px; height: 5px; border-radius: 50%; background: rgba(255,255,255,.28); }

.sticky-action { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; padding: 12px max(18px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); background: linear-gradient(to top, rgba(13,15,17,1) 66%, rgba(13,15,17,0)); }
.sticky-action .button { max-width: 724px; margin: 0 auto; }

.sheet-backdrop { position: fixed; z-index: 60; inset: 0; background: rgba(0,0,0,.66); backdrop-filter: blur(5px); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }
.answer-sheet { position: fixed; z-index: 70; left: 50%; bottom: 0; width: min(100%, 720px); max-height: 92dvh; overflow-y: auto; padding: 10px 20px calc(22px + env(safe-area-inset-bottom)); border: 1px solid var(--line-strong); border-bottom: 0; border-radius: 26px 26px 0 0; background: #171b1e; box-shadow: 0 -30px 80px rgba(0,0,0,.48); transform: translate(-50%, 105%); transition: transform .27s cubic-bezier(.2,.8,.2,1); }
.answer-sheet.is-open { transform: translate(-50%, 0); }
.sheet-handle { width: 44px; height: 4px; margin: 0 auto 22px; border-radius: 99px; background: rgba(255,255,255,.18); }
.sheet-topline { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.sheet-topline h2 { margin-bottom: 0; }
.sheet-close { width: 39px; height: 39px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.035); color: var(--muted); font-size: 24px; cursor: pointer; }
.sheet-note { color: var(--muted); font-size: 13px; line-height: 1.55; }
body.sheet-open { overflow: hidden; }

.success-card { max-width: 540px; text-align: center; }
.success-card .eyebrow { justify-content: center; }
.success-seal { width: 96px; height: 96px; margin: 4px auto 28px; display: grid; place-items: center; border-radius: 50%; border: 1px solid rgba(98,181,140,.32); background: radial-gradient(circle, rgba(98,181,140,.14), transparent 70%); box-shadow: 0 0 0 12px rgba(98,181,140,.025); }
.success-seal span { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 50%; background: var(--ok); color: #08140e; font-size: 28px; font-weight: 900; }
.success-line { height: 1px; margin: 26px 0; background: linear-gradient(90deg, transparent, var(--line-strong), transparent); }
.success-note { color: #c4c8ca; font-size: 14px; line-height: 1.65; }

/* Admin */
.admin-page { background: #0e1012; }
.admin-topbar { width: min(100% - 32px, 1200px); margin: 0 auto; padding: 28px 0 20px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.admin-topbar h1 { margin: 0; font-size: 30px; }
.admin-topbar .section-label { margin-bottom: 5px; }
.admin-actions { display: flex; align-items: center; gap: 10px; }
.game-state { display: inline-flex; align-items: center; gap: 9px; min-height: 48px; padding: 0 15px; border: 1px solid var(--line); border-radius: 13px; color: var(--muted); font-size: 12px; font-weight: 800; }
.game-state--live { color: #e9caca; border-color: rgba(214,47,47,.28); background: rgba(214,47,47,.06); }
.admin-shell { width: min(100% - 32px, 1200px); margin: 0 auto 80px; display: grid; gap: 18px; }
.admin-panel { padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: #15191c; box-shadow: 0 14px 40px rgba(0,0,0,.14); }
.panel-title-row { align-items: flex-start; margin-bottom: 20px; }
.panel-title-row h2 { margin: 0; }
.panel-title-row p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.status-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.status-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 14px; background: #101315; border: 1px solid rgba(255,255,255,.07); border-radius: 12px; }
.status-team { font-size: 13px; font-weight: 800; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-badge { flex: 0 0 auto; padding: 5px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; border: 1px solid transparent; }
.status-badge--idle { color: #899197; background: rgba(137,145,151,.08); border-color: rgba(137,145,151,.12); }
.status-badge--online { color: #d5b265; background: rgba(214,163,74,.09); border-color: rgba(214,163,74,.16); }
.status-badge--playing { color: #e48a86; background: rgba(214,47,47,.10); border-color: rgba(214,47,47,.18); }
.status-badge--done { color: #83c9a5; background: rgba(98,181,140,.09); border-color: rgba(98,181,140,.18); }
.admin-config-form { display: grid; gap: 18px; }
.admin-help { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.team-config-list { display: grid; gap: 12px; }
.team-config-card { padding: 18px; border-radius: 15px; border: 1px solid rgba(255,255,255,.075); background: #101315; }
.team-config-head { display: flex; align-items: end; gap: 14px; margin-bottom: 15px; }
.team-number { flex: 0 0 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; background: var(--accent-soft); color: #ee7b76; font-size: 12px; font-weight: 900; letter-spacing: .08em; }
.clue-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.admin-submit-bar { position: sticky; z-index: 30; bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 16px; border: 1px solid var(--line-strong); border-radius: 16px; background: rgba(24,28,31,.91); backdrop-filter: blur(18px); box-shadow: 0 20px 50px rgba(0,0,0,.34); }
.admin-submit-bar strong, .admin-submit-bar span { display: block; }
.admin-submit-bar strong { font-size: 13px; }
.admin-submit-bar span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.admin-submit-actions { display: flex; gap: 9px; }
.locked-panel { display: flex; align-items: center; gap: 18px; }
.locked-panel > div:nth-child(2) { flex: 1; }
.locked-panel h2 { margin-bottom: 8px; }
.locked-panel p { margin: 0; color: var(--muted); line-height: 1.6; font-size: 13px; }
.lock-icon { flex: 0 0 52px; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 14px; color: #e27873; background: var(--accent-soft); font-size: 25px; }

@media (max-width: 760px) {
    .screen { padding: 18px; }
    .case-card { padding: 24px 20px; }
    .screen--quest { padding-bottom: 108px; }
    .evidence-card { padding: 18px 16px; }
    .evidence-content p { font-size: 16px; }

    .admin-topbar { width: min(100% - 24px, 1200px); padding-top: 18px; align-items: flex-start; }
    .admin-topbar h1 { font-size: 22px; }
    .admin-actions { align-items: flex-end; flex-direction: column; }
    .game-state { min-height: 38px; }
    .admin-actions .button { min-height: 38px; }
    .admin-shell { width: min(100% - 24px, 1200px); }
    .admin-panel { padding: 18px; }
    .status-grid { grid-template-columns: 1fr; }
    .clue-grid { grid-template-columns: 1fr; }
    .panel-title-row { align-items: flex-start; flex-direction: column; gap: 4px; }
    .team-config-head { align-items: stretch; }
    .team-number { margin-top: 20px; }
    .admin-submit-bar { align-items: stretch; flex-direction: column; bottom: 8px; }
    .admin-submit-actions { display: grid; grid-template-columns: 1fr 1.25fr; }
    .locked-panel { align-items: flex-start; flex-wrap: wrap; }
    .locked-panel form { width: 100%; }
    .locked-panel .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
