/* ===========================================================================
   Superhero Fight — components & layout
   The arena is dark ink; everything you read & fill in lives on aged paper.
   =========================================================================== */

/* --- Layout / stage -------------------------------------------------------- */

.stage {
    max-width: 760px;
    margin: 0 auto;
    padding: clamp(1.5rem, 4vw, 3rem) clamp(1.1rem, 4vw, 2rem) 5rem;
    animation: stage-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes stage-in {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- Splash / landing ------------------------------------------------------ */

.splash {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: clamp(1.4rem, 4vw, 2.2rem);
}

.splash-art {
    display: block;
    width: 100%;
    max-width: 440px;
    height: auto;
    border-radius: var(--radius);
}

.splash-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.cta {
    font-family: var(--font-display);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: clamp(1.25rem, 4vw, 1.6rem);
    color: #fff;
    background: var(--red);
    border: 2px solid var(--ink);
    border-radius: 3px;
    box-shadow: 4px 4px 0 var(--ink);
    padding: 0.7rem 1.9rem;
    transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s ease;
}

.cta:hover {
    color: #fff;
    background: #ff5042;
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--ink);
    border-color: var(--ink);
}

.cta:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 var(--ink);
}

.splash-note {
    font-family: var(--font-read);
    font-style: italic;
    color: var(--muted);
    margin: 0;
    max-width: 38ch;
}

@media (max-width: 640px) {
    .splash { gap: 1.1rem; }

    .splash-art {
        width: 100vw;
        max-width: 100vw;
        /* break out of the stage's horizontal padding to the viewport edges */
        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);
        /* sit flush under the header */
        margin-top: calc(-1 * clamp(1.5rem, 4vw, 3rem));
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    /* trim the stage's tall bottom padding on the landing page so it all fits */
    .stage:has(.splash) { padding-bottom: 1.5rem; }
}

/* --- Eyebrow / lede -------------------------------------------------------- */

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5ch;
    font-family: var(--font-ui);
    font-weight: 800;
    font-size: 0.72rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--ink);
    background: var(--gold);
    padding: 0.3rem 0.7rem;
    transform: rotate(-1.4deg);
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.5);
}

.stage > h1 {
    font-size: clamp(2.6rem, 9vw, 4.6rem);
    margin: 0.7rem 0 0.4rem;
    color: var(--cream);
    text-shadow: 4px 4px 0 var(--red), 8px 8px 0 rgba(0, 0, 0, 0.35);
}

.lede {
    font-family: var(--font-read);
    font-size: 1.15rem;
    line-height: 1.55;
    color: var(--muted);
    _max-width: 46ch;
    margin: 0 0 1.8rem;
}

.lede strong { color: var(--cream); font-weight: 600; }

/* --- Paper panels (forms, dossiers, results) ------------------------------- */

.panel {
    position: relative;
    background: var(--paper);
    color: var(--paper-ink);
    border-radius: var(--radius);
    padding: clamp(1.3rem, 4vw, 2.1rem);
    box-shadow: var(--shadow-hard);
    /* subtle paper fibre */
    background-image:
        repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.015) 0 1px, transparent 1px 3px),
        radial-gradient(120% 140% at 0% 0%, rgba(255, 255, 255, 0.5), transparent 45%);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* torn-corner accent strip */
.panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 5px;
    border-radius: var(--radius) var(--radius) 0 0;
    background: linear-gradient(90deg, var(--blue) 0 50%, var(--red) 50% 100%);
}

.panel h2,
.panel h3 { color: var(--paper-ink); }

/* --- Hero editor / character sheet ----------------------------------------- */

.sheet-title {
    font-family: var(--font-display);
    text-transform: uppercase;
    font-size: 1.55rem;
    margin: 0 0 0.2rem;
    color: var(--paper-ink);
}

.sheet-sub {
    font-family: var(--font-read);
    font-style: italic;
    color: var(--paper-mute);
    margin: 0 0 1.4rem;
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: wrap;
    margin-bottom: 1.3rem;
}

.editor-actions-hint {
    font-family: var(--font-read);
    font-style: italic;
    font-size: 0.9rem;
    color: var(--paper-mute);
}

/* Dice / "surprise me" button — a lighter, dashed paper button distinct from .btn. */
.btn-dice {
    font-family: var(--font-display);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.95rem;
    padding: 0.5rem 1.05rem;
    border-radius: 3px;
    cursor: pointer;
    background: var(--paper-2);
    color: var(--paper-ink);
    border: 2px dashed var(--paper-ink);
    box-shadow: 3px 3px 0 rgba(34, 26, 16, 0.45);
    transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s ease;
}

.btn-dice:hover {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 rgba(34, 26, 16, 0.45);
    background: #fff;
}

.btn-dice:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 rgba(34, 26, 16, 0.45);
}

.hero-editor label {
    display: block;
    margin-bottom: 1.05rem;
}

.hero-editor label > span {
    display: block;
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 0.74rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--paper-mute);
    margin-bottom: 0.35rem;
}

.hero-editor label em {
    font-weight: 500;
    color: var(--red-deep);
    font-style: normal;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.92em;
}

.hero-editor input,
.hero-editor textarea {
    width: 100%;
    padding: 0.62rem 0.7rem;
    border: 1.5px solid rgba(34, 26, 16, 0.22);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.55);
    color: var(--paper-ink);
    font: inherit;
    font-size: 1rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.hero-editor input::placeholder,
.hero-editor textarea::placeholder {
    color: rgba(111, 96, 68, 0.65);
}

.hero-editor input:focus,
.hero-editor textarea:focus {
    outline: none;
    border-color: var(--red);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(255, 59, 47, 0.18);
}

.hero-editor textarea { resize: vertical; }

/* Name field with an inline clear (×) button. */
.name-field { position: relative; }
.name-field input { padding-right: 2.4rem; }

.clear-name {
    position: absolute;
    top: 50%;
    right: 0.4rem;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.7rem;
    height: 1.7rem;
    padding: 0;
    color: var(--paper-mute);
    background: transparent;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.clear-name:hover { color: var(--red); background: rgba(0, 0, 0, 0.05); }
.clear-name:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }

/* --- Buttons --------------------------------------------------------------- */

button[type="submit"],
.btn {
    font-family: var(--font-display);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 1.15rem;
    padding: 0.66rem 1.6rem;
    border-radius: 3px;
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s ease;
}

button[type="submit"] {
    background: var(--red);
    color: #fff;
    border: 2px solid var(--ink);
    box-shadow: 4px 4px 0 var(--ink);
    margin-top: 0.4rem;
}

button[type="submit"]:hover:not(:disabled) {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--ink);
    background: #ff5042;
}

button[type="submit"]:active:not(:disabled) {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 var(--ink);
}

button[type="submit"]:disabled,
.btn:disabled { opacity: 0.55; cursor: default; }

/* secondary / paper buttons (manual mode) */
.btn {
    background: var(--paper-2);
    color: var(--paper-ink);
    border: 2px solid var(--paper-ink);
    box-shadow: 3px 3px 0 rgba(34, 26, 16, 0.55);
    font-size: 1rem;
}

.btn:hover:not(:disabled) {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 rgba(34, 26, 16, 0.55);
}

.btn-primary {
    background: var(--blue);
    color: #fff;
    border-color: var(--ink);
    box-shadow: 3px 3px 0 var(--ink);
}

.btn-primary:hover:not(:disabled) { background: #4a8bff; }

.error {
    color: var(--red-deep);
    font-weight: 600;
    margin-top: 0.85rem;
}

/* --- Share / challenge-ready ----------------------------------------------- */

.share h2 {
    font-size: 1.8rem;
    color: var(--paper-ink);
    margin: 0 0 0.4rem;
}

.share p { color: var(--paper-mute); }

.share .you-are {
    font-family: var(--font-read);
    font-size: 0.85rem;
    font-style: italic;
    color: var(--paper-mute);
    margin: 0 0 0.9rem;
    opacity: 0.85;
}

.share .you-are strong {
    font-style: normal;
    color: var(--paper-ink);
}

.share-link-row {
    position: relative;
    margin: 0.4rem 0 0.8rem;
}

.share-link {
    width: 100%;
    padding: 0.7rem 2.6rem 0.7rem 0.8rem;
    font-family: 'Archivo', monospace;
    font-size: 0.95rem;
    color: var(--paper-ink);
    background: #fff;
    border: 2px dashed var(--blue);
    border-radius: 3px;
}

.share-link:focus { outline: none; border-color: var(--red); }

.copy-btn {
    position: absolute;
    top: 50%;
    right: 0.45rem;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    color: var(--blue);
    background: transparent;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.copy-btn:hover { color: var(--red); background: rgba(0, 0, 0, 0.05); }
.copy-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }

/* --- QR code (scan to join) ------------------------------------------------ */

.qr-block {
    display: flex;
    justify-content: center;
    margin: 0.6rem 0 0.4rem;
}

.qr-code {
    width: clamp(180px, 56vw, 240px);
    aspect-ratio: 1;
    padding: 0.7rem;
    background: #fff;
    border: 2px solid var(--ink);
    border-radius: 6px;
    box-shadow: 4px 4px 0 var(--ink);
}

.qr-code svg {
    display: block;
    width: 100%;
    height: 100%;
}

.qr-or {
    text-align: center;
    font-family: var(--font-read);
    font-style: italic;
    margin: 1rem 0 0.3rem;
}

/* --- Awaiting the opponent's verdict --------------------------------------- */

.await-result {
    margin-top: 1.4rem;
    padding-top: 1.2rem;
    border-top: 1px dashed rgba(34, 26, 16, 0.25);
    text-align: center;
}

.await-hint {
    font-family: var(--font-read);
    color: var(--paper-mute);
    margin: 0 0 0.9rem;
}

.await-hint.watching {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0;
    color: var(--paper-ink);
}

.pulse-dot {
    flex: none;
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    background: var(--blue);
    box-shadow: 0 0 0 0 rgba(43, 108, 255, 0.5);
    animation: pulse-dot 1.4s ease-out infinite;
}

@keyframes pulse-dot {
    0%   { box-shadow: 0 0 0 0 rgba(43, 108, 255, 0.5); }
    70%  { box-shadow: 0 0 0 0.6rem rgba(43, 108, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(43, 108, 255, 0); }
}

.open-self {
    margin: 1.2rem 0 0;
    text-align: center;
    font-size: 0.9rem;
}

/* --- Opponent dossier ------------------------------------------------------ */

.opponent {
    position: relative;
    background: var(--paper);
    color: var(--paper-ink);
    border-radius: var(--radius);
    border-left: 6px solid var(--blue);
    padding: 1.1rem 1.3rem;
    margin-bottom: 1.8rem;
    box-shadow: var(--shadow-hard);
}

.opponent::after {
    content: "CHALLENGER";
    position: absolute;
    top: 0.9rem;
    right: 1rem;
    font-family: var(--font-display);
    font-size: 0.7rem;
    letter-spacing: 0.22em;
    color: #fff;
    background: var(--blue);
    padding: 0.18rem 0.5rem;
    border-radius: 2px;
}

.opponent h2 {
    font-size: 1.7rem;
    margin: 0 0 0.3rem;
    color: var(--paper-ink);
}

.opponent em {
    font-family: var(--font-read);
    font-size: 1.05rem;
    color: var(--paper-ink);
}

.opponent .hint {
    color: var(--paper-mute);
    font-size: 0.88rem;
    margin: 0.7rem 0 0;
}

/* --- Manual mode (bring-your-own-LLM) -------------------------------------- */

.manual-steps {
    font-family: var(--font-read);
    color: var(--cream);
    line-height: 1.7;
    margin: 0 0 1.6rem 1.1rem;
    padding: 0;
}

.manual-steps li { margin-bottom: 0.35rem; }

.manual-field {
    display: block;
    margin: 1.2rem 0 0.55rem;
}

.manual-field > span {
    display: block;
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 0.74rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.prompt-box,
.verdict-box {
    width: 100%;
    padding: 0.75rem;
    border-radius: 4px;
    font-family: 'Archivo', monospace;
    font-size: 0.85rem;
    line-height: 1.55;
    resize: vertical;
    color: var(--cream);
}

.prompt-box {
    border: 2px dashed var(--blue);
    background: var(--ink-2);
}

.verdict-box {
    border: 2px solid var(--ink-line);
    background: var(--ink-2);
}

.prompt-box:focus,
.verdict-box:focus {
    outline: none;
    border-color: var(--red);
}

/* =====================================================================
   RESULT — the payoff
   ===================================================================== */

.result-banner {
    position: relative;
    text-align: center;
    padding: 1.2rem 1rem 1.6rem;
    margin-bottom: 1.5rem;
    overflow: hidden;
    isolation: isolate;
}

/* speed-lines burst behind the winner */
.result-banner::before {
    content: "";
    position: absolute;
    inset: -40% -10%;
    z-index: -1;
    background:
        repeating-conic-gradient(from 0deg at 50% 42%,
            rgba(255, 194, 61, 0.16) 0deg 4deg,
            transparent 4deg 10deg);
    -webkit-mask-image: radial-gradient(closest-side, #000 30%, transparent 78%);
            mask-image: radial-gradient(closest-side, #000 30%, transparent 78%);
    animation: spin 30s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.result-kicker {
    font-family: var(--font-ui);
    font-weight: 800;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    font-size: 0.78rem;
    color: var(--gold);
}

.result-banner h1 {
    font-size: clamp(2.4rem, 10vw, 4.4rem);
    margin: 0.4rem 0 0.2rem;
    color: var(--cream);
    text-shadow: 3px 3px 0 var(--red-deep), 0 0 28px rgba(255, 194, 61, 0.35);
}

.result-banner h1 .who { color: var(--gold); display: block; }

/* confidence meter */
.confidence {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-ui);
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: 0.3rem;
}

.confidence .meter {
    width: 130px;
    height: 9px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.confidence .meter > i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--red), var(--gold));
    border-radius: 99px;
}

/* The narrative — the inviting read, on paper, in Fraunces */
.narrative {
    font-family: var(--font-read);
    font-optical-sizing: auto;
    font-size: clamp(1.2rem, 2.6vw, 1.45rem);
    line-height: 1.62;
    color: var(--paper-ink);
    background: var(--paper);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hard);
    padding: clamp(1.4rem, 4vw, 2.2rem) clamp(1.4rem, 4vw, 2.4rem);
    margin: 0 0 1.4rem;
    position: relative;
    quotes: "\201C" "\201D";
}

.narrative::first-letter {
    font-size: 3.1em;
    line-height: 0.78;
    float: left;
    margin: 0.06em 0.1em 0 0;
    color: var(--red);
    font-weight: 500;
}

.narrative::before {
    content: open-quote;
    position: absolute;
    top: -0.35em;
    left: 0.2em;
    font-size: 4rem;
    font-family: var(--font-read);
    color: rgba(255, 59, 47, 0.18);
    pointer-events: none;
}

.reasoning {
    font-family: var(--font-read);
    font-size: 1.02rem;
    line-height: 1.6;
    color: var(--muted);
    border-left: 3px solid var(--ink-line);
    padding-left: 1rem;
    margin: 0 0 1.8rem;
}

.reasoning strong {
    font-family: var(--font-ui);
    font-weight: 800;
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gold);
    display: block;
    margin-bottom: 0.25rem;
}

/* --- Matchup --------------------------------------------------------------- */

.matchup {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: stretch;
    gap: 0.8rem;
    margin-top: 1.5rem;
}

.hero-card {
    background: var(--paper);
    color: var(--paper-ink);
    border-radius: var(--radius);
    padding: 1.1rem 1.15rem;
    box-shadow: var(--shadow-hard);
    border-top: 6px solid var(--blue);
    position: relative;
}

/* corner B is the red corner */
.hero-card:last-of-type { border-top-color: var(--red); }

.corner-chip {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 0.66rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #fff;
    padding: 0.2rem 0.5rem;
    border-radius: 2px;
    margin-bottom: 0.55rem;
}

.corner-chip.corner-a { background: var(--blue); }
.corner-chip.corner-b { background: var(--red); }

.hero-card h3 {
    font-size: 1.3rem;
    margin: 0 0 0.4rem;
    color: var(--paper-ink);
    line-height: 1.05;
}

.hero-card .origin em {
    font-family: var(--font-read);
    color: var(--paper-mute);
    font-size: 0.98rem;
}

.hero-card dl { margin: 0.6rem 0 0; }

.hero-card dt {
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--paper-mute);
    margin-top: 0.65rem;
}

.hero-card dd {
    margin: 0.1rem 0 0;
    font-size: 0.98rem;
    line-height: 1.4;
}

.hero-card.winner {
    border: 2px solid var(--gold);
    border-top-width: 6px;
    box-shadow: 0 0 0 4px rgba(255, 194, 61, 0.25), var(--shadow-hard);
}

.hero-card.winner::after {
    content: "WINNER";
    position: absolute;
    top: -0.7rem;
    right: 0.8rem;
    font-family: var(--font-display);
    font-size: 0.74rem;
    letter-spacing: 0.18em;
    color: var(--ink);
    background: var(--gold);
    padding: 0.2rem 0.55rem;
    border-radius: 2px;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4);
}

/* VS starburst */
.vs {
    align-self: center;
    justify-self: center;
    font-family: var(--font-display);
    font-size: 1.4rem;
    color: #fff;
    width: 3.1rem;
    height: 3.1rem;
    display: grid;
    place-items: center;
    background: var(--ink);
    border-radius: 50%;
    border: 2px solid var(--gold);
    box-shadow: 0 0 0 4px var(--ink), 0 0 22px rgba(255, 194, 61, 0.35);
    z-index: 2;
}

@media (max-width: 540px) {
    .matchup {
        grid-template-columns: 1fr;
    }

    .vs { margin: -0.3rem 0; }

    .hero-card:last-of-type { border-top-color: var(--red); }
}

/* --- Plain helper text ----------------------------------------------------- */

.stage > p > a { font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
    .stage,
    .result-banner::before,
    .pulse-dot { animation: none; }
}

/* --- Live Arena (party mode) ---------------------------------------------- */

/* Secondary CTA on the splash, sat under the primary one. */
.cta-ghost {
    background: var(--blue);
}

.cta-ghost:hover {
    background: #4d82ff;
}

/* Two QR codes side by side — one per fighter. */
.arena-seats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.4rem;
    margin: 0.6rem 0 1rem;
}

.arena-seat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
}

.seat-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.seat-tag {
    font-family: var(--font-display);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.85rem;
    color: #fff;
    padding: 0.2rem 0.6rem;
    border-radius: 2px;
    border: 2px solid var(--ink);
}

.tag-a { background: var(--blue); }
.tag-b { background: var(--red); }

.seat-ready {
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 0.78rem;
    color: #1f9d55;
}

/* A filled seat's QR dims so the crowd's eye goes to the one still open. */
.qr-code.qr-done {
    opacity: 0.32;
    filter: grayscale(1);
}

/* The QR is also a link (handy in dev: click instead of scan). No visual change. */
.qr-link {
    display: inline-block;
    line-height: 0;
}
