/* ═══════════════════════════════════════════════════════════════════════
   Legal AI Escape Room — Style
   ═══════════════════════════════════════════════════════════════════════ */

:root {
    --bg:         #f5f3f1;
    --surface:    #ffffff;
    --card:       #ffffff;
    --border:     #e2dcd8;
    --border-hi:  #c4bbb6;
    --primary:    #911925;
    --primary-light: #b02a37;
    --text:       #231f20;
    --muted:      #6b6466;
    --success:    #2f855a;
    --warning:    #975a16;
    --danger:     #c81e2c;
    --timer-ok:   #231f20;
    --timer-warn: #c05621;
    --timer-crit: #d6001c;
    --radius:     10px;
    --shadow:     0 4px 24px rgba(35,31,32,.1);
}

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

html { font-size: 16px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    accent-color: var(--primary);
}

/* ── Utilities ────────────────────────────────────────────────────────── */
code {
    font-family: 'Courier New', Courier, monospace;
    background: rgba(0,0,0,.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: .9em;
}

hr.form-divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

.mono { font-family: 'Courier New', Courier, monospace; }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: .95rem;
}
.alert-error   { background: rgba(229,62,62,.15); border: 1px solid var(--danger); color: #a61b1b; }
.alert-success { background: rgba(56,161,105,.15); border: 1px solid var(--success); color: #276749; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-danger, .btn-warning, .btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: filter .15s, transform .1s;
}
.btn-primary, .btn-secondary, .btn-danger, .btn-warning { min-width: 120px; }

.btn-primary  { background: var(--primary); color: #fff; }
.btn-secondary{ background: var(--card); color: var(--text); border: 1px solid var(--border-hi); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-warning  { background: var(--warning); color: #fff; }

.btn-primary:hover,
.btn-secondary:hover,
.btn-danger:hover,
.btn-warning:hover { filter: brightness(1.12); }

.btn-primary:active,
.btn-secondary:active { transform: scale(.97); }

.btn-full { width: 100%; }

.btn-sm { padding: 5px 12px; font-size: .82rem; min-width: unset; }

/* ── LOGIN ────────────────────────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

.login-bg {
    position: fixed; inset: 0; z-index: 0;
    background: radial-gradient(ellipse at 50% 40%, rgba(145,25,37,.08) 0%, transparent 70%),
                linear-gradient(180deg, #f5f3f1 0%, #e9e4e0 100%);
    pointer-events: none;
}

.login-wrapper { position: relative; z-index: 1; width: 100%; max-width: 420px; padding: 20px; }

.login-card {
    background: var(--card);
    border: 1px solid var(--border-hi);
    border-radius: 16px;
    padding: 40px 36px;
    box-shadow: var(--shadow), 0 0 60px rgba(145,25,37,.08);
    text-align: center;
}

.lock-icon { font-size: 2.8rem; margin-bottom: 12px; }
.login-logo { display: block; width: 240px; max-width: 100%; height: auto; margin: 0 auto 24px; }

.game-title {
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: .03em;
    margin-bottom: 8px;
    line-height: 1.3;
}

.login-subtitle { color: var(--muted); font-size: .9rem; margin-bottom: 24px; }

.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }

.code-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border-hi);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1.15rem;
    font-family: 'Courier New', Courier, monospace;
    letter-spacing: .12em;
    text-transform: uppercase;
    text-align: center;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.code-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(145,25,37,.18);
}
.code-input::placeholder { letter-spacing: .08em; color: var(--muted); }

/* ── GAME HEADER ──────────────────────────────────────────────────────── */
.game-body {
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-team {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 1rem;
    color: var(--primary);
}

.team-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(56,161,105,.4); }
    50%      { box-shadow: 0 0 0 6px rgba(56,161,105,0); }
}

.timer-wrap { text-align: center; }

.timer-display {
    font-family: 'Courier New', Courier, monospace;
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--timer-ok);
    letter-spacing: .08em;
    line-height: 1;
    transition: color .5s;
}
.timer-display.warn { color: var(--timer-warn); }
.timer-display.crit {
    color: var(--timer-crit);
    animation: blink-red .6s step-start infinite;
}
@keyframes blink-red {
    0%,100% { opacity: 1; }
    50%      { opacity: .45; }
}
.timer-display.timer-done { font-size: 1.4rem; color: var(--success); letter-spacing: .05em; }

.timer-label { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; margin-top: 2px; }

.header-logo { flex: 1; display: flex; justify-content: flex-end; }
.header-logo img {
    display: block;
    height: 48px;
    width: auto;
}
.game-header .header-team { flex: 1; }

.header-progress-bar {
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 6px;
    background: var(--border);
    overflow: hidden;
}
.header-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));

    transition: width .6s ease;
}
.header-progress-tick {
    position: absolute;
    top: 0; bottom: 0;
    width: 2px;
    margin-left: -1px;
    background: var(--surface);
}

/* ── VIDEO SECTION ────────────────────────────────────────────────────── */
.section-video {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.video-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 36px 32px;
    max-width: 760px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow);
}
.video-card h2 { font-size: 1.6rem; color: var(--primary); margin-bottom: 10px; }
.video-hint { color: var(--muted); margin-bottom: 24px; font-size: .95rem; }

.yt-frame-wrap {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
    margin-bottom: 20px;
}
.yt-frame-wrap iframe { width: 100% !important; height: 100% !important; }
.yt-frame-wrap video { width: 100%; height: 100%; display: block; }

.no-video-box {
    background: rgba(0,0,0,.03);
    border: 1px dashed var(--border-hi);
    border-radius: 10px;
    padding: 40px;
    color: var(--muted);
    margin-bottom: 20px;
}

.btn-skip-video, .btn-secondary {
    background: var(--card);
    color: var(--muted);
    border: 1px solid var(--border-hi);
    padding: 10px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: .9rem;
    transition: all .2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-skip-video:hover, .btn-secondary:hover { color: var(--text); border-color: var(--primary); }

/* ── GAME SECTION ─────────────────────────────────────────────────────── */
.section-game {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 32px 20px 60px;
}

.puzzle-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 36px 36px 28px;
    max-width: 720px;
    width: 100%;
    box-shadow: var(--shadow);
}

.puzzle-meta {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--primary);
    margin-bottom: 8px;
}
.puzzle-num { font-weight: 700; }

.puzzle-title {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 20px;
    line-height: 1.3;
}

.puzzle-body {
    color: var(--text);
    font-size: 1.02rem;
    line-height: 1.8;
    background: rgba(0,0,0,.025);
    border-left: 3px solid var(--primary);
    border-radius: 0 8px 8px 0;
    padding: 16px 20px;
    margin-bottom: 28px;
    white-space: pre-line;
}

.answer-zone { margin-bottom: 20px; }

.answer-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.answer-input {
    flex: 1;
    padding: 13px 16px;
    background: var(--surface);
    border: 1px solid var(--border-hi);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1.05rem;
    font-family: 'Courier New', Courier, monospace;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.answer-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(145,25,37,.15);
}
.answer-input:disabled { opacity: .5; cursor: not-allowed; }

.answer-feedback {
    margin-top: 10px;
    min-height: 24px;
    font-size: .9rem;
    padding: 6px 0;
    transition: all .3s;
}
.feedback-correct { color: var(--success); font-weight: 600; }
.feedback-wrong   { color: var(--danger); }

/* ── Hints ────────────────────────────────────────────────────────────── */
.hints-zone {
    margin-top: 20px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.hints-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    color: var(--muted);
    font-size: .88rem;
    user-select: none;
    padding: 4px 0;
    transition: color .15s;
}
.hints-header:hover { color: var(--text); }

.hints-arrow { font-size: .7rem; transition: transform .2s; }
.hints-arrow.open { transform: rotate(180deg); }

.hints-list { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }

.hint-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: rgba(0,0,0,.03);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: .92rem;
    color: var(--muted);
}
.hint-num {
    background: rgba(145,25,37,.2);
    color: var(--primary);
    border-radius: 4px;
    padding: 1px 7px;
    font-size: .8rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 1px;
}

/* ── VIDEO MODAL ──────────────────────────────────────────────────────── */
.video-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,.88);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.video-modal.active { display: flex; }

.video-modal-inner {
    background: var(--card);
    border: 1px solid var(--border-hi);
    border-radius: 16px;
    padding: 28px 28px 24px;
    max-width: 700px;
    width: 100%;
    text-align: center;
    box-shadow: 0 0 60px rgba(0,0,0,.8);
    animation: modal-in .25s ease;
}
@keyframes modal-in {
    from { opacity: 0; transform: scale(.94); }
    to   { opacity: 1; transform: scale(1); }
}

.video-modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
}

.feedback-video {
    width: 100%;
    border-radius: 10px;
    background: #000;
    max-height: 380px;
    margin-bottom: 18px;
    display: block;
}

.video-placeholder {
    background: rgba(0,0,0,.03);
    border: 1px dashed var(--border-hi);
    border-radius: 10px;
    padding: 28px;
    color: var(--muted);
    margin-bottom: 18px;
    font-size: 1rem;
}

.yt-modal-wrap {
    width: 100%;
    aspect-ratio: 16/9;
    max-height: 380px;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
    margin-bottom: 18px;
}
.yt-modal-wrap iframe { width: 100%; height: 100%; display: block; }

.video-field .form-input-file + .form-input { margin-top: 4px; }

.btn-modal-close { min-width: 160px; }

/* ── FINISHED ─────────────────────────────────────────────────────────── */
.section-finished {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.finished-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px 40px;
    max-width: 560px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow), 0 0 80px rgba(56,161,105,.08);
}

.finished-icon { font-size: 3.5rem; margin-bottom: 16px; }

.finished-card h2 {
    font-size: 1.7rem;
    color: var(--primary);
    margin-bottom: 10px;
}

.finished-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 28px 0;
    flex-wrap: wrap;
}

.stat-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 24px;
    min-width: 110px;
}
.stat-value {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
}
.stat-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-top: 4px; }

.wait-msg { color: var(--muted); font-size: .9rem; margin-top: 20px; }

/* ── ADMIN LAYOUT ─────────────────────────────────────────────────────── */
.admin-body { background: var(--bg); min-height: 100vh; }

.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px 24px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
}
.sidebar-icon { font-size: 1.4rem; }

.sidebar-nav { flex: 1; }

.nav-item {
    display: block;
    padding: 10px 20px;
    color: var(--muted);
    text-decoration: none;
    font-size: .92rem;
    border-left: 3px solid transparent;
    transition: all .15s;
}
.nav-item:hover { color: var(--text); background: rgba(0,0,0,.03); }
.nav-item.active { color: var(--primary); border-left-color: var(--primary); background: rgba(145,25,37,.06); }
.nav-logout { color: var(--danger); }

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 12px; }

.admin-main {
    flex: 1;
    padding: 32px 36px;
    max-width: 1000px;
    overflow-x: hidden;
}

.admin-section h2 {
    font-size: 1.4rem;
    color: var(--primary);
    margin-bottom: 20px;
}
.admin-section h3 { font-size: 1rem; color: var(--text); margin-bottom: 12px; }

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.section-head h2 { margin-bottom: 0; }

/* ── ADMIN TABLES ─────────────────────────────────────────────────────── */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
    margin-bottom: 28px;
}
.admin-table th {
    text-align: left;
    padding: 10px 14px;
    background: var(--surface);
    color: var(--muted);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 1px solid var(--border);
}
.admin-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.admin-table tr:hover td { background: rgba(0,0,0,.02); }
.admin-table .row-inactive { opacity: .5; }
.action-cell { display: flex; gap: 6px; }

/* Scoreboard specific */
.scoreboard-table .rank-cell { font-family: 'Courier New', Courier, monospace; font-weight: 700; color: var(--primary); font-size: 1rem; }

.status-badge { padding: 3px 10px; border-radius: 20px; font-size: .78rem; font-weight: 600; }
.status-finished { background: rgba(56,161,105,.15); color: #276749; }
.status-playing  { background: rgba(237,137,54,.12); color: #975a16; }
.status-waiting  { background: rgba(113,128,150,.1); color: var(--muted); }
.status-timeout  { background: rgba(229,62,62,.2); color: #a61b1b; }

/* Row coloring */
tr.status-finished td { background: rgba(56,161,105,.04); }
tr.status-playing td  { background: rgba(237,137,54,.05); }
tr.status-timeout td  { background: rgba(229,62,62,.15); }

/* ── ADMIN FORMS ──────────────────────────────────────────────────────── */
.form-card, .danger-zone {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}
.danger-zone { border-color: rgba(229,62,62,.4); }
.danger-zone h3 { color: var(--danger); }
.danger-zone p  { color: var(--muted); font-size: .9rem; margin-bottom: 14px; }

.inline-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.puzzle-form { display: flex; flex-direction: column; gap: 0; }

.form-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 16px;
}
.form-row label { font-size: .82rem; color: var(--muted); font-weight: 500; }
.form-row small { font-size: .75rem; color: var(--muted); margin-top: -3px; }

.form-row-half { display: flex; gap: 16px; }
.form-row-half .form-row { flex: 1; }

.hint-edit-row { display: flex; gap: 16px; }
.hint-edit-text { flex: 1; }
.hint-edit-penalty { width: 160px; flex-shrink: 0; }
.wrong-penalty-row { max-width: 340px; margin-top: 16px; }

.form-input, .form-textarea, .form-input-file {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border-hi);
    border-radius: 8px;
    color: var(--text);
    font-size: .95rem;
    outline: none;
    transition: border-color .2s;
}
.form-input:focus, .form-textarea:focus {
    border-color: var(--primary);
}
.form-textarea { resize: vertical; font-family: inherit; }
.form-input-file { padding: 8px 12px; cursor: pointer; }

.code-field { font-family: 'Courier New', Courier, monospace; text-transform: uppercase; letter-spacing: .06em; }

.form-check { flex-direction: row; align-items: center; }
.form-check label { display: flex; gap: 8px; align-items: center; cursor: pointer; color: var(--text); }

.form-actions { display: flex; gap: 10px; margin-top: 6px; align-items: center; }

.form-hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }

.current-file {
    background: rgba(0,0,0,.03);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: .82rem;
    color: var(--muted);
    margin-bottom: 6px;
}

.loading-text { color: var(--muted); padding: 20px; }

.live-badge {
    display: inline-block;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .1em;
    color: var(--success);
    background: rgba(56,161,105,.12);
    border: 1px solid rgba(56,161,105,.3);
    border-radius: 20px;
    padding: 2px 8px;
    margin-left: 10px;
    vertical-align: middle;
    animation: live-pulse 2s ease-in-out infinite;
}
@keyframes live-pulse {
    0%,100% { opacity: 1; }
    50%      { opacity: .55; }
}

.last-update-label { font-size: .78rem; color: var(--muted); }

.text-warn { color: var(--timer-warn) !important; }
.text-crit { color: var(--timer-crit) !important; animation: blink-red .6s step-start infinite; }

/* ── Screen Flash (correct / wrong) ──────────────────────────────────── */
.screen-flash {
    position: fixed;
    inset: 0;
    z-index: 3000;
    pointer-events: none;
    opacity: .55;
    transition: opacity .45s ease;
}
.screen-flash.flash-green { background: rgba(47,133,90,.75); }
.screen-flash.flash-red   { background: rgba(197,48,48,.75); }
.screen-flash.flash-solved {
    opacity: 1;
    background: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
}
.solved-check {
    width: clamp(120px, 24vw, 200px);
    aspect-ratio: 1;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: flash-pop .3s cubic-bezier(.34,1.56,.64,1);
}
.solved-check svg {
    width: 68%;
    height: 68%;
    fill: none;
    stroke: var(--success);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── Timeout overlay (0:00) ───────────────────────────────────────────── */
.timeout-overlay {
    position: fixed;
    inset: 0;
    z-index: 1500;
    background: rgba(120,0,0,0);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: background 1.2s ease, opacity .4s ease;
}
.timeout-overlay.active {
    background: rgba(120,0,0,.9);
    pointer-events: all;
    opacity: 1;
}
.timeout-overlay.dimmed {
    background: rgba(80,0,0,.18);
    pointer-events: none;
    opacity: 1;
}

.timeout-inner {
    background: var(--card);
    border: 2px solid var(--danger);
    border-radius: 16px;
    padding: 36px 32px;
    max-width: 720px;
    width: 90%;
    text-align: center;
    box-shadow: 0 0 80px rgba(229,62,62,.5);
}
.timeout-overlay.dimmed .timeout-inner { display: none; }
.timeout-overlay.active .timeout-inner {
    animation: timeout-pop .5s cubic-bezier(.34,1.56,.64,1);
}
@keyframes timeout-pop {
    from { transform: scale(.75); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

.timeout-title {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 800;
    color: var(--danger);
    letter-spacing: .08em;
    margin-bottom: 24px;
    animation: danger-pulse 1s ease-in-out infinite;
}
@keyframes danger-pulse {
    0%,100% { opacity: 1; text-shadow: 0 0 20px rgba(229,62,62,.5); }
    50%      { opacity: .7; text-shadow: 0 0 40px rgba(229,62,62,.8); }
}

.timeout-placeholder {
    background: rgba(229,62,62,.08);
    border: 1px dashed rgba(229,62,62,.3);
    border-radius: 10px;
    padding: 30px;
    color: var(--muted);
    margin-bottom: 20px;
}

/* ── Timer Flash Overlay ──────────────────────────────────────────────── */
.timer-flash-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0,0,0,0);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: background .35s;
}
.timer-flash-overlay.flash-visible {
    background: rgba(0,0,0,.82);
    pointer-events: all;
}
.timer-flash-overlay.flash-out { opacity: 0; transition: opacity .45s; }

.timer-flash-inner { text-align: center; animation: flash-pop .3s cubic-bezier(.34,1.56,.64,1); }
@keyframes flash-pop { from { transform: scale(.55); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.timer-flash-clock {
    font-family: 'Courier New', Courier, monospace;
    font-size: clamp(4.5rem, 14vw, 9rem);
    font-weight: 700;
    color: #fff;
    line-height: 1;
    text-shadow: 0 0 40px currentColor;
    transition: color .35s, text-shadow .35s;
}
.flash-penalty .timer-flash-clock {
    color: #ff6b6b;
    text-shadow: 0 0 60px rgba(252,68,68,.55);
    animation: flash-shake .12s ease-in-out 4;
}
@keyframes flash-shake {
    0%,100% { transform: translateX(0); }
    25%      { transform: translateX(-10px); }
    75%      { transform: translateX(10px); }
}

.timer-flash-penalty-label {
    font-size: clamp(1.1rem, 3vw, 1.8rem);
    font-weight: 700;
    color: #ff6b6b;
    margin-top: 18px;
    opacity: 0;
    transition: opacity .3s .1s;
}
.flash-penalty .timer-flash-penalty-label { opacity: 1; }

/* ── Hint buy buttons ─────────────────────────────────────────────────── */
.hint-request-row { margin-bottom: 6px; }

.btn-hint-buy {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(0,0,0,.03);
    border: 1px dashed var(--border-hi);
    border-radius: 8px;
    color: var(--muted);
    cursor: pointer;
    font-size: .88rem;
    transition: all .15s;
    text-align: left;
}
.btn-hint-buy:hover {
    background: rgba(145,25,37,.07);
    border-color: rgba(145,25,37,.4);
    color: var(--text);
}
.btn-hint-buy:disabled { opacity: .5; cursor: not-allowed; }

.hint-buy-num  { font-weight: 600; }
.hint-buy-cost { font-family: 'Courier New', Courier, monospace; color: var(--warning); font-size: .8rem; font-weight: 700; }

.hint-revealed { display: flex; gap: 10px; align-items: flex-start; }

/* ── Game two-column layout ───────────────────────────────────────────── */
.game-columns {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    max-width: 1040px;
    width: 100%;
}
.game-columns-single { max-width: 790px; } /* no scoreboard: same card width */
.game-main-col { flex: 1; min-width: 0; }
.game-side-col  { width: 230px; flex-shrink: 0; }

/* ── Mini Scoreboard ──────────────────────────────────────────────────── */
.mini-scoreboard {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px 16px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 76px;
}

.mini-sb-title {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.mini-sb-title::before { content: '🏆'; font-size: 1rem; }

.mini-sb-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 8px;
    border-radius: 8px;
    margin-bottom: 4px;
    border: 1px solid transparent;
}
.mini-sb-me {
    background: rgba(145,25,37,.07);
    border-color: rgba(145,25,37,.22);
}

.mini-sb-medal { font-size: 1.25rem; flex-shrink: 0; width: 26px; text-align: center; }

.mini-sb-info  { flex: 1; min-width: 0; }
.mini-sb-name  {
    font-size: .86rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mini-sb-you   { color: var(--primary); font-size: .72rem; font-weight: 400; }
.mini-sb-detail{ font-size: .74rem; color: var(--muted); margin-top: 2px; }

.mini-sb-badge {
    font-size: .8rem;
    font-weight: 700;
    flex-shrink: 0;
    padding: 2px 6px;
    border-radius: 5px;
}
.mini-badge-done { color: var(--success); }
.mini-badge-play { color: var(--primary); }
.mini-badge-wait { color: var(--muted); }
.mini-badge-timeout { color: #a61b1b; }
.mini-sb-row.mini-sb-timeout { background: rgba(229,62,62,.15); }

.mini-sb-loading,
.mini-sb-empty { color: var(--muted); font-size: .82rem; padding: 6px 4px; }

.mini-sb-separator {
    text-align: center;
    color: var(--border-hi);
    font-size: .75rem;
    letter-spacing: .15em;
    padding: 4px 0 2px;
}
.mini-sb-own-rank {
    font-size: .72rem;
    color: var(--muted);
    text-align: center;
    padding: 2px 4px 6px;
}

/* ── Hint Confirm Modal ───────────────────────────────────────────────── */
.confirm-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(0,0,0,.78);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.confirm-modal.active { display: flex; }

.confirm-inner {
    background: var(--card);
    border: 1px solid var(--border-hi);
    border-radius: 16px;
    padding: 32px 28px 28px;
    max-width: 360px;
    width: 100%;
    text-align: center;
    box-shadow: 0 0 60px rgba(0,0,0,.8);
    animation: modal-in .22s ease;
}

.confirm-icon  { font-size: 2.2rem; margin-bottom: 10px; }

.confirm-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
}

.confirm-cost {
    font-family: 'Courier New', Courier, monospace;
    font-size: 2rem;
    font-weight: 700;
    color: var(--warning);
    margin-bottom: 10px;

}

.confirm-note {
    font-size: .8rem;
    color: var(--muted);
    margin-bottom: 24px;
}

.confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.intro-inner { max-width: 480px; }
.intro-text {
    font-size: 1.15rem;
    line-height: 1.55;
    color: var(--primary);
    margin-bottom: 24px;
}
.btn-intro-reopen {
    padding: 2px 10px;
    font-size: .75rem;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border-hi);
    border-radius: 12px;
    cursor: pointer;
}
.btn-intro-reopen:hover { color: var(--primary); border-color: var(--primary); }

.confirm-actions .btn-secondary,
.confirm-actions .btn-warning { min-width: 130px; }

/* ── Zeiten-Tab ───────────────────────────────────────────────────────── */
.time-table .time-th { text-align: center; min-width: 72px; }
.time-table td       { text-align: center; }
.time-table td:first-child { text-align: left; min-width: 120px; }
.time-fast  { color: var(--success) !important; }
.time-slow  { color: var(--timer-warn) !important; }
.time-wrong { font-size: .7rem; color: var(--danger); margin-left: 3px; vertical-align: super; }
.time-empty { color: var(--muted); }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 820px) {
    .game-columns  { flex-direction: column; }
    .game-side-col { width: 100%; }
    .mini-scoreboard { position: static; }
}

@media (max-width: 640px) {
    .admin-sidebar { display: none; }
    .admin-main    { padding: 20px; }
    .game-header   { padding: 10px 14px; gap: 8px; }
    .header-logo img { height: 34px; }
    .timer-display { font-size: 1.8rem; }
    .puzzle-card   { padding: 24px 18px; }
    .answer-row    { flex-direction: column; }
    .finished-stats{ gap: 12px; }
    .form-row-half { flex-direction: column; gap: 0; }
    .hint-edit-row { flex-direction: column; gap: 0; }
    .hint-edit-penalty { width: auto; }
}
