:root {
  --bg: #0b0714;
  --panel: rgba(17, 12, 32, 0.9);
  --panel-solid: #150f27;
  --panel-2: #221a3b;
  --panel-3: #2d2350;
  --line: #3d3163;
  --text: #eef0ff;
  --muted: #aba5cb;
  --accent: #36e0d0;
  --accent-ink: #032a27;
  --xp: #7dff9a;
  --hp: #ff5d7a;
  --gold: #ffd76a;
  --violet: #b98cff;
  --good: #5fe08a;
  --bad: #ff4d6d;
  --radius: 12px;
  --header-h: 48px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--accent);
}

button {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

[hidden] {
  display: none !important;
}

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  font: 600 12px/18px ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
  background: var(--panel-2);
  color: var(--text);
}

/* Key hints only where a keyboard is the likely input. */
.keys {
  display: none;
}
@media (hover: hover) and (pointer: fine) {
  .keys {
    display: inline;
  }
  .touch-only {
    display: none;
  }
}

.site-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.site-header nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.page {
  padding: 8px 8px 40px;
}

/* ---------- Game frame ---------- */

.game-root {
  --hud-top: max(20px, calc(env(safe-area-inset-top, 0px) + 16px));
  --hud-left: max(24px, calc(env(safe-area-inset-left, 0px) + 16px));
  --hud-right: max(24px, calc(env(safe-area-inset-right, 0px) + 16px));
  position: relative;
  margin: 0 auto;
  width: 100%;
  max-width: calc((100vh - var(--header-h) - 24px) * 1.7778);
  max-width: calc((100dvh - var(--header-h) - 24px) * 1.7778);
  min-width: min(100%, 300px);
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 300px;
  overflow: hidden;
  container-type: size;
}

.stage > canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* Portrait screens (phones and tablets held upright): a tall frame. */
@media (orientation: portrait) {
  .game-root {
    max-width: none;
  }
  .stage {
    aspect-ratio: auto;
    height: calc(100vh - var(--header-h) - 20px);
    height: calc(100dvh - var(--header-h) - 20px);
    min-height: 440px;
  }
}

/* Phones on their side: the game takes the whole screen height. */
@media (orientation: landscape) and (max-height: 540px) {
  .page {
    padding: 0 0 32px;
  }
  .game-root {
    max-width: none;
    border: 0;
    border-radius: 0;
  }
  .stage {
    aspect-ratio: auto;
    height: calc(100vh - var(--header-h));
    height: calc(100dvh - var(--header-h));
    min-height: 260px;
  }
}

.game-root:fullscreen {
  max-width: none;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
}
.game-root:fullscreen .stage {
  aspect-ratio: auto;
  height: 100%;
  max-height: none;
  min-height: 0;
}
.game-root:-webkit-full-screen {
  max-width: none;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
}
.game-root:-webkit-full-screen .stage {
  aspect-ratio: auto;
  height: 100%;
  max-height: none;
  min-height: 0;
}

/* Keep the exit above menus, aligned with the HUD's action row. */
#game-root > .am-fs-exit {
  top: var(--hud-top);
}
.game-root:fullscreen .overlay {
  padding-top: calc(var(--hud-top) + 52px);
}
.game-root:-webkit-full-screen .overlay {
  padding-top: calc(var(--hud-top) + 52px);
}
@media (max-width: 760px) {
  #game-root > .am-fs-exit {
    left: var(--hud-left);
  }
}

/* ---------- HUD ---------- */

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.hud button {
  pointer-events: auto;
}

.xp {
  position: absolute;
  left: 0;
  right: 0;
  top: env(safe-area-inset-top, 0px);
  height: 14px;
  background: rgba(4, 2, 10, 0.72);
  border-bottom: 1px solid rgba(125, 255, 154, 0.25);
}
.xp .fill {
  height: 100%;
  width: 100%;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: linear-gradient(90deg, #36e0d0, #7dff9a);
  box-shadow: 0 0 10px rgba(125, 255, 154, 0.6);
}
.xp .lvl {
  position: absolute;
  right: var(--hud-right);
  top: 0;
  font: 800 11px/14px system-ui, sans-serif;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}

.hud-row {
  position: absolute;
  left: var(--hud-left);
  right: var(--hud-right);
  top: var(--hud-top);
  display: flex;
  align-items: center;
  gap: 8px;
}
.hud-stats,
.hud-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hud-actions {
  margin-left: auto;
  flex: none;
}

.hp,
.chip,
.hbtn {
  height: 30px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
}

.hp {
  position: relative;
  width: clamp(104px, 18cqw, 200px);
  overflow: hidden;
  padding: 0;
}
.hp .fill {
  position: absolute;
  inset: 0;
  transform-origin: 0 50%;
  background: linear-gradient(90deg, #d8284f, #ff6b86);
}
.hp span {
  position: relative;
  width: 100%;
  text-align: center;
  font-size: 13px;
  text-shadow: 0 1px 2px #000;
}
.hp.low {
  animation: lowhp 0.9s ease-in-out infinite;
}
@keyframes lowhp {
  50% {
    border-color: #ff4d6d;
    box-shadow: 0 0 12px rgba(255, 77, 109, 0.7);
  }
}

.chip {
  padding: 0 8px 0 6px;
}
.chip .ico svg,
.hbtn svg {
  width: 18px;
  height: 18px;
  display: block;
}
.chip.atp {
  color: #ffe14d;
}

.hbtn {
  width: 44px;
  height: 44px;
  flex: none;
  justify-content: center;
  padding: 0;
  color: var(--text);
}
.hbtn:hover {
  background: var(--panel-3);
}
.hbtn.off {
  color: var(--muted);
}

.timer {
  position: absolute;
  left: 50%;
  top: calc(var(--hud-top) + 52px);
  transform: translateX(-50%);
  padding: 2px 12px;
  border-radius: 8px;
  font: 900 24px/1.1 system-ui, sans-serif;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 4px #000, 0 0 12px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
}
.timer.boss {
  color: #ff8aa5;
}
.timer.goal {
  color: var(--gold);
}

.loadout {
  position: absolute;
  left: var(--hud-left);
  top: calc(var(--hud-top) + 52px);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.loadout .row {
  display: flex;
  gap: 4px;
}
.slot {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(17, 12, 32, 0.78);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}
.slot svg {
  width: 24px;
  height: 24px;
}
.slot.trait {
  width: 26px;
  height: 26px;
  border-radius: 6px;
}
.slot.trait svg {
  width: 18px;
  height: 18px;
}
.slot.matured {
  border-color: var(--gold);
  box-shadow: 0 0 8px rgba(255, 215, 106, 0.55);
}
.slot .pips {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 2px;
  display: flex;
  gap: 1px;
}
.slot .pips i {
  flex: 1;
  height: 3px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.18);
}
.slot .pips i.on {
  background: var(--xp);
}
.slot .lv {
  position: absolute;
  right: 1px;
  bottom: 0;
  font: 800 9px/1 system-ui, sans-serif;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}

#boss {
  position: absolute;
  left: 50%;
  bottom: max(24px, calc(env(safe-area-inset-bottom, 0px) + 16px));
  width: min(560px, 76%);
  transform: translateX(-50%);
  text-align: center;
}
.boss-name {
  font: 900 15px/1.2 system-ui, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffb0c2;
  text-shadow: 0 1px 3px #000;
}
.boss-bar {
  height: 12px;
  margin-top: 3px;
  border-radius: 6px;
  background: rgba(10, 4, 12, 0.8);
  border: 1px solid rgba(255, 120, 150, 0.5);
  overflow: hidden;
}
.boss-bar .fill {
  height: 100%;
  width: 100%;
  transform-origin: 0 50%;
  background: linear-gradient(90deg, #b3123d, #ff4d6d);
}
.boss-note {
  margin-top: 3px;
  font: 700 12px/1.2 system-ui, sans-serif;
  color: var(--muted);
  text-shadow: 0 1px 2px #000;
}
.boss.enraged .boss-bar {
  animation: enrage 0.6s ease-in-out infinite;
}
.boss.enraged .boss-note {
  color: #ff8aa5;
}
@keyframes enrage {
  50% {
    box-shadow: 0 0 14px rgba(255, 60, 100, 0.9);
  }
}

/* Touch stick */
.stick {
  position: absolute;
  width: 104px;
  height: 104px;
  margin: -52px 0 0 -52px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
  pointer-events: none;
}
.knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(220, 240, 255, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
}

/* Banner (big events) and toast (small notes) */
.banner {
  position: absolute;
  left: 50%;
  top: 24%;
  transform: translate(-50%, -8px);
  width: max-content;
  max-width: 92%;
  padding: 8px 18px;
  border-radius: 10px;
  background: rgba(10, 6, 20, 0.72);
  border: 1px solid var(--line);
  text-align: center;
  font: 900 clamp(16px, 3.4cqw, 26px) / 1.2 system-ui, sans-serif;
  text-shadow: 0 2px 4px #000;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.25s,
    transform 0.25s;
}
.banner.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.banner small {
  display: block;
  margin-top: 2px;
  font-size: 0.6em;
  font-weight: 700;
  color: var(--muted);
}
.banner.warn {
  border-color: #ff4d6d;
  color: #ffc2cf;
}
.banner.good {
  border-color: var(--gold);
  color: #fff3c4;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 18%;
  transform: translateX(-50%);
  max-width: 90%;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(10, 6, 20, 0.8);
  border: 1px solid var(--line);
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.toast.show {
  opacity: 1;
}
/* Messages wait behind level-up, booster and pause screens. */
.stage:has(.overlay.show) .banner,
.stage:has(.overlay.show) .toast {
  opacity: 0;
}

/* ---------- Overlay screens ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  padding: max(14px, calc(env(safe-area-inset-top, 0px) + 16px))
    max(14px, calc(env(safe-area-inset-right, 0px) + 16px))
    max(24px, calc(env(safe-area-inset-bottom, 0px) + 16px))
    max(14px, calc(env(safe-area-inset-left, 0px) + 16px));
  overflow: auto;
  overscroll-behavior: contain;
  background: rgba(7, 4, 14, 0.62);
}
.overlay.show {
  display: flex;
}
.overlay.clear {
  background: rgba(7, 4, 14, 0.38);
}
.overlay.dark {
  background: rgba(7, 4, 14, 0.86);
}

.panel {
  width: 100%;
  max-width: 760px;
  max-height: 100%;
  margin: auto;
  padding: 18px;
  overflow: auto;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.panel.narrow {
  max-width: 460px;
}
.panel.wide {
  max-width: 920px;
}
.panel h2 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 900;
}
.panel h3 {
  margin: 14px 0 6px;
  font-size: 15px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.panel p {
  margin: 6px 0;
  line-height: 1.4;
}
.muted {
  color: var(--muted);
}
.center {
  text-align: center;
}

.btn {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-weight: 800;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}
.btn:hover:not(:disabled) {
  background: var(--panel-3);
}
.btn:focus-visible,
.card:focus-visible,
.pick:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn.primary:hover:not(:disabled) {
  background: #5ff0e2;
}
.btn.danger {
  border-color: #7a2238;
  color: #ffc2cf;
}
.btn:disabled {
  opacity: 0.45;
}
.btn svg {
  width: 18px;
  height: 18px;
}
.btn small {
  font-weight: 600;
  color: inherit;
  opacity: 0.75;
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}
/* A panel's closing buttons stay in view while its content scrolls. */
.panel > .btn-row:last-child {
  position: sticky;
  bottom: -18px;
  z-index: 1;
  margin: 14px -18px -18px;
  padding: 10px 18px 14px;
  background: linear-gradient(rgba(19, 14, 36, 0), #130e24 14px);
}
.back {
  margin-top: 14px;
}

/* Menu */
.menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 520px;
  margin: auto;
  text-align: center;
  max-height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
}
.menu > * {
  flex: none;
}
.logo {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  font: 900 clamp(34px, 8cqw, 76px) / 0.95 system-ui, sans-serif;
  letter-spacing: 0.06em;
  color: #e9fffb;
  text-shadow:
    0 0 18px rgba(54, 224, 208, 0.65),
    0 4px 0 #0b3b37,
    0 6px 14px rgba(0, 0, 0, 0.7);
}
.logo .logo-top {
  font-size: 0.42em;
  letter-spacing: 0.42em;
  margin-right: -0.42em;
  color: #9ff3e8;
}
.tagline {
  margin: 0 0 4px;
  color: #cfe9ff;
  font-weight: 700;
  text-shadow: 0 1px 3px #000;
}
.menu-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: min(460px, 100%);
}
.menu-buttons .wide {
  grid-column: 1 / -1;
}
.menu-note {
  font-size: 13px;
  color: var(--muted);
  text-shadow: 0 1px 2px #000;
}
[data-act='daily'] {
  flex-direction: column;
  gap: 0;
}
.daily-line {
  display: block;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.8;
}

/* Setup: pick cell, organ and Fever */
.picks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.pick {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--panel-2);
  text-align: center;
  font-size: 13px;
}
.pick canvas {
  width: 64px;
  height: 64px;
}
.pick b {
  font-size: 15px;
}
.pick .perk {
  color: var(--muted);
  line-height: 1.3;
}
.pick.on {
  border-color: var(--accent);
  background: #173a44;
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.pick.locked {
  opacity: 0.6;
  cursor: default;
}
.pick .lock {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--gold);
  font-size: 12px;
  line-height: 1.3;
}
.pick .lock svg {
  flex: none;
  width: 14px;
  height: 14px;
}
.fever-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}
.fever-row .btn {
  min-width: 44px;
  padding: 6px 10px;
}
.fever-row .btn.on {
  background: #4a1d2a;
  border-color: #ff7a8f;
  color: #ffd2da;
}
.fever-desc {
  min-height: 2.6em;
  font-size: 13px;
}

/* Level-up cards */
.levelup {
  width: 100%;
  max-width: 900px;
  margin: auto;
  text-align: center;
  max-height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
}
.levelup > .btn-row {
  position: sticky;
  bottom: 0;
  padding: 8px 0;
  background: var(--panel-solid);
}
.levelup h2 {
  margin: 0;
  font: 900 clamp(22px, 4.5cqw, 34px) / 1.1 system-ui, sans-serif;
  color: var(--xp);
  text-shadow: 0 0 14px rgba(125, 255, 154, 0.6), 0 2px 3px #000;
}
.levelup .sub {
  margin: 2px 0 10px;
  color: var(--muted);
  font-size: 13px;
  text-shadow: 0 1px 2px #000;
}
.cards {
  display: grid;
  grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr));
  gap: 10px;
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-height: 150px;
  padding: 12px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: linear-gradient(180deg, #241b40, #16102a);
  text-align: left;
  transition:
    transform 0.12s,
    border-color 0.12s;
}
.card:hover,
.card.sel {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.card .top {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.card .ico {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
}
.card .ico svg {
  width: 36px;
  height: 36px;
}
.card .name {
  font-weight: 900;
  font-size: 16px;
  line-height: 1.15;
}
.card .tag {
  display: inline-block;
  margin-top: 2px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: rgba(54, 224, 208, 0.16);
  color: var(--accent);
}
.card .tag.new {
  background: rgba(125, 255, 154, 0.16);
  color: var(--xp);
}
.card .desc {
  font-size: 14px;
  line-height: 1.35;
  color: #dcdcf5;
}
.card .pair {
  margin-top: auto;
  font-size: 12px;
  color: var(--muted);
}
.card .num {
  position: absolute;
  right: 8px;
  top: 6px;
}
.card.mature {
  border-color: var(--gold);
  background: linear-gradient(180deg, #3d3014, #1d160a);
  box-shadow: 0 0 18px rgba(255, 215, 106, 0.35);
}
.card.mature .tag {
  background: rgba(255, 215, 106, 0.2);
  color: var(--gold);
}
.card.banishing {
  border-style: dashed;
  border-color: #ff7a8f;
}
.card:disabled {
  opacity: 0.45;
  transform: none;
}
.levelup .btn-row .btn {
  min-width: 120px;
}
.btn.on {
  border-color: #ff7a8f;
  background: #4a1d2a;
}

/* Booster capsule */
.booster .items {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 10px 0 4px;
}
.booster .item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-weight: 800;
  font-size: 14px;
  opacity: 0;
  transform: scale(0.6);
  transition:
    opacity 0.2s,
    transform 0.25s cubic-bezier(0.3, 1.6, 0.6, 1);
}
.booster .item.show {
  opacity: 1;
  transform: none;
}
.booster .item svg {
  width: 28px;
  height: 28px;
}
.booster .item small {
  display: block;
  font-weight: 600;
  color: var(--muted);
}
.booster .item.mature {
  border-color: var(--gold);
}
.booster h2.jackpot {
  color: var(--gold);
  text-shadow: 0 0 16px rgba(255, 215, 106, 0.7);
}

/* Results */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0;
}
.stat {
  padding: 8px;
  border-radius: 10px;
  background: var(--panel-2);
  text-align: center;
}
.stat b {
  display: block;
  font-size: 22px;
  font-weight: 900;
}
.stat span {
  font-size: 12px;
  color: var(--muted);
}
.pay {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.pay td {
  padding: 3px 0;
}
.pay td:last-child {
  text-align: right;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.pay tr.total td {
  border-top: 1px solid var(--line);
  padding-top: 6px;
  color: #ffe14d;
  font-size: 16px;
}
.dmg-row {
  display: grid;
  grid-template-columns: 22px minmax(90px, 1fr) 2fr 56px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin: 3px 0;
}
.dmg-row svg {
  width: 20px;
  height: 20px;
}
.dmg-row .bar {
  height: 8px;
  border-radius: 4px;
  background: var(--panel-3);
  overflow: hidden;
}
.dmg-row .bar i {
  display: block;
  height: 100%;
  background: var(--accent);
}
.dmg-row .v {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.note {
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--panel-2);
  font-size: 14px;
  line-height: 1.35;
}
.note.gold {
  border: 1px solid rgba(255, 215, 106, 0.5);
  color: #fff3c4;
}
.note.near {
  border: 1px solid rgba(255, 138, 165, 0.5);
  color: #ffd2da;
}
.ach-got {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.ach-got svg {
  flex: none;
  width: 20px;
  height: 20px;
  color: var(--gold);
}

/* Immune Memory, achievements, codex lists */
.list {
  display: grid;
  gap: 6px;
}
.row-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--panel-2);
}
.row-item b {
  font-size: 15px;
}
.row-item .desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.3;
}
.row-item .btn {
  min-height: 44px;
  min-width: 96px;
  padding: 6px 10px;
  font-size: 14px;
}
.lvlpips {
  display: inline-flex;
  gap: 3px;
  margin-left: 6px;
  vertical-align: middle;
}
.lvlpips i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--panel-3);
  border: 1px solid var(--line);
}
.lvlpips i.on {
  background: var(--accent);
  border-color: var(--accent);
}
.balance {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 900;
  font-size: 18px;
  color: #ffe14d;
}
.balance svg {
  width: 22px;
  height: 22px;
}
.head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.row-item.done {
  border: 1px solid rgba(255, 215, 106, 0.35);
}
.row-item .state {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}
.row-item.done .state {
  color: var(--gold);
}
.row-item .state svg {
  width: 16px;
  height: 16px;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 10px;
}
.tabs .btn {
  min-height: 44px;
  padding: 4px 12px;
  font-size: 14px;
}
.tabs .btn.on {
  border-color: var(--accent);
  background: #173a44;
}
.codex {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
}
.entry {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  background: var(--panel-2);
  font-size: 13px;
  line-height: 1.35;
}
.entry canvas,
.entry .ico {
  width: 56px;
  height: 56px;
}
.entry .ico svg {
  width: 44px;
  height: 44px;
  margin: 6px;
}
.entry b {
  display: block;
  font-size: 15px;
}
.entry .meta {
  color: var(--muted);
  font-size: 12px;
}
.entry.unknown {
  opacity: 0.55;
}
.entry .fact {
  margin-top: 3px;
}

.toggles {
  display: grid;
  gap: 8px;
}
.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-weight: 700;
  text-align: left;
}
.toggle .sw {
  flex: none;
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--panel-3);
  border: 1px solid var(--line);
}
.toggle .sw::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s;
}
.toggle[aria-pressed='true'] .sw {
  background: #145e57;
  border-color: var(--accent);
}
.toggle[aria-pressed='true'] .sw::after {
  transform: translateX(20px);
  background: var(--accent);
}

.help ul {
  margin: 6px 0;
  padding-left: 20px;
  line-height: 1.45;
}
.help li {
  margin: 4px 0;
}

.loadout-list {
  display: grid;
  gap: 6px;
  text-align: left;
}
.loadout-list .li {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  line-height: 1.3;
}
.loadout-list svg {
  width: 26px;
  height: 26px;
}
.loadout-list .muted {
  font-size: 12px;
}

/* ---------- Small frames ---------- */

@container (max-width: 700px) {
  .cards {
    grid-template-columns: 1fr;
  }
  .card {
    min-height: 0;
    padding: 9px 10px;
  }
  .card .desc {
    font-size: 13px;
  }
  .stats {
    grid-template-columns: repeat(3, 1fr);
  }
  .stat b {
    font-size: 18px;
  }
  .panel {
    padding: 14px;
  }
  .panel > .btn-row:last-child {
    bottom: -14px;
    margin: 12px -14px -14px;
    padding: 10px 14px 12px;
  }
}

/* Narrow frames split actions and counters; the exit owns the top left. */
@container (max-width: 760px) {
  .hud-row {
    flex-direction: column;
    align-items: stretch;
  }
  .hud-actions {
    order: -1;
  }
  .hud-stats {
    width: 100%;
  }
  .hp {
    flex: 1;
    min-width: 64px;
    max-width: 160px;
  }
  .timer,
  .loadout {
    top: calc(var(--hud-top) + 90px);
  }
  .timer {
    left: auto;
    right: var(--hud-right);
    transform: none;
  }
  .timer.daily {
    /* The goal text is longer: place it beside the smaller trait row. */
    top: calc(var(--hud-top) + 128px);
    font-size: 18px;
    padding-inline: 4px;
  }
}

@container (max-width: 480px) {
  .chip,
  .hp {
    font-size: 13px;
  }
  .timer {
    font-size: 20px;
  }
  .slot {
    width: 28px;
    height: 28px;
  }
  .slot svg {
    width: 20px;
    height: 20px;
  }
  .slot.trait {
    width: 22px;
    height: 22px;
  }
  .slot.trait svg {
    width: 15px;
    height: 15px;
  }
  .picks {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
  .menu-buttons .half {
    grid-column: auto;
  }
  .dmg-row {
    grid-template-columns: 20px minmax(80px, 1fr) 1fr 48px;
  }
}

/* Short frames: phones on their side */
@container (max-height: 460px) {
  .panel {
    padding: 10px 12px;
  }
  .panel h2 {
    font-size: 20px;
  }
  .cards {
    grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr));
  }
  .card {
    min-height: 0;
    padding: 8px;
    gap: 3px;
  }
  .card .ico {
    width: 34px;
    height: 34px;
  }
  .card .ico svg {
    width: 28px;
    height: 28px;
  }
  .card .name {
    font-size: 14px;
  }
  .card .desc {
    font-size: 13px;
  }
  .card .pair {
    display: none;
  }
  .levelup .sub {
    margin-bottom: 6px;
  }
  .levelup .btn-row {
    margin-top: 8px;
  }
  .levelup .btn-row .btn {
    min-width: 96px;
  }
  .logo {
    font-size: 34px;
  }
  .menu {
    gap: 6px;
  }
  .menu-buttons {
    grid-template-columns: 1fr 1fr 1fr;
    width: min(640px, 100%);
  }
  .menu-buttons .wide:not([data-act='play']):not([data-act='continue']) {
    grid-column: auto;
  }
  .tagline {
    display: none;
  }
  .panel > .btn-row:last-child {
    bottom: -10px;
    margin: 10px -12px -10px;
    padding: 8px 12px 10px;
  }
  .menu-buttons .btn {
    padding: 4px 8px;
    font-size: 14px;
  }
  .timer {
    font-size: 18px;
  }
}

/* ---------- About ---------- */

.about {
  max-width: 820px;
  margin: 26px auto 0;
  padding: 0 8px;
  line-height: 1.55;
}
.about h1 {
  font-size: 28px;
  margin: 0 0 8px;
}
.about h2 {
  font-size: 20px;
  margin: 22px 0 6px;
}
.about li {
  margin: 6px 0;
}

.ad-slot {
  max-width: 970px;
  margin: 12px auto 0;
}
