/* AI RODENT'S REVENGE — UI design tokens + layout. Game board is Canvas. */
:root {
  --bg: #0b1020;
  --bg-2: #0f1630;
  --surface: #151c34;
  --surface-2: #1c2542;
  --surface-3: #25304f;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #eef1ff;
  --text-2: #b7bfdc;
  --muted: #7f89ad;
  --accent: #ffb547;      /* player / primary */
  --accent-ink: #2a1a00;
  --enemy: #ff5d73;
  --trap: #a07cff;
  --block: #c9925a;
  --ok: #3ddc97;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.25);
  --font: 'Pretendard', 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Apple SD Gothic Neo',
    'Noto Sans KR', 'Malgun Gothic', sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, /* Typesetting: keep Korean words whole, phrase-aware Japanese breaks,
   no orphans in paragraphs (pretty) and even short blocks (balance). */
html { overflow-wrap: break-word; }
:lang(ko) { word-break: keep-all; }
:lang(ja) { word-break: auto-phrase; }
p, li, dd, dt, label, summary { text-wrap: pretty; }
h1, h2, h3, h4, .kicker, .lead, .sub, small, figcaption, .modal-desc, .step p, .modal-card h3, .btn { text-wrap: balance; }
body { height: 100%; margin: 0; }
body {
  background: radial-gradient(120% 80% at 50% -10%, #1a2350 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--text-2); }

.app {
  position: relative;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  overflow: hidden;
  padding: calc(12px + var(--safe-top)) 16px calc(12px + var(--safe-bottom));
}

/* ---------- screens ---------- */
.screen { display: none; height: 100%; flex-direction: column; animation: screen-in 0.22s ease both; }
/* Motion only (no opacity 0): keeps screen text eligible as the page's LCP element. */
@keyframes screen-in { from { transform: translateY(6px); } to { transform: none; } }
.app[data-screen='MENU'] .screen-menu,
.app[data-screen='LEVEL_SELECT'] .screen-levels,
.app[data-screen='PROFILE'] .screen-profile,
.app[data-screen='GAME'] .screen-game { display: flex; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 1px solid transparent; border-radius: 999px; padding: 12px 22px;
  font-weight: 700; letter-spacing: 0.01em; min-height: 48px;
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible, .icon-btn:focus-visible, .ctrl:focus-visible, .level-card:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 2px;
}
.btn-primary {
  background: linear-gradient(180deg, #ffc56b, var(--accent)); color: var(--accent-ink);
  box-shadow: 0 8px 24px rgba(255, 181, 71, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
.btn-secondary { background: var(--surface-2); border-color: var(--line-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-lg { min-height: 54px; font-size: 1.05rem; }
.btn-xl { min-height: 64px; font-size: 1.2rem; }
.btn-sub { font-size: 0.72rem; font-weight: 600; opacity: 0.7; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 999px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line);
}
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 800; letter-spacing: 0.04em;
}
.pill-level { background: var(--accent); color: var(--accent-ink); }
.pill-muted { background: var(--surface); color: var(--text-2); border: 1px solid var(--line); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.eyebrow { margin: 0; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.16em; color: var(--muted); text-transform: uppercase; }

/* ---------- menu ---------- */
.screen-menu { gap: 14px; overflow-y: auto; scrollbar-width: none; }
.menu-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rank-chip { display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.rank-badge { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 0.9rem; background: linear-gradient(135deg, var(--accent), var(--enemy)); color: #1b0f00; flex: none; }
.rank-badge-lg { width: 56px; height: 56px; font-size: 1.3rem; }
.rank-text { display: grid; gap: 4px; text-align: left; min-width: 0; }
.rank-text strong { font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xp-bar { display: block; width: 110px; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.xp-bar > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--enemy)); border-radius: inherit; transition: width 0.6s ease; }
.xp-bar-lg { width: 100%; height: 10px; }
.star-total { color: var(--accent); font-size: 0.9rem; }
.menu-hero { text-align: center; display: grid; justify-items: center; gap: 6px; }
.menu-art { width: 240px; height: 96px; }
.logo { margin: 0; font-size: clamp(1.7rem, 7.5vw, 2.4rem); line-height: 1; letter-spacing: -0.02em; font-weight: 900; }
.logo span { background: linear-gradient(90deg, var(--accent), var(--enemy)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { margin: 0; color: var(--text-2); font-size: 0.92rem; }
.modes { display: grid; gap: 10px; }
.mode-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-card {
  display: flex; align-items: center; gap: 12px; text-align: left; padding: 14px 16px; border-radius: var(--radius-lg);
  border: 1px solid var(--line); background: var(--surface); min-height: 64px; transition: transform 0.08s ease;
}
.mode-card:active { transform: scale(0.98); }
.mode-classic { background: linear-gradient(135deg, #ffc56b, var(--accent)); color: var(--accent-ink); border: 0; min-height: 76px; box-shadow: 0 10px 28px rgba(255,181,71,0.25); }
.mode-classic .mode-sub { color: rgba(42,26,0,0.72); }
.mode-icon { font-size: 1.6rem; line-height: 1; }
.mode-body { display: grid; gap: 2px; flex: 1; min-width: 0; }
.mode-body strong { font-size: 1.2rem; }
.mode-sub { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.mode-cta { font-weight: 900; padding: 8px 14px; border-radius: 999px; background: rgba(42,26,0,0.12); }
.mode-daily, .mode-endless { flex-direction: column; align-items: flex-start; gap: 4px; }
.mode-daily { background: linear-gradient(160deg, #1f2c55, var(--surface)); }
.mode-endless { background: linear-gradient(160deg, #2a1f4f, var(--surface)); }
.mode-top { display: flex; width: 100%; justify-content: space-between; align-items: center; }
.streak { font-size: 0.8rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,0.08); }
.mode-daily.done { border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.mode-row-small .btn { min-height: 46px; }
.settings { padding: 4px 16px; }
.settings summary { cursor: pointer; font-weight: 700; padding: 12px 0; color: var(--text-2); list-style: none; }
.settings summary::after { content: '▾'; float: right; opacity: 0.6; }
.settings[open] summary::after { content: '▴'; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; border-top: 1px solid var(--line); }
.setting-row small { display: block; color: var(--muted); font-size: 0.78rem; margin-top: 2px; }
.segmented { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.segmented button { border: 0; background: transparent; padding: 7px 14px; border-radius: 999px; font-weight: 700; font-size: 0.85rem; color: var(--text-2); }
.segmented button[aria-checked='true'] { background: var(--surface-3); color: var(--text); }
.switch { appearance: none; width: 50px; height: 30px; border-radius: 999px; background: var(--surface-3); position: relative; cursor: pointer; transition: background 0.15s; flex: none; margin: 0; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.18s ease; }
.switch:checked { background: var(--ok); }
.switch:checked::after { transform: translateX(20px); }
.legal-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 8px; font-size: 0.78rem; color: var(--muted); margin-top: auto; padding-top: 6px; text-align: center; }
.legal-links a { text-decoration: none; }

/* ---------- profile ---------- */
.profile-scroll { overflow-y: auto; display: grid; gap: 12px; padding-bottom: 16px; align-content: start; }
.rank-card { display: flex; align-items: center; gap: 14px; padding: 16px; }
.rank-card-body { display: grid; gap: 6px; flex: 1; }
.rank-card-body strong { font-size: 1.15rem; }
.rank-card-body small { color: var(--muted); }
.section-title { margin: 8px 0 0; font-size: 0.8rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; display: grid; gap: 2px; }
.stat-tile b { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.stat-tile em { font-style: normal; font-size: 0.7rem; color: var(--muted); font-weight: 700; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ach { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); }
.ach .ach-icon { font-size: 1.4rem; filter: grayscale(1); opacity: 0.35; }
.ach.on { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.ach.on .ach-icon { filter: none; opacity: 1; }
.ach strong { display: block; font-size: 0.82rem; }
.ach small { color: var(--muted); font-size: 0.72rem; }

/* ---------- level select ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.topbar h2 { margin: 0; font-size: 1.3rem; }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; overflow-y: auto; padding-bottom: 12px; }
.level-card {
  position: relative; text-align: left; padding: 14px; min-height: 128px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px;
  transition: transform 0.08s ease, border-color 0.15s;
}
.level-card:active { transform: scale(0.98); }
.level-card .num { font-size: 1.6rem; font-weight: 900; letter-spacing: -0.02em; }
.level-card .name { font-size: 0.85rem; color: var(--text-2); font-weight: 600; }
.level-card .meta { margin-top: auto; font-size: 0.74rem; color: var(--muted); }
.level-card .lstars { color: var(--surface-3); letter-spacing: 2px; font-size: 0.95rem; }
.level-card .lstars .on { color: var(--accent); }
.level-card .tag { position: absolute; top: 12px; right: 12px; font-size: 0.68rem; font-weight: 800; padding: 3px 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }
.level-card.cleared { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.level-card.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.level-card.locked { opacity: 0.45; cursor: not-allowed; }
.level-card.locked .num::after { content: ' 🔒'; font-size: 0.9rem; }

/* ---------- game ---------- */
.hud { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hud-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hud-title { display: flex; flex-direction: column; min-width: 0; }
.hud-game { font-size: 0.66rem; letter-spacing: 0.14em; color: var(--muted); font-weight: 800; }
.hud-title strong { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-stats { display: flex; gap: 8px; margin: 12px 0 10px; }
.stat {
  flex: 1; display: flex; align-items: baseline; justify-content: space-between; gap: 6px;
  padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line);
}
.stat em { font-style: normal; font-size: 0.72rem; color: var(--muted); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.stat b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.stat-par b { color: var(--accent); }
.stat-goal b { color: var(--ok); }
.lives { font-size: 0.95rem; letter-spacing: 1px; color: var(--enemy); margin-left: auto; margin-right: 8px; }
.ctrl-hint svg { color: var(--ok); }
.replay-banner { position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%); display: none; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; border-radius: 999px; background: rgba(21,28,52,0.92); border: 1px solid var(--line-2); font-size: 0.85rem; font-weight: 700; }
.app[data-replay='1'] .replay-banner { display: flex; }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 0.8rem; }
.board-wrap { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; }
.board { display: block; touch-action: none; border-radius: var(--radius-lg); }
.hint {
  position: absolute; left: 50%; top: 6px; transform: translate(-50%, -6px); width: max-content; max-width: min(calc(100% - 24px), 460px);
  padding: 9px 14px; border-radius: 999px; font-size: 0.86rem; font-weight: 600; text-align: center;
  background: rgba(21, 28, 52, 0.92); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease; backdrop-filter: blur(8px);
}
.hint.show { opacity: 1; transform: translate(-50%, 0); }
.controls { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 12px; }
.ctrl {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 62px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); font-size: 0.7rem; font-weight: 700; padding: 0 2px; white-space: nowrap;
  color: var(--text-2); transition: transform 0.08s ease, background 0.15s;
}
.ctrl:active { transform: scale(0.95); background: var(--surface-2); }
.ctrl:disabled { opacity: 0.4; }
.ctrl svg { width: 22px; height: 22px; color: var(--text); }

/* ---------- modals ---------- */
.modal {
  position: absolute; inset: 0; display: none; place-items: center; padding: 24px;
  background: rgba(5, 8, 20, 0.62); backdrop-filter: blur(6px); z-index: 10;
}
.app[data-modal='SUCCESS'] #modal-success,
.app[data-modal='FAIL'] #modal-fail,
.app[data-modal='GAMEOVER'] #modal-gameover,
.app[data-modal='PAUSED'] #modal-pause,
.app[data-modal='SETTINGS'] #modal-settings { display: grid; animation: fade-in 0.2s ease both; }
.modal-card {
  width: min(360px, 100%); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-lg);
  padding: 28px 22px 16px; display: grid; gap: 10px; text-align: center; box-shadow: var(--shadow);
  animation: pop 0.28s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
@keyframes pop { from { transform: scale(0.9); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-card h3 { margin: 2px 0 4px; font-size: 1.6rem; letter-spacing: -0.01em; }
.modal-desc { margin: 0 0 8px; color: var(--text-2); font-size: 0.95rem; }
.modal-badge { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin: -60px auto 6px; border: 4px solid var(--surface); }
.modal-badge svg { width: 30px; height: 30px; stroke-width: 3; }
.badge-success { background: var(--ok); color: #05301d; }
.badge-fail { background: var(--enemy); color: #3a0010; }
.badge-endless { background: var(--trap); font-size: 1.8rem; }
.stars { display: flex; justify-content: center; gap: 6px; margin: -8px 0 4px; font-size: 2.6rem; line-height: 1; }
.stars span { color: var(--surface-3); transform: scale(0.6); opacity: 0.4; transition: transform 0.35s cubic-bezier(0.2, 1.6, 0.4, 1), color 0.2s, opacity 0.2s; }
.stars span.on { color: var(--accent); transform: scale(1); opacity: 1; text-shadow: 0 0 18px rgba(255,181,71,0.6); }
.stars span:nth-child(2) { font-size: 3.1rem; margin-top: -8px; }
.par-line { margin: -2px 0 4px; font-size: 0.88rem; }
.unlocks { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.unlocks:empty { display: none; }
.unlock-chip { font-size: 0.78rem; font-weight: 700; padding: 6px 10px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 18%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-row .btn { min-height: 44px; font-size: 0.85rem; padding: 8px 10px; }
.loading { position: absolute; inset: 0; display: none; flex-direction: column; gap: 14px; align-items: center; justify-content: center; background: rgba(5,8,20,0.7); backdrop-filter: blur(4px); z-index: 15; font-weight: 700; color: var(--text-2); }
.app[data-loading='1'] .loading { display: flex; }
.toasts { position: absolute; top: calc(10px + var(--safe-top)); left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 30; width: min(360px, calc(100% - 32px)); pointer-events: none; }
.toast { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: var(--radius); background: rgba(28,37,66,0.96); border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent); box-shadow: var(--shadow); animation: toast-in 0.35s cubic-bezier(0.2,1.4,0.4,1) both, toast-out 0.4s ease 3.2s forwards; }
.toast .t-icon { font-size: 1.5rem; }
.toast strong { display: block; font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.toast span { font-weight: 700; font-size: 0.9rem; }
@keyframes toast-in { from { transform: translateY(-16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to { transform: translateY(-10px); opacity: 0; } }
.result-chips { display: flex; gap: 8px; justify-content: center; margin: 4px 0 10px; }
.chip { flex: 1; display: grid; gap: 2px; padding: 10px 6px; border-radius: var(--radius-sm); background: var(--bg-2); border: 1px solid var(--line); }
.chip em { font-style: normal; font-size: 0.68rem; color: var(--muted); font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.chip b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.keys { margin: 6px 0 0; font-size: 0.74rem; color: var(--muted); }

/* ---------- boot ---------- */
.boot { position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 20; transition: opacity 0.3s; }
.app:not([data-screen='BOOT']) .boot { opacity: 0; pointer-events: none; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-height: 820px) { .controls { margin-bottom: 8px; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- generated art hooks ---------- */
.app::before { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--bg-art, none) center / cover no-repeat; opacity: 0.35; pointer-events: none; }
.app { isolation: isolate; }
.ctrl .ctrl-img { width: 26px; height: 26px; object-fit: contain; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.35)); }
.modal-card { position: relative; }
.hero-art { width: 112px; height: 112px; object-fit: contain; margin: -84px auto -6px; filter: drop-shadow(0 8px 14px rgba(0,0,0,0.45)); }
.hero-art[hidden] { display: none; }
.hero-happy { animation: hero-hop 0.9s cubic-bezier(0.3, 1.6, 0.5, 1) 0.1s both; }
@keyframes hero-hop { 0% { transform: translateY(24px) scale(0.6); opacity: 0; } 55% { transform: translateY(-8px) scale(1.06, 0.96); opacity: 1; } 100% { transform: none; } }
.modal-badge.has-art { width: 104px; height: 104px; margin-top: -86px; background: color-mix(in srgb, var(--enemy) 22%, var(--surface)); overflow: hidden; }
.modal-badge.has-art svg { display: none; }
.badge-art { width: 92%; height: 92%; object-fit: contain; animation: shiver 0.12s linear 0.3s 6 alternate; }
@keyframes shiver { from { transform: translateX(-2px) rotate(-2deg); } to { transform: translateX(2px) rotate(2deg); } }
@media (prefers-reduced-motion: reduce) { .hero-happy, .badge-art { animation: none; } }
.burst { position: absolute; left: 50%; top: -70px; width: 260px; height: 260px; transform: translateX(-50%); pointer-events: none; z-index: -1; animation: burst 1.2s cubic-bezier(0.2, 1, 0.3, 1) both; }
@keyframes burst { from { transform: translateX(-50%) scale(0.3) rotate(-30deg); opacity: 0; } 30% { opacity: 1; } to { transform: translateX(-50%) scale(1) rotate(0); opacity: 0.9; } }
.select { appearance: none; background: var(--bg-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23b7bfdc' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 12px center; color: var(--text); border: 1px solid var(--line-2); border-radius: 999px; padding: 8px 34px 8px 14px; font: inherit; font-weight: 700; font-size: 0.88rem; max-width: 60%; }
.mode-img { width: 44px; height: 44px; object-fit: contain; display: block; }
.mode-daily .mode-img, .mode-endless .mode-img { width: 38px; height: 38px; }
.rank-badge.has-art { background: none; }
.rank-img { width: 100%; height: 100%; object-fit: contain; }
.ach-img { width: 40px; height: 40px; object-fit: contain; display: block; }
.ach .ach-icon img { filter: grayscale(1) brightness(0.6); }
.ach.on .ach-icon img { filter: none; }
.chip-img { width: 20px; height: 20px; object-fit: contain; vertical-align: -5px; margin-right: 4px; }
.toast-img { width: 40px; height: 40px; object-fit: contain; display: block; }
.pill { white-space: nowrap; flex: none; }
.hud-left { min-width: 0; flex: 1; }

/* ---------- in-game Home / Settings ---------- */
.hud-actions { display: flex; align-items: center; gap: 6px; flex: none; }
a.icon-btn { color: var(--text); text-decoration: none; }
.icon-btn { cursor: pointer; color: var(--text); transition: background 0.15s, border-color 0.15s, transform 0.1s; }
.icon-btn:hover { background: var(--surface-2, var(--surface)); border-color: var(--line-2); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.settings-card { text-align: left; width: min(400px, 100%); }
.settings-card h3 { text-align: center; }
.settings-list { display: grid; margin: 4px 0 8px; }
.settings-list .setting-row:first-child { border-top: 0; }
.settings-card .select { max-width: 55%; }
.range { appearance: none; -webkit-appearance: none; width: min(180px, 48%); height: 6px; border-radius: 999px; background: var(--surface-3); outline: none; flex: none; margin: 0; cursor: pointer; }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.4); }
.range::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; }
.range:disabled { opacity: 0.4; cursor: not-allowed; }
.range:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
@media (max-width: 380px) {
  .hud-actions { gap: 4px; }
  .hud-actions .icon-btn { width: 40px; height: 40px; }
  .hud-game { display: none; }
}
.hud-game { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
a.btn { text-decoration: none; }
.range { background: linear-gradient(90deg, var(--accent) var(--v, 80%), var(--surface-3) var(--v, 80%)); }

/* Pinch-zoom stays allowed (a11y); double-tap zoom is suppressed on controls, the board uses touch-action: none. */
button, a, .ctrl, .icon-btn, .btn, select, label { touch-action: manipulation; }

/* live stats (reserved height: appears without shifting the layout) */
.live-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-height: 1.6em; margin: 4px 0 0; justify-content: center; font-size: .9rem; font-weight: 600; color: var(--text-2); opacity: 0; transition: opacity .4s ease; }
.live-stats[data-ready] { opacity: 1; }
.live-stats b { color: var(--text); font-weight: 900; font-variant-numeric: tabular-nums; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok, #3ddc97); box-shadow: 0 0 0 0 rgba(61,220,151,.6); animation: live-ping 2s infinite; flex: none; }
.live-sep { color: var(--muted); }
@keyframes live-ping { 0% { box-shadow: 0 0 0 0 rgba(61,220,151,.55); } 70% { box-shadow: 0 0 0 8px rgba(61,220,151,0); } 100% { box-shadow: 0 0 0 0 rgba(61,220,151,0); } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
