/* Schmoll Crossword: the layout and the pieces every world shares (redesign).
   Every colour, font and corner is a CSS variable; each world sets its own in worlds.css. */

:root {
    --bg: #fbf7ee;
    --surface: rgba(255, 253, 247, .93);
    --surface-solid: #fffdf7;
    --surface-2: #f4eee0;
    --ink: #2b2b33;
    --muted: #6d6a73;
    --line: #d4cab8;
    --hover: rgba(0, 0, 0, .05);
    --accent: #e2483c;
    --accent-2: #2f6fd6;
    --accent-ink: #ffffff;
    --cell: #fffef9;
    --cell-ink: #23232b;
    --block: #2b2b33;
    --grid: #2b2b33;
    --num: #6d6a73;
    --word: #fff2a8;
    --sel: #ffd54a;
    --solved: #e3f4d6;
    --wrong: #d7263d;
    --revealed: #2f6fd6;
    --good: #3a9a52;
    --radius: 14px;
    --radius-sm: 9px;
    --cell-radius: 3px;
    --gap: 2px;
    --shadow: 3px 4px 0 rgba(43, 43, 51, .14);
    --font-body: "Nunito", system-ui, sans-serif;
    --font-head: "Caveat", cursive;
    --font-cell: "Patrick Hand", cursive;
    --head-scale: 1;
    --cell-weight: 400;
    --fire-1: #ffd36b;
    --fire-2: #ff8c3a;
    --fire-3: #e2452b;
    --vine: #4e8a4b;
    --leaf: #77b35f;
    color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-tap-highlight-color: transparent; }
body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
}
#world-bg { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: -1; }
.fx-layer { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 900; pointer-events: none; }
.fx-flash { position: fixed; inset: 0; z-index: 905; pointer-events: none; }
/* a flash is a sheet of colour with a brighter burst in the middle, like light, not a flat colour */
.fx-flash > i { position: absolute; inset: 0; }
.fx-flash-sheet { opacity: .6; }
.crt { display: none; }
#app { position: relative; z-index: 1; min-height: 100vh; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
::selection { background: var(--accent); color: var(--accent-ink); }

/* ---------------------------------------------------------------------------------------------
   Top bar
   --------------------------------------------------------------------------------------------- */
.top-bar {
    position: relative;
    z-index: 50;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 16px;
    max-width: 1120px;
    margin: 0 auto;
    padding: 14px 16px 8px;
}
.logo { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.logo-mark {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    width: 42px;
    height: 42px;
    gap: 2px;
    padding: 2px;
    background: var(--grid);
    border-radius: 9px;
    transform: rotate(-6deg);
    transition: transform .35s cubic-bezier(.2, 1.6, .4, 1);
    box-shadow: var(--shadow);
}
.logo-mark i, .hero-logo i, .intro-mini i {
    display: grid;
    place-items: center;
    background: var(--cell);
    color: var(--cell-ink);
    font: var(--cell-weight) 15px/1 var(--font-cell);
    font-style: normal;
    border-radius: max(2px, calc(var(--cell-radius) - 1px));
}
.logo-mark i.b, .hero-logo i.b, .intro-mini i.b { background: var(--block); }
.logo:hover .logo-mark { transform: rotate(8deg) scale(1.1); }
.logo-text { font: 700 calc(1.75rem * var(--head-scale)) var(--font-head); letter-spacing: .01em; white-space: nowrap; }
/* the screens and the three quick buttons (How to Play, world, sound) share one pill, the buttons right after
   Settings; on narrower screens the pill is just the screens and the buttons sit by the logo */
.bar-group, .modes {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 5px;
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: 999px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}
.bar-group { margin-left: auto; gap: 4px; }
.bar-group .modes { padding: 0; background: none; border: 0; box-shadow: none; backdrop-filter: none; }
.modes a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 999px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 700;
    transition: background .2s, color .2s, transform .2s;
}
.modes a:hover { background: var(--hover); transform: translateY(-1px); }
.modes a.active { background: var(--accent); color: var(--accent-ink); }
.tools { display: flex; gap: 6px; }
.bar-group .tools { gap: 2px; margin-left: 2px; padding-left: 6px; border-left: 1.5px solid var(--line); }
.tool {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1.5px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--ink);
    font-size: 19px;
    cursor: pointer;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    transition: transform .25s cubic-bezier(.2, 1.6, .4, 1), opacity .2s;
}
.tool:hover { transform: translateY(-2px); }
.bar-group .tool { width: 36px; height: 36px; border: 0; background: none; box-shadow: none; backdrop-filter: none; transition: background .2s, transform .2s, opacity .2s; }
.bar-group .tool:hover { background: var(--hover); transform: translateY(-1px); }
.tool[aria-expanded="true"] { background: var(--hover); }
.tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tool .fill { fill: currentColor; }
.tool .x { display: none; }
.tool.off { opacity: .55; }
.tool.off .x { display: inline; }
.tool.off .waves { display: none; }
.world-pop {
    position: absolute;
    top: 66px;
    right: 16px;
    z-index: 60;
    width: min(600px, calc(100vw - 32px));
    padding: 14px;
    background: var(--surface-solid);
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
    animation: pop-in .3s cubic-bezier(.2, 1.4, .4, 1);
    max-height: calc(100vh - 90px);         /* with many worlds, scroll inside instead of running off the screen */
    overflow-y: auto;
    overscroll-behavior: contain;
}
.world-pop-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.world-pop-head > b { font: 700 calc(1.4rem * var(--head-scale)) var(--font-head); }
.pop-mode { display: inline-flex; gap: 4px; padding: 3px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface-2); }
.pop-mode button { padding: 4px 12px; border: 0; border-radius: 999px; background: none; color: var(--muted); font: 800 .82rem var(--font-body); cursor: pointer; }
.pop-mode button.active { background: var(--accent); color: var(--accent-ink); }
.world-pop-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-top: 10px; }
/* the sound menu: every sound option (built by app.js, the same as Settings > Sound) */
.sound-pop {
    position: absolute;
    top: 66px;
    right: 16px;
    z-index: 60;
    width: min(340px, calc(100vw - 32px));
    padding: 14px 16px 16px;
    background: var(--surface-solid);
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
    animation: pop-in .3s cubic-bezier(.2, 1.4, .4, 1);
    max-height: calc(100vh - 90px);
    overflow-y: auto;
    overscroll-behavior: contain;
}
.sound-controls { display: flex; flex-direction: column; gap: 14px; }
#settings-view .sound-controls { margin-top: 12px; }
.snd-group { display: flex; flex-direction: column; gap: 10px; transition: opacity .2s; }
.snd-group + .snd-group { padding-top: 12px; border-top: 1.5px solid var(--line); }
.snd-head { margin: 0; color: var(--muted); font: 800 .78rem var(--font-body); letter-spacing: .02em; }
.snd-master { font-size: 1.05rem; }
.snd-master .snd-label { font-weight: 800; }
/* a slider: its name and value on one line, the slider under them (Master's with its mute button in front) */
.snd-row.range { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
.snd-line { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.snd-line input { flex: 1; min-width: 0; width: 100%; margin: 0; accent-color: var(--accent); cursor: pointer; }
.snd-row output { min-width: 0; color: var(--muted); font-size: .88rem; font-variant-numeric: tabular-nums; }
/* Music and Effects: their sliders sit under the group's name, indented a little */
.snd-group[data-group="music"] .snd-row, .snd-group[data-group="fx"] .snd-row { margin-left: 10px; }
.snd-mute { flex: 0 0 auto; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 50%; border: 1.5px solid var(--line); background: var(--surface-2, transparent); color: var(--ink); cursor: pointer; transition: transform .15s, background .2s; }
.snd-mute:hover { transform: translateY(-1px); }
.snd-mute svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.snd-mute svg .fill { fill: currentColor; stroke: none; }
.snd-mute .x { display: none; }
.snd-mute.off { color: var(--muted); }
.snd-mute.off .x { display: inline; }
.snd-mute.off .waves { display: none; }
.sound-pop { overflow-x: hidden; }
#zoom-card .zoom-row { margin-top: 4px; }
#zoom-card #zoom-reset { margin-top: 12px; }
.snd-group.dim, .snd-row.dim, .snd-row.zero output { opacity: .5; }

main { max-width: 1120px; margin: 0 auto; padding: 6px 16px 90px; }
.screen.enter { animation: screen-in .5s cubic-bezier(.2, .9, .3, 1); }
@keyframes screen-in { from { opacity: 0; transform: translateY(16px); } }
/* Settings and Stats only fade in: in the heavier worlds the slide could start late and make the page jump */
#settings-view.enter, #stats-view.enter { animation: screen-fade .35s ease-out; }
@keyframes screen-fade { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-8px) scale(.94); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes stamp-in { from { opacity: 0; transform: scale(2.2) rotate(-12deg); } }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes blink { 50% { opacity: 0; } }

/* ---------------------------------------------------------------------------------------------
   Cards & buttons
   --------------------------------------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.card-head h2 { margin: 0; font: 700 calc(1.8rem * var(--head-scale)) var(--font-head); line-height: 1.1; }
.kicker { font-size: .74rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.kicker.link { color: var(--accent); text-decoration: none; }
.kicker.link:hover { text-decoration: underline; }
.card-blurb { margin: 0; color: var(--muted); font-weight: 600; line-height: 1.45; }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    background: var(--surface-solid);
    color: var(--ink);
    font: 800 1rem var(--font-body);
    text-decoration: none;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform .18s cubic-bezier(.2, 1.6, .4, 1), box-shadow .18s, background .18s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.btn.big { padding: 14px 24px; font-size: 1.12rem; }
.btn.danger { background: transparent; border-color: var(--wrong); color: var(--wrong); }

/* ---------------------------------------------------------------------------------------------
   Home
   --------------------------------------------------------------------------------------------- */
.hero { display: flex; align-items: center; gap: 24px; margin: 18px 0 24px; }
.hero-logo {
    display: grid;
    grid-template-columns: repeat(2, 48px);
    grid-template-rows: repeat(3, 48px);
    gap: 3px;
    padding: 3px;
    flex-shrink: 0;
    background: var(--grid);
    border-radius: 12px;
    box-shadow: var(--shadow);
    animation: float 6s ease-in-out infinite;
}
.hero-logo i { font-size: 30px; }
@keyframes float { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(-2deg) translateY(-7px); } }
.greeting { margin: 0; color: var(--accent); font-weight: 900; letter-spacing: .05em; }
.hero-title { margin: 2px 0; font: 700 calc(3.2rem * var(--head-scale)) var(--font-head); line-height: 1; }
.today-date { margin: 0; color: var(--muted); font-weight: 700; }
.home-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; }
.home-grid > .card { animation: card-in .6s cubic-bezier(.2, 1.2, .4, 1) backwards; }
.home-grid > .card:nth-child(2) { animation-delay: .07s; }
.home-grid > .card:nth-child(3) { animation-delay: .14s; }
.home-grid > .card:nth-child(4) { animation-delay: .21s; }
@keyframes card-in { from { opacity: 0; transform: translateY(26px) scale(.96); } }
.daily-card { grid-row: span 2; }      /* Unlimited and your streak stack beside it; the streak card reaches down to its bottom */
/* the streak card is as tall as the rest of Daily, so its pieces spread out down it */
.streak-card { display: flex; flex-direction: column; }
.streak-card .streak-line { margin-top: auto; }
.streak-card .home-ach { margin-bottom: auto; }
.streak-card .week { gap: 10px; margin: 22px 0 10px; }
.streak-card .wk-day i { width: 38px; height: 38px; }
/* the leaderboard runs under both, from Daily's edge to the streak's, with today's top 50 in two columns */
.home-grid > .leader-card { grid-column: 1 / -1; }
.leader-card .lb-list.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(var(--rows), auto); grid-auto-flow: column; gap: 4px 18px; }
@media (max-width: 720px) { .leader-card .lb-list.two { display: flex; } }
.leader-card .lb-list:not(.two), .leader-card .lb-you { max-width: 640px; margin-left: auto; margin-right: auto; }
.leader-card .lb-wrap .lb-you { max-width: none; }
.leader-card .lb-hint { text-align: center; }
.daily-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 10px; }
.daily-chip {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    padding: 14px;
    overflow: hidden;
    border: 2px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--ink);
    text-decoration: none;
    animation: card-in .5s cubic-bezier(.2, 1.3, .4, 1) backwards;
    animation-delay: calc(.2s + var(--i, 0) * .08s);
    transition: transform .22s cubic-bezier(.2, 1.6, .4, 1), border-color .2s, background .2s;
}
.daily-chip:hover { transform: translateY(-4px) rotate(-1deg); border-color: var(--accent); }
.pips { display: flex; gap: 3px; }
.pips i { width: 9px; height: 9px; border-radius: 2px; background: var(--accent); }
.chip-name { font: 700 calc(1.55rem * var(--head-scale)) var(--font-head); line-height: 1; }
.chip-state { font-size: .82rem; font-weight: 800; color: var(--muted); }
.daily-chip.done { border-color: var(--good); background: color-mix(in srgb, var(--good) 14%, var(--surface-2)); }
.daily-chip.done .chip-state { color: var(--good); }
.daily-chip.done::after { content: "\2713"; position: absolute; top: 4px; right: 10px; color: var(--good); font-size: 1.8rem; font-weight: 900; animation: stamp-in .45s cubic-bezier(.2, 1.6, .4, 1) .3s backwards; }
.daily-chip.given-up { opacity: .7; border-style: dashed; }
.card-status { margin: 6px 0 0; font-weight: 900; }
.countdown { margin: 4px 0 0; color: var(--muted); font-size: .9rem; font-weight: 600; }
.countdown b { color: var(--ink); font-variant-numeric: tabular-nums; }
.unlimited-card { display: flex; flex-direction: column; gap: 14px; }
.unlimited-card .btn { margin-top: auto; align-self: flex-start; }
.streak-line, .stats-streak, .res-streak { display: flex; justify-content: center; }
.week { display: flex; justify-content: center; gap: 8px; margin: 16px 0 6px; }
.wk-day { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); font-size: .74rem; font-weight: 900; }
.wk-day i {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 2px solid var(--line);
    border-radius: 50%;
    color: var(--accent-ink);
    font-style: normal;
    font-weight: 900;
    transition: transform .2s;
}
.wk-day[data-n="1"] i { background: color-mix(in srgb, var(--accent) 30%, transparent); border-color: var(--accent); }
.wk-day[data-n="2"] i { background: color-mix(in srgb, var(--accent) 48%, transparent); border-color: var(--accent); }
.wk-day[data-n="3"] i { background: color-mix(in srgb, var(--accent) 66%, transparent); border-color: var(--accent); }
.wk-day[data-n="4"] i { background: color-mix(in srgb, var(--accent) 84%, transparent); border-color: var(--accent); }
.wk-day[data-n="5"] i { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 60%, transparent); }
.wk-day.today i { box-shadow: 0 0 0 3px var(--surface-solid), 0 0 0 5px var(--accent-2); }
.wk-day.future { opacity: .45; }
.wk-day:hover i { transform: scale(1.12); }
.home-ach { margin: 8px 0 0; color: var(--muted); font-size: .86rem; font-weight: 700; text-align: center; }

/* World cards (home, settings, the world picker) */
.world-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.world-cards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-top: 10px; }      /* Settings: 5 per row */
@media (max-width: 980px) { .world-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .world-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* the plain Classic page: a bar across the bottom of the world list, not a card */
.world-classic-bar {
    grid-column: 1 / -1;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 10px;
    padding: 10px 14px;
    background: #ffffff;
    color: #1a1a1a;
    border: 2px solid var(--line);
    border-radius: var(--radius-sm);
    font: 600 1rem system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    cursor: pointer;
    transition: border-color .15s, transform .15s;
}
.world-classic-bar small { color: #64666c; font-size: .8rem; }
.world-classic-bar:hover { border-color: var(--accent); transform: translateY(-1px); }
.world-classic-bar.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.world-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    border: 2px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: transform .25s cubic-bezier(.2, 1.5, .4, 1), border-color .2s, box-shadow .2s;
}
.world-card:hover { transform: translateY(-5px) rotate(-.6deg); box-shadow: 0 14px 30px rgba(0, 0, 0, .28); }
.world-card.on { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.world-card.on::after {
    content: "\2713 ON";
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    font: 900 .7rem var(--font-body);
    letter-spacing: .08em;
}
.wc-preview { display: block; width: 100%; aspect-ratio: 16 / 9; }
.world-card.compact .wc-preview { aspect-ratio: 16 / 8; }
.wc-label { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px 10px; font-family: var(--font-body); }
.wc-label b { font-weight: 900; }
.wc-label b i { font-style: normal; }
/* each card's name is written in its own world's lettering */
.world-card[data-wid="paper"] .wc-label b { font-family: "Patrick Hand", cursive; font-size: 1.15rem; font-weight: 400; }
.world-card[data-wid="space"] .wc-label b { font-family: Orbitron, sans-serif; font-size: .92rem; font-weight: 700; letter-spacing: .04em; }
.world-card[data-wid="garden"] .wc-label b { font-family: Fredoka, sans-serif; font-size: 1.05rem; font-weight: 600; }
.world-card[data-wid="arcade"] .wc-label b { font-family: "Press Start 2P", monospace; font-size: .62rem; font-weight: 400; line-height: 1.8; }
.world-card[data-wid="snow"] .wc-label b { font-family: Comfortaa, sans-serif; font-size: 1rem; font-weight: 700; }
.world-card[data-wid="squirrel"] .wc-label b { font-family: "Patua One", serif; font-size: 1.05rem; font-weight: 400; }
.world-card[data-wid="ocean"] .wc-label b { font-family: "Baloo 2", sans-serif; font-size: 1.1rem; font-weight: 800; }
.world-card[data-wid="candy"] .wc-label b { font-family: "Lilita One", sans-serif; font-size: 1.1rem; font-weight: 400; }
.world-card[data-wid="library"] .wc-label b { font-family: "IM Fell English SC", serif; font-size: .98rem; font-weight: 400; white-space: nowrap; }
.world-card[data-wid="volcano"] .wc-label b { font-family: Bungee, sans-serif; font-size: .82rem; font-weight: 400; }
.world-card[data-wid="sky"] .wc-label b { font-family: Comfortaa, sans-serif; font-size: 1rem; font-weight: 700; }
.world-card[data-wid="rift"] .wc-label b { font-family: Cinzel, serif; font-size: .98rem; font-weight: 700; letter-spacing: .03em; }
.world-card[data-wid="desert"] .wc-label b { font-family: Rye, serif; font-size: .95rem; font-weight: 400; }
.world-card[data-wid="robot"] .wc-label b { font-family: "Russo One", sans-serif; font-size: .95rem; font-weight: 400; }
.world-card[data-wid="carnival"] .wc-label b { font-family: Shrikhand, serif; font-size: .86rem; font-weight: 400; white-space: nowrap; }
.world-card[data-wid="rain"] .wc-label b { font-family: Pacifico, cursive; font-size: 1rem; font-weight: 400; }
.wc-label small { color: var(--muted); font-size: .8rem; font-weight: 600; }

/* ---------------------------------------------------------------------------------------------
   The game screen
   --------------------------------------------------------------------------------------------- */
.game-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 12px 20px; margin: 10px 0 16px; }
.game-titles h1 { margin: 0; font: 700 calc(2.5rem * var(--head-scale)) var(--font-head); line-height: 1.05; }
.subtitle { margin: 4px 0 0; color: var(--muted); font-weight: 700; }
.difficulty {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 5px;
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: 999px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}
.difficulty button {
    padding: 8px 16px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--ink);
    font: 800 .95rem var(--font-body);
    cursor: pointer;
    transition: background .2s, color .2s, transform .2s;
}
.difficulty button:hover { transform: translateY(-1px); }
.difficulty button.active { background: var(--accent); color: var(--accent-ink); }
.difficulty button.done::after { content: " \2713"; }
.difficulty button.given-up::after { content: " \00D7"; }
.difficulty .new-puzzle { border: 1.5px dashed var(--accent); }
.status { padding: 50px 0; color: var(--muted); font-weight: 700; text-align: center; }
.status.error { color: var(--wrong); }
.spinner { display: inline-block; width: 20px; height: 20px; margin-right: 10px; vertical-align: -4px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }

.puzzle { display: flex; align-items: flex-start; justify-content: center; gap: 34px; }
.board-area { flex-shrink: 0; width: min(440px, 92vw); }
.hud-row { display: flex; align-items: center; gap: 12px; min-height: 46px; margin-bottom: 10px; }
.timer-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 14px 4px 4px;
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: 999px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}
.ring { width: 36px; height: 36px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 4; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; transition: stroke-dashoffset .45s cubic-bezier(.2, 1.2, .4, 1); }
.timer { min-width: 3.2ch; font: 900 1.3rem var(--font-body); font-variant-numeric: tabular-nums; }
.no-timer .timer { display: none; }
.pct { color: var(--muted); font-size: .75rem; font-weight: 900; }
.points-today { flex: 1; color: var(--muted); font-size: .84rem; font-weight: 800; text-align: right; }
.world-hud:empty { display: none; }
.result-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--good);
    color: #fff;
    font-weight: 800;
    animation: pop-in .5s cubic-bezier(.2, 1.4, .4, 1);
}
.result-banner b { font: 700 calc(1.45rem * var(--head-scale)) var(--font-head); }
.result-banner span { flex: 1; }
.result-banner.surrender { background: var(--muted); }
.result-banner .btn { box-shadow: none; }
/* dark modes use a light green (and a light grey for a surrender): dark text reads better on those */
[data-theme="dark"] .result-banner { color: #0d1a12; }
.clue-bar-row { display: flex; gap: 6px; margin-bottom: 12px; }
.clue-bar {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 3.5em;
    padding: 10px 14px;
    overflow: hidden;
    background: var(--word);
    color: var(--cell-ink);
    border-left: 6px solid var(--accent);
    border-radius: var(--radius-sm);
    font-weight: 800;
    cursor: pointer;
    box-shadow: var(--shadow);
}
.cb-num { flex-shrink: 0; padding: 2px 8px; border-radius: 6px; background: var(--accent); color: var(--accent-ink); font: 900 .95rem var(--font-body); }
.cb-dir { color: var(--accent); font-weight: 900; }
.cb-text { flex: 1; line-height: 1.3; }
.clue-bar.slide .cb-text, .clue-bar.slide .cb-num { animation: clue-in .32s cubic-bezier(.2, 1.3, .4, 1); }
@keyframes clue-in { from { opacity: 0; transform: translateX(-12px); } }

.board-wrap { position: relative; }
.board {
    --size: 5;
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template-columns: repeat(var(--size), 1fr);
    grid-template-rows: repeat(var(--size), 1fr);
    gap: var(--gap);
    width: 100%;
    aspect-ratio: 1;
    padding: var(--gap);
    background: var(--grid);
    border-radius: var(--radius-sm);
    box-shadow: var(--board-shadow, var(--shadow));
}
.board.deal .cell { animation: deal .5s cubic-bezier(.2, 1.3, .4, 1) backwards; animation-delay: calc(var(--i) * 20ms); }
@keyframes deal { from { opacity: 0; transform: scale(.3) rotate(-14deg) translateY(-14px); } 70% { transform: scale(1.06) rotate(1deg); } }
.cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cell);
    color: var(--cell-ink);
    font: var(--cell-weight) clamp(1.6rem, 8.6vw, 2.75rem)/1 var(--font-cell);
    text-transform: uppercase;
    border-radius: var(--cell-radius);
    cursor: pointer;
    user-select: none;
    transition: background-color .16s;
}
.cell.block { background: var(--block); cursor: default; }
/* Challenge mode's 7x7 board: smaller letters and numbers (beats each world's own letter size) */
.board.big .cell { font-size: calc(clamp(1.6rem, 8.6vw, 2.75rem) * 5.4 / var(--size)); }   /* 6x6 to 9x9 */
.board.big .cell .num { top: 2px; left: 3px; font-size: calc(.72rem * 6 / var(--size)); }
.report-btn { justify-self: center; padding: 4px 10px; border: 0; background: none; color: var(--muted); font: 700 .8rem var(--font-body); cursor: pointer; text-decoration: underline dotted; }
.report-btn:hover { color: var(--accent); }
.unlimited-left { align-self: center; padding: 4px 10px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--muted); font: 800 .78rem var(--font-body); white-space: nowrap; }
.unlimited-left:empty { display: none; }
.unlimited-left.low { color: var(--accent); border-color: var(--accent); }
.unlimited-left.out { color: var(--wrong); border-color: var(--wrong); }
.link-btn { padding: 0; border: 0; background: none; color: var(--ink); font: inherit; text-decoration: underline; cursor: pointer; }
.report-card { width: min(460px, 100%); text-align: left; }
.report-card .ask-title { text-align: center; }
.report-card label { display: block; margin: 10px 0 4px; font-weight: 800; font-size: .88rem; }
.report-card select, .report-card textarea { width: 100%; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); font: 600 .95rem var(--font-body); }
.report-card textarea { min-height: 110px; resize: vertical; }
.report-card .count { display: block; margin-top: 2px; color: var(--muted); font-size: .75rem; text-align: right; }
.report-card .res-actions { margin-top: 14px; }
.report-card .report-err { min-height: 1.2em; margin: 6px 0 0; color: var(--wrong); font-weight: 700; font-size: .85rem; }
.about p { margin: 6px 0 10px; }
.credits { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; font-size: .9rem; }
.credits dt { font-weight: 900; color: var(--accent); }
.credits dd { margin: 0; color: var(--muted); font-weight: 600; line-height: 1.45; }
.credits a { color: var(--ink); }
@media (max-width: 480px) { .credits { grid-template-columns: 1fr; gap: 2px; } .credits dd { margin-bottom: 8px; } }
.cell.in-word { background: var(--word); }
.cell.selected { background: var(--sel); }
.cell .ltr { position: relative; z-index: 2; }
.cell .num { position: absolute; top: 3px; left: 5px; z-index: 2; color: var(--num); font: 800 .72rem/1 var(--font-body); }
/* letters show up the instant you type them, with a quick pop (never fading in) */
/* (a springier pop with a little overshoot, and a flash of the accent colour round the letter) */
.cell.typed .ltr { animation: letter-in .3s cubic-bezier(.2, 1.7, .4, 1); }
@keyframes letter-in {
    0% { transform: scale(1.38) translateY(-2px); text-shadow: 0 0 10px color-mix(in srgb, var(--accent) 70%, transparent); }
    55% { transform: scale(.93); }
    100% { transform: none; text-shadow: none; }
}
/* which way you're typing: a small arrow on the selected square */
.board .cell.selected::after { content: "\2192"; position: absolute; inset: auto 3px 1px auto; z-index: 3; color: var(--accent); font: 900 calc(1.05rem * 6 / max(6, var(--size, 5))) var(--font-body); background: none; pointer-events: none; }
.board[data-dir="down"] .cell.selected::after { content: "\2193"; }
.board.solved .cell.selected::after { content: none; }
/* a finished word: each square hops, brightens and rings in green, one after another */
.cell.wave { animation: word-wave .6s ease-out; }
@keyframes word-wave {
    35% { transform: translateY(-6px) scale(1.08); filter: brightness(1.08); box-shadow: 0 6px 14px rgba(0, 0, 0, .16), inset 0 0 0 3px color-mix(in srgb, var(--good) 65%, transparent); }
    70% { transform: translateY(1px) scale(.98); }
}
.cell.shake { animation: shake .45s; }
@keyframes shake { 20% { transform: translateX(-5px) rotate(-3deg); } 40% { transform: translateX(5px) rotate(3deg); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
.cell.ok { animation: ok-flash .7s; }
@keyframes ok-flash { 30% { box-shadow: inset 0 0 0 4px var(--good), 0 0 16px color-mix(in srgb, var(--good) 55%, transparent); transform: scale(1.05); } }
.cell.flip { animation: flip .55s ease var(--d, 0ms) backwards; }
@keyframes flip { from { transform: perspective(300px) rotateY(180deg); filter: brightness(1.7); } 55% { filter: brightness(1.25); } }
.cell.wrong .ltr { color: var(--wrong); }
.cell.wrong::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    background: linear-gradient(to top right, transparent calc(50% - 1.5px), var(--wrong) 50%, transparent calc(50% + 1.5px));
    pointer-events: none;
}
/* Locked squares (checked and right, or revealed): a padlock badge in the corner, a coloured ring inside the
   square, a light tint and a coloured letter. Green (--good) = checked and right; --revealed = revealed. */
.cell.locked, .cell.revealed { --lock: var(--good); }
.cell.revealed { --lock: var(--revealed); }
.cell.locked:not(.block), .cell.revealed:not(.block) {
    background-image: linear-gradient(color-mix(in srgb, var(--lock) 16%, transparent), color-mix(in srgb, var(--lock) 16%, transparent));
    box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--lock) 80%, transparent);
}
.cell.locked .ltr, .cell.revealed .ltr { color: color-mix(in srgb, var(--cell-ink) 35%, var(--lock)); }
.cell.locked::before, .cell.revealed::before {
    content: "";
    position: absolute;
    top: 3px;
    right: 3px;
    z-index: 3;
    width: calc(1.15rem * 6 / max(6, var(--size, 5)));
    height: calc(1.15rem * 6 / max(6, var(--size, 5)));
    border-radius: 50%;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 11V8a4 4 0 0 1 8 0v3' fill='none' stroke='%23fff' stroke-width='2.6'/%3E%3Crect x='5.5' y='10.5' width='13' height='9.5' rx='2' fill='%23fff'/%3E%3C/svg%3E") center / 64% no-repeat, var(--lock);
    box-shadow: 0 0 0 2px var(--cell), 0 1px 3px rgba(0, 0, 0, .3);
    pointer-events: none;
}
.board.solved .cell.locked::before, .board.solved .cell.locked:not(.block) { content: none; box-shadow: none; background-image: none; }
.cell.lock-in { animation: lock-in .6s cubic-bezier(.2, 1.6, .4, 1); }
/* the one-shot square animations win over every world's looping ones (Deep Space's and Neon Arcade's pulsing selected
   square, Coral Reef's shimmer): clicking a square to bring back a letter selects it, and its flip used to be lost */
#board .cell.flip { animation: flip .55s ease var(--d, 0ms) backwards; }
#board .cell.shake { animation: shake .45s; }
#board .cell.ok { animation: ok-flash .7s; }
#board .cell.lock-in { animation: lock-in .6s cubic-bezier(.2, 1.6, .4, 1); }
.cell.lock-in::before { animation: lock-badge .5s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes lock-in { 30% { transform: scale(1.12); box-shadow: inset 0 0 0 6px var(--lock, var(--good)), 0 0 18px color-mix(in srgb, var(--lock, var(--good)) 55%, transparent); } }
@keyframes lock-badge { from { transform: scale(0) rotate(-40deg); } }
.board.solved .cell:not(.block) { background: var(--solved); }
/* a solved board: a band of light sweeps across it once */
.board.solved::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 6;
    pointer-events: none;
    border-radius: inherit;
    background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, .55) 50%, transparent 62%) 0 0 / 260% 100% no-repeat;
    animation: board-shine 1.5s ease-out .25s both;
}
@keyframes board-shine { from { background-position: 115% 0; opacity: 1; } 85% { opacity: 1; } to { background-position: -15% 0; opacity: 0; } }
.board.surrendered .cell:not(.block) { filter: saturate(.4); }

.helpers {
    display: grid;
    gap: 7px;
    margin-top: 14px;
    padding: 10px 12px 8px;
    background: color-mix(in srgb, var(--surface-solid) 92%, transparent);
    border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}
.helper-row { display: flex; align-items: center; gap: 6px; }
.helper-label { width: 4.3em; color: var(--ink); opacity: .8; font-size: .74rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.helper-row button {
    flex: 1;
    padding: 7px 0;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    background: var(--surface-solid);
    color: var(--ink);
    font: 800 .88rem var(--font-body);
    cursor: pointer;
    transition: transform .15s, border-color .15s;
}
.helper-row button:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--accent); }
/* used up (e.g. the puzzle is solved): solid and muted, never see-through, so the scene can't show through the text */
.helper-row button:disabled { background: var(--surface-2); color: var(--muted); border-color: transparent; cursor: default; }

.clues {
    flex: 1;
    display: flex;
    gap: 22px;
    max-width: 580px;
    align-self: flex-start;
    margin-top: 58px;
    padding: 14px 16px 12px;
    background: color-mix(in srgb, var(--surface-solid) 88%, transparent);
    border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}
.clue-col { flex: 1; min-width: 0; }
.clues h2 { margin: 0 0 8px; font: 700 calc(1.7rem * var(--head-scale)) var(--font-head); }
.clues h2 span { padding: 0 4px; background: linear-gradient(transparent 60%, var(--word) 60%); }
.clues ol { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.clues li {
    display: flex;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    line-height: 1.35;
    font-weight: 600;
    animation: clue-in .45s cubic-bezier(.2, 1.2, .4, 1) backwards;
    animation-delay: calc(var(--i) * 45ms + .1s);
    transition: background .15s, transform .15s;
}
.clues li:hover { background: var(--hover); transform: translateX(3px); }
.clues li.active { background: var(--word); color: var(--cell-ink); font-weight: 800; }
.clues li.done:not(.active) .clue-text { opacity: .55; text-decoration: line-through 2px var(--accent); }
.clue-num { min-width: 1.6em; color: var(--accent); font-weight: 900; }

/* ---------------------------------------------------------------------------------------------
   The results screen
   --------------------------------------------------------------------------------------------- */
#overlay { position: fixed; inset: 0; z-index: 800; pointer-events: none; }
/* dialogs and cinematics catch clicks; :where() keeps this rule weak, so anything that says pointer-events: none
   (ability banners, sparkles, a word's fish or score pop) lets clicks through to the board. With "#overlay > *" those
   swallowed clicks for a second or two: clicking a square or a clue sometimes did nothing. */
:where(#overlay) > * { pointer-events: auto; }
.results {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(0, 0, 0, .45);
    backdrop-filter: blur(3px);
    opacity: 0;
    transition: opacity .3s;
}
.results.in { opacity: 1; }
.ask-card { width: min(400px, 100%); }
.ask-title { margin: 0 0 8px; font-size: calc(1.9rem * var(--head-scale)); }
.ask-text { margin: 0 0 18px; color: var(--muted); font-weight: 700; line-height: 1.45; }
.ask-card .res-actions { margin-top: 0; }
.results.out { opacity: 0; }
.res-card {
    position: relative;
    width: min(450px, 100%);
    max-height: calc(100vh - 32px);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 26px 26px 22px;
    background: var(--surface-solid);
    color: var(--ink);
    border: 2px solid var(--line);
    border-radius: 22px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
    text-align: center;
    transform: translateY(40px) scale(.88);
    transition: transform .55s cubic-bezier(.2, 1.4, .4, 1);
}
.results.in .res-card { transform: none; }
.res-rays { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.res-rays::before {
    content: "";
    position: absolute;
    inset: -60%;
    background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--accent) 12%, transparent) 0 8deg, transparent 8deg 20deg);
    animation: spin 40s linear infinite;
}
.res-card > :not(.res-rays) { position: relative; z-index: 1; }
.res-kicker { color: var(--accent); font-weight: 900; letter-spacing: .16em; }
.res-title { margin: 4px 0 10px; font: 700 calc(3.2rem * var(--head-scale)) var(--font-head); line-height: 1; animation: title-pop .7s cubic-bezier(.2, 1.6, .4, 1) .15s backwards; }
@keyframes title-pop { from { opacity: 0; transform: scale(2.2) rotate(-8deg); } }
.res-time { display: inline-flex; align-items: baseline; gap: 10px; padding: 6px 18px; border-radius: 999px; background: var(--surface-2); font-weight: 900; }
.res-time span { color: var(--muted); font-size: .74rem; letter-spacing: .16em; }
.res-time b { font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.res-tally { display: grid; gap: 3px; max-width: 300px; margin: 16px auto 4px; }
/* a new personal best: a gold pill that pops in under the time, with a sweep of light */
.res-pb { position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: 1px; width: max-content; max-width: 100%; margin: 10px auto 0; padding: 6px 18px;
    border-radius: 14px; background: linear-gradient(135deg, #ffe27a, #f6b73c); color: #3a2400; box-shadow: 0 4px 18px rgba(246, 183, 60, .45); animation: pb-in .6s cubic-bezier(.3, 1.6, .5, 1) .55s both; }
.res-pb b { font-size: 1rem; font-weight: 900; }
.res-pb span { font-size: .78rem; font-weight: 800; opacity: .8; }
.res-pb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .75) 50%, transparent 70%); transform: translateX(-120%); animation: pb-shine 1.1s ease-out 1.1s; }
@keyframes pb-in { from { opacity: 0; transform: scale(.4) rotate(-6deg); } }
@keyframes pb-shine { to { transform: translateX(120%); } }
@media (prefers-reduced-motion: reduce) { .res-pb, .res-pb::after { animation: none; } }
.res-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 4px;
    border-bottom: 1.5px dashed var(--line);
    font-weight: 800;
    animation: fade-up .35s ease backwards;
    animation-delay: calc(.3s + var(--i) * .26s);
}
.res-row b { font-variant-numeric: tabular-nums; }
.res-row.total { padding-top: 8px; border: 0; font-size: 1.3rem; }
.res-row.total b { color: var(--accent); font-size: 1.9rem; }
.res-note { margin: 12px 0 0; color: var(--muted); font-weight: 700; }
.res-streak { margin-top: 16px; }
.res-ach { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 6px; margin-top: 14px; }
.res-ach > small { grid-column: 1 / -1; color: var(--accent-2); font-weight: 900; letter-spacing: .14em; animation: pop-in .4s ease backwards; animation-delay: var(--d); }
.res-ach-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    padding: 6px 10px;
    border: 1.5px solid color-mix(in srgb, var(--accent) 45%, transparent);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    text-align: left;
    animation: stamp-in .5s cubic-bezier(.2, 1.6, .4, 1) backwards;
    animation-delay: var(--d);
}
/* a shine sweeps across each badge as it lands */
.res-ach-item::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .45) 50%, transparent 65%); transform: translateX(-120%); animation: badge-shine .9s ease forwards; animation-delay: calc(var(--d) + .3s); pointer-events: none; }
@keyframes badge-shine { to { transform: translateX(120%); } }
.res-ach-item > i { font-size: 1.4rem; font-style: normal; }
.res-ach-item b { display: block; font-size: .86rem; font-weight: 900; line-height: 1.15; }
.res-ach-item small { display: block; color: var(--muted); font-size: .72rem; font-weight: 700; line-height: 1.2; }
.res-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 20px; }

/* ---------------------------------------------------------------------------------------------
   The streak badge, with fire. data-level: 0 = none, 1 = 1-2 days, 2 = 3-6, 3 = 7+
   --------------------------------------------------------------------------------------------- */
.streak-badge {
    --fire-size: 1;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 10px 22px 10px 16px;
    background: var(--surface-solid);
    border: 2px solid var(--line);
    border-radius: 999px;
    box-shadow: var(--shadow);
}
.streak-badge[data-level="0"] { opacity: .8; }
.streak-badge[data-level="2"] { --fire-size: 1.25; }
.streak-badge[data-level="3"] { --fire-size: 1.55; border-color: var(--fire-2); box-shadow: var(--shadow), 0 0 26px rgba(255, 140, 58, .35); }
.streak-badge .fire { position: relative; width: calc(38px * var(--fire-size)); height: calc(46px * var(--fire-size)); }
.streak-badge[data-level="0"] .fire { display: none; }
.streak-text { display: flex; align-items: baseline; gap: 8px; }
.streak-num { font-size: 2.1rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.streak-label { color: var(--muted); font-weight: 800; }
.flame {
    position: absolute;
    bottom: 0;
    left: 50%;
    border-radius: 50% 0 50% 50%;
    transform-origin: 50% 100%;
    background: radial-gradient(circle at 60% 65%, var(--fire-1) 0 20%, var(--fire-2) 50%, var(--fire-3) 85%);
    filter: blur(.4px);
}
.flame.f1 { width: 70%; height: 70%; margin-left: -35%; animation: flicker .9s ease-in-out infinite alternate; }
.flame.f2 { width: 46%; height: 52%; margin-left: -40%; opacity: .85; animation: flicker .7s ease-in-out -.3s infinite alternate; }
.flame.f3 { width: 40%; height: 48%; margin-left: -5%; opacity: .85; animation: flicker .8s ease-in-out -.5s infinite alternate; }
@keyframes flicker {
    0% { transform: rotate(-45deg) scale(1, 1); }
    50% { transform: rotate(-40deg) scale(.92, 1.1) skew(3deg, 2deg); }
    100% { transform: rotate(-50deg) scale(1.05, .95) skew(-3deg, -2deg); }
}
.streak-badge .fire::before {
    content: "";
    position: absolute;
    inset: -30%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 140, 58, .35), transparent 65%);
    animation: fire-glow 1.6s ease-in-out infinite alternate;
}
.streak-badge[data-level="3"] .fire::before { inset: -55%; background: radial-gradient(circle, rgba(255, 140, 58, .5), transparent 65%); }
@keyframes fire-glow { to { opacity: .55; transform: scale(.9); } }
.ember { position: absolute; bottom: 40%; width: 4px; height: 4px; border-radius: 50%; background: var(--fire-1); animation: ember 1.8s ease-out infinite; }
.ember.e1 { left: 30%; }
.ember.e2 { left: 55%; animation-delay: -.6s; }
.ember.e3 { left: 70%; animation-delay: -1.2s; }
.streak-badge[data-level="1"] .ember { display: none; }
@keyframes ember { from { opacity: 1; transform: translate(0, 0); } to { opacity: 0; transform: translate(6px, calc(-30px * var(--fire-size))); } }

/* ---------------------------------------------------------------------------------------------
   Toasts (achievements) & the mascot
   --------------------------------------------------------------------------------------------- */
.toasts { position: fixed; top: 80px; left: 50%; z-index: 1000; display: flex; flex-direction: column; gap: 8px; transform: translateX(-50%); pointer-events: none; }
.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 270px;
    padding: 10px 20px 10px 12px;
    background: var(--surface-solid);
    color: var(--ink);
    border: 2px solid var(--accent);
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .3);
    opacity: 0;
    transform: translateY(-34px) scale(.8);
    transition: transform .5s cubic-bezier(.2, 1.5, .4, 1), opacity .3s;
}
.toast.in { opacity: 1; transform: none; }
.toast { position: relative; overflow: hidden; }
.toast.in::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .5) 50%, transparent 65%) 0 0 / 250% 100% no-repeat; animation: board-shine 1.1s ease-out .2s both; }
.toast.out { opacity: 0; transform: translateY(-20px); }
.toast-icon { font-size: 2.1rem; }
.toast.in .toast-icon { animation: stamp-in .6s cubic-bezier(.2, 1.6, .4, 1) .15s backwards; }
.toast-body small { display: block; color: var(--accent); font-size: .68rem; font-weight: 900; letter-spacing: .16em; }
.toast-body b { display: block; font-size: 1.05rem; }
.toast-body span { color: var(--muted); font-size: .82rem; font-weight: 600; }

.mascot { position: fixed; right: 12px; bottom: 8px; z-index: 700; display: flex; align-items: flex-end; gap: 2px; pointer-events: none; transition: transform .45s cubic-bezier(.3, 1.3, .5, 1), opacity .3s; }
.mascot.away, .intro-on .mascot, .cinematic .mascot { opacity: 0; transform: translateY(150%); }
.m-face { width: 118px; height: 118px; padding: 0; border: 0; background: none; cursor: pointer; pointer-events: auto; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .25)); transition: transform .2s; }
.m-face:hover { transform: scale(1.06) rotate(-4deg); }
.m-face canvas { width: 118px; height: 118px; }
[data-view="game"] .m-face, [data-view="game"] .m-face canvas { width: 96px; height: 96px; }
.m-bubble {
    position: relative;
    max-width: 290px;
    margin-bottom: 64px;
    padding: 16px 18px 12px;
    background: var(--surface-solid);
    color: var(--ink);
    border: 2px solid var(--line);
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .28);
    font-weight: 800;
    font-size: .95rem;
    line-height: 1.4;
    pointer-events: auto;
    cursor: pointer;
    transform-origin: right bottom;
    transition: opacity .25s, transform .35s cubic-bezier(.2, 1.4, .4, 1);
}
.m-bubble.hide { opacity: 0; transform: scale(.5) translate(30px, 30px); pointer-events: none; }
.m-bubble p { min-height: 1.4em; margin: 0; }
.m-name { position: absolute; top: -12px; left: 14px; padding: 1px 10px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font: 900 .7rem var(--font-body); letter-spacing: .14em; }
.m-next { position: absolute; right: 10px; bottom: 5px; border: 5px solid transparent; border-top-color: var(--accent); animation: blink 1s steps(2) infinite; }

/* ---------------------------------------------------------------------------------------------
   Title cards & the intro
   --------------------------------------------------------------------------------------------- */
.tc { position: fixed; inset: 0; z-index: 820; display: grid; place-items: center; pointer-events: auto; cursor: pointer; }
.intro {
    position: fixed;
    inset: 0;
    z-index: 950;
    display: grid;
    place-items: center;
    padding: 16px;
    /* see-through in the middle, so the world's own animated scene shows behind the intro */
    background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--bg) 30%, transparent), color-mix(in srgb, var(--bg) 85%, transparent) 78%);
    cursor: pointer;
    overflow: hidden;
}
.intro::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 50% 45%, transparent 30%, rgba(0, 0, 0, .25)); pointer-events: none; }
.intro-on body { overflow: hidden; }
.intro-on #app { visibility: hidden; }           /* the intro shows the world's scene, not the page */
.intro-rays {
    position: absolute;
    top: 45%;
    left: 50%;
    width: 220vmax;
    height: 220vmax;
    margin: -110vmax 0 0 -110vmax;
    background: repeating-conic-gradient(color-mix(in srgb, var(--accent) 16%, transparent) 0 7deg, transparent 7deg 18deg);
    -webkit-mask: radial-gradient(circle, #000, transparent 55%);
    mask: radial-gradient(circle, #000, transparent 55%);
    animation: spin 50s linear infinite;
    pointer-events: none;
    transition: opacity .6s;
}
.intro-tiles { position: absolute; inset: 0; overflow: hidden; pointer-events: none; transition: opacity .7s; }
.it-tile {
    position: absolute;
    top: 104%;
    left: var(--x);
    display: grid;
    place-items: center;
    width: var(--s);
    height: var(--s);
    background: var(--cell);
    color: var(--cell-ink);
    border: 2px solid var(--grid);
    border-radius: max(4px, var(--cell-radius));
    font: var(--cell-weight) calc(var(--s) * .58)/1 var(--font-cell);
    opacity: var(--o);
    filter: blur(var(--b));
    box-shadow: 2px 3px 0 rgba(0, 0, 0, .2);
    animation: it-rise var(--t) linear var(--d) infinite;
}
@keyframes it-rise { from { transform: translateY(0) rotate(var(--r)); } to { transform: translateY(-128vh) rotate(calc(var(--r) * -1)); } }
.intro.go .intro-tiles { opacity: .25; }
.intro.go .intro-rays { opacity: .5; }
.intro-press { position: relative; display: flex; flex-direction: column; align-items: center; gap: 22px; text-align: center; }
.intro-mini {
    display: grid;
    grid-template-columns: repeat(2, 60px);
    grid-template-rows: repeat(2, 60px);
    gap: 4px;
    padding: 4px;
    background: var(--grid);
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .3);
    animation: float 4s ease-in-out infinite;
}
.intro-mini i { font-size: 38px; }
.intro-start {
    position: relative;
    overflow: hidden;
    padding: 12px 34px;
    border: 3px solid var(--ink);
    border-radius: 18px;
    background: var(--accent);
    color: var(--accent-ink);
    font: 700 calc(clamp(2rem, 6vw, 3.8rem) * var(--head-scale)) var(--font-head);
    cursor: pointer;
    box-shadow: 6px 6px 0 var(--ink), 0 0 40px color-mix(in srgb, var(--accent) 60%, transparent);
    animation: press 1.2s ease-in-out infinite;
}
.intro-start::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .55) 50%, transparent 65%); transform: translateX(-120%); animation: it-shine 2.4s ease-in-out infinite; }
@keyframes it-shine { 55%, 100% { transform: translateX(120%); } }
@keyframes press { 50% { transform: scale(1.06) rotate(-2deg); } }
.intro-worlds { display: flex; gap: 16px; font-size: 30px; }
.intro-worlds .iw { display: inline-block; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .25)); animation: iw-bob 1.8s ease-in-out calc(var(--i) * -.3s) infinite; }
@keyframes iw-bob { 50% { transform: translateY(-9px) rotate(9deg); } }
.intro small { color: var(--muted); font-weight: 700; letter-spacing: 0; }
.intro-ticker {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    overflow: hidden;
    padding: 10px 0;
    background: color-mix(in srgb, var(--ink) 90%, transparent);
    color: var(--bg);
    font: 700 .9rem var(--font-body);
    letter-spacing: .01em;
    white-space: nowrap;
}
.intro-ticker > div { display: inline-flex; gap: 52px; padding-left: 52px; animation: ticker 26s linear infinite; }
@keyframes ticker { to { transform: translateX(-50%); } }
.intro-grid { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.intro-grid line { stroke: color-mix(in srgb, var(--ink) 22%, transparent); stroke-width: 2; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw .8s ease-out forwards; }
.intro-grid rect { fill: color-mix(in srgb, var(--ink) 12%, transparent); transform-box: fill-box; transform-origin: center; animation: it-blk .45s cubic-bezier(.2, 1.6, .4, 1) backwards; }
@keyframes it-blk { from { transform: scale(0) rotate(-45deg); } }
.intro-stage { position: relative; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.intro-logo { --t: min(6.6vh, 10.5vw, 60px); position: relative; display: grid; grid-template-columns: repeat(7, var(--t)); grid-template-rows: repeat(9, var(--t)); gap: 5px; }
.logo-tile {
    position: relative;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: var(--cell);
    color: var(--cell-ink);
    border: 3px solid var(--grid);
    border-radius: max(4px, var(--cell-radius));
    font: var(--cell-weight) calc(var(--t) * .6)/1 var(--font-cell);
    box-shadow: 3px 4px 0 rgba(0, 0, 0, .25);
}
/* a shine sweeps across the logo, tile by tile */
.logo-tile::after { content: ""; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .7) 50%, transparent 70%); transform: translateX(-130%); }
.landed .logo-tile::after { animation: tile-shine .7s ease calc(var(--i) * 45ms) forwards; }
@keyframes tile-shine { to { transform: translateX(130%); } }
.landed .logo-tile { animation: tile-wave .6s ease calc(var(--i) * 35ms); }
.landed .logo-tile.cross { background: var(--sel); animation: cross-pop .8s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes tile-wave { 40% { transform: translateY(-10px) rotate(-4deg); } }
@keyframes cross-pop { 40% { transform: scale(1.4) rotate(12deg); } }
.intro-orbit { position: absolute; top: 50%; left: 50%; z-index: 2; width: 0; height: 0; pointer-events: none; }
.intro-orbit.on { animation: spin 7s linear infinite; }
.intro-orbit .io { position: absolute; top: -24px; left: -24px; display: grid; place-items: center; width: 48px; height: 48px; font-size: 34px; transform: rotate(calc(var(--i) * 360deg / var(--n))) translateX(calc(var(--t) * 5.4)) rotate(calc(var(--i) * -360deg / var(--n))); }
.intro-orbit .io b { display: block; opacity: 0; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .3)); }
.intro-orbit.on .io b { animation: io-pop .5s cubic-bezier(.2, 1.6, .4, 1) calc(var(--i) * 90ms) both, spin 7s linear reverse infinite; }
.intro-orbit .io b.gone { animation: io-gone .3s ease-in forwards; }
@keyframes io-pop { from { opacity: 0; transform: scale(0); } to { opacity: 1; } }
@keyframes io-gone { from { opacity: 1; } to { opacity: 0; transform: scale(2); } }
.intro-skip { opacity: .7; }

/* ---------------------------------------------------------------------------------------------
   Stats
   --------------------------------------------------------------------------------------------- */
.page-head { margin: 14px 0 18px; text-align: center; }
.page-head h1 { margin: 0; font: 700 calc(2.8rem * var(--head-scale)) var(--font-head); line-height: 1; }
#stats-view > .card, .stats-grid { margin-top: 18px; }
.stats-top { margin-bottom: 18px; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat-tile {
    padding: 14px 16px;
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
    animation: card-in .5s cubic-bezier(.2, 1.3, .4, 1) backwards;
    animation-delay: calc(var(--i) * 60ms);
}
.stat-tile .value { font-size: 1.8rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.stat-tile .label { color: var(--muted); font-size: .84rem; font-weight: 700; }
.stats-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
.heatmap { display: grid; grid-template-columns: repeat(var(--weeks, 18), minmax(0, 1fr)); gap: 4px; padding: 4px 0; }
.hm-col { display: grid; grid-template-rows: 16px repeat(7, auto); gap: 4px; }
.hm-month { overflow: visible; color: var(--muted); font-size: .7rem; font-weight: 800; white-space: nowrap; }
.hm-cell { aspect-ratio: 1; }
.hm-cell, .hm-key i { border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); animation: pop-in .4s ease backwards; animation-delay: var(--d, 0ms); }
.hm-cell[data-n="1"], .hm-key i[data-n="1"] { background: color-mix(in srgb, var(--accent) 25%, var(--surface-2)); }
.hm-cell[data-n="2"], .hm-key i[data-n="2"] { background: color-mix(in srgb, var(--accent) 45%, var(--surface-2)); }
.hm-cell[data-n="3"], .hm-key i[data-n="3"] { background: color-mix(in srgb, var(--accent) 65%, var(--surface-2)); }
.hm-cell[data-n="4"], .hm-key i[data-n="4"] { background: color-mix(in srgb, var(--accent) 82%, var(--surface-2)); }
.hm-cell[data-n="5"], .hm-key i[data-n="5"] { background: var(--accent); }
.hm-cell.today { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.hm-cell.future { opacity: .3; }
.hm-key { display: inline-flex; align-items: center; gap: 3px; }
.hm-key i { display: inline-block; width: 11px; height: 11px; animation: none; }
.times-chart { display: grid; gap: 14px; margin-top: 6px; }
.tc-row { display: grid; grid-template-columns: 76px 1fr; gap: 4px 10px; align-items: center; }
.tc-bars { position: relative; height: 18px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.tc-bars i { position: absolute; top: 0; bottom: 0; left: 0; width: var(--w); border-radius: 999px; animation: bar-grow .9s cubic-bezier(.2, 1.2, .4, 1) backwards; }
.tc-avg, .key-avg { background: color-mix(in srgb, var(--accent-2) 55%, transparent); }
.tc-best, .key-best { background: var(--accent); }
.key-best, .key-avg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
@keyframes bar-grow { from { width: 0; } }
.tc-val { grid-column: 2; color: var(--muted); font-size: .8rem; font-weight: 700; }
.diff-tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 900; text-transform: capitalize; background: var(--surface-2); }
.diff-tag.easy { background: color-mix(in srgb, var(--good) 22%, var(--surface-2)); }
.diff-tag.medium { background: color-mix(in srgb, var(--accent-2) 22%, var(--surface-2)); }
.diff-tag.hard { background: color-mix(in srgb, var(--accent) 25%, var(--surface-2)); }
.diff-tag.challenge { background: linear-gradient(135deg, #f6c445, #f08a24); color: #3a2200; }
/* the Challenge button and home card: gold, with a star */
.difficulty .challenge-btn { margin-left: 6px; background: linear-gradient(135deg, color-mix(in srgb, #f6c445 35%, transparent), color-mix(in srgb, #f08a24 30%, transparent)); }
.difficulty .challenge-btn.active { background: linear-gradient(135deg, #f6c445, #f08a24); border-color: transparent; color: #3a2200; box-shadow: 0 0 16px rgba(246, 180, 60, .55); }
.difficulty .challenge-btn span { display: inline-block; animation: spin 6s linear infinite; }
.daily-chip.challenge { grid-column: 1 / -1; border-color: #e9a93a; background: linear-gradient(120deg, color-mix(in srgb, #f6c445 22%, var(--surface-2)), color-mix(in srgb, #f08a24 14%, var(--surface-2))); }
.daily-chip.challenge .pips.star { color: #e99a1c; font-size: 1.2rem; line-height: 1; }
.chip-sub { display: block; color: var(--muted); font-size: .78rem; font-weight: 700; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.ach-tile { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; align-items: center; padding: 10px 12px; border: 1.5px dashed var(--line); border-radius: var(--radius-sm); opacity: .55; }
.ach-tile.got { border-style: solid; border-color: var(--accent); background: var(--surface-2); opacity: 1; }
.ach-icon { grid-row: span 2; font-size: 1.8rem; }
.ach-tile b { font-size: .92rem; }
.ach-tile small { color: var(--muted); font-size: .76rem; font-weight: 600; }
.history { width: 100%; border-collapse: collapse; }
.history th, .history td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.history th { color: var(--muted); font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; }
.history .num { text-align: right; font-variant-numeric: tabular-nums; }
.empty-note { color: var(--muted); font-weight: 700; text-align: center; }

/* ---------------------------------------------------------------------------------------------
   Settings
   --------------------------------------------------------------------------------------------- */
.settings { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.settings fieldset { margin: 0; min-width: 0; }
.settings fieldset.wide { grid-column: 1 / -1; }
.settings legend { float: left; width: 100%; margin-bottom: 6px; padding: 0; font: 700 calc(1.6rem * var(--head-scale)) var(--font-head); }
.settings .hint { clear: both; margin: 8px 0 0; color: var(--muted); font-size: .85rem; font-weight: 600; }
.options { clear: both; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.options.col { flex-direction: column; gap: 10px; margin-top: 12px; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt span { display: inline-block; padding: 8px 16px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface-2); font-weight: 800; cursor: pointer; transition: background .2s, color .2s, transform .2s; }
.opt span:hover { transform: translateY(-1px); }
.opt input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.opt input:focus-visible + span { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.mode-locked .opt input[name="theme"] + span { opacity: .55; cursor: not-allowed; transform: none; }
#mode-note { color: var(--accent-2); font-weight: 800; }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { position: relative; flex-shrink: 0; width: 46px; height: 26px; border-radius: 999px; background: var(--surface-2); border: 1.5px solid var(--line); transition: background .2s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%; background: var(--muted); transition: transform .25s cubic-bezier(.2, 1.5, .4, 1), background .2s; }
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(20px); background: var(--accent-ink); }
.switch input:focus-visible + .track { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.range { display: flex; align-items: center; gap: 12px; font-weight: 700; }
.range input { flex: 1; accent-color: var(--accent); }
.range output { min-width: 3em; text-align: right; font-variant-numeric: tabular-nums; }
#replay-intro { margin-top: 12px; }

/* ---------------------------------------------------------------------------------------------
   Touch screens: on-screen keyboard and clue arrows
   --------------------------------------------------------------------------------------------- */
.keyboard, .clue-step { display: none; }
@media (pointer: coarse) {
    .clue-step { display: block; width: 38px; padding: 0; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-size: 1.5rem; line-height: 1; }
    .puzzle { flex-wrap: wrap; }
    .keyboard {
        position: sticky;
        bottom: 0;
        z-index: 20;
        display: grid;
        flex-basis: 100%;
        align-self: stretch;
        gap: 6px;
        width: 100%;
        padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
        background: var(--surface-solid);
        border-top: 1.5px solid var(--line);
    }
    .key-row { display: flex; justify-content: center; gap: 5px; }
    .key {
        flex: 1 1 0;
        max-width: 44px;
        height: 48px;
        padding: 0;
        border: 0;
        border-radius: 8px;
        background: var(--surface-2);
        color: var(--ink);
        box-shadow: 0 2px 0 var(--line);
        font: 900 1.15rem var(--font-body);
        touch-action: manipulation;
        user-select: none;
    }
    .key:active { background: var(--sel); transform: translateY(2px); box-shadow: none; }
    .key.wide { flex-grow: 1.5; max-width: 66px; background: var(--hover); }
    .board .cell, .clues li, .difficulty button, .helper-row button { touch-action: manipulation; }
}

/* ---------------------------------------------------------------------------------------------
   Smaller screens
   --------------------------------------------------------------------------------------------- */
/* between a laptop and a tablet, the logo is just "Schmoll" so the bar still fits in one row */
@media (max-width: 1100px) { .logo-text span { display: none; } }
@media (max-width: 980px) {
    .bar-group { display: contents; }
    .bar-group .modes { order: 3; width: 100%; justify-content: space-between; margin-left: 0; padding: 5px; background: var(--surface); border: 1.5px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(10px); }
    .bar-group .tools { margin-left: auto; padding-left: 0; border-left: 0; gap: 6px; }
    .bar-group .tool { border: 1.5px solid var(--line); background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(10px); }
    .world-pop, .sound-pop { top: 116px; }
    .home-grid { grid-template-columns: 1fr; }
    .world-strip { grid-template-columns: repeat(2, 1fr); }
    .stats-grid, .settings { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
    .puzzle { flex-direction: column; align-items: center; gap: 22px; }
    .clues { width: min(440px, 92vw); max-width: none; margin-top: 0; flex-direction: column; gap: 14px; }
    .top-bar { padding: 10px 12px 6px; }
    .logo-text span { display: none; }
    .modes a { padding: 6px 10px; font-size: .9rem; }
    .tool, .bar-group .tool { width: 36px; height: 36px; font-size: 16px; }
    .hero { gap: 16px; margin: 8px 0 16px; }
    .hero-logo { grid-template-columns: repeat(2, 34px); grid-template-rows: repeat(3, 34px); }
    .hero-logo i { font-size: 21px; }
    .game-head { margin: 4px 0 12px; }
    .world-pop, .sound-pop { top: 104px; }
    .world-pop-cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
    main { padding: 4px 12px 40px; }
    .modes, .bar-group .modes { gap: 0; padding: 3px; max-width: 100%; }
    .modes a { padding: 6px 7px; font-size: .8rem; letter-spacing: -.01em; }   /* all six fit on a phone */
    .daily-chips { grid-template-columns: 1fr; }
    .difficulty button { padding: 6px 11px; }
    .m-face, .m-face canvas { width: 84px !important; height: 84px !important; }
    .m-bubble { max-width: 220px; margin-bottom: 50px; font-size: .86rem; }
    .history th, .history td { padding: 8px 5px; }
    .stat-tiles { grid-template-columns: 1fr 1fr; }
    .stat-tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* People whose device asks for less motion get no animations */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    .board.solved::after, .toast.in::after { display: none; }     /* (the sweeps of light would stand still) */
}

/* Text written straight on a world's scene: a soft halo in the page colour keeps it readable on any background */
.hero-title, .greeting, #game-title, .game-titles .subtitle, .page-head h1, .page-head .subtitle, .hero .subtitle {
    text-shadow: 0 0 2px var(--bg), 0 0 6px var(--bg), 0 0 12px var(--bg), 0 0 20px var(--bg);
}
/* Daily Boss / Unlimited Boss: a boss race from the Daily and Unlimited pages */
.difficulty .boss-mode-btn { margin-left: 6px; color: #fff; border-color: transparent; background: linear-gradient(135deg, #e2483c, #8a2bbf); box-shadow: 0 3px 0 rgba(43, 34, 51, .35), 0 0 14px rgba(226, 72, 60, .35); font-weight: 900; }
.difficulty .boss-mode-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.difficulty .boss-mode-btn[hidden] { display: none; }

/* Home: today's boss, under the Challenge in the Daily card */
.boss-chip { grid-column: 1 / -1; position: relative; display: flex; align-items: center; gap: 14px; padding: 10px 14px; text-align: left; cursor: pointer; overflow: hidden;
    border: 2px solid color-mix(in srgb, var(--boss, #e2483c) 70%, transparent); border-radius: var(--radius-sm); color: var(--ink); font: inherit;
    background: linear-gradient(120deg, color-mix(in srgb, var(--boss, #e2483c) 20%, var(--surface-2)), color-mix(in srgb, #8a2bbf 12%, var(--surface-2)));
    animation: card-in .5s cubic-bezier(.2, 1.3, .4, 1) .55s backwards; transition: transform .22s cubic-bezier(.2, 1.6, .4, 1), border-color .2s; }
.boss-chip:hover { transform: translateY(-4px) rotate(-1deg); border-color: var(--boss, #e2483c); }
.boss-chip[hidden] { display: none; }
.boss-chip .bchip-art { width: 64px; height: 64px; flex: 0 0 auto; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .25)); animation: hb-bob 2.4s ease-in-out infinite alternate; }
.boss-chip .bchip-art svg { width: 100%; height: 100%; display: block; }
.boss-chip .bchip-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.boss-chip .chip-sub { font-size: .75rem; color: var(--muted); }
.boss-chip.done { border-color: var(--good); }
.boss-chip.done .chip-state { color: var(--good); }
@keyframes hb-bob { to { transform: translateY(-4px) rotate(-2deg); } }
.unlimited-card .hb-btns { display: flex; gap: 10px; flex-wrap: wrap; }
@media (prefers-reduced-motion: reduce) { .boss-chip .bchip-art { animation: none; } }
.daily-chips .boss-chip, .daily-chips .boss-chip .bchip-text, .daily-chips .boss-chip .chip-name { color: var(--ink); }
.daily-chips .boss-chip .chip-sub, .daily-chips .boss-chip .chip-state { color: var(--muted); }
.daily-chips .boss-chip.done .chip-state { color: var(--good); }

/* ---------------------------------------------------------------------------------------------
   Polish pass:
   quiet Title Case labels instead of spaced-out capitals, lighter
   body text, and calm motion (a small lift on hover, a gentle press) instead of springy bounces and tilts.
   Every world keeps its own fonts, colours and corners.
   --------------------------------------------------------------------------------------------- */
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
.kicker { font-size: .8rem; font-weight: 700; letter-spacing: 0; text-transform: none; }
.card-blurb { font-weight: 500; line-height: 1.5; }
.chip-sub { font-weight: 600; }
.btn { font-weight: 700; letter-spacing: -.005em; transition: transform .2s cubic-bezier(.25, .1, .25, 1), box-shadow .2s, background .2s, filter .2s; }
.btn:hover { transform: translateY(-1px); filter: brightness(1.03); }
.btn:active { transform: scale(.98); }
.difficulty button { font-weight: 700; }
.difficulty button:hover { transform: none; background: var(--hover); }
.difficulty button.active:hover { background: var(--accent); }
.daily-chip, .boss-chip { transition: transform .25s cubic-bezier(.25, .1, .25, 1), border-color .2s, background .2s, box-shadow .25s; }
.daily-chip:hover, .boss-chip:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0, 0, 0, .1); }
.daily-chip:active, .boss-chip:active { transform: scale(.99); }   /* the Boss chip moves like the others */
.subtitle { font-weight: 600; }

/* the start screen: the 15 bosses parade along the bottom, above the ticker, and drop away when you press start */
.intro-bosses { position: absolute; left: 0; right: 0; bottom: 46px; display: flex; justify-content: center; gap: clamp(2px, 1vw, 12px); padding: 0 12px; pointer-events: none; }
.intro-bosses .ib { width: clamp(40px, 5.4vw, 74px); aspect-ratio: 1; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .25));
    animation: ib-in .6s cubic-bezier(.2, 1.4, .4, 1) calc(var(--i) * 60ms) backwards, ib-bob 2.2s ease-in-out calc(var(--i) * -.37s) infinite; }
.intro-bosses .ib svg { width: 100%; height: 100%; display: block; }
.intro-bosses .ib svg * { animation: none !important; }       /* the parade moves; their parts stay still (cheaper) */
.intro-bosses.leave .ib { animation: ib-out .45s ease-in calc(var(--i) * 25ms) forwards; }
@keyframes ib-in { from { transform: translateY(80px) scale(.6); opacity: 0; } }
@keyframes ib-bob { 50% { transform: translateY(-7px); } }
@keyframes ib-out { to { transform: translateY(120px) scale(.7); opacity: 0; } }
@media (max-width: 700px) { .intro-bosses .ib:nth-child(n + 9) { display: none; } }
@media (prefers-reduced-motion: reduce) { .intro-bosses .ib { animation: none; } }
.subtitle:empty, .card-status:empty, .chip-sub:empty { display: none; }
.settings legend + * { clear: both; }        /* the legend floats; what follows starts below it (the hint used to do that) */
.diff-tag.boss { background: linear-gradient(135deg, #8a6bff, #c06bff); color: #fff; }

/* ---- the World Leaderboard ---- */
.leaderboard-card { margin-bottom: 18px; }
.lb-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; counter-reset: none; }
.lb-row { display: grid; grid-template-columns: 2.4em 1fr auto auto; align-items: center; gap: 10px; padding: 7px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-weight: 700; }
.lb-row:nth-child(1) .lb-rank { color: #d4a017; } .lb-row:nth-child(2) .lb-rank { color: #9aa3ad; } .lb-row:nth-child(3) .lb-rank { color: #b8733a; }
.lb-row.me { background: color-mix(in srgb, var(--accent) 16%, var(--surface-2)); box-shadow: inset 0 0 0 2px var(--accent); }
.lb-row.far { margin-top: 6px; }
.lb-rank { font-weight: 900; font-variant-numeric: tabular-nums; text-align: right; color: var(--muted); }
.lb-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-dailies { color: var(--muted); font-size: .8rem; letter-spacing: .08em; }
.lb-points { font-variant-numeric: tabular-nums; }
.lb-empty, .lb-hint, .lb-count { color: var(--muted); font-weight: 600; margin: 6px 0 0; }
.lb-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.lb-form input { padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface-solid); color: var(--ink); font: 700 .95rem var(--font-body); }
.lb-form .lb-first { width: 11em; } .lb-form .lb-init { width: 3em; text-align: center; text-transform: uppercase; }
.lb-note, .lb-err { flex-basis: 100%; color: var(--muted); font-weight: 600; } .lb-err { color: var(--wrong); }
.lb-me { margin-top: 14px; padding-top: 12px; border-top: 1.5px solid var(--line); font-weight: 700; }
.res-leader { margin: 14px 0 4px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); text-align: left; }
.lb-kicker { display: block; font-weight: 800; font-size: .72rem; letter-spacing: .1em; color: var(--muted); }
.lb-line { margin: 4px 0; font-weight: 700; }
.lb-link { color: var(--accent); font-weight: 800; text-decoration: none; }
@media (max-width: 370px) { .modes a { padding: 5px 5px; font-size: .74rem; } }

/* Unlimited: the picker it opens on (game.js showPicker). While playing, the difficulty buttons are replaced by
   New Puzzle, which brings the picker back, so no puzzle is ever loaded by a stray click */
#game-view.unlimited .difficulty button[data-difficulty], #game-view.unlimited #boss-mode { display: none; }
#game-view.picking #new-puzzle { display: none; }
.un-picker { margin: 8px 0 0; }
.un-title { margin: 0 0 14px; font-size: 1.15rem; }
.un-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.un-card { display: grid; gap: 4px; justify-items: start; padding: 18px 18px 16px; border: 1px solid var(--line); border-radius: 16px;
    background: var(--surface); color: inherit; font: inherit; text-align: left; cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s; }
.un-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 6px 18px rgba(0, 0, 0, .08); }
.un-card:active { transform: translateY(0) scale(.99); }
.un-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.un-card b { font-size: 1.1rem; font-weight: 900; }
.un-card small { color: var(--muted); font-weight: 700; }
.un-card::before { content: ""; width: 28px; height: 6px; border-radius: 999px; background: var(--surface-2); margin-bottom: 6px; }
.un-card.easy::before { background: var(--good); }
.un-card.medium::before { background: #f2c230; }
.un-card.hard::before { background: #e5484d; }
.un-card.challenge::before { background: linear-gradient(135deg, #f6c445, #f08a24); }
.un-card.boss::before { background: linear-gradient(135deg, #8a6bff, #c06bff); }
.un-card.continue { grid-column: 1 / -1; border-color: var(--accent); }
.un-card.continue::before { background: var(--accent); }
