/* Mirror Garden — one stylesheet.
   Concept: a calm garden at dawn (light) and under an indigo night sky (dark).
   Soft rounded cards, gentle shadows, the Sun's warm orange and the Moon's
   indigo as the two accents; each garden tints the page while you play in it.
   Type: the system's rounded face where there is one; tabular numbers. */

:root {
  color-scheme: light;
  --font: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Nunito", "Quicksand", "Varela Round", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #f6efe4;
  --bg-2: #ece7f6;
  --surface: #ffffff;
  --surface-2: #faf6ef;
  --surface-3: #f2ece2;
  --ink: #1f2140;
  --ink-2: #545a78;
  --ink-3: #6d7290;
  --line: rgba(31, 33, 64, 0.1);
  --line-2: rgba(31, 33, 64, 0.16);
  --sun: #f7941d;
  --sun-ink: #a24f00;
  --sun-soft: #fff0dc;
  --moon: #4b4fc4;
  --moon-ink: #3a3ea8;
  --moon-soft: #ebecff;
  --gold: #c98a00;
  --gold-ink: #8a5d00;
  --gold-soft: #fff4d2;
  --good: #23885a;
  --warn: #d9363e;
  --ca-accent: #4b4fc4;
  --primary: #4b4fc4;
  --primary-ink: #ffffff;
  --focus: #2f6fe0;
  --shadow-1: 0 1px 2px rgba(40, 30, 60, 0.06), 0 2px 8px rgba(40, 30, 60, 0.06);
  --shadow-2: 0 2px 6px rgba(40, 30, 60, 0.08), 0 12px 32px rgba(40, 30, 60, 0.12);
  --radius: 18px;
  --radius-s: 12px;
  --bar-h: 56px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --garden-bg: var(--bg);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141630;
  --bg-2: #1c1a3a;
  --surface: #1e2142;
  --surface-2: #232750;
  --surface-3: #2a2f5c;
  --ink: #eef0ff;
  --ink-2: #b8bce0;
  --ink-3: #9da2c8;
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);
  --sun: #ff9f2e;
  --sun-ink: #ffbf73;
  --sun-soft: rgba(255, 159, 46, 0.14);
  --moon: #8a8fff;
  --moon-ink: #aeb2ff;
  --moon-soft: rgba(106, 111, 240, 0.18);
  --gold: #f0b83a;
  --gold-ink: #f6cd6e;
  --gold-soft: rgba(240, 184, 58, 0.14);
  --good: #4cc78a;
  --warn: #ff6b70;
  --ca-accent: #5a5fe0;
  --primary: #5a5fe0;
  --focus: #8fb3ff;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.35), 0 16px 40px rgba(0, 0, 0, 0.4);
}

/* the garden you play in tints the page */
body[data-garden="rose"] { --garden-bg: #fbeef0; }
body[data-garden="zen"] { --garden-bg: #f3ecdd; }
body[data-garden="hedge"] { --garden-bg: #e5efdc; }
body[data-garden="ice"] { --garden-bg: #e8f3fb; }
body[data-garden="crystal"] { --garden-bg: #f0ebfa; }
body[data-garden="daily"] { --garden-bg: #fbf2dc; }
:root[data-theme="dark"] body[data-garden="rose"] { --garden-bg: #24161f; }
:root[data-theme="dark"] body[data-garden="zen"] { --garden-bg: #1f1c16; }
:root[data-theme="dark"] body[data-garden="hedge"] { --garden-bg: #111d15; }
:root[data-theme="dark"] body[data-garden="ice"] { --garden-bg: #0f1b29; }
:root[data-theme="dark"] body[data-garden="crystal"] { --garden-bg: #18142a; }
:root[data-theme="dark"] body[data-garden="daily"] { --garden-bg: #211a0e; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  background-image: radial-gradient(120% 70% at 15% -10%, rgba(255, 196, 120, 0.35), transparent 60%), radial-gradient(90% 60% at 100% 0%, rgba(150, 150, 255, 0.22), transparent 60%);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
:root[data-theme="dark"] body {
  background-image: radial-gradient(110% 60% at 10% -10%, rgba(120, 110, 255, 0.22), transparent 60%), radial-gradient(80% 50% at 100% 0%, rgba(255, 160, 80, 0.1), transparent 60%);
}
body[data-screen="play"] { background: var(--garden-bg); background-image: none; transition: background-color 0.3s var(--ease); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--moon-ink); }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 10px; }

/* ---- shell ------------------------------------------------------------------------------ */
.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding-left: var(--safe-l); padding-right: var(--safe-r); }
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  min-height: calc(var(--bar-h) + var(--safe-t));
  padding: var(--safe-t) 10px 0 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--line);
}
body[data-screen="play"] .bar { background: color-mix(in srgb, var(--garden-bg) 85%, transparent); }
body[data-screen="landing"] .bar, body[data-screen="boot"] .bar { display: none; }
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; text-decoration: none; color: inherit; border-radius: 12px; padding: 4px 4px 4px 2px; }
.brand-icon { width: 30px; height: 30px; border-radius: 9px; flex: none; box-shadow: var(--shadow-1); }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-weight: 800; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-tools { display: flex; align-items: center; gap: 2px; flex: none; }
.chip-slot { min-width: 44px; display: flex; justify-content: center; margin-left: 2px; }
.icon-btn {
  width: 44px; height: 44px; flex: none;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 14px; background: transparent; color: var(--ink);
  transition: background-color 0.15s, transform 0.12s var(--ease);
}
.icon-btn:hover { background: var(--line); }
.icon-btn:active { transform: scale(0.94); }
@media (max-width: 380px) { .brand-sub { display: none; } .brand-title { font-size: 16px; } }

.main { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.screen {
  flex: 1; display: flex; flex-direction: column;
  width: 100%; max-width: 980px; margin: 0 auto;
  padding: 16px 16px calc(24px + var(--safe-b));
  animation: screen-in 0.2s var(--ease) both;
}
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.screen-title { font-size: 26px; font-weight: 800; margin: 4px 2px 14px; }
.screen-lead { color: var(--ink-2); margin: -6px 2px 16px; }
.boot { flex: 1; display: grid; place-items: center; min-height: 60vh; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--sun); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- buttons ------------------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px;
  border-radius: 14px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); font-weight: 700; text-align: center;
  box-shadow: var(--shadow-1);
  transition: transform 0.12s var(--ease), background-color 0.15s, box-shadow 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.primary:hover { background: color-mix(in srgb, var(--primary) 88%, #000); }
.btn.sun { background: linear-gradient(180deg, #ffb340, #f08a10); color: #2b1600; border-color: transparent; }
.btn.gold { background: linear-gradient(180deg, #ffd56a, #e8a92a); color: #2e1f00; border-color: transparent; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.big { min-height: 56px; font-size: 18px; padding: 12px 26px; border-radius: 16px; }
.btn.wide { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
.link-btn { background: none; border: 0; padding: 10px 6px; min-height: 44px; color: var(--moon-ink); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* ---- cards --------------------------------------------------------------------------------- */
.card {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line);
  box-shadow: var(--shadow-1); padding: 16px;
}
button.card { width: 100%; text-align: left; display: block; transition: transform 0.15s var(--ease), box-shadow 0.15s; }
button.card:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }
button.card:active { transform: scale(0.985); }

/* ---- landing -------------------------------------------------------------------------------- */
.landing { max-width: 1040px; padding-top: calc(12px + var(--safe-t)); }
.landing-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.landing-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.landing-brand img { width: 36px; height: 36px; border-radius: 10px; box-shadow: var(--shadow-1); }
.landing-tools { display: flex; align-items: center; gap: 6px; }
.seg { display: inline-flex; padding: 3px; border-radius: 14px; background: var(--surface-3); border: 1px solid var(--line); }
.seg button { min-width: 44px; min-height: 38px; padding: 6px 10px; border: 0; border-radius: 11px; background: transparent; font-weight: 700; font-size: 14px; color: var(--ink-2); }
.seg button[aria-pressed="true"], .seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.hero { display: grid; gap: 18px; align-items: center; margin: 18px 0 28px; grid-template-areas: "text" "demo" "cta"; }
.hero-text { grid-area: text; display: grid; gap: 10px; justify-items: start; }
.hero-cta { grid-area: cta; display: grid; gap: 14px; justify-items: start; }
.hero h1 { font-size: clamp(36px, 9vw, 58px); font-weight: 900; letter-spacing: -0.03em; }
.promise { font-size: clamp(18px, 4.6vw, 22px); color: var(--ink-2); font-weight: 600; max-width: 30ch; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--moon-soft); color: var(--ink); font-weight: 600; font-size: 15px; max-width: 46ch; }
.notice .icon { flex: none; color: var(--moon-ink); margin-top: 1px; }
.hero-actions { display: grid; gap: 2px; justify-items: start; }
.demo { grid-area: demo; justify-self: center; width: min(100%, 400px); display: grid; justify-items: center; gap: 12px; }
.demo-board { width: 100%; display: grid; place-items: center; }
.demo canvas { width: var(--board-size, 300px); height: var(--board-size, 300px); filter: drop-shadow(0 18px 30px rgba(60, 40, 80, 0.18)); }
.demo-caption { display: flex; gap: 10px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.demo-caption .k { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 6px; border-radius: 9px; background: var(--surface); box-shadow: var(--shadow-1); color: var(--ink); transition: transform 0.12s, background-color 0.12s; }
.demo-caption .k.on { background: var(--sun); color: #2b1600; transform: scale(1.1); }
@media (max-width: 440px) { .landing-brand span { display: none; } }
.features { display: grid; gap: 12px; margin-bottom: 26px; }
.feature { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; align-items: start; }
.feature .f-icon { grid-row: span 2; width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; }
.feature h3 { font-size: 17px; }
.feature p { color: var(--ink-2); font-size: 15px; }
.f-icon.sun { background: var(--sun-soft); color: var(--sun-ink); }
.f-icon.moon { background: var(--moon-soft); color: var(--moon-ink); }
.f-icon.gold { background: var(--gold-soft); color: var(--gold-ink); }
.how h2 { font-size: 22px; margin-bottom: 12px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: step; }
.steps li { display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: center; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.steps .n { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); color: var(--ink); }
.landing-foot { margin-top: 26px; text-align: center; color: var(--ink-3); font-size: 13px; }
@media (min-width: 820px) {
  .hero { grid-template-columns: 1.05fr 1fr; grid-template-areas: "text demo" "cta demo"; margin-top: 36px; align-items: end; }
  .hero-cta { align-self: start; }
  .features { grid-template-columns: repeat(3, 1fr); }
  .feature { grid-template-columns: 1fr; }
  .feature .f-icon { grid-row: auto; }
  .steps { grid-template-columns: repeat(3, 1fr); }
}

/* ---- main menu ------------------------------------------------------------------------------ */
.menu-grid { display: grid; gap: 12px; }
.welcome { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center; padding: 16px; border-radius: var(--radius); background: linear-gradient(135deg, var(--sun-soft), var(--moon-soft)); border: 1px solid var(--line); }
.welcome .pair { grid-row: span 3; display: flex; }
.welcome .pair canvas { width: 40px; height: 40px; }
.welcome .pair canvas + canvas { margin-left: -8px; }
.welcome h2 { font-size: 20px; }
.welcome p { color: var(--ink-2); }
.welcome .btn { justify-self: start; margin-top: 6px; }
.mcard { position: relative; overflow: hidden; display: grid !important; grid-template-columns: auto 1fr auto; gap: 4px 14px; align-items: center; padding: 16px !important; min-height: 96px; }
.mcard .m-icon { grid-row: span 3; width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; }
.mcard h2 { font-size: 20px; font-weight: 800; }
.mcard .m-sub { color: var(--ink-2); font-size: 15px; }
.mcard .m-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 14px; color: var(--ink-2); font-weight: 600; }
.mcard .m-go { grid-row: span 3; color: var(--ink-3); }
.mcard.daily { background: linear-gradient(135deg, var(--gold-soft), var(--surface) 70%); border-color: color-mix(in srgb, var(--gold) 35%, transparent); }
.mcard.daily .m-icon { background: linear-gradient(180deg, #ffd56a, #e8a92a); color: #3a2600; }
.mcard.campaign .m-icon { background: linear-gradient(180deg, #ffb7c9, #e8668d); color: #3d0a1c; }
.mcard.practice .m-icon { background: linear-gradient(180deg, #b9c0ff, #6a6ff0); color: #0f1140; }
.mcard.highlight { box-shadow: 0 0 0 3px color-mix(in srgb, var(--sun) 55%, transparent), var(--shadow-2); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; background: var(--surface-3); color: var(--ink); font-weight: 700; font-size: 13px; }
.pill.done { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.pill.flame .icon { color: #e8571e; }
.pill .icon { width: 15px; height: 15px; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; grid-column: 2 / 3; }
.progress > span { display: block; height: 100%; width: var(--p, 0%); border-radius: inherit; background: linear-gradient(90deg, var(--sun), #ffcf6b); transition: width 0.6s var(--ease); }
.menu-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.menu-row .btn { min-height: 56px; }
@media (min-width: 760px) {
  .menu-grid { grid-template-columns: 1fr 1fr; }
  .menu-grid .welcome, .menu-grid .mcard.daily { grid-column: 1 / -1; }
  .menu-row { grid-column: 1 / -1; }
}

/* ---- gardens -------------------------------------------------------------------------------- */
.gardens { display: grid; gap: 14px; }
@media (min-width: 640px) { .gardens { grid-template-columns: 1fr 1fr; } }
@media (min-width: 980px) { .gardens { grid-template-columns: 1fr 1fr 1fr; } }
.gcard { padding: 0 !important; overflow: hidden; display: flex !important; flex-direction: column; }
.gcard canvas { width: 100%; height: 118px; display: block; }
.gcard .g-body { padding: 12px 14px 14px; display: grid; gap: 6px; }
.gcard h2 { font-size: 19px; font-weight: 800; }
.gcard .g-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--ink-2); font-size: 14px; font-weight: 600; }
.gcard .progress { grid-column: auto; }
.gcard.locked canvas { filter: grayscale(0.85) brightness(0.92); opacity: 0.55; }
.gcard.locked { background: var(--surface-2); }
.lock-badge { position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); color: var(--ink-2); box-shadow: var(--shadow-1); }
.gcard { position: relative; }
.gcard.opening { animation: glow 1s var(--ease); }
.gcard.opening .lock-badge { animation: lock-pop 0.7s var(--ease) forwards; }
@keyframes glow { 0% { box-shadow: 0 0 0 0 rgba(255, 196, 80, 0.8); } 60% { box-shadow: 0 0 0 12px rgba(255, 196, 80, 0); } 100% { box-shadow: var(--shadow-1); } }
@keyframes lock-pop { 0% { transform: none; opacity: 1; } 40% { transform: translateY(-10px) rotate(-12deg) scale(1.15); } 100% { transform: translateY(-26px) rotate(14deg) scale(0.6); opacity: 0; } }

/* ---- level tiles ---------------------------------------------------------------------------- */
.levels-head { display: flex; justify-content: space-between; align-items: end; gap: 10px; margin: 4px 2px 14px; }
.levels-head .screen-title { margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(5, 1fr); } }
.tile {
  position: relative; aspect-ratio: 1; min-height: 64px;
  display: grid; place-items: center; align-content: center; gap: 4px;
  border-radius: 16px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-1);
  font-weight: 800; font-size: 20px;
  transition: transform 0.12s var(--ease), box-shadow 0.15s;
}
.tile:hover { box-shadow: var(--shadow-2); }
.tile:active { transform: scale(0.96); }
.tile .stars { display: flex; gap: 1px; }
.tile .st { color: var(--line-2); display: inline-flex; }
.tile .st.on { color: #f2b01e; }
.tile.locked { background: var(--surface-2); color: var(--ink-3); box-shadow: none; }
.tile.locked .icon { opacity: 0.55; }
.tile.next { border-color: var(--sun); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--sun) 45%, transparent); } 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--sun) 0%, transparent); } }
.stars .st .icon { width: 1em; height: 1em; }

/* ---- game ------------------------------------------------------------------------------------- */
.game { max-width: none; padding: 8px 10px calc(10px + var(--safe-b)); display: grid; grid-template-rows: auto 1fr auto; gap: 8px; min-height: 0; height: calc(100dvh - var(--bar-h) - var(--safe-t)); }
.hud { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: space-between; max-width: 640px; width: 100%; margin: 0 auto; }
.hud-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hud-name { font-weight: 800; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.axis-badge { flex: none; display: inline-grid; place-items: center; min-width: 36px; height: 30px; padding: 0 8px; border-radius: 10px; background: var(--moon-soft); color: var(--moon-ink); font-weight: 800; font-size: 17px; }
.counters { display: flex; gap: 6px; }
.counter { display: grid; justify-items: center; min-width: 54px; padding: 4px 8px; border-radius: 12px; background: color-mix(in srgb, var(--surface) 80%, transparent); border: 1px solid var(--line); }
.counter b { font-size: 18px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.counter small { font-size: 11px; color: var(--ink-2); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
.counter.bump b { animation: bump 0.25s var(--ease); }
@keyframes bump { 40% { transform: scale(1.3); } }
.hint-dots { display: flex; gap: 3px; align-items: center; height: 22px; }
.hint-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--sun); }
.hint-dots i.used { background: var(--line-2); }
.hint-cap { display: inline-flex; color: var(--sun-ink); }
.board-area { position: relative; min-height: 0; display: grid; place-items: center; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.board-area canvas { width: var(--board-size, 300px); height: var(--board-size, 300px); display: block; touch-action: none; }
.board-overlay { position: absolute; inset: 0; pointer-events: none; display: grid; place-items: center; }
.warn-line {
  position: absolute; top: 4px; left: 50%; transform: translate(-50%, -6px); z-index: 3;
  max-width: calc(100% - 16px); padding: 8px 14px; border-radius: 12px;
  background: var(--warn); color: #fff; font-weight: 800; font-size: 15px; text-align: center;
  box-shadow: var(--shadow-2); opacity: 0; transition: opacity 0.15s, transform 0.2s var(--ease);
}
.warn-line.show { opacity: 1; transform: translate(-50%, 0); }
.axis-flash {
  position: absolute; z-index: 3; padding: 10px 16px; border-radius: 14px; max-width: calc(100% - 24px); text-align: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: var(--shadow-2);
  font-weight: 800; display: flex; gap: 10px; align-items: center; opacity: 0; transform: scale(0.94); transition: opacity 0.2s, transform 0.25s var(--ease);
}
.axis-flash.show { opacity: 1; transform: none; }
.axis-flash .axis-badge { font-size: 20px; }
.gen-spinner { position: absolute; z-index: 2; display: grid; justify-items: center; gap: 10px; color: var(--ink-2); font-weight: 700; }
.tipcard {
  position: absolute; z-index: 4; top: 6px; left: 50%; transform: translateX(-50%);
  width: min(440px, calc(100% - 12px));
  display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; align-items: center;
  padding: 12px 14px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-2); border: 1px solid var(--line);
  animation: rise 0.25s var(--ease) both;
}
.tipcard .t-art { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--moon-soft); color: var(--moon-ink); }
.tipcard .t-art .icon { animation: wiggle 1.6s ease-in-out infinite; }
@keyframes wiggle { 0%, 100% { transform: translateX(-3px); } 50% { transform: translateX(3px); } }
.tipcard p { font-weight: 700; }
.tipcard .btn { grid-column: 1 / -1; justify-self: end; min-height: 44px; padding: 8px 16px; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

.side { display: grid; gap: 10px; justify-items: center; }
.actions { display: flex; gap: 8px; justify-content: center; flex-wrap: nowrap; }
.act {
  display: grid; justify-items: center; align-content: center; gap: 2px;
  min-width: 56px; min-height: 56px; padding: 6px 8px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1);
  font-size: 11.5px; font-weight: 700; transition: transform 0.12s var(--ease), background-color 0.15s, opacity 0.15s;
}
.act:hover { background: var(--surface-2); }
.act:active { transform: scale(0.97); }
.act[disabled] { opacity: 0.4; pointer-events: none; }
.act .lbl { max-width: 72px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act.pulse { animation: act-pulse 0.6s ease-in-out 4; border-color: var(--sun); }
@keyframes act-pulse { 50% { transform: scale(1.08); background: var(--sun-soft); } }
.dpad { display: grid; grid-template-columns: repeat(3, 60px); grid-template-rows: repeat(3, 56px); gap: 4px; }
.dpad button {
  border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 92%, transparent); color: var(--ink); border-radius: 16px;
  display: grid; place-items: center; box-shadow: var(--shadow-1); touch-action: none; user-select: none; -webkit-user-select: none;
  transition: transform 0.08s, background-color 0.12s;
}
.dpad button.down, .dpad button:active { transform: scale(0.94); background: var(--sun-soft); }
.dpad button.pulse { animation: act-pulse 0.6s ease-in-out 3; border-color: var(--sun); }
.dpad .d-up { grid-area: 1 / 2; }
.dpad .d-left { grid-area: 2 / 1; }
.dpad .d-right { grid-area: 2 / 3; }
.dpad .d-down { grid-area: 3 / 2; }
.dpad .d-mid { grid-area: 2 / 2; display: grid; place-items: center; color: var(--ink-3); }
@media (max-height: 700px) and (orientation: portrait) {
  .dpad { grid-template-columns: repeat(4, 58px); grid-template-rows: 54px; }
  .dpad .d-up { grid-area: 1 / 2; } .dpad .d-left { grid-area: 1 / 1; } .dpad .d-right { grid-area: 1 / 4; } .dpad .d-down { grid-area: 1 / 3; }
  .dpad .d-mid { display: none; }
  .act { min-height: 52px; }
}
@media (max-width: 359px) { .act { min-width: 50px; padding: 6px 4px; } .actions { gap: 5px; } .counter { min-width: 46px; padding: 3px 5px; } }
/* landscape phones and desktops: the board on the left, the controls on the right */
@media (orientation: landscape) and (min-width: 600px) {
  .game {
    grid-template-columns: minmax(0, 1fr) minmax(250px, 300px); grid-template-rows: 1fr; align-items: center; column-gap: 20px;
    padding: 10px 18px calc(10px + var(--safe-b));
    width: 100%; max-width: calc(min(100dvh - 90px, 700px) + 360px); margin: 0 auto;
  }
  .game .board-area { grid-row: 1; grid-column: 1; height: 100%; }
  .game .side-wrap {
    grid-column: 2; grid-row: 1; display: grid; gap: 14px; align-content: center;
    padding: 16px; border-radius: 22px; background: color-mix(in srgb, var(--surface) 72%, transparent); border: 1px solid var(--line); box-shadow: var(--shadow-1);
  }
  .game .hud { flex-direction: column; align-items: stretch; gap: 10px; }
  .game .hud-title { flex-wrap: wrap; }
  .game .hud-name { white-space: normal; }
  .game .counters { display: grid; grid-template-columns: repeat(3, 1fr); }
  .game .counter { min-width: 0; }
  .game .actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .game .act { grid-auto-flow: column; justify-content: start; gap: 8px; padding: 8px 12px; font-size: 14px; }
  .game .act .lbl { max-width: none; }
  .game .side { width: 100%; }
  .side-wrap .tipcard { position: static; transform: none; width: 100%; animation: fade-in 0.25s ease both; box-shadow: none; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .dpad { grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, 46px); }
  .act { min-height: 48px; min-width: 52px; }
  .counter small { font-size: 10px; }
}
.game .side-wrap { display: contents; }
@media (orientation: landscape) and (min-width: 600px) { .game .side-wrap { display: grid; } }

/* ---- lists, segmented, tabs -------------------------------------------------------------------- */
.tabs { display: flex; padding: 4px; gap: 4px; border-radius: 16px; background: var(--surface-3); margin-bottom: 14px; }
.tabs button { flex: 1; min-height: 44px; border: 0; border-radius: 12px; background: transparent; font-weight: 800; color: var(--ink-2); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.dates { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; margin-bottom: 8px; scrollbar-width: none; }
.dates::-webkit-scrollbar { display: none; }
.dates button { flex: none; min-width: 58px; min-height: 52px; padding: 6px 8px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); display: grid; justify-items: center; font-weight: 700; font-size: 13px; color: var(--ink-2); }
.dates button b { font-size: 17px; color: var(--ink); }
.dates button[aria-pressed="true"] { background: var(--gold-soft); border-color: var(--gold); color: var(--ink); }
.rank-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rank-list li > button {
  width: 100%; display: grid; grid-template-columns: 30px 38px 1fr auto; gap: 10px; align-items: center;
  padding: 8px 12px; min-height: 56px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); text-align: left;
}
.rank-list li.me > button { background: linear-gradient(90deg, var(--sun-soft), var(--surface)); border-color: color-mix(in srgb, var(--sun) 40%, transparent); }
.rank { font-weight: 800; color: var(--ink-2); text-align: center; font-variant-numeric: tabular-nums; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; background: hsl(var(--hue, 240) 46% 46%); }
.who { min-width: 0; display: grid; }
.who b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: var(--ink-2); font-weight: 600; }
.res { display: grid; justify-items: end; font-variant-numeric: tabular-nums; }
.res b { font-size: 17px; }
.res .stars { display: flex; color: #f2b01e; }
.res .st { color: var(--line-2); display: inline-flex; }
.res .st.on { color: #f2b01e; }
.note { padding: 14px; border-radius: 14px; background: var(--surface-2); color: var(--ink-2); font-weight: 600; border: 1px dashed var(--line-2); }
.board-foot { margin-top: 14px; display: grid; gap: 8px; justify-items: start; color: var(--ink-3); font-size: 14px; }
.heart { color: #e5487a; margin-left: 4px; }

/* ---- stats -------------------------------------------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 22px; }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat { padding: 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); display: grid; gap: 2px; }
.stat b { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat span { color: var(--ink-2); font-size: 14px; font-weight: 600; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge { padding: 14px 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); display: grid; justify-items: center; text-align: center; gap: 6px; }
.badge .b-art { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 35% 30%, #ffe6a3, #f2b01e 60%, #c98a00); color: #4a2f00; box-shadow: 0 4px 12px rgba(201, 138, 0, 0.35); }
.badge b { font-size: 15px; }
.badge small { color: var(--ink-2); font-size: 13px; }
.badge.locked .b-art { background: var(--surface-3); color: var(--ink-3); box-shadow: none; }
.badge.locked { background: var(--surface-2); }
.section-title { font-size: 19px; font-weight: 800; margin: 6px 2px 12px; display: flex; justify-content: space-between; align-items: baseline; }
.section-title small { color: var(--ink-2); font-size: 14px; }

/* ---- daily & practice --------------------------------------------------------------------------- */
.daily-card { display: grid; gap: 14px; justify-items: start; padding: 20px !important; background: linear-gradient(160deg, var(--gold-soft), var(--surface) 65%) !important; }
.daily-card .d-icon { width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; background: linear-gradient(180deg, #ffd56a, #e8a92a); color: #3a2600; }
.daily-card h2 { font-size: 24px; font-weight: 800; }
.daily-card .d-date { color: var(--gold-ink); font-weight: 800; }
.daily-card .d-rules { color: var(--ink-2); font-size: 15px; }
.daily-card .d-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.daily-card .d-done { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-weight: 700; }
.pcards { display: grid; gap: 12px; }
@media (min-width: 760px) { .pcards { grid-template-columns: repeat(3, 1fr); } }
.pcard { display: grid !important; gap: 8px; padding: 18px !important; }
.pcard .p-size { justify-self: start; padding: 4px 10px; border-radius: 10px; font-weight: 800; background: var(--surface-3); }
.pcard h2 { font-size: 21px; font-weight: 800; }
.pcard p { color: var(--ink-2); }
.pcard.easy .p-size { background: #ffe0e8; color: #8a1c3d; }
.pcard.medium .p-size { background: #dff0d8; color: #2c5a22; }
.pcard.hard .p-size { background: #e6defa; color: #47228a; }
:root[data-theme="dark"] .pcard.easy .p-size { background: #4a2a36; color: #ffc1d2; }
:root[data-theme="dark"] .pcard.medium .p-size { background: #24402c; color: #bfe8b3; }
:root[data-theme="dark"] .pcard.hard .p-size { background: #352a5c; color: #d6c6ff; }

/* ---- sheets --------------------------------------------------------------------------------------- */
dialog.sheet {
  border: 0; padding: 0; color: var(--ink); background: var(--surface);
  width: min(560px, 100vw); max-height: min(88dvh, 860px);
  border-radius: 24px; box-shadow: var(--shadow-2);
  overflow: auto; overscroll-behavior: contain;
}
dialog.sheet[open] { animation: sheet-in 0.25s var(--ease) both; }
dialog.sheet.closing { animation: sheet-out 0.16s ease-in both; }
dialog.sheet::backdrop { background: rgba(18, 16, 40, 0.42); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog.sheet[open]::backdrop { animation: fade-in 0.2s ease both; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes sheet-out { to { opacity: 0; transform: translateY(16px); } }
@keyframes fade-in { from { opacity: 0; } }
@media (max-width: 600px) {
  dialog.sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 24px 24px 0 0; max-height: 92dvh; padding-bottom: var(--safe-b); }
}
.sheet-small { width: min(420px, 100vw); }
.sheet-wide { width: min(720px, 100vw); }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 12px 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 20px; font-weight: 800; }
.sheet-body { padding: 16px 20px 22px; display: grid; gap: 14px; }
.group { display: grid; gap: 4px; }
.group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); margin: 6px 0 4px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row > span { font-weight: 600; }
.row .seg button { min-width: 0; padding: 6px 10px; }
.switch { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 99px; background: var(--line-2); position: relative; flex: none; transition: background-color 0.2s; cursor: pointer; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.2s var(--ease); }
.switch:checked { background: var(--good); }
.switch:checked::after { transform: translateX(20px); }
input[type="range"] { width: min(200px, 48vw); accent-color: var(--sun); min-height: 44px; }
.about { display: grid; gap: 10px; padding: 14px; border-radius: 16px; background: var(--surface-2); }
.about p { color: var(--ink-2); font-size: 14px; }
.version { color: var(--ink-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.pause-list { display: grid; gap: 8px; }
.pause-list .btn { justify-content: flex-start; }
.pause-note { color: var(--ink-2); font-size: 14px; text-align: center; }

/* help */
.help-sec { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.help-sec:last-child { border-bottom: 0; }
.help-art { width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); }
.help-sec h3 { font-size: 17px; margin-bottom: 4px; }
.help-sec p { color: var(--ink-2); font-size: 15px; }
.help-sec p + p { margin-top: 6px; }
.help-sec .warn-txt { color: var(--sun-ink); font-weight: 700; }
.axes { display: grid; gap: 8px; margin-top: 10px; }
.axis-row { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center; font-size: 14px; color: var(--ink-2); }
.axis-row .axis-badge { justify-self: start; }
.formula { font-variant-numeric: tabular-nums; padding: 8px 10px; border-radius: 10px; background: var(--surface-3); font-weight: 700; color: var(--ink); margin-top: 6px; display: inline-block; }
.tip-list { display: grid; gap: 6px; }
.tip-list button { text-align: left; padding: 10px 12px; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
kbd { display: inline-block; padding: 1px 7px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface-2); font: inherit; font-size: 13px; font-weight: 700; }

/* result */
.sheet-result { width: min(460px, 100vw); }
.result { display: grid; justify-items: center; text-align: center; gap: 12px; }
.result h2 { font-size: 26px; font-weight: 900; }
.result .r-sub { color: var(--ink-2); font-weight: 600; }
.big-stars { display: flex; gap: 8px; margin: 4px 0; }
.big-stars .st { display: inline-flex; color: var(--line-2); transform: scale(0.4); opacity: 0; }
.big-stars .st .icon { width: 52px; height: 52px; }
.big-stars .st.pop { animation: star-pop 0.25s var(--ease) forwards; }
.big-stars .st.on.pop .icon { color: #f2b01e; filter: drop-shadow(0 3px 6px rgba(242, 176, 30, 0.45)); }
@keyframes star-pop { 0% { transform: scale(0.4); opacity: 0; } 70% { transform: scale(1.18); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
.r-score { font-size: 44px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1; }
.r-score-label { color: var(--ink-2); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
.r-facts { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.r-facts .fact { padding: 8px 12px; border-radius: 12px; background: var(--surface-2); display: grid; min-width: 96px; }
.r-facts .fact b { font-size: 17px; font-variant-numeric: tabular-nums; }
.r-facts .fact small { color: var(--ink-2); font-weight: 700; font-size: 12px; }
.r-note { font-size: 14px; color: var(--ink-2); font-weight: 600; }
.r-note.warnish { color: var(--sun-ink); }
.r-best { color: var(--good); font-weight: 800; }
.r-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px; width: 100%; }
.r-actions .btn { padding: 10px 8px; }
.r-actions .btn.primary { grid-column: 1 / -1; }
.friends-box { width: 100%; text-align: left; display: grid; gap: 8px; }
.friends-box h3 { font-size: 16px; }
.friends-box .ca-board { min-height: 80px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(18px + var(--safe-b)); z-index: 60; transform: translate(-50%, 30px);
  max-width: min(92vw, 460px); padding: 12px 18px; border-radius: 14px; background: #24264a; color: #fff; font-weight: 700; text-align: center;
  box-shadow: var(--shadow-2); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast[data-kind="gold"] { background: linear-gradient(180deg, #ffd56a, #e8a92a); color: #2e1f00; }

/* ---- high contrast and reduced motion ------------------------------------------------------------ */
:root[data-contrast="true"] { --line: rgba(31, 33, 64, 0.3); --line-2: rgba(31, 33, 64, 0.45); --ink-2: #33374f; }
:root[data-contrast="true"][data-theme="dark"] { --line: rgba(255, 255, 255, 0.3); --line-2: rgba(255, 255, 255, 0.45); --ink-2: #dadcf4; }
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after {
  animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important;
}
:root[data-motion="reduce"] .big-stars .st.pop { opacity: 1; transform: none; }
:root[data-motion="reduce"] .tile.next { animation: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--sun) 55%, transparent); }
:root[data-motion="reduce"] .act.pulse, :root[data-motion="reduce"] .dpad button.pulse { animation: none; background: var(--sun-soft); }
:root[data-motion="reduce"] .screen { animation: fade-only 0.15s linear both !important; animation-duration: 0.15s !important; }
@keyframes fade-only { from { opacity: 0; } }
@media (max-width: 380px) { body[data-screen="play"] .brand-text { display: none; } }
