/* Math With Mr DJ · Daily Puzzles
   Brand colors match the Mr DJ Command page and YouTube thumbnails. */

/* Fonts are served from this site (not Google) so visitors aren't tracked.
   All are open-license (SIL OFL); Latin characters only. */
@font-face { font-family: Anton; font-weight: 400; font-display: swap; src: url(../fonts/anton.woff2) format("woff2"); }
@font-face { font-family: Fredoka; font-weight: 300 700; font-display: swap; src: url(../fonts/fredoka.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url(../fonts/plex-mono-500.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 600 700; font-display: swap; src: url(../fonts/plex-mono-600.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 100 700; font-display: swap; src: url(../fonts/plex-sans.woff2) format("woff2"); }

:root {
  --violet: #7E03F2;
  --blue: #0049D2;
  --navy: #001282;
  --gold: #FCD604;
  --ground: #F7F5FC;
  --surface: #FFFFFF;
  --surface-2: #F0EDF8;
  --surface-3: #E7E2F4;
  --ink: #17121F;
  --ink-2: #463C5C;
  --ink-3: #6F6589;
  --line: #E2DCF0;
  --line-2: #CFC7E4;
  --good: #0F7F62;
  --good-bg: #E3F5EF;
  --bad: #BE2F2F;
  --bad-bg: #FBE8E8;

  --mild: #0F7F62;    --mild-bg: #E0F4EC;
  --medium: #B35400;  --medium-bg: #FDEBD6;
  --spicy: #C81E2E;   --spicy-bg: #FBE2E4;

  --hit: #12A57A;     /* Equation Guess: right spot */
  --near: #F4C300;    /* in the equation, wrong spot */
  --miss: #8A82A0;    /* not in the equation */
  --cage-line: #17121F;

  --hero: linear-gradient(115deg, #7E03F2, #001282 55%, #0049D2);
  --shadow: 0 1px 2px rgba(23, 18, 31, .06), 0 10px 26px -14px rgba(46, 18, 96, .32);
  --radius: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --violet: #A369FF; --blue: #5B9DFF; --gold: #FFD814;
    --ground: #100D18; --surface: #1A1626; --surface-2: #241E33; --surface-3: #2E2740;
    --ink: #EDE9F6; --ink-2: #C0B8D6; --ink-3: #8F86A8;
    --line: #2B2439; --line-2: #3C3352;
    --good: #3ED2B4; --good-bg: #10332C; --bad: #FF7B6B; --bad-bg: #3A1B18;
    --mild: #3ED2B4; --mild-bg: #10332C;
    --medium: #F5A04A; --medium-bg: #3A2510;
    --spicy: #FF6B7A; --spicy-bg: #3A1519;
    --hit: #1DB386; --near: #E5B800; --miss: #4A4360;
    --cage-line: #EDE9F6;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px -16px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --violet: #A369FF; --blue: #5B9DFF; --gold: #FFD814;
  --ground: #100D18; --surface: #1A1626; --surface-2: #241E33; --surface-3: #2E2740;
  --ink: #EDE9F6; --ink-2: #C0B8D6; --ink-3: #8F86A8;
  --line: #2B2439; --line-2: #3C3352;
  --good: #3ED2B4; --good-bg: #10332C; --bad: #FF7B6B; --bad-bg: #3A1B18;
  --mild: #3ED2B4; --mild-bg: #10332C;
  --medium: #F5A04A; --medium-bg: #3A2510;
  --spicy: #FF6B7A; --spicy-bg: #3A1519;
  --hit: #1DB386; --near: #E5B800; --miss: #4A4360;
  --cage-line: #EDE9F6;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px -16px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

/* ---- base ---------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 16px/1.5 "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
a { color: var(--violet); }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; border-radius: 6px; }
main:focus { outline: none; }
img { max-width: 100%; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 1000px; margin: 0 auto; padding: 0 16px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; }
.center { text-align: center; }
.eyebrow {
  display: block;
  font: 600 11px/1 "IBM Plex Mono", monospace;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.fine { font-size: 13px; color: var(--ink-3); margin-top: 22px; }
.pose { display: block; user-select: none; pointer-events: none; }

main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); min-height: 70vh; }
body.playing main { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }

/* ---- masthead ------------------------------------------------------------ */

.masthead {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--ground) 86%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.top { display: flex; align-items: center; gap: 12px; height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; margin-right: auto; text-decoration: none; color: inherit; }
.brand-face {
  flex: none; width: 42px; height: 42px; border-radius: 50%; overflow: hidden;
  background: var(--hero); border: 2px solid var(--gold);
}
.brand-face img { width: 200%; max-width: none; margin: -2px 0 0 -50%; }
.brand-words { min-width: 0; }
.brand-words b {
  display: block; white-space: nowrap;
  font: 400 21px/1 Anton, Impact, sans-serif; letter-spacing: .015em; text-transform: uppercase;
  background: linear-gradient(96deg, var(--violet), var(--blue));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-words small {
  display: block; margin-top: 4px;
  font: 600 10.5px/1 "IBM Plex Mono", monospace; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-3);
}

.me-chip {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  height: 38px; padding: 0 12px 0 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14px;
}
.me-chip .flame { font-variant-numeric: tabular-nums; }
.me-chip .flame.cold { filter: grayscale(1); opacity: .6; }
.chip-player { max-width: 132px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }

.nav-top { display: none; }
.nav-top a, .nav-bottom a { color: var(--ink-3); text-decoration: none; font-weight: 600; }
.nav-top a.on, .nav-bottom a.on { color: var(--violet); }

.nav-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-bottom a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 8px; font-size: 11.5px; }
body.playing .nav-bottom { display: none; }

@media (max-width: 420px) {
  .chip-player { display: none; }
  .brand-words b { font-size: 19px; }
}

@media (min-width: 860px) {
  .nav-bottom { display: none; }
  .nav-top { display: flex; gap: 2px; }
  .nav-top a { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 10px; font-size: 14.5px; }
  .nav-top a svg { width: 20px; height: 20px; }
  .nav-top a:hover { background: var(--surface-2); }
  .nav-top a.on { background: color-mix(in srgb, var(--violet) 12%, transparent); }
  main { padding-bottom: 56px; }
}

/* ---- shared bits ------------------------------------------------------- */

.level {
  --lvl: var(--ink-3); --lvl-bg: var(--surface-2);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px 5px 8px; border-radius: 999px;
  background: var(--lvl-bg); color: var(--lvl);
  font: 700 12px/1 "IBM Plex Mono", monospace; letter-spacing: .1em; text-transform: uppercase;
  white-space: nowrap;
}
.level .peppers { font-size: 13px; letter-spacing: -2px; }
.level.small { padding: 3px 9px 3px 6px; font-size: 11px; }
.level.small .peppers { font-size: 11px; }
.level-mild { --lvl: var(--mild); --lvl-bg: var(--mild-bg); }
.level-medium { --lvl: var(--medium); --lvl-bg: var(--medium-bg); }
.level-spicy { --lvl: var(--spicy); --lvl-bg: var(--spicy-bg); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: 14px; border: 0;
  font-weight: 700; font-size: 16px; text-decoration: none; text-align: center; white-space: nowrap;
  transition: transform .1s, filter .15s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary { background: var(--violet); color: #fff; }
.btn.secondary { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-2); }
.btn.gold { background: var(--gold); color: #17121F; }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.btn.block { width: 100%; }
.btn:hover { filter: brightness(1.06); }
.btn-stack { display: grid; gap: 10px; margin-top: 18px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.btn-row .btn { flex: 1 1 140px; }
.center-btn { display: flex; margin: 12px auto 0; }

.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; flex: none;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
}
.linkish { background: none; border: 0; padding: 8px 0; color: var(--ink-3); text-decoration: underline; font-size: 13px; }

.tool {
  flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 46px; padding: 0 10px; border-radius: 12px; white-space: nowrap;
  border: 1px solid var(--line-2); background: var(--surface-2); font-weight: 600; font-size: 15px;
}
.tool[aria-pressed="true"] { background: var(--violet); border-color: var(--violet); color: #fff; }
.tool.subtle { flex: 0 0 auto; background: transparent; border-color: transparent; color: var(--ink-3); }

/* ---- home ---------------------------------------------------------------- */

.hero {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; align-items: center; min-height: 200px;
  margin: 16px 0 12px; padding: 22px 20px; border-radius: 24px;
  background: var(--hero); color: #fff;
}
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: .13;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cg fill='none' stroke='white' stroke-width='5' stroke-linecap='round'%3E%3Cpath d='M18 10v20M8 20h20M78 22h22M50 70l14 14M64 70L50 84M98 66v0M90 92h16M98 100v0'/%3E%3C/g%3E%3Cg fill='white'%3E%3Ccircle cx='98' cy='86' r='3'/%3E%3Ccircle cx='98' cy='98' r='3'/%3E%3C/g%3E%3C/svg%3E");
}
.hero-text { position: relative; z-index: 1; max-width: 64%; }
.hero-eyebrow {
  font: 600 11.5px/1 "IBM Plex Mono", monospace; letter-spacing: .16em; text-transform: uppercase;
  color: rgba(255, 255, 255, .85); margin-bottom: 10px;
}
.hero-date {
  font: 400 clamp(36px, 10vw, 60px)/.95 Anton, Impact, sans-serif;
  text-transform: uppercase; letter-spacing: .01em;
  -webkit-text-stroke: 2px #000; paint-order: stroke fill;
}
.hero-date span { display: block; color: var(--gold); font-size: .62em; margin-top: 4px; }
.hero-line {
  margin-top: 10px;
  font: 700 15px/1.2 Fredoka, sans-serif; letter-spacing: .02em; color: #fff;
}
.hero-count { margin-top: 12px; font-size: 13px; color: rgba(255, 255, 255, .85); }
.hero-count b {
  display: inline-block; margin-left: 4px; padding: 3px 8px; border-radius: 8px;
  background: rgba(0, 0, 0, .28); color: #fff; font: 600 14px/1.2 "IBM Plex Mono", monospace;
}
.hero-pose {
  position: absolute; right: -44px; bottom: -8px; z-index: 0;
  height: 104%; max-height: 270px; width: auto;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, .35));
}
@media (min-width: 440px) { .hero-pose { right: -14px; height: 112%; } }
@media (min-width: 720px) {
  .hero { min-height: 230px; padding: 30px 34px; }
  .hero-pose { right: 24px; }
}

.today-strip {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 0 0 14px; font-size: 14px; color: var(--ink-2);
}
.today-strip .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--line-2); }

.cards { display: grid; gap: 12px; }
.pcard {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 58px 1fr; column-gap: 14px; row-gap: 4px; align-items: start;
  padding: 18px 16px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  color: inherit; text-decoration: none;
  transition: transform .15s, box-shadow .15s;
}
.pcard::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: var(--lvl); }
.pcard:hover { transform: translateY(-2px); }
.pcard-art { grid-row: 1 / span 3; width: 58px; height: 58px; display: block; }
.pcard-art svg { width: 100%; height: 100%; display: block; }
.pcard .level { justify-self: start; }
.pcard h2 { font: 400 25px/1.05 Anton, Impact, sans-serif; text-transform: uppercase; letter-spacing: .015em; margin-top: 4px; }
.pcard p { color: var(--ink-2); font-size: 14.5px; line-height: 1.4; }
.pcard-cta {
  grid-column: 1 / -1; margin-top: 12px;
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; border-radius: 12px;
  background: var(--violet); color: #fff; font-weight: 700;
}
.pcard.started .pcard-cta { background: var(--gold); color: #17121F; }
.pcard.done .pcard-cta { background: var(--good-bg); color: var(--good); }
.pcard.revealed .pcard-cta { background: var(--surface-2); color: var(--ink-3); }

@media (min-width: 720px) {
  .cards { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .pcard { grid-template-columns: 1fr; padding: 22px 18px 18px; }
  .pcard-art { grid-row: auto; width: 64px; height: 64px; margin-bottom: 8px; }
  .pcard-cta { margin-top: auto; }
  .pcard p { margin-bottom: 14px; }
}

.home-links { display: grid; gap: 12px; margin-top: 14px; }
@media (min-width: 560px) { .home-links { grid-template-columns: 1fr 1fr; } }
.link-card {
  display: flex; align-items: center; gap: 14px; padding: 16px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  color: var(--ink); text-decoration: none;
}
.link-card svg { flex: none; width: 44px; height: 44px; padding: 10px; border-radius: 12px; background: var(--surface-2); color: var(--violet); }
.link-card b { display: block; font-size: 16px; }
.link-card small { display: block; color: var(--ink-3); font-size: 13.5px; }

/* ---- pages (past, leaderboard, me) ------------------------------------ */

.page { max-width: 640px; margin: 0 auto; padding-top: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1, .empty-page h1 { font: 400 36px/1 Anton, Impact, sans-serif; text-transform: uppercase; letter-spacing: .015em; }
.page-sub { margin-top: 6px; color: var(--ink-2); font-size: 14.5px; }
.pose-head { width: 96px; height: auto; flex: none; margin-bottom: -6px; }
.empty-page { text-align: center; padding-top: 40px; }
.empty-page .pose-head { margin: 0 auto 8px; width: 150px; }
.empty-page p { margin: 10px 0 20px; color: var(--ink-2); }

.past-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.past-row {
  display: grid; grid-template-columns: 1fr; gap: 8px; padding: 12px;
  border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
}
.past-date b { font-size: 15px; }
.past-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 560px) {
  .past-row { grid-template-columns: 150px 1fr; align-items: center; }
}
.chip {
  position: relative; display: flex; flex-direction: column; gap: 2px;
  padding: 9px 10px; border-radius: 11px; min-height: 56px;
  background: var(--surface-2); border: 1.5px solid transparent;
  color: var(--ink); text-decoration: none;
}
.chip-name { font-weight: 700; font-size: 14px; }
.chip-lvl { font-size: 11px; letter-spacing: -1px; }
.chip-mark {
  position: absolute; bottom: 7px; right: 7px; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 800;
}
.chip.solved { background: var(--good-bg); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.chip.solved .chip-mark { background: var(--good); color: var(--surface); }
.chip.started { border-color: var(--gold); }
.chip.started .chip-mark { background: var(--gold); color: #17121F; }
.chip.revealed .chip-mark { background: var(--line-2); color: var(--ink-2); }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); margin-bottom: 14px; }
.seg a { display: grid; place-items: center; min-height: 42px; border-radius: 11px; color: var(--ink-2); font-weight: 700; text-decoration: none; font-size: 15px; }
.seg a.on { background: var(--surface); color: var(--violet); box-shadow: var(--shadow); }

.picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pick {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 4px;
  border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface);
}
.pick b { font-size: 14.5px; }
.pick span { font-size: 11px; letter-spacing: -1px; }
.pick.on { border-color: var(--violet); background: color-mix(in srgb, var(--violet) 9%, var(--surface)); }
.lb-rule { margin: 12px 2px 8px; font-size: 13.5px; color: var(--ink-3); }
.lb { list-style: none; margin: 0; padding: 0; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.lb-row { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 8px; min-height: 52px; padding: 0 14px 0 8px; border-top: 1px solid var(--line); }
.lb-row:first-child { border-top: 0; }
.lb-rank { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; font-weight: 700; color: var(--ink-3); }
.lb-row.top1 .lb-rank { background: #FCD604; color: #17121F; }
.lb-row.top2 .lb-rank { background: #D5D9E2; color: #17121F; }
.lb-row.top3 .lb-rank { background: #E9A66B; color: #17121F; }
.lb-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-name em { margin-left: 6px; padding: 2px 7px; border-radius: 6px; background: var(--violet); color: #fff; font: 700 11px/1 "IBM Plex Mono", monospace; font-style: normal; text-transform: uppercase; letter-spacing: .08em; vertical-align: 2px; }
.lb-score { font: 600 15px/1 "IBM Plex Mono", monospace; color: var(--ink-2); }
.lb-row.you { background: color-mix(in srgb, var(--violet) 10%, var(--surface)); }
.lb-gap { text-align: center; color: var(--ink-3); border-top: 1px solid var(--line); line-height: 28px; }
.lb-empty { display: grid; justify-items: center; gap: 6px; padding: 22px 16px; border-radius: 16px; border: 1px dashed var(--line-2); background: var(--surface); text-align: center; color: var(--ink-2); }
.pose-small { width: 110px; height: auto; }
.loading { padding: 40px 0; text-align: center; color: var(--ink-3); font-weight: 600; }
.form-note { min-height: 20px; color: var(--bad); font-size: 14px; font-weight: 600; text-align: center; margin-top: 8px; }
.lb-nudge {
  display: block; margin-top: 12px; padding: 14px 16px; border-radius: 14px;
  background: var(--gold); color: #17121F; font-weight: 700; text-decoration: none; text-align: center;
}

.prose h2 { font: 400 22px/1.15 Anton, Impact, sans-serif; text-transform: uppercase; letter-spacing: .015em; margin: 24px 0 8px; }
.prose p, .prose li { color: var(--ink-2); }
.prose ul { padding-left: 20px; display: grid; gap: 8px; margin: 0; }
.prose .btn { margin-top: 18px; }

.me-card { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.me-avatar {
  flex: none; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%;
  background: var(--hero); color: #fff; font: 400 32px/1 Anton, Impact, sans-serif;
  border: 3px solid var(--gold);
}
.me-name { font: 400 30px/1.05 Anton, Impact, sans-serif; letter-spacing: .015em; overflow-wrap: anywhere; }
.me-status { margin-top: 4px; color: var(--ink-3); font-size: 14px; display: flex; align-items: center; gap: 5px; }
.me-status svg { color: var(--good); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { padding: 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.stat b { display: block; font: 400 34px/1 Anton, Impact, sans-serif; }
.stat span { display: block; margin-top: 6px; color: var(--ink-2); font-size: 13.5px; }
.save-card {
  position: relative; overflow: hidden; margin-top: 14px; padding: 20px;
  border-radius: var(--radius); background: var(--surface); border: 2px solid var(--violet);
}
.save-card h2 { font: 400 23px/1.1 Anton, Impact, sans-serif; text-transform: uppercase; letter-spacing: .015em; max-width: 72%; }
.save-card p { margin-top: 6px; color: var(--ink-2); font-size: 14.5px; max-width: 72%; }
.save-pose { position: absolute; right: -16px; top: 6px; width: 120px; }
@media (min-width: 560px) { .save-card h2, .save-card p { max-width: 78%; } }

.code-box {
  display: flex; align-items: center; gap: 8px; margin-top: 14px; padding: 10px 10px 10px 14px;
  border-radius: 14px; background: var(--surface-2); border: 1px dashed var(--line-2);
}
.code-box .mono { flex: 1; font-size: 19px; font-weight: 600; letter-spacing: .06em; }
.warn { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--medium-bg); color: var(--medium); font-size: 14px; font-weight: 600; }

.name-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.name-option {
  min-height: 52px; padding: 6px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--surface); font-weight: 700; font-size: 15px; overflow-wrap: anywhere;
}
.name-option.on { border-color: var(--violet); background: color-mix(in srgb, var(--violet) 10%, var(--surface)); color: var(--violet); }

.code-form { display: grid; gap: 10px; margin-top: 14px; }
.code-form label { font-weight: 600; font-size: 14px; }
.code-form input {
  height: 52px; padding: 0 14px; border-radius: 12px; border: 2px solid var(--line-2);
  background: var(--surface); color: var(--ink); font-size: 19px; letter-spacing: .06em; text-transform: uppercase;
}

/* ---- play ---------------------------------------------------------------- */

.play { max-width: 560px; margin: 0 auto; }
.play-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 12px 0 10px; }
.back {
  display: inline-flex; align-items: center; gap: 2px; height: 42px; padding: 0 10px 0 4px;
  border-radius: 12px; color: var(--ink-2); text-decoration: none; font-weight: 600;
}
.back span { display: none; }
@media (min-width: 480px) { .back span { display: inline; } }
.play-title { min-width: 0; }
.play-title h1 { font: 400 24px/1 Anton, Impact, sans-serif; text-transform: uppercase; letter-spacing: .015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.play-sub { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; color: var(--ink-3); }
.play-tools { display: flex; align-items: center; gap: 8px; }
.timer {
  min-width: 62px; padding: 9px 10px; border-radius: 12px; text-align: center;
  background: var(--surface); border: 1px solid var(--line);
  font: 600 16px/1 "IBM Plex Mono", monospace;
}
.note { margin: 0 0 10px; padding: 9px 12px; border-radius: 12px; background: var(--surface-2); color: var(--ink-2); font-size: 13.5px; }
.finish-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 0 0 12px; padding: 8px 8px 8px 14px; border-radius: 14px; font-weight: 600;
}
.finish-bar > span { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.finish-bar.won { background: var(--good-bg); color: var(--good); }
.finish-bar.lost { background: var(--surface-2); color: var(--ink-2); }
.puzzle-host { position: relative; }

/* Cage Grid */
.cage-board {
  --cell: calc(min(100vw - 32px, 480px) / var(--n));
  display: grid; grid-template-columns: repeat(var(--n), 1fr);
  width: 100%; max-width: 480px; margin: 4px auto 0;
  border: 3px solid var(--cage-line); border-radius: 8px; overflow: hidden;
  background: var(--surface); user-select: none; -webkit-user-select: none;
}
.cell {
  position: relative; aspect-ratio: 1; min-width: 0; padding: 0; margin: 0;
  display: grid; place-items: center;
  border: 0; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2);
  background: transparent; border-radius: 0;
}
.cell.tR { border-right: 3px solid var(--cage-line); }
.cell.tB { border-bottom: 3px solid var(--cage-line); }
.cell.eR { border-right: 0; }
.cell.eB { border-bottom: 0; }
.cell.peer { background: color-mix(in srgb, var(--violet) 6%, transparent); }
.cell.mate { background: color-mix(in srgb, var(--violet) 12%, transparent); }
.cell.sel { background: color-mix(in srgb, var(--gold) 55%, transparent); }
.cell.clash .val { color: var(--bad); }
.cell.clash { background: var(--bad-bg); }
.cell.wrong .cage-label { color: var(--bad); }
.cell:focus-visible { outline-offset: -4px; }
.cage-label {
  position: absolute; top: 3px; left: 4px;
  font: 700 clamp(10px, calc(var(--cell) * .2), 15px)/1 "IBM Plex Sans", sans-serif;
  color: var(--ink); letter-spacing: -.01em;
}
.val { font: 600 calc(var(--cell) * .5)/1 Fredoka, sans-serif; color: var(--violet); margin-top: 10%; }
.cell.given .val { color: var(--ink); }
.notes {
  position: absolute; inset: 26% 8% 6%; display: grid; grid-template-columns: repeat(3, 1fr);
  font: 600 clamp(9px, calc(var(--cell) * .17), 14px)/1 Fredoka, sans-serif; color: var(--ink-3);
}
.notes i { font-style: normal; display: grid; place-items: center; }
.cage-board.solved .cell { animation: wave .5s ease both; animation-delay: var(--d); }
.cage-board.solved .val { color: var(--good); }

.pad { max-width: 480px; margin: 14px auto 0; }
.pad-nums { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 8px; }
.pad-key {
  height: 58px; border-radius: 14px; border: 1.5px solid var(--line-2); background: var(--surface);
  font: 600 27px/1 Fredoka, sans-serif; box-shadow: 0 3px 0 var(--line-2);
}
.pad-key:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line-2); }
.pad.notes-on .pad-key { font-size: 19px; color: var(--violet); border-style: dashed; }
.pad-tools { display: flex; gap: 8px; margin-top: 10px; }

/* Target */
.tg { text-align: center; }
.tg-target { margin: 2px 0 20px; }
.tg-target .eyebrow { margin-bottom: 8px; }
.tg-target b {
  display: inline-block; min-width: 150px; padding: 10px 26px 12px; border-radius: 20px;
  background: var(--hero); color: #fff;
  font: 400 64px/1 Anton, Impact, sans-serif; letter-spacing: .02em;
  -webkit-text-stroke: 2px #000; paint-order: stroke fill;
  box-shadow: 0 10px 24px -12px rgba(46, 18, 96, .6);
}
.tg-tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; max-width: 360px; margin: 0 auto; }
.tg-tiles[data-count="4"] { max-width: 240px; }
.tile {
  width: 94px; height: 94px; flex: none; border-radius: 50%; padding: 0;
  border: 3px solid var(--ink); background: var(--surface); color: var(--ink);
  box-shadow: 0 5px 0 var(--ink);
  font: 600 34px/1 Fredoka, sans-serif;
  transition: transform .12s, background .12s, box-shadow .12s;
}
.tile.long { font-size: 26px; }
.tile.made { background: color-mix(in srgb, var(--violet) 14%, var(--surface)); }
.tile.sel { background: var(--gold); color: #17121F; transform: translateY(-3px); box-shadow: 0 8px 0 var(--ink); }
.tile.hit { background: var(--good); border-color: var(--good); color: #fff; box-shadow: 0 5px 0 color-mix(in srgb, var(--good) 60%, #000); }
.tile.empty { border: 2px dashed var(--line-2); box-shadow: none; background: transparent; }
.tile.nope { animation: shake .38s; }
.tile:disabled { opacity: 1; }
.tg-ops { display: flex; justify-content: center; gap: 10px; margin: 24px 0 4px; }
.op {
  width: 66px; height: 58px; border-radius: 14px; border: 2px solid var(--line-2);
  background: var(--surface-2); font: 600 31px/1 Fredoka, sans-serif;
}
.op.on { background: var(--violet); border-color: var(--violet); color: #fff; }
.tg-msg { min-height: 24px; margin: 6px 0; color: var(--bad); font-weight: 600; font-size: 14.5px; }
.tg-steps { list-style: none; margin: 0 auto 12px; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.tg-steps li, .tg-answer li {
  padding: 6px 10px; border-radius: 9px; background: var(--surface-2);
  font: 600 14.5px/1 "IBM Plex Mono", monospace;
}
.tg-answer { margin: 4px auto 14px; padding: 14px; border-radius: 16px; border: 2px dashed var(--line-2); max-width: 360px; }
.tg-answer ol { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; justify-items: center; }
.tg-tools { display: flex; gap: 8px; max-width: 420px; margin: 0 auto; }

/* Equation Guess */
.eq { text-align: center; }
.eq-board { display: grid; gap: 6px; max-width: calc(var(--len) * 56px); margin: 4px auto 0; }
.eq-row { display: grid; grid-template-columns: repeat(var(--len), 1fr); gap: 6px; }
.eq-tile {
  aspect-ratio: 1; display: grid; place-items: center; min-width: 0;
  border: 2px solid var(--line-2); border-radius: 9px; background: var(--surface);
  font: 600 clamp(18px, 6vw, 28px)/1 Fredoka, sans-serif;
}
.eq-tile.filled { border-color: var(--ink-3); animation: pop .12s; }
.eq-tile.correct, .key.correct, .key-chip.correct { background: var(--hit); border-color: var(--hit); color: #fff; }
.eq-tile.present, .key.present, .key-chip.present { background: var(--near); border-color: var(--near); color: #17121F; }
.eq-tile.absent, .key.absent, .key-chip.absent { background: var(--miss); border-color: var(--miss); color: #fff; }
.eq-tile.flip { animation: flip .5s ease both; animation-delay: var(--d); }
.eq-row.shake { animation: shake .4s; }
.eq-msg { min-height: 24px; margin: 10px 0 6px; font-weight: 600; font-size: 14.5px; color: var(--ink-2); }
.eq-keys { display: grid; gap: 7px; max-width: 520px; margin: 0 auto; }
.krow { display: grid; gap: 5px; }
.krow.digits { grid-template-columns: repeat(10, 1fr); }
.krow.ops { grid-template-columns: 1.7fr repeat(5, 1fr) 1.3fr; }
.key {
  height: 56px; min-width: 0; padding: 0; border-radius: 9px; border: 0;
  background: var(--surface-3); color: var(--ink);
  font: 600 21px/1 Fredoka, sans-serif;
}
.key.sym { font-size: 26px; }
.key.wide { font: 700 14px/1 "IBM Plex Sans", sans-serif; }
.key.wide[data-key="Backspace"] { font-size: 22px; }
.key-chip { display: inline-block; padding: 1px 7px; border-radius: 6px; font-weight: 700; }

/* ---- modals and toasts --------------------------------------------------- */

#modal-root { position: relative; z-index: 60; }
.modal-backdrop {
  position: fixed; inset: 0; display: grid; place-items: end center; padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: rgba(16, 13, 24, .55); opacity: 0; transition: opacity .16s;
}
.modal-backdrop.open { opacity: 1; }
@media (min-width: 600px) { .modal-backdrop { place-items: center; } }
.modal {
  position: relative; width: 100%; max-width: 440px; max-height: calc(100dvh - 24px); overflow: auto;
  padding: 22px 20px 20px; border-radius: 24px; background: var(--surface);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .5);
  transform: translateY(18px); transition: transform .2s;
}
.modal:focus { outline: none; }
.modal-backdrop.open .modal { transform: none; }
.modal-x {
  position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: var(--surface-2); font-size: 24px; line-height: 1; color: var(--ink-2);
}
.modal h2 { font: 400 32px/1.05 Anton, Impact, sans-serif; text-transform: uppercase; letter-spacing: .015em; text-align: center; }
.pose-modal { width: auto; height: 150px; margin: -4px auto 6px; }
.modal-text { margin-top: 8px; color: var(--ink-2); text-align: center; }
.big-time { text-align: center; font: 400 54px/1 Anton, Impact, sans-serif; color: var(--violet); margin-top: 8px; }
.rank-line { margin-top: 10px; text-align: center; padding: 10px; border-radius: 12px; background: var(--surface-2); }
.share-grid { margin: 14px auto 0; text-align: center; font-size: 20px; line-height: 1.15; letter-spacing: 1px; font-family: inherit; }
.howto-sub { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 6px; color: var(--ink-3); font-weight: 600; }
.howto { margin: 16px 0 18px; padding-left: 22px; display: grid; gap: 10px; color: var(--ink-2); }
.howto li::marker { color: var(--violet); font-weight: 700; }

#toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 80;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 12px 18px; border-radius: 14px; background: var(--ink); color: var(--ground);
  font-weight: 600; font-size: 15px; box-shadow: var(--shadow); transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- motion ------------------------------------------------------------- */

@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes pop { 50% { transform: scale(1.08); } }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes wave { 40% { transform: scale(1.08); } }

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