/* Nightlight — storybook night. Warm lantern gold against cold blue-violet ink. */
:root {
  --ink: #0b0a1f;
  --panel: rgba(22, 16, 46, 0.94);
  --panel2: rgba(40, 30, 82, 0.94);
  --gold: #ffd27a;
  --amber: #ffab4a;
  --ember: #ff7a2f;
  --cream: #fff3d6;
  --text: #f3ecff;
  --muted: #b8aed8;
  --violet: #8a74d8;
  --line: rgba(255, 210, 122, 0.3);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --round: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: var(--round);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
body { position: fixed; inset: 0; }
#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; touch-action: manipulation; cursor: pointer; }
button:focus { outline: none; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ---------- screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: calc(var(--sat) + 14px) calc(var(--sar) + 16px) calc(var(--sab) + 14px) calc(var(--sal) + 16px);
  text-align: center;
}
.overlay {
  background: radial-gradient(ellipse at 50% 38%, rgba(26, 18, 60, 0.62), rgba(5, 3, 14, 0.9) 75%);
  animation: fadeIn 0.22s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

h2 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 700;
  margin: 0;
  color: var(--gold);
  text-shadow: 0 0 22px rgba(255, 180, 80, 0.55), 0 2px 0 rgba(0, 0, 0, 0.5);
}

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(54, 40, 104, 0.95), rgba(26, 19, 56, 0.95));
  color: var(--cream);
  font-weight: 700;
  font-size: 16px;
  min-height: 48px;
  padding: 10px 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; }
.btn.primary {
  background: linear-gradient(180deg, #ffe3a0, #ffae52 60%, #f08a34);
  color: #2b1405;
  border-color: #ffe9b8;
  box-shadow: 0 0 34px rgba(255, 170, 70, 0.5), 0 8px 24px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  text-shadow: 0 1px 0 rgba(255, 240, 200, 0.6);
}
.btn.big { font-size: 22px; min-width: 230px; min-height: 58px; border-radius: 20px; letter-spacing: 0.3px; }
.btn.mid { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 150px; line-height: 1.15; }
.btn.mid small { font-weight: 600; font-size: 12px; color: var(--muted); margin-top: 3px; }
.btn.small { font-size: 14px; min-height: 44px; padding: 8px 16px; }
.btn.ghost { background: transparent; box-shadow: none; border-color: rgba(255, 255, 255, 0.12); color: var(--muted); }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(18, 12, 40, 0.6);
  display: grid;
  place-items: center;
  color: var(--cream);
  font-size: 20px;
}
.icon-btn.muted .note { opacity: 0.35; text-decoration: line-through; }
.top-right { display: flex; align-items: center; gap: 8px; }
.board-btn { min-height: 44px; padding: 6px 12px; }
.res-lb { max-width: min(92vw, 420px); }
.pause-btn {
  position: fixed;
  z-index: 8;
  top: calc(var(--sat) + 24px);
  right: calc(var(--sar) + 8px);
}
.pause-btn .bars { width: 14px; height: 16px; border-left: 4px solid var(--cream); border-right: 4px solid var(--cream); }

/* ---------- title ---------- */
.title { justify-content: flex-start; gap: 10px; }
.topbar { width: 100%; max-width: 560px; display: flex; justify-content: space-between; align-items: center; }
.back { color: var(--muted); text-decoration: none; font-weight: 700; font-size: 15px; padding: 12px 6px; min-height: 44px; display: inline-flex; align-items: center; }
.logo { margin-top: 2px; }
.logo h1 {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 700;
  font-size: clamp(50px, 15vw, 84px);
  line-height: 1;
  letter-spacing: 0.5px;
  color: #ffe2a0;
  text-shadow: 0 0 18px rgba(255, 190, 90, 0.75), 0 0 48px rgba(255, 140, 60, 0.45), 0 3px 0 rgba(40, 20, 0, 0.6);
}
.logo .tag {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #c9bdf0;
  text-shadow: 0 0 12px rgba(120, 100, 220, 0.6);
}
.spacer { flex: 1 1 auto; min-height: 120px; }
.hero-pick { display: flex; align-items: center; gap: 8px; }
.arrow {
  width: 44px; height: 64px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(18, 12, 40, 0.55); color: var(--cream); font-size: 30px; line-height: 1;
}
.hero-card {
  display: flex; align-items: center; gap: 10px; min-width: 250px; max-width: 300px; padding: 6px 14px 6px 6px;
  border-radius: 18px; background: rgba(16, 11, 36, 0.72); border: 1px solid rgba(255, 210, 122, 0.2); text-align: left;
}
.hero-card canvas { width: 60px; height: 60px; flex: none; }
.hero-text { display: flex; flex-direction: column; gap: 1px; }
.hero-text b { font-size: 17px; color: var(--cream); }
.hero-weapon { font-size: 13px; color: var(--gold); font-weight: 700; }
.hero-perk { font-size: 12px; color: var(--muted); }
.hero-card.locked canvas { filter: brightness(0.15); }
.hero-card.locked .hero-weapon { color: #ff9d7a; }
.depth-row { display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 700; }
.depth-row b { color: #ff9d7a; font-size: 20px; min-width: 18px; }
.mini { width: 44px; height: 40px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.14); background: rgba(18, 12, 40, 0.6); font-size: 20px; }
.best-info { margin: 0; min-height: 18px; color: var(--muted); font-size: 13px; font-weight: 600; }
.howto { display: flex; gap: 8px; justify-content: center; margin-top: 2px; }
.how { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 78px; font-size: 11px; line-height: 1.2; color: var(--muted); font-weight: 600; }
.how canvas { width: 40px; height: 40px; }

/* ---------- level up ---------- */
.levelup { gap: 10px; }
.lv-title { font-size: 40px; }
.lv-sub { margin: -6px 0 4px; color: var(--muted); font-weight: 600; font-size: 14px; letter-spacing: 1px; text-transform: uppercase; }
.cards { display: flex; flex-direction: column; gap: 10px; width: min(94vw, 440px); }
.card {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  min-height: 86px;
  border-radius: 18px;
  text-align: left;
  border: 1.5px solid rgba(255, 210, 122, 0.25);
  background: linear-gradient(180deg, rgba(50, 38, 98, 0.97), rgba(24, 17, 52, 0.97));
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
  animation: cardIn 0.32s cubic-bezier(0.2, 1.4, 0.4, 1) both;
  transition: transform 0.08s ease, border-color 0.15s ease;
}
.card:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3) { animation-delay: 0.1s; }
.card:nth-child(4) { animation-delay: 0.15s; }
@keyframes cardIn { from { opacity: 0; transform: translateY(26px) scale(0.94); } to { opacity: 1; transform: none; } }
.card canvas { width: 60px; height: 60px; }
.card .ctext { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.card .cname { font-weight: 800; font-size: 18px; color: var(--cream); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card .tag { font-size: 11px; font-weight: 800; letter-spacing: 0.8px; padding: 2px 7px; border-radius: 99px; background: rgba(255, 255, 255, 0.1); color: var(--muted); }
.card .tag.new { background: var(--gold); color: #2b1405; }
.card .cdesc { font-size: 14px; color: #d8cff2; line-height: 1.3; }
.card .ckey { font-size: 11px; color: rgba(255, 255, 255, 0.3); font-weight: 700; }
.card.sel { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255, 210, 122, 0.35), 0 10px 26px rgba(0, 0, 0, 0.45); }
.card:active { transform: scale(0.97); }
.card.evo {
  border-color: #ffe08a;
  background: linear-gradient(120deg, rgba(90, 60, 140, 0.98), rgba(150, 90, 60, 0.98), rgba(70, 50, 130, 0.98));
  background-size: 200% 200%;
  animation: cardIn 0.32s cubic-bezier(0.2, 1.4, 0.4, 1) both, shimmer 2.4s ease-in-out infinite;
  box-shadow: 0 0 30px rgba(255, 200, 100, 0.45), 0 10px 26px rgba(0, 0, 0, 0.45);
}
.card.evo .tag { background: linear-gradient(90deg, #ffe08a, #ff9ad5); color: #2b1405; }
@keyframes shimmer { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.lv-actions { margin-top: 4px; }

/* ---------- chest ---------- */
.chest h2 { font-size: 38px; }
.chest .reel-stage { position: relative; display: grid; place-items: center; width: 220px; height: 150px; }
.chest .rays {
  position: absolute; inset: -40px; border-radius: 50%; pointer-events: none;
  background: repeating-conic-gradient(from 0deg, rgba(255, 214, 130, 0.28) 0deg 8deg, rgba(255, 214, 130, 0) 8deg 22deg);
  -webkit-mask-image: radial-gradient(circle, #000 20%, transparent 68%);
  mask-image: radial-gradient(circle, #000 20%, transparent 68%);
  animation: spin 9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.reel-wrap {
  position: relative;
  width: 96px; height: 96px; overflow: hidden; border-radius: 22px; border: 2px solid #ffe08a;
  background: radial-gradient(circle, rgba(255, 210, 122, 0.25), rgba(20, 12, 40, 0.95));
  box-shadow: 0 0 40px rgba(255, 190, 90, 0.55);
}
.reel { display: flex; flex-direction: column; will-change: transform; }
.reel canvas { width: 96px; height: 96px; flex: none; padding: 12px; }
.chest-items { display: flex; flex-direction: column; gap: 6px; min-height: 40px; width: min(92vw, 380px); }
.chest-item {
  display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-radius: 14px; background: var(--panel2);
  border: 1px solid var(--line); text-align: left; font-weight: 700; animation: cardIn 0.3s ease-out both;
}
.chest-item canvas { width: 36px; height: 36px; }
.chest-item small { display: block; color: var(--muted); font-weight: 600; }
.chest-embers { margin: 0; color: #ffb36b; font-weight: 800; min-height: 20px; }

/* ---------- pause ---------- */
.pause h2 { font-size: 40px; }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: min(92vw, 380px); }
.toggle {
  min-height: 46px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.14); background: rgba(18, 12, 40, 0.7);
  color: var(--muted); font-weight: 700; font-size: 14px;
}
.toggle[aria-pressed="true"] { color: #2b1405; background: linear-gradient(180deg, #ffe3a0, #ffb35a); border-color: #ffe9b8; }
.build { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: min(92vw, 420px); }
.build canvas { width: 38px; height: 38px; }
.build.small canvas { width: 30px; height: 30px; }
.build.small .slot i { font-size: 10px; }
.build .slot { position: relative; }
.build .slot i { position: absolute; right: -2px; bottom: -3px; font-style: normal; font-size: 11px; font-weight: 800; background: #1a1233; border: 1px solid var(--line); border-radius: 8px; padding: 0 4px; color: var(--gold); }

/* ---------- results ---------- */
.results { gap: 10px; }
.results.win { background: radial-gradient(ellipse at 50% -10%, rgba(255, 196, 120, 0.55), rgba(120, 60, 60, 0.55) 45%, rgba(24, 12, 24, 0.9) 85%); }
.results.win .kicker { color: #fff0d0; }
.results .row .btn.mid { min-width: 140px; }
.pill.heroes canvas { margin-right: -6px; }
.goal { margin: 2px 0 0; font-size: 14px; font-weight: 700; color: #c9bdf0; }
.goal::before { content: '✦ '; color: var(--gold); }
.kicker { margin: 0; font-family: var(--serif); font-style: italic; font-size: 20px; color: #c9bdf0; }
.res-time { font-size: 68px; line-height: 1; font-family: var(--round); font-style: normal; font-weight: 800; }
.results.win .res-time { color: #fff0b8; }
.res-best { margin: 0; min-height: 22px; font-weight: 800; color: var(--gold); letter-spacing: 0.5px; }
.res-best.new { animation: pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1) both; color: #ffe08a; text-shadow: 0 0 18px rgba(255, 200, 90, 0.8); }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: none; opacity: 1; } }
.stats { display: flex; gap: 10px; }
.stats div { min-width: 92px; padding: 8px 10px; border-radius: 14px; background: var(--panel); border: 1px solid rgba(255, 255, 255, 0.08); }
.stats b { display: block; font-size: 22px; color: var(--cream); }
.stats span { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; }
.news { display: flex; flex-direction: column; gap: 6px; align-items: center; max-width: min(92vw, 420px); }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 99px; font-weight: 700; font-size: 14px;
  background: rgba(255, 210, 122, 0.12); border: 1px solid var(--line); color: var(--cream); animation: cardIn 0.35s ease-out both;
}
.pill canvas { width: 26px; height: 26px; }

/* ---------- campfire ---------- */
.camp {
  justify-content: flex-start;
  background: radial-gradient(ellipse at 50% 115%, rgba(255, 120, 40, 0.42), rgba(60, 20, 30, 0.25) 35%, rgba(8, 6, 20, 0.97) 70%), var(--ink);
}
.embers-pill { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 99px; background: rgba(255, 122, 47, 0.14); border: 1px solid rgba(255, 150, 70, 0.4); font-size: 18px; color: #ffcf9a; }
.ember-ico { width: 12px; height: 16px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: radial-gradient(circle at 50% 65%, #fff2b0, #ff9a3c 45%, #c2381a); display: inline-block; box-shadow: 0 0 10px rgba(255, 130, 40, 0.8); }
.camp-title { font-size: 34px; }
.camp-head { display: flex; align-items: center; gap: 6px; margin-top: -6px; }
.camp-head canvas { width: 60px; height: 60px; }
.up-row { grid-template-columns: 44px 1fr auto !important; }
.up-row canvas { width: 44px; height: 44px; }
.tabs { display: flex; gap: 5px; flex-wrap: nowrap; justify-content: center; }
.tab { min-height: 44px; padding: 6px 12px; font-size: 15px; border-radius: 99px; border: 1px solid rgba(255, 255, 255, 0.12); background: rgba(18, 12, 40, 0.7); color: var(--muted); font-weight: 700; }
.tab.on { background: linear-gradient(180deg, #ffe3a0, #ffb35a); color: #2b1405; border-color: #ffe9b8; }
.camp-list {
  width: min(94vw, 560px);
  flex: 1 1 auto;
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 2px 20px;
}
.up-row {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; text-align: left; padding: 10px 12px;
  border-radius: 16px; background: var(--panel); border: 1px solid rgba(255, 255, 255, 0.08);
}
.up-row b { font-size: 16px; color: var(--cream); }
.up-row p { margin: 2px 0 6px; font-size: 13px; color: var(--muted); }
.pips { display: flex; gap: 4px; }
.pips i { width: 16px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); }
.pips i.on { background: linear-gradient(90deg, #ffb35a, #ffe08a); box-shadow: 0 0 6px rgba(255, 180, 80, 0.7); }
.buy { min-width: 86px; min-height: 44px; border-radius: 14px; border: 1px solid rgba(255, 150, 70, 0.5); background: rgba(255, 122, 47, 0.16); color: #ffcf9a; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 6px; }
.buy:disabled { opacity: 0.4; }
.buy.max { border-color: rgba(255, 255, 255, 0.12); background: transparent; color: var(--muted); }
.hero-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.hero-tile {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px; border-radius: 16px; background: var(--panel);
  border: 1.5px solid rgba(255, 255, 255, 0.08); min-height: 150px;
}
.hero-tile canvas { width: 64px; height: 64px; }
.hero-tile b { font-size: 15px; }
.hero-tile span { font-size: 12px; color: var(--muted); line-height: 1.25; }
.hero-tile .hw { color: var(--gold); font-weight: 700; }
.hero-tile.sel { border-color: var(--gold); box-shadow: 0 0 18px rgba(255, 200, 90, 0.35); }
.hero-tile.locked canvas { filter: brightness(0.12); }
.hero-tile.locked .hw { color: #ff9d7a; }
.sec-h { margin: 8px 0 2px; font-family: var(--serif); font-style: italic; color: var(--gold); font-size: 18px; text-align: left; }
.codex-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: var(--panel); text-align: left; }
.codex-row canvas { width: 44px; height: 44px; flex: none; }
.codex-row.unknown canvas { filter: brightness(0.1) saturate(0); }
.codex-row b { display: block; color: var(--cream); }
.codex-row span { font-size: 13px; color: var(--muted); }
.feat { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 14px; background: var(--panel); text-align: left; }
.feat .chk { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.2); flex: none; display: grid; place-items: center; font-size: 14px; }
.feat.done .chk { background: var(--gold); border-color: var(--gold); color: #2b1405; }
.feat b { display: block; color: var(--cream); font-size: 15px; }
.feat span { font-size: 13px; color: var(--muted); }
.feat em { margin-left: auto; font-style: normal; color: #ffb36b; font-weight: 800; font-size: 13px; white-space: nowrap; }

/* ---------- banner / toast / hint ---------- */
.banner {
  position: fixed; z-index: 9; left: 0; right: 0; top: 24%; text-align: center; pointer-events: none; opacity: 0;
  font-family: var(--serif); font-style: italic; font-weight: 700; font-size: clamp(24px, 7vw, 38px); color: #ffe2a0;
  text-shadow: 0 0 20px rgba(255, 170, 70, 0.8), 0 2px 0 rgba(0, 0, 0, 0.6); padding: 0 20px;
}
.banner.show { animation: banner 2.8s ease-in-out both; }
.banner.cold { color: #e6dcff; text-shadow: 0 0 20px rgba(150, 120, 255, 0.85), 0 2px 0 rgba(0, 0, 0, 0.6); }
.banner.dawn { color: #fffaf0; font-size: clamp(40px, 13vw, 64px); text-shadow: 0 0 30px rgba(255, 160, 60, 0.9), 0 3px 14px rgba(110, 40, 0, 0.75), 0 2px 0 rgba(90, 40, 0, 0.6); }
@keyframes banner { 0% { opacity: 0; transform: scale(0.9); } 12% { opacity: 1; transform: none; } 78% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }
.toast {
  position: fixed; z-index: 30; left: 50%; bottom: calc(var(--sab) + 70px); transform: translateX(-50%); pointer-events: none; opacity: 0;
  max-width: min(90vw, 420px); padding: 10px 16px; border-radius: 14px; background: rgba(20, 14, 44, 0.92); border: 1px solid var(--line);
  color: var(--cream); font-weight: 700; font-size: 14px; text-align: center;
}
.toast.show { animation: toast 3.2s ease-in-out both; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 10px); } 10% { opacity: 1; transform: translate(-50%, 0); } 85% { opacity: 1; } 100% { opacity: 0; } }
.hint {
  position: fixed; z-index: 7; left: 50%; bottom: calc(var(--sab) + 110px); transform: translateX(-50%); pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--cream); font-weight: 700; font-size: 16px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8); animation: fadeIn 0.6s ease-out both;
}
.hint .finger { width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(255, 243, 214, 0.8); background: rgba(255, 243, 214, 0.25); animation: finger 1.6s ease-in-out infinite; }
@keyframes finger { 0%, 100% { transform: translateX(-40px); } 50% { transform: translateX(40px); } }
.debug {
  position: fixed; z-index: 50; left: calc(var(--sal) + 6px); bottom: calc(var(--sab) + 6px); pointer-events: none;
  font: 600 11px/1.3 ui-monospace, Menlo, monospace; color: #b8ffb8; background: rgba(0, 0, 0, 0.55); padding: 4px 6px; border-radius: 6px;
  white-space: pre; max-width: 94vw; overflow: hidden;
}

/* ---------- wide screens ---------- */
@media (min-width: 860px) and (min-aspect-ratio: 1/1) {
  .cards { flex-direction: row; width: min(96vw, 980px); justify-content: center; }
  .card { grid-template-columns: 1fr; justify-items: center; text-align: center; width: 220px; min-height: 230px; padding: 18px 14px; align-content: start; }
  .card canvas { width: 72px; height: 72px; }
  .card .cname { justify-content: center; }
  .card .ctext { align-items: center; }
}
@media (max-height: 740px) {
  .results .build { display: none; }
  .res-time { font-size: 56px; }
}
@media (max-height: 700px) {
  .howto { display: none; }
  .logo h1 { font-size: 54px; }
  .spacer { min-height: 60px; }
}
@media (max-height: 560px) {
  .title { gap: 6px; }
  .logo .tag { display: none; }
  .card { min-height: 64px; padding: 8px 12px; }
  .card canvas { width: 44px; height: 44px; }
  .card .cdesc { font-size: 13px; }
  .lv-title { font-size: 30px; }
  .res-time { font-size: 48px; }
}
/* Short landscape phones: logo + hero on the left, choices on the right. */
@media (orientation: landscape) and (max-height: 520px) {
  .title {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto 1fr auto auto auto;
    column-gap: 18px;
    row-gap: 8px;
    align-items: center;
    justify-items: center;
  }
  .title .topbar { grid-column: 1 / -1; grid-row: 1; max-width: none; }
  .title .logo { grid-column: 1; grid-row: 2; }
  .title .logo h1 { font-size: 46px; }
  .title .logo .tag { font-size: 13px; letter-spacing: 3px; }
  .title .spacer { grid-column: 1; grid-row: 3 / 7; align-self: stretch; justify-self: stretch; min-height: 0; }
  .title .hero-pick { grid-column: 2; grid-row: 2 / 4; align-self: end; }
  .title #playBtn { grid-column: 2; grid-row: 4; }
  .title .row { grid-column: 2; grid-row: 5; }
  .title .depth-row { grid-column: 2; grid-row: 6; }
  .title .best-info, .title .howto { display: none; }
  .btn.big { min-height: 52px; }
  .levelup .cards { flex-direction: row; flex-wrap: wrap; justify-content: center; width: min(96vw, 900px); }
  .levelup .card { width: calc(50% - 6px); min-height: 70px; }
  .lv-title { font-size: 28px; }
  .lv-sub { display: none; }
  .results { display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; row-gap: 6px; align-content: center; }
  .results > * { grid-column: 1; justify-self: center; }
  .results #againBtn, .results .row, .results .news, .results .res-lb { grid-column: 2; }
  .results #againBtn { grid-row: 1 / 3; align-self: end; }
  .results .res-time { font-size: 44px; }
  .results .build { display: none; }
  .camp-head { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .chest .rays { animation: none; }
  .card, .card.evo, .pill, .chest-item, .res-best.new { animation: fadeIn 0.2s ease-out both; }
  .hint .finger { animation: none; }
}
