/* Colors as tokens so dark mode (shared/theme.js) only has to swap values. */
:root {
    --bg: #fbf9f1;
    --text: #1f2937;
    --muted: #6b7280;
    --card: #ffffff;
    --border: #e7e2cf;
    --accent: #d9480f;
    --accent-text: #ffffff;
    /* The stage behind the shadow: a spotlight, and the shadow itself (read by script.js) */
    --art-bg: radial-gradient(circle at 50% 45%, #fff6cf 0%, #fde68a 55%, #f6c453 100%);
    --shade: #1f1b2e;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 14px rgba(15, 23, 42, 0.06);
    --hit: #2fa45a;
    --miss: #e5484d;
    --bar: #ece8da;
    --chip: #f3f0e4;
}

:root[data-theme="dark"] {
    --bg: #15161a;
    --text: #e7e9ee;
    --muted: #9aa0ab;
    --card: #1f2127;
    --border: #2f323a;
    --accent: #ff8a4c;
    --accent-text: #1c0d03;
    --art-bg: radial-gradient(circle at 50% 45%, #6b6390 0%, #474063 55%, #2e2a42 100%);
    --shade: #0c0a14;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
    --hit: #4ade80;
    --miss: #f87171;
    --bar: #2f323a;
    --chip: #2a2c34;
}

/* No double-tap zoom (pinch zoom still works) */
html {
    touch-action: manipulation;
}

body {
    margin: 0;
    font-family: system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
}

main {
    max-width: 560px;
    margin: auto;
    padding: 64px 16px 40px;
}

header {
    text-align: center;
}

h1 {
    margin: 0 0 6px;
    font-size: 2rem;
}

.tagline {
    margin: 0;
    color: var(--muted);
}

.tagline strong {
    color: var(--text);
}

/* Daily / Practice */
.play-tabs {
    display: flex;
    justify-content: center;
    margin-top: 16px;
}

.play-tab {
    min-width: 100px;
    padding: 8px 18px;
    font: inherit;
    font-weight: 700;
    color: var(--muted);
    background: var(--card);
    border: 2px solid var(--border);
    cursor: pointer;
}

.play-tab:first-child {
    border-radius: 999px 0 0 999px;
}

.play-tab:last-child {
    margin-left: -2px;
    border-radius: 0 999px 999px 0;
}

.play-tab[aria-selected="true"] {
    position: relative;
    color: var(--accent-text);
    background: var(--accent);
    border-color: var(--accent);
}

.scores {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin: 16px 0 20px;
    color: var(--muted);
    font-size: 0.95rem;
}

.scores [hidden] {
    display: none;
}

.scores b {
    color: var(--text);
    font-size: 1.15rem;
    margin-left: 4px;
    font-variant-numeric: tabular-nums;
}

/* ---------- The shadow ---------- */

.art {
    position: relative;
    width: min(100%, 340px);
    aspect-ratio: 1;
    margin: 0 auto;
    background: var(--art-bg);
    border-radius: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.art canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.art-status {
    position: absolute;
    inset: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    padding: 24px;
    text-align: center;
    color: var(--muted);
}

.art-status[hidden] {
    display: none;
}

/* ---------- Hints ---------- */

.hints {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
}

.hint {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 2px 12px 2px 6px;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 999px;
    font-size: 0.85rem;
}

.hint-name {
    padding: 2px 8px;
    color: var(--muted);
    background: var(--chip);
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hint-value {
    display: flex;
    gap: 4px;
    font-weight: 700;
}

.hint.locked .hint-value {
    color: var(--muted);
    font-weight: 500;
}

.hint.locked .hint-value::before {
    content: "🔒";
    font-size: 0.75rem;
}

/* Type pills: the same colors in light and dark mode */
.type {
    padding: 2px 9px;
    border-radius: 999px;
    color: #ffffff;
    font-size: 0.8rem;
    background: #8a8a7a;
}

.type-normal { background: #8f8f78; }
.type-fighting { background: #b73a2e; }
.type-flying { background: #7d6fd8; }
.type-poison { background: #94409a; }
.type-ground { background: #b08f3c; }
.type-rock { background: #9c8a36; }
.type-bug { background: #7d8f1d; }
.type-ghost { background: #64508e; }
.type-steel { background: #7e7e98; }
.type-fire { background: #e0661f; }
.type-water { background: #4b7be0; }
.type-grass { background: #4c9a35; }
.type-electric { background: #f2c41b; color: #2b2300; }
.type-psychic { background: #e8467a; }
.type-ice { background: #7dcfcf; color: #0d2a2a; }
.type-dragon { background: #5d33e6; }
.type-dark { background: #5a463a; }
.type-fairy { background: #d76ea0; }

/* ---------- Guessing ---------- */

.guess {
    max-width: 440px;
    margin: 12px auto 0;
}

.guess[hidden] {
    display: none;
}

.guess-row {
    display: flex;
    gap: 8px;
}

.guess-input {
    box-sizing: border-box;
    flex: 1;
    min-width: 0;
    height: 46px;
    padding: 0 16px;
    font: inherit;
    font-size: 1rem; /* 16px or more, so iPhones don't zoom in on focus */
    color: var(--text);
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 999px;
}

.guess-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Matching names: one row of chips at a fixed height, scrolling sideways when they don't fit */
.suggest {
    position: relative; /* so script.js can measure the chips against it */
    display: flex;
    align-items: center;
    gap: 6px;
    height: 44px;
    margin: 0 0 8px;
    padding: 0 2px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    list-style: none;
}

.suggest::-webkit-scrollbar {
    display: none;
}

.suggest li {
    flex: none;
    padding: 7px 13px;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
}

.suggest li[aria-selected="true"] {
    color: var(--accent-text);
    background: var(--accent);
    border-color: var(--accent);
}

/* "Start typing…" or "No Pokémon by that name" when there are no chips */
.suggest .suggest-empty {
    margin: 0 auto;
    padding: 0;
    color: var(--muted);
    font-weight: 500;
    background: none;
    border: 0;
    cursor: default;
}

@media (hover: hover) {
    .suggest li:not(.suggest-empty):hover:not([aria-selected="true"]) {
        border-color: var(--accent);
    }
}

.go {
    flex: none;
    padding: 12px 22px;
    font: inherit;
    font-weight: 700;
    color: var(--accent-text);
    background: var(--accent);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
}

.go-alt {
    color: var(--accent);
    background: transparent;
    box-shadow: inset 0 0 0 2px var(--accent);
}

/* A quiet text button under the box; the first tap turns it red to ask for a second */
.give-up {
    display: block;
    margin: 8px auto 0;
    padding: 4px 10px;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    background: none;
    border: 0;
    border-radius: 999px;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.give-up.confirm {
    color: var(--miss);
}

.go[hidden] {
    display: none;
}

.feedback {
    min-height: 1.4em;
    margin: 10px 0 6px;
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
}

.misses {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.misses li {
    padding: 4px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 999px;
}

.misses .miss {
    color: var(--miss);
}

.misses .hit {
    color: var(--hit);
    border-color: var(--hit);
}

.misses .skip {
    color: var(--muted);
}

/* ---------- After the round ---------- */

.done {
    margin-top: 18px;
    text-align: center;
}

.done[hidden] {
    display: none;
}

.done-kind,
.section-heading {
    margin: 0 0 2px;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.done h2 {
    margin: 0;
    font-size: 1.6rem;
}

.done-note {
    margin: 4px 0 16px;
    color: var(--muted);
}

/* "Next daily" link under the Daily's result (shared/next-daily.css) */
.next-daily {
    margin-top: 14px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.actions .go {
    padding: 12px 28px;
}

.stats {
    max-width: 360px;
    margin: 28px auto 0;
    padding: 16px;
    background: var(--card);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.stats[hidden] {
    display: none;
}

.stat-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin: 10px 0 14px;
}

.stat-row div {
    display: flex;
    flex-direction: column-reverse;
}

.stat-row dt {
    color: var(--muted);
    font-size: 0.72rem;
}

.stat-row dd {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

/* Guess distribution: 1 to 6, then X for a loss */
.dist {
    margin: 0;
    padding: 0;
    list-style: none;
}

.dist li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.dist li + li {
    margin-top: 4px;
}

.dist-n {
    width: 1em;
    font-weight: 700;
    color: var(--muted);
}

.dist-bar {
    flex: 1;
    display: flex;
}

.dist-bar span {
    box-sizing: border-box;
    min-width: 1.8em;
    padding: 1px 8px;
    text-align: right;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    background: var(--bar);
    border-radius: 6px;
}

.dist .today .dist-bar span {
    color: var(--accent-text);
    background: var(--accent);
}

.countdown {
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.countdown b {
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

/* ---------- Generation picker (Practice) ---------- */

.picker {
    margin-top: 36px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.picker[hidden],
.gens-note[hidden] {
    display: none;
}

.picker .section-heading {
    margin-bottom: 8px;
}

.gens {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.gen {
    padding: 7px 14px;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}

.gen[aria-pressed="true"] {
    color: var(--accent-text);
    background: var(--accent);
    border-color: var(--accent);
}

.gens-note {
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.retry {
    padding: 6px 12px;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text);
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
}

/* Hover styles only for real pointers: on touch screens :hover sticks to the last thing tapped */
@media (hover: hover) {
    .gen:hover,
    .retry:hover,
    .help:hover {
        border-color: var(--accent);
    }
}

/* ---------- How to play ---------- */

.help {
    width: 26px;
    height: 26px;
    padding: 0;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--muted);
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
}

.intro {
    width: min(420px, calc(100% - 32px));
    max-height: calc(100% - 32px);
    padding: 0;
    color: var(--text);
    background: var(--card);
    border: 0;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* ::backdrop doesn't see :root's tokens in every browser, so it gets a plain color */
.intro::backdrop {
    background: rgba(15, 23, 42, 0.55);
}

.intro-body {
    padding: 20px;
}

.intro h2 {
    margin: 0 0 14px;
    font-size: 1.3rem;
    text-align: center;
}

.intro-steps {
    margin: 0;
    padding-left: 20px;
    font-size: 0.92rem;
    line-height: 1.4;
}

.intro-steps li + li {
    margin-top: 6px;
}

.intro-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

.intro-actions button {
    padding: 10px 18px;
    font: inherit;
    font-weight: 700;
    border-radius: 999px;
    cursor: pointer;
}

.intro-hide {
    color: var(--muted);
    background: transparent;
    border: 2px solid var(--border);
}

.intro-ok {
    min-width: 88px;
    color: var(--accent-text);
    background: var(--accent);
    border: 2px solid var(--accent);
}

.play-tab:focus-visible,
.go:focus-visible,
.gen:focus-visible,
.retry:focus-visible,
.give-up:focus-visible,
.help:focus-visible,
.intro-actions button:focus-visible {
    position: relative;
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

@media (max-width: 620px) {
    .scores {
        gap: 16px;
    }

    .guess .go {
        padding: 12px 16px;
    }

    /* Both hints on one line */
    .hints {
        gap: 6px;
    }

    .hint {
        gap: 5px;
        padding: 2px 9px 2px 4px;
        font-size: 0.75rem;
    }

    .gens {
        gap: 6px;
    }

    .gen {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
}
