/* Between Stars – browser version. Night palette from the app and the between-stars pages:
   night blue, starlight cyan, aura violet, figure gold. Web layout: sidebar navigation, pages
   with breadcrumbs and card grids, game with an info column on wide screens. Text stays at
   ~7:1 or better against the background. */
:root {
  --night: #05061f;
  --ink: #eef0ff;
  --muted: #b9bde6;
  --faint: rgba(238, 240, 255, 0.66);
  --cyan: #8cd9ff;
  --violet: #c9a6ff;
  --gold: #ffd98c;
  --green: #7fe3b0;
  --panel: rgba(255, 255, 255, 0.055);
  --panel-hi: rgba(255, 255, 255, 0.095);
  --line: rgba(255, 255, 255, 0.11);
  --side-bg: rgba(7, 8, 30, 0.82);
  --radius: 12px;
  --side-w: 248px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  /* melon-dialog.js picks these up */
  --m-card: #12153a;
  --m-fg: #eef0ff;
  --m-muted: rgba(255, 255, 255, 0.08);
  --m-primary: #ffd98c;
  --m-primary-hover: #ffe4a8;
  --m-primary-fg: #1a1405;
  --m-ring-line: rgba(255, 255, 255, 0.14);
  --m-focus: rgba(140, 217, 255, 0.55);
  --m-radius-card: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--cyan); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 18px; height: 18px; flex: none; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
kbd { display: inline-block; min-width: 1.6em; padding: 1px 5px; border: 1px solid rgba(255, 255, 255, 0.22); border-bottom-width: 2px; border-radius: 5px; background: rgba(255, 255, 255, 0.06); font: 600 11px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-align: center; color: var(--muted); }
kbd + kbd { margin-left: 3px; }
code { font: 600 15px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.06em; }

#sky { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------------------------------------------------------------- loading */
#loading { position: fixed; inset: 0; display: none; place-items: center; z-index: 5; }
body.is-loading #loading { display: grid; }
#loading p { color: var(--muted); font-size: 15px; letter-spacing: 0.02em; }
body.is-loading .app { visibility: hidden; }

/* ---------------------------------------------------------------- app layout */
.app { position: fixed; inset: 0; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); z-index: 1; }
.main { position: relative; min-width: 0; overflow: hidden; }
#view { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-color: rgba(255, 255, 255, 0.18) transparent; }
#view[hidden] { display: none; }
.mtop { display: none; }
.side-scrim { display: none; }
body.is-fs .app { grid-template-columns: 0 minmax(0, 1fr); }
body.is-fs .side { visibility: hidden; }

/* sidebar */
.side { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; background: var(--side-bg); border-right: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.14) transparent; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 12px; color: var(--ink); text-decoration: none; font: 400 21px/1.2 var(--serif); letter-spacing: 0.02em; }
.brand-star { position: relative; width: 22px; height: 22px; flex: none; border-radius: 50%; background: radial-gradient(circle, #fff 0 18%, rgba(191, 230, 255, 0.85) 28%, rgba(140, 191, 255, 0.25) 55%, transparent 72%); }
.nav { display: grid; gap: 1px; padding: 4px 10px 12px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: rgba(238, 240, 255, 0.86); text-decoration: none; font-size: 14px; font-weight: 500; }
.nav-link:hover { background: var(--panel); color: #fff; }
.nav-link.is-on { background: rgba(140, 217, 255, 0.13); color: #fff; }
.nav-link .ic { width: 17px; height: 17px; color: var(--cyan); }
.nav-link.sub { padding-left: 37px; }
.nav-label { flex: 1; min-width: 0; }
.nav-count { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; display: inline-flex; }
.nav-count .ic { width: 13px; height: 13px; color: var(--faint); }
.nav-badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--gold); color: #1a1405; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.nav-badge[hidden] { display: none; }
.nav-group { display: flex; align-items: center; gap: 10px; margin: 12px 0 2px; padding: 0 10px; font-size: 12px; font-weight: 650; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.nav-group .ic { width: 17px; height: 17px; color: var(--violet); }
.nav-sep { height: 1px; margin: 10px 10px 8px; background: var(--line); }
.side-foot { margin-top: auto; display: grid; gap: 10px; padding: 12px 14px 16px; border-top: 1px solid var(--line); }
.side-res { display: flex; align-items: center; justify-content: space-between; }
.side-sync { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.side-sync.is-ok { background: var(--green); }
.side-sync.is-syncing { background: var(--cyan); animation: pulse 1s ease-in-out infinite; }
.side-sync.is-error { background: #ff9aa2; }
.side-sync[hidden] { display: none; }
@keyframes pulse { 50% { opacity: 0.35; } }
.side-owned { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: var(--muted); }
.side-owned .ok { color: var(--green); }
.side-tools { display: flex; gap: 6px; }
.tool { display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: rgba(255, 255, 255, 0.85); cursor: pointer; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; }
.tool:hover { background: var(--panel-hi); }
.tool[aria-pressed="false"] { color: var(--faint); }
.res-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; background: rgba(255, 217, 140, 0.1); color: var(--gold); font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.res-chip .ic { width: 13px; height: 13px; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border: 1px solid var(--line); border-radius: 10px;
  background: rgba(255, 255, 255, 0.07); color: rgba(255, 255, 255, 0.94);
  font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.13); border-color: rgba(255, 255, 255, 0.2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn .ic { width: 16px; height: 16px; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1a1405; box-shadow: 0 4px 18px rgba(255, 200, 110, 0.22); }
.btn.gold:hover:not(:disabled) { background: #ffe4a8; border-color: #ffe4a8; }
.btn.big { min-height: 50px; padding: 0 26px; font-size: 16px; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.danger { color: #ffb3b8; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------------------------------------------------------------- pages */
.screen { max-width: 1120px; margin: 0 auto; padding: 28px 32px 56px; animation: rise 0.22s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen { animation: none; } }
.page-head { margin-bottom: 18px; }
.page-head h1 { margin: 4px 0 2px; font: 300 34px/1.15 var(--serif); letter-spacing: 0.01em; }
.page-head h1:focus { outline: none; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--faint); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: #fff; text-decoration: underline; }
.crumbs [aria-current] { color: var(--faint); }
.lead { color: var(--muted); margin: 4px 0 0; font-size: 15px; }
.muted { color: var(--faint); font-size: 13px; }
.kicker { margin: 0 0 10px; text-transform: uppercase; letter-spacing: 0.12em; font-size: 12px; color: var(--faint); font-weight: 650; }
.count { font-variant-numeric: tabular-nums; }
.block { margin-top: 30px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.block-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.block-head a { font-size: 14px; text-decoration: none; }
.block-head a:hover { text-decoration: underline; }
.panel { padding: 18px 20px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.panel h2 { margin: 0 0 8px; font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.panel h3 { margin: 16px 0 4px; font-size: 15px; }
.panel p { margin: 0 0 12px; color: var(--muted); }
.links { text-align: center; color: var(--faint); font-size: 14px; margin-top: 26px; }

/* hero */
.hero { display: flex; align-items: center; gap: 28px; padding: 18px 0 6px; }
.hero-aura { position: relative; width: 120px; height: 120px; flex: none; }
.hero-aura span, .hero-aura::before, .hero-aura::after { content: ""; position: absolute; inset: 0; border-radius: 50%; }
.hero-aura::before { background: radial-gradient(circle, rgba(140, 191, 255, 0.55), rgba(140, 191, 255, 0) 68%); animation: breathe 3.6s ease-in-out infinite; }
.hero-aura span { inset: 30%; background: radial-gradient(circle, rgba(191, 230, 255, 0.85), rgba(191, 230, 255, 0) 70%); }
.hero-aura::after { inset: 44%; background: #fff; box-shadow: 0 0 10px 2px #bfe6ff; }
.hero-aura.small { width: 72px; height: 72px; margin: 0 auto 6px; }
@keyframes breathe { 50% { transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .hero-aura::before { animation: none; } }
.title { margin: 0; font: 300 clamp(36px, 5vw, 54px)/1.1 var(--serif); letter-spacing: 0.02em; }
.tagline { margin: 6px 0 0; max-width: 34em; color: var(--muted); font-size: 16px; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 18px; }
.hint-line { margin: 0; color: var(--faint); font-size: 13px; }

/* cards */
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.cards.two { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.cards.narrow { max-width: 360px; margin-bottom: 8px; }
.card { display: flex; gap: 14px; align-items: center; min-width: 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: inherit; text-align: left; text-decoration: none; cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.15s; }
a.card:hover, button.card:hover:not(.is-locked) { background: var(--panel-hi); border-color: rgba(140, 217, 255, 0.35); transform: translateY(-1px); }
.card.is-locked { cursor: default; color: rgba(255, 255, 255, 0.62); }
.card.is-gold { background: rgba(255, 217, 140, 0.09); border-color: rgba(255, 217, 140, 0.22); }
.card-thumb { width: 76px; height: 76px; flex: none; border-radius: 10px; background: rgba(0, 0, 0, 0.3); padding: 4px; }
.card-thumb svg { width: 100%; height: 100%; display: block; }
.card-body { flex: 1; min-width: 0; display: grid; gap: 3px; }
.card-title { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 15px; }
.card-title > span:first-of-type { flex: 1; min-width: 0; }
.card-title .ic { color: var(--cyan); }
.card.is-gold .card-title .ic, .card.is-today .card-title .ic { color: var(--gold); }
.card.is-done .card-title .ic { color: var(--green); }
.card.is-locked .card-title .ic { color: var(--faint); }
.card-meta { display: inline-flex; align-items: center; }
.card-meta .ok { color: var(--green); width: 20px; height: 20px; }
.card-sub { font-size: 13px; color: var(--faint); }
.card-bar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; font-size: 12px; color: var(--faint); }
.card-bar > span:first-child:empty { display: none; }
.card-bar > span:first-child:empty + .meter { grid-column: 1 / 3; }
.pill-mini { font-size: 11px; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: rgba(255, 217, 140, 0.13); color: var(--gold); letter-spacing: 0.04em; }
.meter { display: block; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; min-width: 40px; }
.meter > span { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--cyan), var(--violet)); transition: width 0.3s; }
.daily-card .card-thumb { width: 88px; height: 88px; }
.resume-line { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; }

.banner-full { display: flex; align-items: center; gap: 24px; margin-top: 30px; padding: 20px 22px; border-radius: var(--radius); border: 1px solid rgba(255, 217, 140, 0.25); background: linear-gradient(120deg, rgba(255, 217, 140, 0.1), rgba(201, 166, 255, 0.08)); }
.banner-full div { flex: 1; }
.banner-full h2 { margin: 0 0 4px; font: 400 24px/1.2 var(--serif); color: var(--gold); }
.banner-full p { margin: 0; color: var(--muted); }

/* level grids */
.grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tile { position: relative; display: grid; gap: 6px; width: 100%; padding: 8px 8px 10px; border: 1px solid transparent; border-radius: var(--radius); background: var(--panel); color: inherit; text-align: left; text-decoration: none; cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.15s; }
a.tile:hover, button.tile:hover { background: var(--panel-hi); border-color: rgba(140, 217, 255, 0.35); transform: translateY(-2px); }
span.tile { cursor: default; }
.tile.is-locked { opacity: 0.55; }
.tile-thumb { display: block; aspect-ratio: 1; border-radius: 9px; background: rgba(0, 0, 0, 0.3); padding: 5px; }
.tile-thumb svg { width: 100%; height: 100%; display: block; }
.tile-name { font-size: 13px; font-weight: 600; line-height: 1.3; min-height: 2.6em; padding-right: 30px; }
.tile-num { color: var(--faint); font-weight: 500; margin-right: 6px; font-variant-numeric: tabular-nums; }
.tile-meta { position: absolute; right: 9px; bottom: 9px; color: var(--faint); }
.tile-meta .ok { color: var(--green); width: 20px; height: 20px; }
.tile-meta .ic { width: 15px; height: 15px; }
.tile.is-const:not(.is-done) .tile-name { color: var(--faint); font-weight: 500; }
.tile.is-const.is-done .tile-name { color: var(--gold); font-family: var(--serif); font-weight: 400; font-size: 14px; }
.reward { display: inline-flex; align-items: center; gap: 3px; color: var(--gold); font-size: 12px; font-weight: 650; }
.reward .ic { width: 11px; height: 11px; }

svg .tu { stroke: rgba(200, 215, 240, 0.55); stroke-width: 1.6; fill: none; stroke-linecap: round; }
svg .ts { stroke: #9cf2ff; stroke-width: 2; fill: none; stroke-linecap: round; }
svg .tf { stroke: var(--gold); stroke-width: 2.2; fill: none; stroke-linecap: round; }
svg .tn { fill: #bfe0ff; }
svg .tfn { fill: #fff3d6; }
svg .tst { fill: none; stroke: #fff; stroke-width: 1.6; opacity: 0.9; }

/* chapters */
.jump { position: sticky; top: 0; z-index: 2; display: flex; gap: 6px; overflow-x: auto; margin: 0 -32px 6px; padding: 10px 32px; scrollbar-width: none; }
.jump::-webkit-scrollbar { display: none; }
.jump-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(14, 16, 48, 0.94); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.jump-btn:hover { color: #fff; border-color: rgba(140, 217, 255, 0.4); }
.jump-btn .count { color: var(--faint); font-weight: 500; }
.jump-btn .ic { width: 12px; height: 12px; }
.jump-btn.is-locked { color: var(--faint); }
.chapter { margin: 26px 0 0; scroll-margin-top: 56px; }
.chapter-head h2 { margin: 0; font-size: 20px; font-weight: 600; }
.chapter-kicker { margin: 0 0 2px; text-transform: uppercase; letter-spacing: 0.12em; font-size: 12px; color: var(--faint); }
.chapter-tag { margin: 2px 0 12px; color: var(--muted); font-size: 14px; font-style: italic; }
.lock-note { display: flex; align-items: center; gap: 10px; width: 100%; margin: 0 0 12px; padding: 10px 14px; border: 1px solid rgba(255, 217, 140, 0.28); border-radius: 10px; background: rgba(255, 217, 140, 0.07); color: var(--gold); font-size: 14px; text-align: left; cursor: pointer; }
.lock-note:hover { background: rgba(255, 217, 140, 0.12); }
.lock-note span { flex: 1; }
.lock-note .ic { width: 16px; height: 16px; }
.lock-note.static { cursor: default; color: var(--muted); border-color: var(--line); background: rgba(255, 255, 255, 0.03); }

/* sky map */
.sky-habitat h2 { margin: 28px 0 12px; text-transform: uppercase; letter-spacing: 0.14em; font-size: 12px; color: var(--faint); font-weight: 650; }
.sky-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.sky-fig { display: grid; gap: 4px; text-align: center; }
.sky-art { display: block; aspect-ratio: 1; }
.sky-art svg { width: 100%; height: 100%; }
.sky-fig:not(.is-found) svg .tf { stroke: rgba(255, 255, 255, 0.13); stroke-width: 1.4; }
.sky-fig:not(.is-found) svg .tfn { fill: rgba(255, 255, 255, 0.22); }
.sky-fig.is-found svg { filter: drop-shadow(0 0 4px rgba(255, 210, 120, 0.5)); }
.sky-name { font-size: 12px; color: var(--faint); }
.sky-fig.is-found .sky-name { color: var(--gold); font-family: var(--serif); font-size: 14px; }

/* random picker */
.cards.tiers { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.custom { max-width: 520px; margin-top: 22px; }
.slider { display: grid; grid-template-columns: 120px 1fr 2.4em; align-items: center; gap: 12px; margin: 10px 0; }
.slider label { color: var(--muted); }
.slider input { width: 100%; accent-color: var(--gold); }
.slider output { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.custom .btn { margin-top: 8px; }

/* complete */
.complete { text-align: center; padding: 14vh 8px 0; }
.complete .hero-aura { margin: 0 auto 10px; }
.complete .tagline { font-style: italic; margin: 8px auto 0; }
.gold { color: var(--gold); display: inline-flex; gap: 6px; align-items: center; margin: 18px 0; font-weight: 600; }
.gold .ic { width: 16px; height: 16px; }

/* daily */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 16px; max-width: 640px; }
.stat { position: relative; display: grid; padding: 12px 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.stat strong { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--faint); }
.stat .ic { position: absolute; right: 12px; top: 12px; color: var(--gold); }
.share-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 14px; }
.archive { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.arch-day { display: grid; gap: 5px; padding: 8px 10px 10px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.arch-date { font-size: 12px; color: var(--faint); font-weight: 600; }
.arch-btn { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border: 0; border-radius: 7px; background: rgba(255, 255, 255, 0.05); color: var(--muted); font-size: 13px; text-decoration: none; text-align: left; cursor: pointer; }
.arch-btn:hover { background: rgba(255, 255, 255, 0.11); color: #fff; }
.arch-btn .ic { width: 14px; height: 14px; color: var(--cyan); }
.arch-btn.is-done .ic { color: var(--green); }
.arch-btn.is-locked .ic { color: var(--faint); }

/* full version + forms */
.full-page { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; }
.offer-panel { text-align: center; }
.offer-panel h2 { justify-content: center; font: 400 26px/1.2 var(--serif); }
.offer { list-style: none; margin: 8px 0 18px; padding: 0; display: grid; gap: 12px; text-align: left; }
.offer li { display: flex; gap: 12px; align-items: flex-start; }
.offer .ic { color: var(--gold); margin-top: 2px; }
.offer div { display: grid; }
.offer span { color: var(--faint); font-size: 13px; }
.fine { color: var(--muted); font-size: 13px; margin: 12px 0 0; }
.form { display: grid; gap: 6px; margin-top: 4px; }
.form label { font-weight: 600; font-size: 14px; }
.form-row { display: flex; flex-wrap: wrap; gap: 8px; }
.form-row input { min-width: 190px; }
.form input, select { flex: 1; min-width: 0; min-height: 40px; padding: 0 12px; border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 10px; background: rgba(0, 0, 0, 0.3); color: var(--ink); }
.form input#keyInput { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.06em; text-transform: uppercase; }
.form input::placeholder { color: rgba(255, 255, 255, 0.35); }
select { max-width: 240px; }
.form-msg { margin: 0; min-height: 1.2em; font-size: 13px; color: var(--green); }
.form-msg.is-err { color: #ffb3b8; }
.form-msg:empty { display: none; }
.recover { margin-top: 14px; }
.recover summary { cursor: pointer; color: var(--cyan); font-size: 14px; }
.recover .form { margin-top: 8px; }
.key-line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 6px 0 14px; }
.key-line code { padding: 6px 12px; border-radius: 8px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); }
.key-line.center { justify-content: center; }
.settings { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); align-items: start; }
.check { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--gold); margin: 0; }
.keys { border-collapse: collapse; font-size: 14px; }
.keys td { padding: 4px 14px 4px 0; vertical-align: middle; color: var(--muted); }
.keys td:first-child { white-space: nowrap; }

/* shop */
.shop { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.shop-left { position: sticky; top: 0; display: grid; gap: 12px; }
.shop-preview { position: relative; border-radius: var(--radius); overflow: hidden; background: #08080f; border: 1px solid var(--line); }
#shopCanvas { display: block; width: 100%; height: clamp(200px, 38vh, 340px); }
.shop-play { position: absolute; right: 10px; bottom: 10px; }
.shop-bar { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.shop-bar:empty { display: none; }
.shop-bar div { flex: 1; display: grid; min-width: 0; }
.shop-bar span { font-size: 13px; color: var(--faint); }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.tab { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.tab:hover { color: #fff; }
.tab.is-on { background: rgba(140, 217, 255, 0.15); border-color: rgba(140, 217, 255, 0.4); color: #fff; }
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px 10px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); text-align: left; cursor: pointer; }
.item:hover { background: var(--panel-hi); }
.item.is-sel { border-color: rgba(140, 217, 255, 0.6); background: rgba(140, 217, 255, 0.08); }
.swatch i { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: rgba(0, 0, 0, 0.35); color: var(--cyan); font-style: normal; }
.swatch i.glyph .ic { width: 20px; height: 20px; }
.item-name { flex: 1; font-weight: 600; font-size: 14px; }
.price { display: inline-flex; align-items: center; gap: 4px; color: var(--gold); font-weight: 650; font-variant-numeric: tabular-nums; }
.price .ic { width: 12px; height: 12px; }
.tag { font-size: 12px; color: var(--faint); display: inline-flex; gap: 4px; align-items: center; }
.tag.on { color: var(--green); }
.tag .ic { width: 15px; height: 15px; }

/* ---------------------------------------------------------------- modal + toast */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(3, 4, 16, 0.62); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal[hidden] { display: none; }
.modal-card { position: relative; width: min(460px, 100%); max-height: calc(100dvh - 32px); overflow: auto; padding: 24px 22px 20px; border-radius: 16px; background: #10133a; border: 1px solid var(--line); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5); text-align: center; }
.modal-card h2 { margin: 0 0 12px; font: 400 23px/1.25 var(--serif); }
.modal-x { position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--faint); cursor: pointer; }
.modal-x:hover { background: var(--panel-hi); color: #fff; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 16px; }
.modal-alt { margin: 12px 0 0; font-size: 14px; }
.modal-card .keys { margin: 0 auto; text-align: left; }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); z-index: 30; transform: translate(-50%, 10px); max-width: min(92vw, 460px); margin: 0; padding: 10px 16px; border-radius: 10px; background: #1b1f52; border: 1px solid rgba(255, 255, 255, 0.16); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); font-size: 14px; opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast[hidden] { display: none; }

/* ---------------------------------------------------------------- game */
#game { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; }
#game[hidden] { display: none; }
.stage-wrap { position: relative; min-width: 0; min-height: 0; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#stage:focus { outline: none; }
.hud-top { display: none; }
.hint, .banner {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 22px;
  width: max-content; max-width: min(92%, 540px); margin: 0; padding: 10px 16px; border-radius: 12px;
  background: rgba(20, 24, 66, 0.78); border: 1px solid var(--line); color: rgba(255, 255, 255, 0.92);
  font-size: 14px; text-align: center; pointer-events: none;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.hint[hidden], .banner[hidden] { display: none; }

.gpanel { display: flex; flex-direction: column; gap: 16px; min-height: 0; overflow-y: auto; padding: 20px 18px; background: var(--side-bg); border-left: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.gp-back { display: inline-flex; align-items: center; gap: 4px; margin-left: -4px; color: var(--muted); font-size: 13px; text-decoration: none; }
.gp-back:hover { color: #fff; }
.gp-back .ic { width: 15px; height: 15px; }
.gp-kicker { margin: 14px 0 2px; text-transform: uppercase; letter-spacing: 0.1em; font-size: 11px; color: var(--faint); font-weight: 650; }
.gp-title { margin: 0; font: 400 25px/1.2 var(--serif); }
.gp-remain { margin: 10px 0 6px; font-size: 15px; color: var(--ink); }
.gp-meter { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; font-size: 12px; color: var(--faint); }
.gp-controls { display: grid; gap: 6px; }
.ctl { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255, 255, 255, 0.05); color: rgba(255, 255, 255, 0.92); font-size: 14px; font-weight: 600; cursor: pointer; text-align: left; }
.ctl:hover:not(:disabled) { background: rgba(255, 255, 255, 0.11); }
.ctl:disabled { opacity: 0.4; cursor: default; }
.ctl span { flex: 1; }
.ctl[hidden] { display: none; }
.ctl-exit { display: none; }
.gp-foot { display: flex; gap: 6px; margin-top: auto; }
.gp-keys { display: grid; gap: 6px; margin: 0; padding: 12px 0 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--faint); }
.gp-keys div { display: flex; justify-content: space-between; gap: 8px; }
#game.is-won .gp-keys { display: none; }
@media (hover: none) { .gp-keys { display: none; } }

.win { padding: 16px; border-radius: var(--radius); text-align: center; background: rgba(255, 217, 140, 0.08); border: 1px solid rgba(255, 217, 140, 0.28); animation: winIn 0.4s ease-out; }
.win[hidden] { display: none; }
#game.is-won .gp-controls { display: none; }
@keyframes winIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .win { animation: none; } }
.win-kicker { margin: 0; text-transform: uppercase; letter-spacing: 0.12em; font-size: 12px; color: var(--faint); font-weight: 650; }
.win-figure { margin: 4px 0 0; font: 300 27px/1.2 var(--serif); color: var(--gold); }
.win-title { margin: 4px 0 0; font: 400 20px/1.25 var(--serif); }
.win-flavor { margin: 10px 0 0; font-style: italic; color: rgba(255, 255, 255, 0.86); font-size: 14px; }
.win-res { display: inline-flex; align-items: center; gap: 5px; margin: 12px 0 0; color: var(--gold); font-weight: 650; font-size: 14px; }
.win-res .ic { width: 14px; height: 14px; }
.win-time { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.win p:has(> .btn) { margin: 10px 0 0; }
.win-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.win-actions .btn { width: 100%; }
.win-actions .btn.gold { order: -1; }

/* ---------------------------------------------------------------- about (static, overview only) */
.about { position: relative; z-index: 1; }
.about-inner { max-width: 760px; margin: 0; padding: 0 0 40px; color: var(--muted); font-size: 15px; }
.about h2 { color: var(--ink); font-size: 19px; font-weight: 600; margin: 34px 0 8px; }
.about p { margin: 0 0 10px; }
.about ul { margin: 0 0 10px; padding-left: 20px; }
.about-foot { margin-top: 18px; font-size: 13px; color: var(--faint); }
.about[hidden] { display: none; }

/* ---------------------------------------------------------------- narrow screens: drawer menu, HUD over the stage */
@media (max-width: 899px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 15; top: 0; bottom: 0; left: 0; width: min(86vw, 300px); transform: translateX(-102%); transition: transform 0.22s ease-out; padding-top: var(--safe-t); background: rgba(7, 8, 30, 0.97); }
  body.nav-open .side { transform: none; }
  body.nav-open .side-scrim { display: block; position: fixed; inset: 0; z-index: 14; background: rgba(3, 4, 16, 0.55); }
  .main { display: flex; flex-direction: column; }
  .mtop { display: flex; align-items: center; gap: 10px; padding: calc(8px + var(--safe-t)) 12px 8px; background: rgba(7, 8, 30, 0.85); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); position: relative; z-index: 3; }
  .mtop .brand { flex: 1; padding: 0; font-size: 19px; }
  .mtop .tool { border: 0; }
  #view { position: relative; inset: auto; flex: 1; }
  body.in-game .mtop { display: none; }
  .screen { padding: 18px 16px calc(40px + var(--safe-b)); }
  .page-head h1 { font-size: 28px; }
  .jump { margin: 0 -16px 6px; padding: 10px 16px; }
  .hero { flex-direction: column; text-align: center; gap: 8px; padding-top: 8px; }
  .hero-aura { width: 96px; height: 96px; }
  .hero-actions { justify-content: center; flex-direction: column; }
  .hero-actions .btn { width: 100%; max-width: 360px; }
  .tagline { margin-left: auto; margin-right: auto; }
  .banner-full { flex-direction: column; align-items: stretch; text-align: center; }
  .full-page, .shop { grid-template-columns: minmax(0, 1fr); }
  .shop-left { position: static; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
  .cards.two, .cards { grid-template-columns: minmax(0, 1fr); }
  .cards.tiers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { gap: 8px; }
  .stat { padding: 10px; }
  .stat strong { font-size: 17px; }
  .stat .ic { display: none; }
  .slider { grid-template-columns: 96px 1fr 2.2em; }
  .settings { grid-template-columns: minmax(0, 1fr); }
  .about-inner { padding-top: 6px; }

  #game { position: absolute; inset: 0; display: block; }
  .stage-wrap { position: absolute; inset: 0; }
  .hud-top { display: grid; position: absolute; top: 0; left: 0; right: 0; justify-items: center; gap: 6px; padding: calc(12px + var(--safe-t)) 16px 0; pointer-events: none; text-align: center; }
  .hud-title { margin: 0; text-transform: uppercase; letter-spacing: 0.14em; font-size: 12px; color: var(--faint); font-weight: 650; }
  .hud-remain { margin: 0; padding: 6px 14px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); font-size: 14px; color: rgba(255, 255, 255, 0.9); }
  .gpanel { position: absolute; left: 0; right: 0; bottom: 0; display: block; padding: 0; overflow: visible; background: none; border: 0; backdrop-filter: none; -webkit-backdrop-filter: none; pointer-events: none; }
  .gp-info, .gp-foot, .gp-keys { display: none; }
  .gp-controls { display: flex; justify-content: center; gap: 10px; padding: 10px 12px calc(14px + var(--safe-b)); pointer-events: auto; }
  #game.is-won .gp-controls { display: flex; }
  .ctl { flex-direction: column; justify-content: center; gap: 2px; width: 68px; min-height: 58px; padding: 6px 4px; border: 0; background: rgba(255, 255, 255, 0.06); font-size: 11px; font-weight: 500; color: rgba(255, 255, 255, 0.86); text-align: center; }
  .ctl span { flex: none; }
  .ctl kbd { display: none; }
  .ctl-exit { display: flex; }
  .ctl[data-act="copy-link"] { display: none; }
  .win { position: absolute; left: 50%; bottom: calc(92px + var(--safe-b)); width: min(380px, calc(100vw - 32px)); transform: translateX(-50%); background: rgba(20, 24, 66, 0.82); border-color: var(--line); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); pointer-events: auto; animation: winInM 0.4s ease-out; }
  @keyframes winInM { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }
  .hint, .banner { bottom: calc(96px + var(--safe-b)); }
}
@media (max-width: 899px) and (max-height: 600px) {
  .ctl { min-height: 46px; }
  .ctl span { display: none; }
  .win { bottom: calc(70px + var(--safe-b)); padding: 10px 14px; }
  .hint, .banner { bottom: calc(72px + var(--safe-b)); }
}
@media (min-width: 900px) and (max-width: 1180px) {
  :root { --side-w: 220px; }
  #game { grid-template-columns: minmax(0, 1fr) 260px; }
  .screen { padding: 24px 24px 48px; }
  .jump { margin: 0 -24px 6px; padding: 10px 24px; }
}
@media (hover: none) { .ctl kbd, .gp-foot [data-act="help"] { display: none; } }
