/* Prompt Relay — global styles.
   A clean, playful party-game look with a dark backdrop and bright accents.
   Kept dependency-free (no build step, no external fonts). */

:root {
    --bg: #0f1226;              /* page background */
    --bg-soft: #1a1e3a;         /* card background */
    --bg-soft-2: #232849;       /* nested surfaces */
    --ink: #eef0ff;             /* primary text */
    --ink-muted: #a6abcf;       /* secondary text */
    --accent: #ff6b6b;          /* primary accent (buttons, brand) */
    --accent-2: #5ea0ff;        /* secondary accent */
    --good: #4ecb80;            /* detail present */
    --bad: #ff7a90;             /* detail absent */
    --border: #313765;
    --radius: 16px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: radial-gradient(1200px 600px at 50% -10%, #23285a 0%, var(--bg) 55%);
    color: var(--ink);
    line-height: 1.55;
    min-height: 100vh;
}

/* Header */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    backdrop-filter: blur(8px);
    background: rgba(15, 18, 38, 0.7);
    z-index: 10;
}
.brand { font-weight: 800; font-size: 1.2rem; color: var(--ink); text-decoration: none; }
.site-header nav { display: flex; align-items: center; gap: 24px; }
.site-header nav a { color: var(--ink-muted); text-decoration: none; font-weight: 600; white-space: nowrap; }
.site-header nav a:hover { color: var(--ink); }

/* Layout */
.container { max-width: 900px; margin: 0 auto; padding: 28px 20px 60px; }

.card {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
    margin-bottom: 22px;
}
.card.center { text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }

h1 { font-size: 2rem; margin: 0 0 8px; }
h2 { font-size: 1.3rem; margin: 0 0 16px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.78rem; color: var(--accent-2); margin: 0 0 4px; font-weight: 700; }
.lede { color: var(--ink-muted); font-size: 1.05rem; }
.muted { color: var(--ink-muted); font-size: 0.9rem; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 20px; }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.field span { font-size: 0.95rem; }
input[type="text"], select, textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-soft-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--ink);
    font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); border-color: transparent; }

.btn {
    display: inline-block;
    padding: 12px 22px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-soft-2);
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.05s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: transparent; color: #2a0a0a; }

/* Login error banner */
.login-error {
    background: rgba(255, 122, 144, 0.14);
    border: 1px solid var(--bad);
    color: var(--bad);
    border-radius: 12px;
    padding: 10px 14px;
    font-weight: 600;
    margin: 0 0 8px;
}

/* Timer */
.timer {
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    background: var(--bg-soft-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 18px;
    min-width: 84px;
    text-align: center;
    /* Pinned so the countdown stays on screen while the player scrolls the
       round page (fixed, top-right, below the sticky site header). */
    position: fixed;
    top: 74px;
    right: 24px;
    z-index: 50;
    box-shadow: var(--shadow);
}
.timer.big { font-size: 2.4rem; }
.timer.warn { color: #ffd166; border-color: #ffd166; }
.timer.danger { color: var(--accent); border-color: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 50% { filter: brightness(1.4); } }

/* Canvas */
.canvas-frame {
    background: var(--bg-soft-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.canvas-frame.small { aspect-ratio: 1 / 1; }
.canvas-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.canvas-blank {
    color: var(--ink-muted);
    text-align: center;
    font-weight: 700;
    padding: 20px;
}
.canvas-blank span { font-weight: 400; font-size: 0.85rem; }

/* Round layout — one centered image (the target for P1, or the previous player's
   image for P2/P3), with the prompt form below. Trimmed padding + a height-capped
   image so the whole round fits a laptop viewport without scrolling. */
.round-card { padding: 20px 24px; }
.round-card h1 { font-size: 1.5rem; }
.round-single { max-width: 460px; margin: 10px auto 0; }
.canvas-panel { margin: 0; }
/* Cap the image by height (not a 1:1 box) so tall screens don't overflow. */
.round-single .canvas-frame { aspect-ratio: auto; }
.round-single .canvas-img { max-height: 40vh; width: auto; max-width: 100%; }
.canvas-panel figcaption { text-align: center; color: var(--accent-2); font-weight: 700; margin-top: 8px; }
.prompt-form { margin: 14px 0 0; }

/* Requirement 1: "generating" overlay shown while the image is being made. */
.gen-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 18, 38, 0.82);
    backdrop-filter: blur(6px);
    animation: gen-fade 0.25s ease;
}
.gen-overlay[hidden] { display: none; }
.gen-overlay__box {
    max-width: 460px;
    text-align: center;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 34px 30px;
}
.gen-spinner {
    width: 54px;
    height: 54px;
    margin: 0 auto 18px;
    border-radius: 50%;
    border: 5px solid var(--bg-soft-2);
    border-top-color: var(--accent);
    border-right-color: var(--accent-2);
    animation: gen-spin 0.9s linear infinite;
}
.gen-overlay__title { margin: 0 0 6px; font-size: 1.4rem; }
.gen-overlay__sub { margin: 0; color: var(--ink-muted); }
.gen-overlay__prompt {
    margin: 16px 0 0;
    padding: 12px 16px;
    border-left: 4px solid var(--accent-2);
    border-radius: 8px;
    background: var(--bg-soft-2);
    color: var(--ink);
    font-style: italic;
    text-align: left;
}
@keyframes gen-spin { to { transform: rotate(360deg); } }
@keyframes gen-fade { from { opacity: 0; } to { opacity: 1; } }

/* Reveal / results */
.score-row { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; }
.score-badge {
    background: var(--bg-soft-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px 26px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.score-badge .score-num { font-size: 2.6rem; font-weight: 800; color: var(--good); line-height: 1; }
.score-badge.subtle .score-num { color: var(--accent-2); font-size: 2rem; }
.score-den { color: var(--ink-muted); font-weight: 700; }
.score-label { color: var(--ink-muted); font-size: 0.85rem; margin-top: 6px; }

.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.compare-grid figcaption, .relay-step figcaption { text-align: center; color: var(--ink-muted); margin-top: 8px; }

.verdict-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.verdict {
    display: grid;
    grid-template-columns: 28px 1fr;
    grid-template-areas: "mark detail" "mark reason";
    gap: 2px 10px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--bg-soft-2);
    border-left: 4px solid var(--border);
}
.verdict.hit { border-left-color: var(--good); }
.verdict.miss { border-left-color: var(--bad); }
.verdict .mark { grid-area: mark; font-size: 1.3rem; font-weight: 800; }
.verdict.hit .mark { color: var(--good); }
.verdict.miss .mark { color: var(--bad); }
.verdict .detail { grid-area: detail; font-weight: 700; }
.verdict .reason { grid-area: reason; color: var(--ink-muted); font-size: 0.9rem; }

.relay-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.relay-step .prompt-quote { display: block; font-style: italic; color: var(--ink); margin-top: 4px; }

/* Leaderboard */
.table-wrap { overflow-x: auto; }
table.leaderboard { width: 100%; border-collapse: collapse; }
table.leaderboard th, table.leaderboard td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
table.leaderboard th { color: var(--ink-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }
table.leaderboard tbody tr:hover { background: var(--bg-soft-2); }
.rank { font-weight: 800; color: var(--accent-2); }
.thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; border: 1px solid var(--border); }
.pill { display: inline-block; background: var(--bg-soft-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 12px; font-weight: 700; }
.row-new { animation: flash 1.4s ease; }
@keyframes flash { from { background: rgba(94, 160, 255, 0.28); } to { background: transparent; } }
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--good); margin-right: 6px; box-shadow: 0 0 0 0 rgba(78,203,128,0.6); animation: live 1.6s infinite; }
@keyframes live { 70% { box-shadow: 0 0 0 8px rgba(78,203,128,0); } }
.empty-state { color: var(--ink-muted); text-align: center; padding: 30px; }

/* Winners podium — up to five ranked pedestals (rank 1 tallest, descending).
   Each pedestal lists every group tied at that score, so a pedestal with 2+
   cards is a tie. Cards are clickable to open the breakdown modal. */
.podium {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 12px;
    margin: 10px 0 28px;
    flex-wrap: wrap;
}
.podium-tier {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1 1 148px;
    max-width: 220px;
    min-width: 130px;
}
.tier-groups { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-bottom: 10px; }
.podium-place {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
    padding: 12px 10px;
    border-radius: 12px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.08s ease, filter 0.15s ease;
}
.podium-place:hover, .podium-place:focus-visible { filter: brightness(1.12); transform: translateY(-2px); outline: none; }
.podium-thumb { width: 60px; height: 60px; border-radius: 10px; object-fit: cover; border: 1px solid var(--border); }
.podium-name { font-weight: 800; }
.podium-gid { color: var(--ink-muted); font-size: 0.8rem; }
.podium-pct { font-size: 1.3rem; font-weight: 800; color: var(--good); }
/* Pedestal "riser" whose FIXED, rank-based height creates the stepped podium
   (rank 1 tallest). Height is driven only by rank — never by label length — so
   the steps always descend. Medal (or rank number) is centered on the riser. */
.tier-riser {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px 12px 0 0;
    background: var(--bg-soft-2);
    border: 1px solid var(--border);
    border-bottom: none;
}
.tier-medal { font-size: 1.9rem; line-height: 1; font-weight: 800; }
/* Fixed-height caption below the riser so every column shares the same bottom
   block; long "Tied for …" labels wrap inside it without shifting the steps. */
.tier-caption {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: 800;
    font-size: 0.82rem;
    line-height: 1.15;
    padding: 0 4px;
}
/* Descending riser heights + medal accents (gold/silver/bronze). */
.podium .tier-1 .tier-riser { height: 92px; border-color: #ffd24a; background: linear-gradient(180deg, rgba(255,210,74,0.24), var(--bg-soft-2)); }
.podium .tier-2 .tier-riser { height: 74px; border-color: #cfd3e0; background: linear-gradient(180deg, rgba(207,211,224,0.18), var(--bg-soft-2)); }
.podium .tier-3 .tier-riser { height: 58px; border-color: #e0975a; background: linear-gradient(180deg, rgba(224,151,90,0.18), var(--bg-soft-2)); }
.podium .tier-4 .tier-riser { height: 44px; }
.podium .tier-5 .tier-riser { height: 32px; }
.podium .tier-1 .tier-medal { font-size: 2.2rem; }

/* Table rows are clickable to open the breakdown modal. */
.leaderboard tbody tr.lb-row { cursor: pointer; }

/* Breakdown modal (opened from the leaderboard). */
.lb-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 18, 38, 0.82);
    backdrop-filter: blur(6px);
    animation: gen-fade 0.2s ease;
}
.lb-modal[hidden] { display: none; }
.lb-modal__box {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: 88vh;
    overflow-y: auto;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
}
.lb-modal__close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    color: var(--ink-muted);
    font-size: 1.9rem;
    line-height: 1;
    cursor: pointer;
}
.lb-modal__close:hover { color: var(--ink); }
.modal-gid { color: var(--ink-muted); font-weight: 600; font-size: 1rem; }
#lb-download { margin: 4px 0 18px; }
/* Caption under the swappable generated image (which round + its prompt). */
#modal-gen-cap { text-align: center; color: var(--ink-muted); margin-top: 8px; font-weight: 700; }
#modal-gen-cap .prompt-quote { display: block; font-style: italic; font-weight: 400; color: var(--ink); margin-top: 4px; }
/* Toggle bar: one compressed thumbnail per generated round; the active one is
   accented. Clicking swaps the large generated image above. */
.modal-toggle-bar { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 14px 0 4px; }
.modal-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--bg-soft-2);
    color: var(--ink-muted);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.12s ease, filter 0.12s ease;
}
.modal-toggle:hover { filter: brightness(1.12); }
.modal-toggle.active { border-color: var(--accent-2); color: var(--ink); }
.modal-toggle-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; }
/* Placeholder thumbnail for a solo round that was forfeited (no image). */
.modal-toggle-thumb--blank { display: grid; place-items: center; color: var(--ink-muted); background: var(--surface-2, rgba(127,127,127,0.12)); }

/* Solo: per-round blocks on the reveal + the group/solo board switch link */
.solo-round { padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--border); }
.solo-round:first-of-type { padding-top: 0; margin-top: 0; border-top: 0; }
.board-switch { margin: 0 0 4px; }

/* How-to list + hero */
.hero .lede { max-width: 60ch; }
.how-to ol { margin: 0; padding-left: 20px; color: var(--ink-muted); }
.how-to li { margin-bottom: 6px; }

/* Responsive */
@media (max-width: 720px) {
    .compare-grid { grid-template-columns: 1fr; }
    .relay-grid { grid-template-columns: 1fr; }
    h1 { font-size: 1.6rem; }
    .timer.big { font-size: 1.8rem; }
    /* Keep the pinned timer clear of the header + screen edge on small screens. */
    .timer { top: 64px; right: 12px; padding: 8px 14px; min-width: 64px; }
    .round-single .canvas-img { max-height: 34vh; }
}
