/* Colors as tokens so dark mode (shared/theme.js) only has to swap values. */
:root {
    --bg: #f4f8f9;
    --text: #1f2937;
    --muted: #6b7280;
    --card: #ffffff;
    --border: #d9e4e7;
    --accent: #0e7c8a;
    --accent-text: #ffffff;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 14px rgba(15, 23, 42, 0.06);
    --sprite-bg: #e9f2f4;
    --line: #9fb7bd;
    --bar: #e4ecee;
    --chip: #eaf1f3;
}

:root[data-theme="dark"] {
    --bg: #15161a;
    --text: #e7e9ee;
    --muted: #9aa0ab;
    --card: #1f2127;
    --border: #2f323a;
    --accent: #4fc8d6;
    --accent-text: #04181b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
    --sprite-bg: #2a2d35;
    --line: #4a5361;
    --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 chain ---------- */

.chain {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 360px;
    margin: 0 auto;
    padding: 0;
    list-style: none;
}

.card {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 5px 10px 5px 5px;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.card-start,
.card-target {
    border-color: var(--accent);
}

.card-new {
    animation: pop 0.25s ease-out;
}

@keyframes pop {
    from {
        transform: scale(0.92);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .card-new {
        animation: none;
    }
}

/* The sprites have a wide empty border, so they're cropped to the middle */
.sprite-box {
    flex: none;
    width: 48px;
    height: 48px;
    overflow: hidden;
    background: var(--sprite-bg);
    border-radius: 12px;
}

.sprite {
    display: block;
}

.sprite-box .sprite {
    width: 68px;
    height: 68px;
    margin: -10px;
}

.card-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex: 1;
    gap: 1px;
    min-width: 0;
}

.card-role {
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-name {
    font-size: 1rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

/* Types on the right, side by side, or stacked when the name needs the room */
.card-types {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 7px;
    max-width: 50%;
    padding: 2px;
}

/* The types a Pokémon shares with its neighbors stand out; the rest fade */
.type.on {
    box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--text);
    font-weight: 700;
}

.type.off {
    opacity: 0.4;
}

/* Between two cards: a line, with the shared type on it */
.joint {
    position: relative;
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 5px 0;
}

.joint::before,
.gap::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    border-left: 3px solid var(--line);
    transform: translateX(-50%);
}

.joint .type {
    position: relative;
    box-shadow: 0 0 0 3px var(--bg);
}

/* Still to fill: a dashed line from the name box down to the target */
.gap {
    position: relative;
    height: 16px;
}

.gap::before {
    border-left-style: dashed;
}

.chain-end[hidden] {
    display: none;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* 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: 6px 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);
}

.go:disabled {
    opacity: 0.45;
    cursor: default;
}

/* A quiet text button under the box (Practice: skip to another pair) */
.text-btn {
    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;
}

.text-btn[hidden] {
    display: none;
}

.feedback[hidden] {
    display: none;
}

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

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

.done {
    margin-top: 24px;
    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;
}

/* One shortest chain, revealed at the end when yours was longer: a small version of the chain */
.solution {
    margin: 0 auto 20px;
}

.solution[hidden] {
    display: none;
}

.mini-chain {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
}

.mini-card {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 12px 2px 2px;
    font-size: 0.85rem;
    font-weight: 700;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 999px;
}

.mini-card .sprite {
    width: 32px;
    height: 32px;
    object-fit: cover;
    background: var(--sprite-bg);
    border-radius: 50%;
}

.mini-joint {
    position: relative;
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.mini-joint::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    border-left: 2px solid var(--line);
    transform: translateX(-50%);
}

.mini-joint .type {
    position: relative;
    font-size: 0.7rem;
    box-shadow: 0 0 0 2px var(--bg);
}

/* ---------- Practice results popup: the same look as the Daily's (shared/next-daily.css) ---------- */

.results {
    box-sizing: border-box;
    width: min(380px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    margin: auto;
    padding: 22px 20px 20px;
    overflow-y: auto;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    font-size: 0.9rem;
    line-height: 1.35;
    text-align: center;
}

.results[open] {
    animation: results-in 0.22s ease-out;
}

@keyframes results-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }
}

@media (prefers-reduced-motion: reduce) {
    .results[open] {
        animation: none;
    }
}

/* ::backdrop doesn't see :root's tokens in every browser, so it gets a plain color */
.results::backdrop {
    background: rgba(0, 0, 0, 0.45);
}

.results-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    font-size: 1rem;
    color: inherit;
    background: transparent;
    border: 0;
    border-radius: 8px;
    opacity: 0.6;
    cursor: pointer;
}

.results-kicker {
    margin: 0 0 4px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.6;
}

.results-title {
    margin: 0 28px 6px;
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.2;
}

.results-note {
    margin: 0 0 12px;
    opacity: 0.8;
}

.results-share-text {
    margin: 0 0 14px;
    padding: 10px 12px;
    font: inherit;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: var(--chip);
    border-radius: 10px;
}

.results-share,
.results-again {
    width: 100%;
    padding: 11px 16px;
    font: inherit;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
}

.results-share {
    color: var(--bg);
    background: var(--text);
    border: 0;
}

.results-again {
    margin-top: 8px;
    color: var(--accent);
    background: transparent;
    border: 2px solid var(--accent);
}

@media (hover: hover) {
    .results-close:hover {
        opacity: 1;
        background: var(--chip);
    }
}

.results-close:focus-visible,
.results-share:focus-visible,
.results-again:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- 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);
}

@media (hover: hover) {
    .help:hover {
        border-color: var(--accent);
    }

    .text-btn:hover {
        color: var(--text);
    }
}

.play-tab:focus-visible,
.go:focus-visible,
.text-btn: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;
    }
}
