/* Prompt Fighter II — shared styles.
   Black arena from the original game, Hymaïa DS 26 for everything on it:
   lime (#DDFF00) as the dark-ground primary, Greycliff CF, 15px panels with
   hairlines, pill buttons, DS status tones. Page-specific rules live in each
   page's <style> block. */

@font-face { font-family: 'Greycliff CF'; src: url('fonts/GreycliffCF-Light.woff2') format('woff2'); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: 'Greycliff CF'; src: url('fonts/GreycliffCF-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Greycliff CF'; src: url('fonts/GreycliffCF-RegularOblique.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Greycliff CF'; src: url('fonts/GreycliffCF-Medium.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Greycliff CF'; src: url('fonts/GreycliffCF-DemiBold.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Greycliff CF'; src: url('fonts/GreycliffCF-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Greycliff CF'; src: url('fonts/GreycliffCF-ExtraBold.woff2') format('woff2'); font-weight: 800; font-style: normal; font-display: swap; }
@font-face { font-family: 'Greycliff CF'; src: url('fonts/GreycliffCF-Heavy.woff2') format('woff2'); font-weight: 900; font-style: normal; font-display: swap; }

/* ---------- Tokens ---------- */
:root {
    /* DS 26 */
    --lime: #DDFF00;
    --lime-hover: #C2E000;
    --lime-active: #A8C400;
    --navy: #1B1768;              /* ink on lime and on white */
    --white: #FFFFFF;

    /* Ground */
    --background: #05060A;
    --raised: #14151C;            /* floating surfaces: toast, dock, chips */
    --panel: rgba(255, 255, 255, 0.06);
    --field: rgba(255, 255, 255, 0.07);
    --scrim: rgba(5, 6, 10, 0.9);

    /* Roles */
    --foreground: var(--white);
    --muted: #BFBCE6;             /* content-on-inverse-secondary */
    --border-soft: rgba(255, 255, 255, 0.18);
    --border-strong: rgba(255, 255, 255, 0.45);
    --accent: var(--lime);
    --on-accent: var(--navy);
    --error: #EB908F;             /* status-error-on-inverse */
    --error-solid: #DA3633;
    --success: #4AB792;           /* status-success-on-inverse */
    --info: #A598FF;              /* status-info-on-inverse */

    /* Type */
    --font: 'Greycliff CF', ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --fs-display: clamp(28px, 1.25rem + 2.5vw, 52px);
    --fs-h2: clamp(22px, 1.1rem + 1vw, 32px);
    --fs-h3: clamp(18px, 1rem + 0.4vw, 22px);
    --fs-stat: clamp(28px, 1.2rem + 2.2vw, 48px);
    --tracking-display: -0.025em;
    --tracking-tag: 0.04em;
    --tracking-eyebrow: 0.08em;

    /* Spacing scale */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 24px;
    --sp-6: 32px;
    --sp-7: 48px;
    --gutter: clamp(16px, 3vw, 32px);

    /* Shape & motion */
    --r-sm: 6px;
    --r-md: 10px;
    --r-card: 15px;
    --r-pill: 9999px;
    --cta-glow: 0 6px 24px rgba(221, 255, 0, 0.25);
    --shadow-float: 0 16px 40px rgba(0, 0, 0, 0.5);
    --ease: cubic-bezier(0.2, 0, 0.2, 1);
    --dur-fast: 150ms;
    --dur-base: 250ms;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

* { font-synthesis: none; }

html { background: var(--background); }

/* Page shell: logo on top, the active section fills the rest of the viewport.
   No position here: thumbnails on the big screen are placed with document offsets. */
body {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 800px;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    padding: var(--gutter);
    background: var(--background);
    color: var(--foreground);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

::selection { background: var(--lime); color: var(--navy); }

h1, h2, h3 { margin: 0; line-height: 1.2; color: var(--foreground); }
p { margin: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

section { display: none; }
section.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1 0 auto;
    gap: var(--sp-5);
    padding: var(--sp-5) 0;
}

.hidden { display: none; }

/* ---------- Controls ---------- */
button {
    font-family: var(--font);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    background: var(--accent);
    color: var(--on-accent);
    border: 1.5px solid transparent;
    border-radius: var(--r-pill);
    padding: 10px 20px;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease),
                transform var(--dur-fast) var(--ease);
}
button:hover { background: var(--lime-hover); }
button:active { transform: scale(0.97); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Secondary on a dark ground: white outline, fills white on hover */
button.secondary,
.btn-secondary {
    background: transparent;
    color: var(--white);
    border-color: var(--white);
}
button.secondary:hover,
.btn-secondary:hover {
    background: var(--white);
    color: var(--navy);
}

button:disabled,
button:disabled:hover,
button.secondary:disabled,
.btn-secondary:disabled {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.4);
    border-color: transparent;
    box-shadow: none;
    transform: none;
    cursor: not-allowed;
}

.btn {
    padding: 14px 28px;
    font-size: 16px;
}

/* The one glow left: the game's primary call to action */
.btn-accent { box-shadow: var(--cta-glow); }
.btn-accent:active { background: var(--lime-active); }

input, select, textarea {
    font-family: var(--font);
    font-size: 16px; /* iOS won't zoom at 16px or larger */
    line-height: 1.4;
    max-width: 100%;
    background: var(--field);
    color: var(--foreground);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    padding: 10px 12px;
    transition: border-color var(--dur-fast) var(--ease);
}
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
}
select option { background: var(--raised); color: var(--white); }

::placeholder { color: rgba(255, 255, 255, 0.5); opacity: 1; }

/* ---------- Layout ---------- */
.logo-container {
    flex: none;
    text-align: center;
}
#logo {
    display: inline-block;
    width: 100%;
    max-width: 280px;
    height: auto;
}

.section-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--sp-5);
}

.panel-card {
    width: 100%;
    max-width: 720px;
    padding: clamp(20px, 4vw, 32px);
    background: var(--panel);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-card);
    text-align: center;
    /* gap, not sibling margins: hidden children (empty errors, hidden images) take no space */
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.panel-scroll {
    max-height: 320px;
    overflow-y: auto;
    padding: var(--sp-2);
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--r-md);
}
.panel-scroll::-webkit-scrollbar { width: 6px; }
.panel-scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: var(--r-pill); }

.action-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--sp-3);
}

.form-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.form-row input { flex: 1 1 180px; min-width: 0; }

.admin-form {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    margin: var(--sp-5) auto;
}
#admin-auth-form { display: none; }

/* ---------- Type roles ---------- */
/* Display: Heavy, all caps, tight — section-scale headings only */
.hero-title {
    font-size: var(--fs-display);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: var(--tracking-display);
    line-height: 1.12;
    text-align: center;
}

/* Eyebrow: Light, uppercase, tracked */
.hero-subtitle {
    color: var(--accent);
    font-size: 14px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: var(--tracking-eyebrow);
    text-align: center;
}

.section-heading {
    font-size: var(--fs-h3);
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    margin-bottom: var(--sp-4);
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-accent { color: var(--accent); }
.text-muted { color: var(--muted); }
.text-error { color: var(--error); }
.mb-3 { margin-bottom: var(--sp-4); }
.mb-4 { margin-bottom: var(--sp-5); }
.panel-card .mb-3,
.panel-card .mb-4 { margin-bottom: 0; } /* the panel's gap spaces its children */

.error:empty { display: none; }

.list-reset { list-style: none; margin: 0; padding: 0; }
.list-item + .list-item { margin-top: var(--sp-1); }

/* ---------- Game components ---------- */
.game-link {
    display: block;
    padding: var(--sp-3) var(--sp-4);
    color: var(--foreground);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.game-link:hover {
    text-decoration: none;
    color: var(--accent);
    background: rgba(221, 255, 0, 0.06);
    border-color: rgba(221, 255, 0, 0.4);
}

/* Stat chip pinned to the viewport corner (only the active section's chip shows) */
.corner-badge {
    position: fixed;
    top: var(--gutter);
    right: var(--gutter);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    line-height: 1;
    background: var(--raised);
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: var(--tracking-tag);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-pill);
}
.corner-badge span {
    color: var(--accent);
    font-size: 20px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
}

/* Timer as a stat */
.timer-pill {
    color: var(--accent);
    font-size: var(--fs-stat);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1;
    text-align: center;
    transition: color var(--dur-base) var(--ease);
}
.timer-pill:empty { display: none; }
.timer-pill.is-urgent { color: var(--error); }

.qr-frame {
    width: 100%;
    max-width: 300px;
    padding: var(--sp-3);
    background: var(--white);
    border-radius: var(--r-card);
}
.qr-frame img,
#game-qrcode { display: block; width: 100%; border-radius: var(--r-sm); }

.image-container { text-align: center; }
.image-container img,
#target-image,
#jury-target-image {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    object-fit: contain;
    border: 1px solid var(--border-soft);
    border-radius: var(--r-card);
}
.panel-highlight,
img.panel-highlight {
    border: 2px solid var(--accent);
    border-radius: var(--r-card);
}
.image-container.panel-highlight { overflow: hidden; }
.image-container.panel-highlight img { width: 100%; border: 0; border-radius: 0; }

/* Alerts — DS status tones, inverse variants */
.alert,
.error-message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    font-weight: 500;
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    background: var(--panel);
}
.alert::before,
.error-message::before {
    content: '';
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}
.alert-warning { color: var(--accent); border-color: rgba(221, 255, 0, 0.4); background: rgba(221, 255, 0, 0.06); }
.alert-error,
.error-message { color: var(--error); border-color: rgba(235, 144, 143, 0.5); background: rgba(218, 54, 51, 0.12); }
.error-message { animation: slideInUp var(--dur-base) var(--ease); }

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* Progress */
.progress-wrapper { width: 100%; text-align: center; }
.progress-shell {
    width: 100%;
    max-width: 640px;
    height: 12px;
    margin: 0 auto var(--sp-3);
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--r-pill);
    overflow: hidden;
}
.progress-fill {
    width: 0%;
    height: 100%;
    background: var(--accent);
    border-radius: var(--r-pill);
    transition: width var(--dur-base) var(--ease);
}
.progress-text {
    color: var(--accent);
    font-size: 18px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Leaderboard */
.leaderboard-panel {
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
    padding: clamp(20px, 4vw, 32px);
    background: var(--panel);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-card);
}
.leaderboard-title {
    margin-bottom: var(--sp-5);
    font-size: var(--fs-h2);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: var(--tracking-display);
    text-align: center;
}
.leaderboard-table { width: 100%; border-collapse: collapse; }
.leaderboard-table th,
.leaderboard-table td {
    padding: var(--sp-3) var(--sp-2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
}
.leaderboard-table th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: var(--tracking-eyebrow);
}
.leaderboard-table td { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.leaderboard-table th:last-child,
.leaderboard-table td:last-child { text-align: right; }
.leaderboard-table td:last-child { color: var(--accent); font-weight: 800; font-variant-numeric: tabular-nums; }

/* Animated results */
.reveal-panel { position: relative; overflow: hidden; }
.reveal-table { border-collapse: separate; border-spacing: 0 8px; }
.reveal-table th { border: 0; }
.reveal-table td { background: #191a22; border-top: 1px solid #33343e; border-bottom: 1px solid #33343e; font-size: var(--rank-size); }
.reveal-table td:first-child { border-left: 1px solid #33343e; border-radius: 10px 0 0 10px; color: var(--muted); }
.reveal-table td:last-child { border-right: 1px solid #33343e; border-radius: 0 10px 10px 0; }
.reveal-table .leader-row td { background: #293113; border-color: var(--accent); font-size: clamp(21px, 4vw, 27px); }
.reveal-table .leader-row td:first-child { color: var(--accent); }
.revealing .reveal-item { animation: leaderboard-rise .85s cubic-bezier(.16,1,.3,1) var(--reveal-delay) both; }
.revealing .reveal-item.leader-row { animation-name: leaderboard-winner; }
@keyframes leaderboard-rise {
    0% { opacity: 0; transform: translateY(75px) scale(.65) rotate(-5deg); filter: blur(8px); }
    65% { opacity: 1; transform: translateY(-10px) scale(1.04) rotate(1deg); filter: blur(0); }
    100% { opacity: 1; transform: none; filter: blur(0); }
}
@keyframes leaderboard-winner {
    0% { opacity: 0; transform: translateY(110px) scale(.3) rotate(-12deg); filter: blur(12px); }
    55% { opacity: 1; transform: translateY(-18px) scale(1.12) rotate(3deg); filter: blur(0); }
    75% { transform: translateY(5px) scale(.97) rotate(-1deg); }
    100% { opacity: 1; transform: none; filter: blur(0); }
}
.leader-confetti { position: absolute; top: -15px; left: var(--x); width: 7px; height: 11px; background: var(--color); opacity: 0; pointer-events: none; animation: leaderboard-confetti var(--fall-duration) linear var(--fall-delay) forwards; }
@keyframes leaderboard-confetti {
    0% { opacity: 1; transform: translateY(0) rotate(0); }
    90% { opacity: 1; }
    100% { opacity: 0; transform: translateY(700px) rotate(var(--spin)); }
}
@media (prefers-reduced-motion: reduce) {
    .revealing .reveal-item { animation: none; opacity: 1; }
    .leader-confetti { display: none; }
}

.winner-badge {
    align-self: center;
    margin-bottom: var(--sp-2);
    padding: 2px var(--sp-3);
    background: var(--accent);
    color: var(--on-accent);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--tracking-tag);
    border-radius: var(--r-pill);
}
.grid-image-container.winner-border,
.winner-border { border: 2px solid var(--accent); }

.leaderboard-view { display: block; }
.leaderboard-view.hidden { display: none; }

/* Image grids (results, live wall) */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--sp-4);
    width: 100%;
    padding: 0;
    margin-bottom: var(--sp-5);
}
.grid-image-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    padding: var(--sp-3);
    background: var(--panel);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-card);
}
.grid-image {
    width: 100%;
    height: auto;
    max-height: 220px;
    object-fit: contain;
    border-radius: var(--r-md);
}
.grid-player-name {
    margin-top: var(--sp-3);
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    overflow-wrap: anywhere;
}
.grid-prompt {
    margin-top: var(--sp-1);
    max-width: 100%;
    color: var(--muted);
    font-size: 13px;
    font-style: italic;
    line-height: 1.4;
    text-align: center;
    overflow-wrap: anywhere;
}

/* Floating thumbnails over the target on the big screen */
.thumbnail-container {
    position: absolute;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: opacity 1s ease-out;
}
.thumbnail-container.fade-out { opacity: 0; }
.thumbnail-image {
    max-width: min(360px, 40vw);
    max-height: min(360px, 40vh);
    border: 2px solid var(--accent);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-float);
}
.thumbnail-player-name {
    margin-top: var(--sp-2);
    padding: 2px var(--sp-3);
    background: var(--accent);
    color: var(--on-accent);
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--r-pill);
}

.video-container {
    position: fixed;
    inset: 0;
    z-index: 1;
    overflow: hidden;
}
.video-container video { width: 100%; height: 100%; object-fit: cover; }

#round-qrcode { width: 100%; height: 100%; border-radius: var(--r-sm); }

/* ---------- Admin ---------- */
body.admin { display: block; }
body.admin h1 {
    margin: var(--sp-2) 0 var(--sp-5);
    font-size: var(--fs-h2);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: var(--tracking-display);
}
.card {
    margin-bottom: var(--sp-4);
    padding: clamp(16px, 4vw, 24px);
    background: var(--panel);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-card);
}
.card h2 {
    margin-bottom: var(--sp-4);
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--tracking-eyebrow);
}
.card h3 { margin: var(--sp-4) 0 var(--sp-2); font-size: 17px; font-weight: 600; }
.card p { margin: var(--sp-1) 0; }
.card > div:not([class]):not([id]) { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.card > div:not([class]):not([id]) > select { flex: 1 1 240px; min-width: 0; }
.button-group { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-2) 0; }
.status { min-height: 1.5em; margin-top: var(--sp-3); color: var(--muted); font-size: 14px; }
.status.info { color: var(--info); }
.status.success { color: var(--success); }
.status.error { color: var(--error); }
.phase-indicator {
    display: inline-block;
    margin-left: var(--sp-2);
    padding: 2px var(--sp-3);
    background: var(--accent);
    color: var(--navy);       /* every phase colour is light: navy ink holds */
    font-size: 12px;
    font-weight: 600;
    letter-spacing: var(--tracking-tag);
    vertical-align: middle;
    border-radius: var(--r-pill);
}
.phase-indicator:empty { display: none; }
#current-phase { color: var(--accent); font-weight: 800; letter-spacing: var(--tracking-tag); }
.phase-buttons button.current {
    background: var(--accent);
    color: var(--on-accent);
    border-color: var(--accent);
}
.player-list { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.player-item {
    padding: var(--sp-1) var(--sp-3);
    background: rgba(255, 255, 255, 0.1);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--r-md);
}

/* ---------- Brand sign-off (big screen) ---------- */
.brand-signoff {
    position: fixed;
    right: var(--gutter);
    bottom: var(--sp-4);
    z-index: 50;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    color: var(--muted);
    font-size: 12px;
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: var(--tracking-eyebrow);
    pointer-events: none;
}
.brand-signoff img { display: block; width: auto; height: 20px; }

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