:root {
    color-scheme: dark;
    --ink: #f7f7fb;
    --muted: #b9c0d4;
    --bg: #101119;
    --panel: rgba(19, 21, 34, 0.78);
    --line: rgba(255, 255, 255, 0.15);
    --blue: #2459ff;
    --cyan: #22d3ee;
    --rose: #ff4d8d;
    --gold: #ffd166;
    --green: #38d996;
    --danger: #ff6575;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 18% 12%, rgba(34, 211, 238, 0.22), transparent 28%),
        radial-gradient(circle at 82% 20%, rgba(255, 77, 141, 0.2), transparent 24%),
        linear-gradient(135deg, #0b0c12 0%, #171927 42%, #101119 100%);
    color: var(--ink);
}

button, input, textarea {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
}

.hero {
    min-height: 100vh;
    display: grid;
    place-items: center;
    overflow: hidden;
    position: relative;
    padding: 24px;
    isolation: isolate;
}

.hero-art {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(5, 7, 16, 0.92) 0%, rgba(8, 10, 20, 0.7) 38%, rgba(8, 10, 20, 0.18) 72%),
        radial-gradient(circle at 68% 12%, rgba(255, 209, 102, 0.24), transparent 28%),
        url("assets/hero-jeopardy-studio.png") center / cover;
}

.hero-art::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(0, 0, 0, 0.14), rgba(0, 0, 0, 0.48)),
        radial-gradient(circle at 76% 58%, transparent 0 24%, rgba(3, 5, 12, 0.55) 72%);
}

.hero-art::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background:
        linear-gradient(100deg, transparent 0 38%, rgba(255, 255, 255, 0.16) 39%, transparent 45%),
        linear-gradient(80deg, transparent 0 62%, rgba(34, 211, 238, 0.13) 63%, transparent 70%);
    mix-blend-mode: screen;
    opacity: 0.75;
}

.tile {
    position: absolute;
    z-index: 1;
    display: grid;
    place-items: center;
    min-width: 120px;
    height: 84px;
    padding: 0 18px;
    border: 1px solid rgba(255,255,255,0.28);
    background: rgba(36, 89, 255, 0.78);
    color: white;
    font-weight: 900;
    font-size: 28px;
    transform: rotate(var(--r));
    box-shadow: 0 24px 80px rgba(0,0,0,0.35);
    backdrop-filter: blur(8px);
}

.t1 { --r: -8deg; top: 13%; right: 17%; }
.t2 { --r: 6deg; top: 36%; right: 7%; background: rgba(255, 77, 141, 0.82); }
.t3 { --r: 4deg; bottom: 14%; right: 18%; background: rgba(255, 209, 102, 0.9); color: #15110a; }
.t4 { --r: -4deg; bottom: 20%; left: 12%; background: rgba(56, 217, 150, 0.78); color: #07150f; }
.t5 { --r: 7deg; top: 15%; left: 15%; background: rgba(34, 211, 238, 0.76); color: #051115; }

.hero-panel {
    position: relative;
    z-index: 2;
    width: min(560px, 100%);
    margin-right: auto;
    margin-left: min(8vw, 100px);
    padding: 34px;
    border: 1px solid var(--line);
    background: rgba(12, 13, 22, 0.72);
    backdrop-filter: blur(18px);
    box-shadow: 0 30px 120px rgba(0,0,0,0.42), inset 0 1px 0 rgba(255,255,255,0.08);
}

.hero-panel h1 {
    margin: 0 0 14px;
    font-size: clamp(48px, 8vw, 96px);
    line-height: 0.92;
}

.hero-panel p {
    color: var(--muted);
    font-size: 18px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--cyan);
    text-transform: uppercase;
    letter-spacing: 0;
    font-size: 12px;
    font-weight: 800;
}

.login-form {
    display: flex;
    gap: 10px;
    margin-top: 30px;
}

input, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--ink);
    padding: 13px 14px;
    outline: 0;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

.primary, .ghost, .danger {
    min-height: 44px;
    border-radius: 8px;
    padding: 0 16px;
    color: white;
    font-weight: 800;
}

.primary { background: linear-gradient(135deg, var(--blue), #7c3aed); }
.ghost { background: rgba(255,255,255,0.1); border: 1px solid var(--line); }
.danger { background: rgba(255, 101, 117, 0.16); color: #ffd7dc; border: 1px solid rgba(255,101,117,0.4); }
.mini { min-height: 34px; font-size: 12px; }
.wide { width: 100%; margin-top: 10px; }

.form-error {
    min-height: 24px;
    color: #ffd7dc !important;
}

.dashboard, .editor, .play {
    min-height: 100vh;
    padding: 26px;
}

.topbar, .playbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.topbar h1, .playbar h1 {
    margin: 0;
    font-size: 42px;
}

.top-actions, .card-actions, .stage-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.game-list {
    display: grid;
    gap: 14px;
}

.game-card, .category-block, .editor-meta, .modal-box {
    border: 1px solid var(--line);
    background: var(--panel);
    backdrop-filter: blur(14px);
    border-radius: 8px;
}

.game-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 20px;
}

.game-card h2 {
    margin: 0;
}

.game-card p {
    margin: 0;
    color: var(--muted);
}

.game-title-line {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 5px;
}

.session-summary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(255,255,255,0.11);
    border-radius: 999px;
    padding: 5px 10px;
    background: rgba(255,255,255,0.055);
    color: var(--ink);
    font-size: 12px;
    line-height: 1.2;
}

.session-summary:hover {
    border-color: rgba(34, 211, 238, 0.5);
    background: rgba(34, 211, 238, 0.08);
}

.session-summary.empty {
    border-color: transparent;
    background: transparent;
    color: var(--muted);
    padding-inline: 0;
}

.session-summary strong {
    color: var(--gold);
    font-weight: 800;
}

.compact {
    align-items: flex-end;
}

.title-input {
    font-size: 34px;
    font-weight: 900;
}

.editor-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 18px;
    margin-bottom: 18px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.team-editor {
    min-width: 0;
}

.team-list {
    display: grid;
    gap: 8px;
}

.team-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.category-tools {
    margin-bottom: 18px;
}

.category-editor {
    display: grid;
    gap: 18px;
}

.category-block {
    padding: 16px;
}

.category-head {
    display: flex;
    gap: 12px;
    margin-bottom: 14px;
}

.category-head input {
    font-weight: 900;
}

.question-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.question-table {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
}

.question-table-head, .question-row {
    display: grid;
    grid-template-columns: 92px minmax(220px, 1.25fr) minmax(220px, 1.25fr) minmax(210px, 0.9fr);
    gap: 10px;
    align-items: start;
}

.question-table-head {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.question-row {
    padding: 10px;
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 8px;
    background: rgba(255,255,255,0.045);
}

.question-row textarea {
    min-height: 118px;
}

.question-card {
    display: grid;
    gap: 12px;
    padding: 14px;
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
}

.image-control {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.image-stack {
    display: grid;
    gap: 10px;
}

.image-control img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 8px;
}

.play {
    display: grid;
    grid-template-rows: auto 1fr;
    padding: 16px;
}

.playbar {
    min-height: 96px;
    margin: 0 0 14px;
}

.scoreboard {
    display: flex;
    gap: 10px;
    flex: 1;
    justify-content: center;
}

.score {
    min-width: 130px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 14px;
    background: rgba(255,255,255,0.08);
    text-align: center;
}

.score span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.score strong {
    font-size: 32px;
}

.board {
    display: grid;
    grid-template-columns: repeat(var(--cols), minmax(130px, 1fr));
    gap: 10px;
    min-height: 0;
}

.board-column {
    display: grid;
    grid-template-rows: minmax(82px, 0.72fr) repeat(5, minmax(82px, 1fr));
    gap: 10px;
    min-height: 0;
}

.board-category, .board-cell {
    display: grid;
    place-items: center;
    border-radius: 8px;
    text-align: center;
    padding: 10px;
    min-width: 0;
}

.board-category {
    background: rgba(255,255,255,0.14);
    border: 1px solid var(--line);
    font-weight: 900;
    text-transform: uppercase;
}

.board-cell {
    background: linear-gradient(135deg, rgba(36, 89, 255, 0.95), rgba(124, 58, 237, 0.88));
    color: var(--gold);
    font-size: clamp(26px, 4vw, 58px);
    font-weight: 1000;
    text-shadow: 0 3px 0 rgba(0,0,0,0.3);
}

.board-cell.opened {
    color: rgba(255, 255, 255, 0.42);
    background: rgba(255,255,255,0.07);
    text-shadow: none;
}

.modal, .question-modal, .winner {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(5, 6, 12, 0.78);
    backdrop-filter: blur(12px);
}

.modal-box {
    width: min(520px, 100%);
    padding: 24px;
}

.import-box {
    width: min(820px, 100%);
}

.import-box textarea {
    min-height: 320px;
    margin-top: 12px;
}

.question-stage {
    width: min(1100px, 100%);
    max-height: 94vh;
    overflow: auto;
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 8px;
    padding: 32px;
    background: linear-gradient(135deg, rgba(18, 24, 46, 0.96), rgba(42, 25, 60, 0.96));
    text-align: center;
}

.question-value {
    color: var(--gold);
    font-size: 34px;
    font-weight: 1000;
}

.question-stage h2 {
    font-size: clamp(34px, 5vw, 72px);
    line-height: 1.05;
}

.answer p {
    font-size: clamp(28px, 4vw, 54px);
    color: var(--green);
    font-weight: 900;
}

.stage-image {
    max-width: min(760px, 100%);
    max-height: 42vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 80px rgba(0,0,0,0.35);
}

.award-row {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 24px 0;
}

.winner {
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 25%, rgba(255, 209, 102, 0.34), transparent 30%),
        linear-gradient(135deg, rgba(36, 89, 255, 0.92), rgba(255, 77, 141, 0.9));
}

.winner-copy {
    position: relative;
    z-index: 2;
    text-align: center;
    animation: winnerPop 900ms cubic-bezier(.2, 1.4, .3, 1) both;
}

.winner-copy p {
    text-transform: uppercase;
    font-weight: 900;
}

.winner-copy h2 {
    margin: 0;
    font-size: clamp(54px, 12vw, 150px);
    line-height: 0.9;
}

.winner-copy strong {
    display: block;
    margin: 18px 0 32px;
    font-size: 34px;
    color: var(--gold);
}

.confetti i {
    position: absolute;
    top: -20px;
    left: var(--x);
    width: 12px;
    height: 24px;
    background: hsl(calc(var(--i) * 41), 90%, 62%);
    animation: fall calc(2.5s + var(--d)) linear infinite;
    transform: rotate(calc(var(--i) * 17deg));
}

@keyframes fall {
    to { transform: translateY(110vh) rotate(720deg); }
}

@keyframes winnerPop {
    from { transform: scale(0.7); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@media (max-width: 800px) {
    .hero-panel { margin: 0; }
    .login-form, .topbar, .playbar, .game-card, .editor-meta, .category-head {
        flex-direction: column;
        display: flex;
        align-items: stretch;
    }
    .scoreboard { flex-wrap: wrap; justify-content: flex-start; }
    .question-table-head { display: none; }
    .question-row {
        grid-template-columns: 1fr;
    }
    .board {
        grid-template-columns: repeat(var(--cols), minmax(96px, 1fr));
        overflow-x: auto;
    }
    .topbar h1, .playbar h1 { font-size: 30px; }
}
