:root {
  --bg: #050816;
  --panel: rgba(9, 14, 34, 0.78);
  --panel-solid: #0c1330;
  --line: rgba(120, 170, 255, 0.22);
  --line-2: rgba(140, 190, 255, 0.4);
  --text: #e8eeff;
  --muted: #a9b4d6;
  --dim: #7884a8;
  --accent: #38d6ff;
  --gold: #ffd36b;
  --good: #7cf27a;
  --bad: #ff6b6b;
  --violet: #c9b6ff;
  --radius: 12px;
  --header-h: 48px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --t-min: 14px;
  color-scheme: dark;
}

@media (pointer: coarse) {
  :root {
    --t-min: 15px;
  }
}

@media (pointer: coarse) and (max-width: 599px), (pointer: coarse) and (max-height: 599px) {
  :root {
    --t-min: 13px;
  }
}

* {
  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;
}

[hidden] {
  display: none !important;
}

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

/* ---------- The game's frame ---------- */

.game-root {
  position: relative;
  margin: 0 auto;
  width: 100%;
  max-width: 1600px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #03050f;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

.stage {
  position: relative;
  width: 100%;
  height: calc(100vh - var(--header-h) - 18px);
  height: calc(100dvh - var(--header-h) - 18px);
  min-height: min(420px, calc(100vh - var(--header-h)));
  min-height: min(420px, calc(100dvh - var(--header-h)));
  max-height: 1000px;
  overflow: hidden;
  --in-t: 0px;
  --in-r: var(--safe-r);
  --in-b: var(--safe-b);
  --in-l: var(--safe-l);
  --gap: 10px;
  --tap: 10px;
  --corner: 0px;
  --side-l: max(var(--corner), calc(var(--in-l) + var(--gap)));
  --side-r: max(var(--corner), calc(var(--in-r) + var(--gap)));
  --top: calc(var(--in-t) + var(--gap));
  --bottom: calc(var(--in-b) + var(--gap));
}

@media (pointer: coarse) {
  .stage {
    --tap: 16px;
  }
}

@media (pointer: coarse) and (max-width: 599px), (pointer: coarse) and (max-height: 599px) {
  .stage {
    --gap: 8px;
    --corner: 24px;
  }
}

/* Phones: the stage takes the screen under the header. */
@media (max-width: 700px), (max-height: 500px) {
  .page {
    padding: 0 0 40px;
  }
  .game-root {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  .stage {
    height: calc(100vh - var(--header-h));
    height: calc(100dvh - var(--header-h));
    max-height: none;
    min-height: 300px;
  }
}

/* Full screen (the site's button; main.js sets .full): edge to edge, the HUD
   inside the safe areas, "Leave full screen" at the top in the middle. */
.game-root.full {
  border: 0;
  border-radius: 0;
  max-width: none;
}

.game-root.full .stage {
  height: 100%;
  min-height: 0;
  max-height: none;
  --in-t: var(--safe-t);
}

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

html.in-run,
html.in-run .stage,
html.in-run .stage * {
  touch-action: none;
}

html.in-run {
  overscroll-behavior: none;
}

/* A hit taken: a red edge for a moment. */
.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 0 rgba(255, 60, 60, 0);
  transition: box-shadow 0.25s ease-out;
}

.game-root.hurt .stage::after {
  box-shadow: inset 0 0 90px 10px rgba(255, 60, 60, 0.45);
  transition: none;
}

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

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-size: max(14px, var(--t-min));
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

.hud button {
  pointer-events: auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.hud-tl {
  position: absolute;
  top: var(--top);
  left: var(--side-l);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(46%, 300px);
}

.orbit-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  width: max-content;
}

.orbit-panel canvas {
  width: 44px;
  height: 44px;
  flex: none;
}

.orbit-n {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.orbit-n b {
  color: var(--gold);
}

.orbit-n span {
  color: var(--muted);
  font-size: 17px;
  font-weight: 700;
}

.orbit-panel.full .orbit-n span {
  color: var(--gold);
}

.orbit-panel.over .orbit-n b,
.orbit-panel.over .orbit-n span {
  color: #ffb13b;
}

.orbit-panel.empty .orbit-n b {
  color: var(--bad);
}

.orbit-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: max(13px, var(--t-min));
  font-weight: 600;
  margin-top: 3px;
  white-space: nowrap;
}

.plates {
  display: inline-flex;
  gap: 3px;
}

.plates i {
  width: 10px;
  height: 10px;
  transform: rotate(45deg);
  border: 1.5px solid var(--violet);
  border-radius: 2px;
}

.plates i.on {
  background: var(--violet);
  box-shadow: 0 0 6px var(--violet);
}

.feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: max(13px, var(--t-min));
}

.feed li {
  background: rgba(6, 10, 26, 0.7);
  border-left: 3px solid var(--line-2);
  border-radius: 6px;
  padding: 4px 8px;
  width: max-content;
  max-width: 100%;
  transition: opacity 0.6s;
  animation: feed-in 0.25s ease-out;
}

.feed li.good {
  border-left-color: var(--good);
}

.feed li.bad {
  border-left-color: var(--bad);
}

.feed li.old {
  opacity: 0;
}

@keyframes feed-in {
  from {
    transform: translateX(-12px);
    opacity: 0;
  }
}

.hud-tr {
  position: absolute;
  top: var(--top);
  right: var(--side-r);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.hud-tr-row {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--text);
}

.icon-btn:hover {
  border-color: var(--line-2);
}

.icon-btn[aria-expanded='false'] {
  color: var(--dim);
}

.board {
  list-style: none;
  margin: 0;
  padding: 6px 4px;
  width: 210px;
  font-size: max(13px, var(--t-min));
}

.board li {
  display: grid;
  grid-template-columns: 22px 10px 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 6px;
}

.board li.me {
  background: rgba(56, 214, 255, 0.16);
  font-weight: 700;
}

.board li.sep {
  margin-top: 4px;
  border-top: 1px dashed var(--line);
}

.board .rk {
  color: var(--dim);
  font-weight: 700;
  text-align: right;
}

.board li:first-child .rk {
  color: var(--gold);
}

.board .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.board .nm {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board .hl {
  color: var(--gold);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.minimap {
  position: absolute;
  left: var(--side-l);
  bottom: var(--bottom);
  width: 150px;
  height: 150px;
  pointer-events: none;
}

.banner {
  position: absolute;
  top: calc(var(--top) + 56px);
  left: 50%;
  transform: translate(-50%, -8px);
  max-width: min(80%, 560px);
  text-align: center;
  font-weight: 700;
  font-size: max(16px, var(--t-min));
  background: rgba(6, 10, 26, 0.78);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 8px 18px;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
}

.banner.on {
  opacity: 1;
  transform: translate(-50%, 0);
}

.banner.gold {
  color: var(--gold);
  border-color: rgba(255, 211, 107, 0.6);
}

.banner.warn {
  color: #ffc58a;
}

.banner.comet {
  color: #ffd0a0;
  border-color: rgba(255, 170, 90, 0.6);
}

.banner.tip {
  color: #cfeeff;
}

.netbar {
  position: absolute;
  top: calc(var(--top) + 100px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(60, 20, 10, 0.85);
  border-radius: 8px;
  padding: 6px 12px;
  font-weight: 700;
}

.dockhint {
  position: absolute;
  bottom: calc(var(--bottom) + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(6, 10, 26, 0.8);
  border: 1px solid rgba(201, 182, 255, 0.5);
  color: var(--violet);
  border-radius: 999px;
  padding: 7px 16px;
  font-weight: 700;
  white-space: nowrap;
  font-size: max(14px, var(--t-min));
}

/* ---------- Touch controls ---------- */

.touch {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.stick {
  position: absolute;
  left: calc(var(--side-l) + var(--tap));
  bottom: calc(var(--bottom) + var(--tap));
  width: 136px;
  height: 136px;
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
  background: radial-gradient(circle, rgba(56, 214, 255, 0.1) 0 55%, rgba(56, 214, 255, 0.04) 56% 100%);
  border: 2px solid rgba(140, 200, 255, 0.35);
}

.stick .knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(255, 255, 255, 0.55), rgba(120, 190, 255, 0.35) 60%, rgba(60, 120, 220, 0.3));
  border: 2px solid rgba(200, 230, 255, 0.6);
}

.stick.on {
  border-color: rgba(140, 220, 255, 0.7);
}

.tbtns {
  position: absolute;
  right: calc(var(--side-r) + var(--tap));
  bottom: calc(var(--bottom) + var(--tap));
  width: 196px;
  height: 172px;
}

.tbtn {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
  border-radius: 50%;
  border: 2px solid rgba(200, 220, 255, 0.45);
  background: radial-gradient(circle at 40% 30%, rgba(60, 80, 140, 0.8), rgba(12, 18, 44, 0.85));
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
}

.tbtn .tb-icon canvas {
  display: block;
  width: 30px;
  height: 30px;
}

.tbtn .tb-label {
  font-size: var(--t-min);
  font-weight: 800;
  letter-spacing: 0.02em;
  margin-top: 1px;
}

.tbtn.down {
  transform: scale(0.94);
  border-color: #ffffff;
}

.tbtn-fire {
  right: 0;
  bottom: 0;
  width: 92px;
  height: 92px;
  border-color: rgba(255, 211, 107, 0.75);
  background: radial-gradient(circle at 40% 30%, rgba(140, 100, 30, 0.85), rgba(40, 24, 6, 0.88));
}

.tbtn-fire .tb-icon canvas {
  width: 38px;
  height: 38px;
}

.tbtn-fire.empty {
  opacity: 0.55;
}

.tbtn-dash {
  right: 104px;
  bottom: 0;
  width: 64px;
  height: 64px;
}

.tbtn-dash .cd {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(rgba(0, 0, 0, 0.6) calc(var(--cd, 0) * 360deg), transparent 0);
  pointer-events: none;
}

.tbtn-dock {
  right: 14px;
  bottom: 104px;
  width: 64px;
  height: 64px;
  opacity: 0.6;
}

.tbtn-dock.ready,
.tbtn-dock.docked {
  opacity: 1;
  border-color: var(--violet);
  box-shadow: 0 0 14px rgba(201, 182, 255, 0.6);
}

/* With touch controls the minimap moves above the stick, and the dock hint above the buttons. */
.touch-ui .minimap {
  bottom: calc(var(--bottom) + var(--tap) + 150px);
  width: 120px;
  height: 120px;
}

.touch-ui .dockhint {
  bottom: calc(var(--bottom) + var(--tap) + 178px);
  right: calc(var(--side-r) + var(--tap));
  left: auto;
  transform: none;
}

@media (max-width: 599px), (max-height: 520px) {
  .minimap {
    display: none;
  }
  .board {
    width: 172px;
    padding: 4px 2px;
  }
  .board.compact {
    width: 160px;
  }
  .board li {
    grid-template-columns: 18px 8px 1fr auto;
    gap: 5px;
    padding: 2px 6px;
  }
  .orbit-n {
    font-size: 22px;
  }
}

/* Phones held sideways: everything tighter so the sky stays open, the buttons in one row. */
@media (max-height: 520px) {
  .stick {
    width: 120px;
    height: 120px;
  }
  .tbtns {
    width: 224px;
    height: 84px;
  }
  .tbtn-fire {
    width: 84px;
    height: 84px;
  }
  .tbtn-dash {
    right: 92px;
    width: 60px;
    height: 60px;
  }
  .tbtn-dock {
    right: 164px;
    bottom: 0;
    width: 60px;
    height: 60px;
  }
  .touch-ui .dockhint {
    bottom: calc(var(--bottom) + var(--tap) + 96px);
  }
  .hud-tl .feed li:nth-child(n + 3) {
    display: none;
  }
}

/* Narrow screens: banners under the board, clear of the HUD. */
@media (max-width: 599px) {
  .banner {
    top: calc(var(--top) + 128px);
    font-size: max(15px, var(--t-min));
    padding: 7px 14px;
  }
}

/* Phones held sideways: the dock hint between the stick and the buttons, on two lines if it must. */
@media (max-height: 520px) {
  .touch-ui .dockhint {
    top: calc(var(--top) + 100px);
    bottom: auto;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    max-width: 230px;
    white-space: normal;
    text-align: center;
    border-radius: 14px;
  }
}

/* Narrow phones held upright: a smaller stick and buttons, still 44 px and more, never touching. */
@media (max-width: 380px) {
  .stick {
    width: 118px;
    height: 118px;
  }
  .stick .knob {
    width: 50px;
    height: 50px;
    margin: -25px 0 0 -25px;
  }
  .tbtns {
    width: 172px;
    height: 150px;
  }
  .tbtn-fire {
    width: 80px;
    height: 80px;
  }
  .tbtn-dash {
    right: 90px;
    width: 56px;
    height: 56px;
  }
  .tbtn-dock {
    right: 12px;
    bottom: 90px;
    width: 56px;
    height: 56px;
  }
  .touch-ui .minimap {
    display: none;
  }
}

/* Phones held upright: the board is a little narrower. */
@media (max-width: 420px) {
  .board,
  .board.compact {
    width: 150px;
  }
  /* The feed takes what the board leaves, with a gap. */
  .hud-tl {
    max-width: calc(100% - var(--side-l) - var(--side-r) - 158px);
  }
}

/* ---------- Trading ---------- */

.trade {
  position: absolute;
  left: 50%;
  bottom: var(--bottom);
  transform: translateX(-50%);
  width: min(680px, calc(100% - var(--side-l) - var(--side-r)));
  background: rgba(8, 12, 30, 0.92);
  border: 1px solid rgba(201, 182, 255, 0.45);
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  transform-origin: 50% 100%;
  animation: trade-in 0.22s ease-out;
  font-size: max(14px, var(--t-min));
}

/* It grows up from its own bottom edge, never past the screen's. */
@keyframes trade-in {
  from {
    transform: translateX(-50%) scale(0.94);
    opacity: 0;
  }
}

.game-root.docked .touch {
  display: none;
}

.trade-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.keeper {
  width: 56px;
  height: 56px;
  flex: none;
}

.th-text {
  flex: 1;
  min-width: 0;
}

.th-text h3 {
  margin: 0;
  font-size: 19px;
}

.th-text p {
  margin: 2px 0 0;
  color: var(--muted);
  font-style: italic;
}

.wallet {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 24px;
  font-weight: 800;
  color: var(--gold);
}

.sat-ico {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff6dc, #ffd36b 55%, #b8862a);
  box-shadow: 0 0 8px rgba(255, 211, 107, 0.7);
  vertical-align: -2px;
}

.wares {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.ware {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
  min-height: 118px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: linear-gradient(160deg, rgba(40, 56, 110, 0.6), rgba(14, 20, 46, 0.8));
}

.ware:not(:disabled):hover {
  border-color: #ffffff;
}

.ware.attack {
  border-color: rgba(255, 120, 100, 0.55);
}

.ware.grow {
  border-color: rgba(124, 242, 122, 0.5);
}

.ware.escape {
  border-color: rgba(56, 214, 255, 0.5);
}

.ware:disabled {
  cursor: default;
}

.ware.cant .wn,
.ware.cant .what {
  opacity: 0.55;
}

.ware.cant .cost {
  color: var(--bad);
}

.ware .kind {
  font-size: var(--t-min);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.ware.attack .kind {
  color: #ff9a87;
}

.ware.grow .kind {
  color: var(--good);
}

.ware.escape .kind {
  color: var(--accent);
}

.ware .wn {
  font-size: 18px;
  font-weight: 800;
}

.ware .pips {
  display: flex;
  gap: 4px;
}

.ware .pips i {
  width: 18px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.18);
}

.ware .pips i.on {
  background: var(--gold);
}

.ware .what {
  color: var(--text);
  font-size: max(13px, var(--t-min));
}

.ware .cost {
  margin-top: auto;
  font-weight: 800;
  font-size: 18px;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 5px;
}

.ware kbd {
  position: absolute;
  top: 8px;
  right: 8px;
  font: 700 var(--t-min) system-ui, sans-serif;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  padding: 1px 6px;
}

.trade-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.trade-foot .timer {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.trade-foot .timer i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--violet), var(--accent));
}

/* A phone held upright: the wares as rows. */
@media (max-width: 560px) {
  .wares {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .ware {
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: 'wn cost' 'what pips';
    padding: 8px 12px;
    row-gap: 2px;
  }
  .ware .kind,
  .ware kbd {
    display: none;
  }
  .ware .wn {
    grid-area: wn;
    font-size: 16px;
  }
  .ware .what {
    grid-area: what;
  }
  .ware .cost {
    grid-area: cost;
    margin: 0;
  }
  .ware .pips {
    grid-area: pips;
    justify-self: end;
    align-self: center;
  }
  .keeper {
    width: 44px;
    height: 44px;
  }
}

/* A phone held sideways: compact. */
@media (max-height: 520px) {
  .trade {
    padding: 8px 10px;
    width: min(640px, calc(100% - var(--side-l) - var(--side-r)));
  }
  .trade-head {
    margin-bottom: 6px;
  }
  .keeper {
    width: 40px;
    height: 40px;
  }
  .th-text p {
    display: none;
  }
  .ware {
    min-height: 0;
    padding: 6px 10px;
    gap: 2px;
  }
  .ware .kind {
    display: none;
  }
  .ware .wn {
    font-size: 15px;
  }
  .trade-foot {
    margin-top: 6px;
  }
}

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

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: calc(var(--top) + 52px) calc(var(--side-r) + 4px) calc(var(--bottom) + 4px) calc(var(--side-l) + 4px);
  background: radial-gradient(ellipse at center, rgba(4, 7, 20, 0.25), rgba(3, 5, 14, 0.72));
  overflow: auto;
  font-size: max(15px, var(--t-min));
}

.overlay.on {
  display: flex;
}

.overlay.title {
  background: radial-gradient(ellipse at center, rgba(4, 7, 20, 0.1), rgba(3, 5, 14, 0.55));
}

.card {
  width: min(540px, 100%);
  max-height: 100%;
  overflow: auto;
  margin: auto;
  background: rgba(9, 14, 34, 0.86);
  border: 1px solid var(--line-2);
  border-radius: 18px;
  padding: 20px 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.card h2 {
  margin: 0 0 10px;
  font-size: 24px;
}

.card .sub,
.card .muted {
  color: var(--muted);
}

.card .small {
  font-size: max(13px, var(--t-min));
}

.btn {
  min-height: 44px;
  min-width: 44px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: rgba(30, 44, 92, 0.7);
  color: var(--text);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover {
  border-color: #ffffff;
}

/* Where focus is: the keyboard's Tab, and a gamepad moving through a card's buttons. */
.overlay button:focus-visible,
:root[data-input='pad'] .overlay button:focus,
#trade button:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

.btn.primary {
  background: linear-gradient(180deg, #46e0ff, #1aa6d6);
  color: #03121e;
  border-color: #9cf0ff;
}

.btn.big {
  font-size: 22px;
  min-height: 58px;
  padding: 12px 40px;
  border-radius: 16px;
  box-shadow: 0 0 24px rgba(56, 214, 255, 0.35);
}

.row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 12px 0 4px;
}

.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.95;
  margin: 0 0 6px !important;
  font-size: clamp(40px, 9vw, 64px) !important;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.logo .l1 {
  background: linear-gradient(180deg, #ffffff, #7fe6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 14px rgba(56, 214, 255, 0.45));
}

.logo .l2 {
  background: linear-gradient(180deg, #fff3c4, #ffb627);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 14px rgba(255, 182, 39, 0.4));
}

.title-card .tag {
  color: var(--muted);
  margin: 4px 0 12px;
}

.title-card .who {
  margin: 0 0 14px;
}

.title-card .status {
  color: var(--muted);
  margin: 10px 0 0;
  font-size: max(14px, var(--t-min));
}

.skin-prev {
  width: 36px;
  height: 36px;
}

.levelbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  font-size: max(13px, var(--t-min));
  color: var(--muted);
}

.levelbar .lv {
  font-weight: 800;
  color: var(--text);
}

.levelbar .bar {
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.levelbar .bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}

.tips {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  text-align: left;
  display: grid;
  gap: 10px;
}

.tips li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.tips b {
  display: block;
}

.tips span {
  color: var(--muted);
}

.tip-icon {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(30, 44, 92, 0.6);
  border: 1px solid var(--line-2);
}

.keys {
  color: var(--muted);
}

.skins {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
  margin: 10px 0 14px;
}

.skin {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(20, 30, 70, 0.5);
}

.skin .skin-prev {
  width: 72px;
  height: 72px;
}

.skin.on {
  border-color: var(--gold);
  background: rgba(80, 60, 20, 0.45);
}

.skin.locked {
  opacity: 0.55;
}

.skin .nm {
  font-weight: 700;
}

.skin .lk {
  color: var(--muted);
  font-size: max(13px, var(--t-min));
}

.tabs {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 8px 0;
}

.tab {
  min-height: 44px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  font-weight: 700;
}

.tab[aria-selected='true'] {
  background: rgba(56, 214, 255, 0.2);
  border-color: var(--accent);
}

.board-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.board-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: max(13px, var(--t-min));
  padding: 4px 6px;
}

.board-table td {
  padding: 6px;
  border-top: 1px solid var(--line);
}

.board-table tr.me td {
  background: rgba(56, 214, 255, 0.15);
  font-weight: 700;
}

.board-table .sc {
  color: var(--gold);
  font-weight: 800;
}

.board-table .ex {
  color: var(--muted);
  font-size: max(13px, var(--t-min));
}

.results-card .kicker {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: max(13px, var(--t-min));
}

.results-card .peak {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 6px 0 4px;
}

.results-card .peak .big {
  font-size: 64px;
  font-weight: 900;
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(255, 182, 39, 0.45);
}

.results-card .peak .lbl {
  color: var(--muted);
  font-weight: 700;
}

.newbest {
  color: var(--good);
  font-weight: 800;
  margin: 4px 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 10px 0;
}

.stat {
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 8px 2px;
}

.stat b {
  font-size: 20px;
}

.stat span {
  color: var(--muted);
  font-size: var(--t-min);
}

.board-note {
  min-height: 1.3em;
  margin: 8px 0;
}

.xpline {
  font-weight: 800;
  color: var(--accent);
}

.unlock {
  color: var(--gold);
  font-weight: 700;
}

.ach {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  text-align: left;
}

.ach li {
  display: grid;
  grid-template-columns: 22px auto 1fr;
  align-items: center;
  gap: 8px;
  background: rgba(255, 211, 107, 0.12);
  border: 1px solid rgba(255, 211, 107, 0.35);
  border-radius: 10px;
  padding: 6px 10px;
  margin: 4px 0;
}

.ach .medal {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff6d0, #ffc93d 55%, #a8721a);
  box-shadow: 0 0 8px rgba(255, 201, 61, 0.6);
}

.ach b {
  color: var(--gold);
}

.ach .desc {
  color: var(--muted);
}

/* Under the results and the menu, the HUD steps back. */
.game-root.ko .hud .orbit-panel,
.game-root.ko .hud .feed,
.game-root.ko .minimap {
  opacity: 0.25;
}

.connecting p {
  margin: 10px 0 0;
  font-weight: 700;
}

.spinner {
  width: 54px;
  height: 54px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px dashed var(--accent);
  animation: spin 1.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 480px) {
  .card {
    padding: 16px 14px;
  }
  .stats {
    grid-template-columns: repeat(3, 1fr);
  }
  .results-card .peak .big {
    font-size: 52px;
  }
}

@media (max-height: 520px) {
  .overlay {
    padding-top: calc(var(--top) + 4px);
  }
  .card {
    padding: 12px 16px;
  }
  .logo {
    flex-direction: row;
    gap: 12px;
    font-size: 36px !important;
  }
  .results-card .peak .big {
    font-size: 44px;
  }
  .stats {
    margin: 6px 0;
  }
  .levelbar {
    margin-top: 8px;
  }
}

/* ---------- The page around the game ---------- */

.about {
  max-width: 820px;
  margin: 28px auto 0;
  padding: 0 16px;
  line-height: 1.6;
  color: #d6def5;
}

.about h1 {
  font-size: 28px;
  margin: 0 0 8px;
}

.about h2 {
  font-size: 20px;
  margin: 22px 0 6px;
}

.about kbd {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  padding: 0 6px;
  font: 600 0.92em system-ui, sans-serif;
}

.ad-slot:empty {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  /* Keep flight, hits, pickup and feed feedback; calm panel/loader decoration. */
  .spinner, .trade { animation: none; }
  button, .panel { transition: none; }
}

/* Phones held sideways: the results in two columns, the run and its buttons on the
   left, the details on the right, so "Fly again" is on screen without scrolling. */
@media (max-height: 520px) and (orientation: landscape) {
  .results-card {
    width: min(880px, 100%);
    display: grid;
    grid-template-columns: minmax(190px, 1fr) 1.8fr;
    grid-auto-flow: row dense;
    column-gap: 20px;
    align-items: center;
  }
  .results-card > * {
    grid-column: 2;
  }
  .results-card > .kicker {
    grid-column: 1 / -1;
  }
  .results-card > .peak,
  .results-card > .newbest,
  .results-card > #btn-again,
  .results-card > .row {
    grid-column: 1;
  }
  .results-card > #btn-again {
    justify-self: center;
    padding: 10px 26px;
    min-height: 50px;
  }
  .results-card > .row {
    margin: 6px 0 0;
  }
  .results-card .stats {
    margin: 0;
  }
  .results-card .stat {
    padding: 5px 2px;
  }
  .results-card .stat span {
    white-space: nowrap;
  }
  .results-card .board-note {
    margin: 4px 0;
  }
}
