/* Tiny Fish Grows — one living ocean under frosted-glass panels.
   The ocean looks the same in both themes; the themes switch the panels,
   cards, menus and the page around them. */

:root {
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ca-accent: #0b7285;
  --accent: #0b7285;
  --accent-ink: #ffffff;
  --coral: #ff7a4d;
  --coral-deep: #c8432a;
  --food: #33b46f;
  --danger: #e2442a;
  --gentle: #7d82e8;
  --page: #e8f7fa;
  --ink: #0c2a3c;
  --muted: #4a6677;
  --line: rgba(12, 42, 60, 0.12);
  --glass: rgba(246, 252, 255, 0.74);
  --glass-strong: rgba(250, 254, 255, 0.9);
  --glass-edge: rgba(255, 255, 255, 0.75);
  --chip: rgba(12, 42, 60, 0.06);
  --shadow: 0 18px 50px rgba(3, 30, 52, 0.22), 0 2px 6px rgba(3, 30, 52, 0.08);
  --focus: #0b7285;
  --r: 20px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --accent: #44d3dc;
  --accent-ink: #062027;
  --page: #0b1a2c;
  --ink: #e8f6fb;
  --muted: #a2bccb;
  --line: rgba(160, 220, 255, 0.14);
  --glass: rgba(10, 26, 44, 0.7);
  --glass-strong: rgba(12, 30, 50, 0.92);
  --glass-edge: rgba(150, 220, 255, 0.16);
  --chip: rgba(160, 220, 255, 0.08);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
  --focus: #6fe6ee;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--page);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}
button, input, select { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 12px; }

.ocean {
  position: fixed; inset: 0; width: 100vw; height: 100dvh; display: block;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  background: #1e90c8;
}
.ocean.play { cursor: crosshair; }
body.playing .ocean { cursor: crosshair; }

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow);
  border-radius: var(--r);
}

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--glass-strong); color: var(--ink); font-weight: 700; font-size: 16px; cursor: pointer;
  transition: transform 0.16s var(--ease), background 0.2s, box-shadow 0.2s, opacity 0.2s;
  touch-action: manipulation;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: 0 8px 22px rgba(11, 114, 133, 0.35); }
.btn.ghost { background: transparent; }
.btn.big { min-height: 56px; font-size: 18px; padding: 0 26px; border-radius: 18px; }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--glass-strong); color: var(--ink); cursor: pointer;
  transition: transform 0.16s var(--ease), background 0.2s;
  touch-action: manipulation;
}
.icon-btn:hover { transform: translateY(-1px); }
.icon-btn:active { transform: scale(0.94); }

.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--chip); border: 1px solid var(--line); flex-wrap: wrap; }
.seg button {
  min-height: 38px; min-width: 44px; padding: 0 12px; border-radius: 10px; border: 0; background: transparent;
  font-weight: 700; font-size: 14px; color: var(--muted); cursor: pointer; transition: background 0.2s, color 0.2s;
}
.seg button[aria-checked="true"], .seg button[aria-selected="true"] { background: var(--glass-strong); color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }
.seg.small button { min-height: 34px; min-width: 40px; font-size: 13px; padding: 0 10px; }

/* ---------------------------------------------------------------- screens */
.screen { position: fixed; inset: 0; z-index: 2; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
.brand img { border-radius: 11px; box-shadow: 0 4px 12px rgba(3, 30, 52, 0.25); }
.brand b { font-size: 18px; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; }
.brand small { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand span { min-width: 0; }
.brand span b { display: block; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 480px) { .bar .nav .icon-btn { display: none; } }

/* landing */
.landing { overflow-y: auto; overscroll-behavior: contain; padding: calc(var(--sat) + 10px) calc(var(--sar) + 14px) calc(var(--sab) + 24px) calc(var(--sal) + 14px); scroll-behavior: smooth; }
.landing > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.land-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 18px; background: var(--glass); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border: 1px solid var(--glass-edge); }
.land-tools { display: flex; gap: 8px; align-items: center; }
.land-tools .seg { flex-wrap: nowrap; }
.land-tools .seg button { min-width: 38px; padding: 0 7px; }
@media (max-width: 420px) { .land-bar .brand b { display: none; } }
.hero { min-height: calc(100dvh - 120px); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 8px 30px; pointer-events: none; }
.hero > * { pointer-events: auto; position: relative; }
.hero::before { content: ""; position: absolute; left: 50%; top: 50%; width: min(120vw, 900px); height: 70%; transform: translate(-50%, -50%); background: radial-gradient(closest-side, rgba(4, 44, 74, 0.32), rgba(4, 44, 74, 0)); pointer-events: none; }
.hero { position: relative; }
.hero h1 {
  margin: 0; font-size: clamp(44px, 12vw, 84px); line-height: 0.95; font-weight: 900; letter-spacing: -0.03em; color: #ffffff;
  text-shadow: 0 2px 0 rgba(8, 60, 90, 0.25), 0 10px 40px rgba(4, 50, 80, 0.45);
}
.hero .promise { margin: 18px auto 26px; max-width: 30ch; font-size: clamp(17px, 4.6vw, 21px); line-height: 1.4; font-weight: 700; color: #ffffff; text-shadow: 0 2px 18px rgba(4, 50, 80, 0.55); }
.hero-hint { margin: 16px 0 0; font-size: 14px; font-weight: 700; color: rgba(255, 255, 255, 0.92); text-shadow: 0 1px 8px rgba(4, 50, 80, 0.6); pointer-events: none; }
.land-cards { display: grid; gap: 12px; grid-template-columns: 1fr; margin-bottom: 14px; }
.card3 { padding: 18px; display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; align-items: center; }
.card3 .ic { grid-row: span 2; width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; }
.card3 .ic canvas { width: 52px; height: 39px; border-radius: 10px; }
.card3 .ic.food { background: rgba(51, 180, 111, 0.16); color: #1d8a52; box-shadow: inset 0 0 0 2px rgba(51, 180, 111, 0.55); }
.card3 .ic.danger { background: rgba(226, 68, 42, 0.14); color: #c23a22; box-shadow: inset 0 0 0 2px rgba(226, 68, 42, 0.5); }
.card3 .ic.grow { background: rgba(255, 122, 77, 0.16); color: #c8432a; box-shadow: inset 0 0 0 2px rgba(255, 122, 77, 0.5); }
:root[data-theme="dark"] .card3 .ic.food { color: #6fe0a0; }
:root[data-theme="dark"] .card3 .ic.danger { color: #ff8a70; }
:root[data-theme="dark"] .card3 .ic.grow { color: #ffa47f; }
.card3 h2 { margin: 0; font-size: 17px; font-weight: 800; }
.card3 p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.4; font-weight: 600; }
.land-turn, .land-codex, .land-join { padding: 18px; margin-bottom: 14px; }
.land-turn { display: grid; gap: 14px; align-items: center; }
.land-turn h2, .land-codex h2 { margin: 0 0 6px; font-size: 20px; font-weight: 800; }
.land-turn p, .land-codex p, .land-join p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.45; font-weight: 600; }
.turn-canvas { width: 100%; aspect-ratio: 2.2 / 1; border-radius: 14px; display: block; background: #1e90c8; }
.codex-teaser { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.land-join { text-align: center; display: grid; gap: 14px; justify-items: center; }
.land-join p { max-width: 46ch; }
.offline-note { color: var(--danger) !important; }
.land-foot { text-align: center; padding: 10px; font-size: 13px; font-weight: 700; color: rgba(255, 255, 255, 0.85); text-shadow: 0 1px 6px rgba(4, 50, 80, 0.6); }

/* menu */
.menu { display: flex; flex-direction: column; padding: calc(var(--sat) + 10px) calc(var(--sar) + 12px) calc(var(--sab) + 12px) calc(var(--sal) + 12px); pointer-events: none; }
.menu > * { pointer-events: auto; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 8px 8px 10px; border-radius: 18px; background: var(--glass); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border: 1px solid var(--glass-edge); box-shadow: 0 6px 22px rgba(3, 30, 52, 0.12); }
.nav { display: flex; gap: 8px; align-items: center; flex: none; }
.account-chip { display: flex; align-items: center; min-width: 44px; min-height: 44px; }
.menu-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; pointer-events: none; }
.menu-center > * { pointer-events: auto; }
.btn.play {
  min-height: 74px; min-width: 210px; padding: 0 40px; font-size: 26px; font-weight: 900; border-radius: 26px; border: 0; color: #fff;
  background: linear-gradient(180deg, #ff8a5c, #e2552f 60%, #c8432a); box-shadow: 0 14px 34px rgba(200, 67, 42, 0.42), inset 0 2px 0 rgba(255, 255, 255, 0.35);
  text-shadow: 0 1px 2px rgba(110, 30, 10, 0.4); letter-spacing: 0.01em;
}
.btn.play svg { width: 28px; height: 28px; }
.btn.play:hover { transform: translateY(-2px) scale(1.02); }
.menu-continue { margin: -10px 0 0; font-size: 14px; font-weight: 700; color: #fff; text-shadow: 0 1px 8px rgba(4, 50, 80, 0.7); }
.menu-icons { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; max-width: 560px; }
.tile-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: 94px; min-height: 84px; padding: 10px 6px;
  border-radius: 18px; border: 1px solid var(--glass-edge); background: var(--glass); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  color: var(--ink); font-weight: 800; font-size: 13px; line-height: 1.15; cursor: pointer; box-shadow: 0 8px 22px rgba(3, 30, 52, 0.16);
  transition: transform 0.18s var(--spring), background 0.2s; text-align: center;
}
.tile-btn svg { width: 26px; height: 26px; color: var(--accent); }
.tile-btn:hover { transform: translateY(-3px); }
.tile-btn:active { transform: scale(0.95); }
.menu-foot { display: flex; justify-content: center; gap: 28px; padding: 10px 20px; margin: 0 auto; border-radius: 16px; }
.menu-foot span { display: flex; flex-direction: column; align-items: center; }
.menu-foot small { font-size: 12px; font-weight: 700; color: var(--muted); }
.menu-foot b { font-size: 20px; font-weight: 900; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------- HUD */
.hud { position: fixed; inset: 0; z-index: 3; pointer-events: none; color: #fff; font-weight: 800; }
.hud > * { position: absolute; }
.hud-time {
  top: calc(var(--sat) + 12px); left: calc(var(--sal) + 14px); font-size: 26px; font-variant-numeric: tabular-nums; letter-spacing: 0.01em;
  text-shadow: 0 2px 10px rgba(0, 20, 40, 0.55); padding: 4px 12px; border-radius: 12px; background: rgba(4, 24, 44, 0.24);
}
.hud-size { top: calc(var(--sat) + 10px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 5px 14px 7px; border-radius: 14px; background: rgba(4, 24, 44, 0.26); }
.hud-size b { font-size: 20px; text-shadow: 0 2px 10px rgba(0, 20, 40, 0.55); font-variant-numeric: tabular-nums; transition: transform 0.25s var(--spring); }
.hud-size b.pop { transform: scale(1.25); }
.growbar { width: min(34vw, 180px); height: 8px; border-radius: 6px; background: rgba(4, 24, 44, 0.38); overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); }
.growbar i { display: block; height: 100%; width: 100%; transform-origin: left; transform: scaleX(0); background: linear-gradient(90deg, #ffd27a, #ff8a5c); border-radius: 6px; }
.pearls { display: flex; gap: 4px; height: 9px; }
.pearls i { width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, 0.18); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35); transition: transform 0.25s var(--spring), background 0.2s; }
.pearls i.on { background: radial-gradient(circle at 35% 35%, #ffffff, #ffe6a8 45%, #ffb35c); transform: scale(1.15); box-shadow: 0 0 8px rgba(255, 220, 140, 0.8); }
.hud-pause { top: calc(var(--sat) + 10px); right: calc(var(--sar) + 12px); pointer-events: auto; background: rgba(4, 24, 44, 0.3); border-color: rgba(255, 255, 255, 0.28); color: #fff; }
.depth { top: calc(var(--sat) + 70px); right: calc(var(--sar) + 18px); width: 8px; bottom: calc(var(--sab) + 120px); border-radius: 6px; overflow: visible; display: flex; flex-direction: column; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.3); }
.depth .z { flex: 1; display: block; }
.depth .z1 { background: linear-gradient(#3fd0d4, #1e90c8); border-radius: 6px 6px 0 0; }
.depth .z2 { background: linear-gradient(#1d6fa8, #16407a); }
.depth .z3 { background: linear-gradient(#0f2a55, #0a1530); }
.depth .z4 { background: linear-gradient(#081129, #050a1a); border-radius: 0 0 6px 6px; }
.depth b { position: absolute; left: -7px; top: 0; width: 22px; height: 6px; margin-top: -3px; border-radius: 4px; background: #fff; box-shadow: 0 0 8px rgba(255, 255, 255, 0.9), 0 0 0 1px rgba(0, 20, 40, 0.4); transform: translateY(0); }
.stamina { bottom: calc(var(--sab) + 22px); left: 50%; width: min(46vw, 240px); height: 10px; margin-left: calc(min(46vw, 240px) / -2); border-radius: 8px; background: rgba(4, 24, 44, 0.38); overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3); }
.stamina i { display: block; height: 100%; width: 100%; transform-origin: left; background: linear-gradient(90deg, #5ff0e0, #a6fff4); border-radius: 8px; transition: background 0.3s; }
.stamina.locked i { background: linear-gradient(90deg, #8aa3b5, #b8c8d4); }
.stamina.boosting i { background: linear-gradient(90deg, #ffe27a, #fff3c4); }
.key-hint { bottom: calc(var(--sab) + 40px); left: 50%; transform: translateX(-50%); }
.key-hint kbd { display: inline-block; padding: 6px 16px; border-radius: 10px; background: rgba(255, 255, 255, 0.9); color: #0c2a3c; font: 800 14px var(--font); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); animation: nudge 0.9s var(--ease) infinite alternate; }
.boost-btn {
  bottom: calc(var(--sab) + 26px); right: calc(var(--sar) + 22px); width: 72px; height: 72px; border-radius: 50%; border: 0; padding: 0; pointer-events: auto;
  background: radial-gradient(circle at 40% 35%, rgba(255, 255, 255, 0.4), rgba(4, 24, 44, 0.35)); color: #fff; display: grid; place-items: center;
  touch-action: none; -webkit-user-select: none; user-select: none; box-shadow: 0 6px 18px rgba(0, 20, 40, 0.3); transition: transform 0.12s var(--ease);
}
.boost-btn.left { right: auto; left: calc(var(--sal) + 22px); }
.boost-btn.held { transform: scale(0.92); }
.boost-btn .ring { position: absolute; inset: 0; width: 72px; height: 72px; transform: rotate(-90deg); }
.boost-btn .ring circle { fill: none; stroke-width: 5; }
.boost-btn .ring .track { stroke: rgba(255, 255, 255, 0.2); }
.boost-btn .ring .fill { stroke: #7ff6ec; stroke-dasharray: 194.8; stroke-dashoffset: 0; stroke-linecap: round; }
.boost-btn.locked .ring .fill { stroke: #9fb3c2; }
.boost-btn .glyph { width: 30px; height: 30px; }
.boost-btn.pulse, .key-hint.pulse kbd { animation: pulse 0.8s var(--ease) infinite; }
body:not(.touch) .boost-btn { display: none; }
.zone-banner {
  top: 26%; left: 50%; transform: translate(-50%, 10px); opacity: 0; font-size: clamp(24px, 6vw, 40px); font-weight: 900; letter-spacing: 0.02em;
  text-shadow: 0 2px 20px rgba(0, 20, 40, 0.7); transition: opacity 0.5s var(--ease), transform 0.6s var(--ease); white-space: nowrap; text-align: center;
}
.zone-banner small { display: block; font-size: 14px; font-weight: 700; opacity: 0.85; letter-spacing: 0.08em; text-transform: uppercase; }
.zone-banner.show { opacity: 1; transform: translate(-50%, 0); }
.card-pop {
  top: calc(var(--sat) + 64px); left: calc(var(--sal) + 14px); display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 14px;
  background: rgba(4, 24, 44, 0.5); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); font-size: 14px;
  opacity: 0; transform: translateX(-12px); transition: opacity 0.35s var(--ease), transform 0.45s var(--spring);
}
.card-pop canvas { width: 48px; height: 36px; border-radius: 8px; }
.card-pop small { display: block; font-size: 11px; opacity: 0.8; letter-spacing: 0.06em; text-transform: uppercase; }
.card-pop.show { opacity: 1; transform: none; }

@keyframes pulse { 0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(127, 246, 236, 0.7); } 50% { transform: scale(1.1); box-shadow: 0 0 0 14px rgba(127, 246, 236, 0); } }
@keyframes nudge { from { transform: translateY(0); } to { transform: translateY(-4px); } }

/* --------------------------------------------------------------- pause */
.pause-panel {
  position: fixed; z-index: 6; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(92vw, 380px); padding: 22px; display: grid; gap: 12px;
  animation: rise 0.32s var(--ease);
}
.pause-panel h2 { margin: 0 0 4px; text-align: center; font-size: 24px; font-weight: 900; }
.pause-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pause-row .btn { padding: 0 10px; font-size: 15px; }
.btn.confirm { background: var(--danger); color: #fff; border-color: transparent; }
.countdown { position: fixed; z-index: 6; left: 50%; top: 50%; width: 120px; height: 120px; margin: -60px 0 0 -60px; pointer-events: none; }
.countdown svg { width: 120px; height: 120px; transform: rotate(-90deg); }
.countdown circle { fill: none; stroke-width: 7; }
.countdown .track { stroke: rgba(255, 255, 255, 0.25); }
.countdown .fill { stroke: #ffffff; stroke-linecap: round; stroke-dasharray: 276.5; stroke-dashoffset: 0; filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.8)); }

/* --------------------------------------------------------------- results */
.results {
  position: fixed; z-index: 6; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(94vw, 460px); max-height: calc(100dvh - var(--sat) - var(--sab) - 24px);
  display: flex; flex-direction: column; overflow: hidden; animation: rise 0.42s var(--spring);
}
.res-body { padding: 22px 20px 8px; overflow-y: auto; overscroll-behavior: contain; text-align: center; }
.res-kicker { margin: 0; font-size: 14px; font-weight: 800; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.res-time { margin: 2px 0 0; font-size: 64px; line-height: 1.05; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.res-best { display: inline-flex; align-items: center; gap: 6px; margin: 8px 0 0; padding: 6px 14px; border-radius: 999px; background: linear-gradient(90deg, #ffd27a, #ff9a5c); color: #4a1a06; font-weight: 900; animation: pop 0.5s var(--spring); }
.res-best svg { width: 18px; height: 18px; }
.res-rank { margin: 8px 0 0; font-weight: 800; color: var(--accent); }
.res-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 16px 0 6px; }
.res-grid div { padding: 10px; border-radius: 14px; background: var(--chip); border: 1px solid var(--line); }
.res-grid small { display: block; font-size: 12px; font-weight: 700; color: var(--muted); }
.res-grid b { font-size: 19px; font-weight: 900; font-variant-numeric: tabular-nums; }
.res-killer { display: flex; align-items: center; gap: 12px; margin: 10px 0; padding: 8px; border-radius: 16px; background: var(--chip); border: 1px solid var(--line); text-align: left; }
.res-killer canvas { width: 84px; height: 63px; border-radius: 12px; flex: none; }
.res-killer small { display: block; font-size: 12px; font-weight: 700; color: var(--muted); }
.res-killer b { font-size: 17px; font-weight: 900; }
.res-new { margin: 10px 0; text-align: left; }
.res-new h3, .friends h3 { margin: 12px 0 8px; font-size: 14px; font-weight: 800; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--chip); border: 1px solid var(--line); font-weight: 800; font-size: 13.5px; animation: pop 0.45s var(--spring) both; }
.chip canvas { width: 32px; height: 24px; border-radius: 999px; }
.chip svg { width: 18px; height: 18px; margin-left: 4px; color: var(--accent); }
.friends { text-align: left; }
.friends-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.friends-board { min-height: 60px; }
.res-actions { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 12px 16px calc(14px + 0px); border-top: 1px solid var(--line); background: var(--glass-strong); }
.btn.again { font-size: clamp(16px, 5vw, 20px); white-space: nowrap; padding: 0 14px; }
.res-actions .btn { white-space: nowrap; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, calc(-50% + 24px)) scale(0.97); } to { opacity: 1; transform: translate(-50%, -50%); } }
@keyframes pop { from { opacity: 0; transform: scale(0.7); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- sheets */
.backdrop { position: fixed; inset: 0; z-index: 7; background: rgba(2, 16, 30, 0.42); animation: fade 0.25s var(--ease); }
.sheet {
  position: fixed; z-index: 8; left: 50%; bottom: 0; width: min(100vw, 680px); max-height: min(92dvh, 860px); transform: translateX(-50%);
  display: flex; flex-direction: column; background: var(--glass-strong); -webkit-backdrop-filter: blur(22px) saturate(1.4); backdrop-filter: blur(22px) saturate(1.4);
  border: 1px solid var(--glass-edge); border-bottom: 0; border-radius: 24px 24px 0 0; box-shadow: var(--shadow); animation: sheet 0.36s var(--ease);
  padding-bottom: var(--sab);
}
.sheet.narrow { width: min(100vw, 480px); z-index: 9; }
.sheet:focus { outline: none; }
.sheet > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 14px 8px 20px; }
.sheet > header h2 { margin: 0; font-size: 22px; font-weight: 900; }
.sheet-tabs { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 8px; align-items: center; justify-content: space-between; }
.sheet-body { padding: 4px 20px 22px; overflow-y: auto; overscroll-behavior: contain; }
@keyframes sheet { from { transform: translate(-50%, 40px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 760px) and (min-height: 560px) {
  .sheet { bottom: auto; top: 50%; transform: translate(-50%, -50%); border-radius: 24px; border-bottom: 1px solid var(--glass-edge); padding-bottom: 0; animation: sheetc 0.36s var(--ease); }
  @keyframes sheetc { from { transform: translate(-50%, calc(-50% + 30px)); opacity: 0; } to { transform: translate(-50%, -50%); opacity: 1; } }
}
.sheet h3 { margin: 18px 0 8px; font-size: 14px; font-weight: 800; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.prose p, .prose li { font-size: 15.5px; line-height: 1.5; font-weight: 600; }
.prose ul { padding-left: 20px; margin: 6px 0; }
.prose li { margin: 4px 0; }
.legend { display: grid; gap: 8px; margin: 8px 0; }
.legend div { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 14px; background: var(--chip); }
.legend canvas { width: 72px; height: 54px; border-radius: 10px; flex: none; }
.legend b { display: block; font-size: 15px; color: var(--ink); }
.legend span { font-size: 13.5px; color: var(--muted); font-weight: 600; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; font-weight: 600; font-size: 14.5px; }
.keys kbd { justify-self: start; padding: 3px 8px; border-radius: 8px; background: var(--chip); border: 1px solid var(--line); font: 800 13px var(--font); white-space: nowrap; }

/* codex */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.card {
  position: relative; display: flex; flex-direction: column; gap: 6px; padding: 6px 6px 8px; border-radius: 16px; border: 1px solid var(--line); background: var(--chip);
  cursor: pointer; text-align: center; font-weight: 800; font-size: 13px; line-height: 1.15; color: var(--ink); transition: transform 0.18s var(--spring), box-shadow 0.2s;
  content-visibility: auto; contain-intrinsic-size: 120px;
}
.card canvas { width: 100%; aspect-ratio: 4 / 3; border-radius: 11px; display: block; }
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(3, 30, 52, 0.18); }
.card.locked { color: var(--muted); }
.card.selected { box-shadow: 0 0 0 3px var(--accent); }
.count { font-weight: 800; color: var(--muted); margin: 0 0 10px; font-size: 14px; }
.detail canvas { width: 100%; aspect-ratio: 4 / 3; border-radius: 18px; display: block; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.facts div { padding: 8px; border-radius: 12px; background: var(--chip); text-align: center; }
.facts small { display: block; font-size: 11.5px; color: var(--muted); font-weight: 700; }
.facts b { font-size: 14.5px; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.badge { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 14px; background: var(--chip); border: 1px solid var(--line); }
.badge .medal { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; background: radial-gradient(circle at 35% 30%, #fff3c4, #ffc94a 55%, #d98a12); color: #5a3206; box-shadow: 0 3px 8px rgba(160, 90, 10, 0.35); }
.badge.locked .medal { background: var(--chip); color: var(--muted); box-shadow: inset 0 0 0 2px var(--line); }
.badge b { display: block; font-size: 13.5px; line-height: 1.2; }
.badge small { font-size: 12px; color: var(--muted); font-weight: 700; }

/* stats and boards */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.tile { padding: 12px; border-radius: 14px; background: var(--chip); border: 1px solid var(--line); }
.tile small { display: block; font-size: 12.5px; color: var(--muted); font-weight: 700; }
.tile b { font-size: 21px; font-weight: 900; font-variant-numeric: tabular-nums; }
table.recent { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.recent th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 800; padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.recent td { padding: 7px 4px; border-bottom: 1px solid var(--line); font-weight: 600; }
table.recent .num { text-align: right; }
.empty { color: var(--muted); font-weight: 700; text-align: center; padding: 18px 0; }
.note { color: var(--muted); font-size: 13.5px; font-weight: 600; line-height: 1.45; }
.mine { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--chip); border: 1px solid var(--line); margin: 8px 0 4px; font-weight: 800; }

/* settings */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 6px 0; }
.set-row > span { font-weight: 700; }
.toggle { display: flex; align-items: center; gap: 12px; min-height: 48px; cursor: pointer; font-weight: 700; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle .track { width: 50px; height: 30px; border-radius: 999px; background: var(--line); position: relative; transition: background 0.2s; flex: none; }
.toggle .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25); transition: transform 0.22s var(--spring); }
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(20px); }
.toggle input:focus-visible + .track { outline: 3px solid var(--focus); outline-offset: 2px; }
.about { display: grid; gap: 10px; }
.about .btn { justify-self: start; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* toast */
.toast {
  position: fixed; z-index: 10; left: 50%; bottom: calc(var(--sab) + 100px); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 16px; border-radius: 14px; background: var(--glass-strong); color: var(--ink); font-weight: 800; box-shadow: var(--shadow);
  transition: opacity 0.3s var(--ease), transform 0.4s var(--spring); max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------ responsive */
@media (min-width: 640px) {
  .land-cards { grid-template-columns: repeat(3, 1fr); }
  .card3 { grid-template-columns: 1fr; text-align: center; justify-items: center; gap: 10px; padding: 22px 16px; }
  .card3 .ic { grid-row: auto; }
  .land-turn { grid-template-columns: 1.15fr 1fr; }
  .codex-teaser { grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 380px) {
  .brand small { display: none; }
  .tile-btn { width: 84px; min-height: 78px; font-size: 12px; }
  .menu-icons { gap: 8px; }
  .hud-time { font-size: 22px; }
  .hud-size b { font-size: 17px; }
  .res-time { font-size: 52px; }
  .btn.play { min-width: 180px; font-size: 23px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .menu-center { flex-direction: row; flex-wrap: wrap; gap: 14px; align-content: center; }
  .tile-btn { width: 80px; min-height: 70px; }
  .menu-icons { max-width: 440px; }
  .hero { min-height: calc(100dvh - 70px); }
  .depth { top: calc(var(--sat) + 60px); bottom: calc(var(--sab) + 90px); }
  .results { width: min(96vw, 680px); }
  .res-grid { grid-template-columns: repeat(4, 1fr); }
  .res-time { font-size: 48px; }
}
@media (hover: hover) {
  .card:focus-visible, .tile-btn:focus-visible { outline-offset: 3px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.12s !important; }
}
:root.reduced *, :root.reduced *::before, :root.reduced *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.12s !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) { color-scheme: dark; }
}
.hud { transition: opacity 0.5s var(--ease); }
.hud.fading { opacity: 0; }
