/* Play layout: HUD on top, scene in the middle, upgrade/production panel on the right (desktop),
   below the scene (portrait phones) or as a narrow right column (landscape phones). */
#app { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); height: 100dvh; padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }
#boot-msg { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; font: 700 16px var(--mono); color: var(--muted); background: var(--bg); z-index: 60; }
#app:not(.booting) #boot-msg { display: none; }
#boot-msg.error { color: var(--red); padding: 20px; text-align: center; white-space: pre-wrap; }

#hud { display: flex; align-items: center; gap: 12px; padding: 6px 12px; background: var(--night); border-bottom: 2px solid var(--ink); box-shadow: inset 0 -2px 0 var(--slate), inset 0 2px 0 #24284a; min-height: 52px; z-index: 3; }
.hud-brand { display: flex; align-items: center; gap: 6px; font-weight: 800; letter-spacing: .02em; }
.hud-brand .title { font-size: 15px; }
.tag-test { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; padding: 1px 5px; color: #062c33; background: var(--cyan); border: 1px solid var(--ink); }
.tag-modified { font-size: 10px; font-weight: 800; padding: 1px 5px; color: #fff; background: var(--red2); border: 1px solid var(--ink); }
.hud-stat { display: flex; align-items: center; gap: 6px; }
.hud-credits b { font: 800 18px/1 var(--mono); color: #cdf6fb; }
.hud-credits small { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.hud-credits.bump b { animation: bump .4s steps(2); }
@keyframes bump { 50% { color: var(--green2); } }
.hud-energy .meter { width: 150px; }
.hud-cargo .meter { width: 130px; }
.hud-status { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; font-weight: 700; font-size: 13px; }
.hud-status .txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.hud-status .dot { width: 10px; height: 10px; flex: none; background: var(--green2); border: 2px solid var(--ink); }
.hud-status.warn .dot { background: var(--gold); }
.hud-status.bad .dot { background: var(--red); animation: blink 1s steps(2) infinite; }
.hud-status.info .dot { background: var(--cyan); }
@keyframes blink { 50% { opacity: .2; } }
.hud-menu { display: flex; gap: 6px; }
#btn-start { min-width: 150px; }

#main { display: grid; grid-template-columns: minmax(0, 1fr) 372px; min-height: 0; }
#stage { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #08070f; }
#stage-inner { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; background-color: #0c0a16; background-repeat: repeat; background-position: center; image-rendering: pixelated; }
#stage-inner::after { content: ''; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 0 2px #0c0a16; }
#scene { display: block; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: manipulation; box-shadow: 0 0 0 2px #120b17, 0 0 0 4px #5e300c, 0 0 0 6px #120b17; }
#banner { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 6; background: var(--night); border: 2px solid var(--ink); box-shadow: inset 0 0 0 2px var(--gold2); padding: 6px 10px; font-size: 13px; display: flex; gap: 8px; align-items: center; max-width: 94%; }
#banner.bad { box-shadow: inset 0 0 0 2px var(--red2); }
#tips { position: absolute; top: 8px; right: 8px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; z-index: 4; max-width: min(330px, 70%); }
.tip { background: #1a1c33f2; border: 2px solid var(--ink); box-shadow: inset 0 0 0 2px var(--cyan); padding: 7px 9px; font-size: 13px; line-height: 1.35; animation: popin .14s steps(3); }
.tip b { color: var(--cyan); }
.tip .row { margin-top: 6px; justify-content: flex-end; }
/* ---------- Earnings bar (focus element) ---------- */
.earnbar { position: relative; padding: 8px 14px 9px;
  background: linear-gradient(#2a1c06 0 2px, #1a1206 2px calc(100% - 2px), #0e0904 calc(100% - 2px));
  border-top: 2px solid var(--ink); box-shadow: inset 0 2px 0 var(--gold2), inset 0 4px 0 #5e300c, 0 -2px 0 #120b17; z-index: 3; }
.earnbar.bump { animation: ebbump .45s steps(3); }
@keyframes ebbump { 30% { box-shadow: inset 0 2px 0 var(--gold), inset 0 4px 0 var(--gold2), 0 -2px 0 #120b17; filter: brightness(1.25); } }
.eb-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.eb-coin { image-rendering: pixelated; flex: none; }
.eb-col { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.eb-label { display: flex; align-items: center; gap: 8px; font: 800 11px/1 var(--mono); letter-spacing: .12em; color: #e8c46a; }
.eb-title { color: var(--gold); text-shadow: 1px 1px 0 #5e300c; }
.eb-live { font-size: 9px; padding: 1px 4px; border: 1px solid var(--ink); background: #3b3020; color: #9a8a6a; letter-spacing: .08em; }
.eb-live.on { background: var(--green1); color: #fff; animation: blink 1.6s steps(2) infinite; }
.eb-tag { font: 600 10px var(--font); letter-spacing: 0; color: #a48e5c; text-transform: none; }
.eb-amount-wrap { position: relative; line-height: 0; }
.eb-amount { image-rendering: pixelated; display: block; }
.eb-sub { display: flex; gap: 10px; align-items: center; font: 700 12px var(--mono); color: #d8c08a; min-height: 14px; }
.eb-trend.up { color: var(--green2); }
.eb-trend.down { color: var(--red); }
.eb-basis { color: #a48e5c; font-weight: 600; font-family: var(--font); font-size: 11px; }
.eb-basis.warn { color: var(--red); }
.earnbar { container: earnbar / inline-size; }
.eb-inner { display: flex; align-items: center; gap: 18px; }
.eb-stats { display: grid; grid-template-columns: repeat(2, minmax(118px, 1fr)); gap: 4px; margin-left: auto; flex: none; }
.eb-chart { display: flex; flex-direction: column; gap: 3px; margin-left: auto; flex: none; padding: 4px 8px 5px; background: #120c05; border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px #5e300c; }
.eb-chart span { font: 700 10px var(--mono); color: #a48e5c; text-transform: uppercase; letter-spacing: .06em; }
.eb-chart-c { image-rendering: pixelated; display: block; }
.eb-chart + .eb-stats { margin-left: 0; }
.earnbar.eb-nochart .eb-chart { display: none; }
.earnbar.eb-nochart .eb-chart + .eb-stats { margin-left: auto; }
/* narrow: the four stats move to their own full-width row */
@container earnbar (max-width: 900px) {
  .eb-inner { flex-wrap: wrap; gap: 8px 18px; }
  .eb-chart { display: none; }
  .eb-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; margin-left: 0 !important; }
}
.eb-stat { display: flex; flex-direction: column; gap: 1px; padding: 3px 8px; min-width: 0; background: #120c05; border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px #5e300c; }
.eb-stat span { font: 700 10px var(--mono); color: #a48e5c; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.eb-stat b { font: 800 15px var(--mono); color: #ffe9a6; font-variant-numeric: tabular-nums; white-space: nowrap; }
.eb-next b { color: #cdf6fb; font-size: 14px; }
.eb-prog { height: 5px; background: #2b2010; border: 1px solid var(--ink); margin-top: 2px; }
.eb-prog i { display: block; height: 100%; width: 0; background: var(--gold2); box-shadow: inset 0 1px 0 var(--gold); }
.eb-pops { position: absolute; left: 0; top: -6px; pointer-events: none; }
.eb-pop { position: absolute; left: 30px; top: 0; font: 900 18px var(--mono); color: var(--green2); text-shadow: 2px 2px 0 #10301a, -1px -1px 0 #10301a; animation: ebpop 1.4s steps(10) forwards; white-space: nowrap; }
@keyframes ebpop { 0% { transform: translateY(6px); opacity: 1; } 70% { opacity: 1; } 100% { transform: translateY(-26px); opacity: 0; } }
.coin-fx { position: fixed; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; image-rendering: pixelated; }
#devbar { background: #0d0c17; border-top: 2px solid var(--ink); padding: 6px 8px; font: 12px var(--mono); max-height: 180px; overflow: auto; }
#devbar .log { white-space: pre; color: var(--muted); }

#panel { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-left: 2px solid var(--ink); box-shadow: inset 2px 0 0 var(--slate); }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; background: var(--night); border-bottom: 2px solid var(--ink); position: sticky; top: 0; z-index: 2; }
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 2px 5px; background: transparent; border: none; border-right: 2px solid var(--ink); color: var(--muted); cursor: pointer; font-weight: 700; font-size: 12px; }
.tabs button:last-child { border-right: none; }
.tabs button.active { color: var(--text); background: var(--navy); box-shadow: inset 0 -3px 0 var(--gold); }
.tabs button .pxi { width: 24px; height: 24px; }
.tabs button .count { position: absolute; }
.tab-body { flex: 1; overflow: auto; padding: 10px; scrollbar-width: thin; }

/* Upgrade cards */
.upg { display: grid; grid-template-columns: 36px 1fr auto; gap: 4px 8px; align-items: center; }
.upg .pxi { width: 36px; height: 36px; grid-row: span 2; }
.upg .name { font-weight: 800; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.upg .lvl { font: 700 11px var(--mono); color: var(--muted); }
.upg .pips { display: inline-flex; gap: 2px; }
.upg .pips i { width: 6px; height: 8px; background: #0d0c17; border: 1px solid var(--ink); }
.upg .pips i.on { background: var(--gold); }
.upg .stats { grid-column: 2 / 4; font-size: 12px; display: grid; grid-template-columns: auto auto auto auto; gap: 1px 6px; align-items: baseline; justify-content: start; }
.upg .stats .k { color: var(--muted); }
.upg .stats .v { font-family: var(--mono); }
.upg .stats .arrow { color: var(--dim); }
.upg .stats .nx { font-family: var(--mono); color: var(--green2); font-weight: 700; }
.upg .buy { grid-row: 1; grid-column: 3; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.upg .buy .btn { min-width: 108px; }
.upg .notes { grid-column: 1 / 4; display: flex; gap: 6px; flex-wrap: wrap; font-size: 11px; }
.cost { font: 800 13px var(--mono); }
.cost.no { color: var(--red); }
.goals { margin: 0; padding: 0; list-style: none; font-size: 12px; }
.goals li { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.goals li .pxi { width: 12px; height: 12px; }
.goals li.done { color: var(--dim); text-decoration: line-through; }

/* Miners */
.miner { display: grid; grid-template-columns: 60px 1fr auto; gap: 4px 10px; align-items: center; }
.miner img.portrait { width: 60px; height: 78px; image-rendering: pixelated; background: #0d0c17; border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px var(--line); object-fit: none; }
.miner .who { font-weight: 800; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.miner.active { box-shadow: inset 0 0 0 2px var(--gold), inset 0 4px 0 var(--card2); }
.has-pixel-ui .miner.active { filter: drop-shadow(0 0 0 var(--gold)); outline: 2px solid var(--gold); outline-offset: -2px; }
.miner.selected { outline: 2px solid var(--cyan); outline-offset: -2px; }
.tier-badge { width: 26px; height: 28px; image-rendering: pixelated; }

/* Fusion */
.fusion-slots { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center; gap: 6px; margin: 6px 0 8px; }
.slot { min-height: 104px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: #0d0c17; border: 2px dashed var(--slate); font-size: 11px; color: var(--muted); text-align: center; padding: 4px; }
.slot.filled { border-style: solid; border-color: var(--cyan); color: var(--text); }
.slot.result { border-color: var(--gold); }
.slot img { width: 48px; height: 62px; image-rendering: pixelated; object-fit: none; }
.fusion-op { font: 800 18px var(--mono); color: var(--muted); }
.fusion-canvas { display: block; margin: 0 auto; image-rendering: pixelated; border: 2px solid var(--ink); box-shadow: inset 0 0 0 2px var(--line); background: #0d0c17; max-width: 100%; }

/* Production */
.bars { display: flex; flex-direction: column; gap: 3px; font-size: 11px; }
.bars .bar { display: grid; grid-template-columns: 110px 1fr 40px; gap: 6px; align-items: center; }
.bars .track { height: 8px; background: #0d0c17; border: 1px solid var(--ink); }
.bars .track i { display: block; height: 100%; background: var(--cyan); }
.bars .bar.bad .track i { background: var(--red); }
.bars .bar.warn .track i { background: var(--gold2); }
.window-progress { height: 10px; background: #0d0c17; border: 2px solid var(--ink); margin: 4px 0; }
.window-progress i { display: block; height: 100%; background: var(--cyan); }

/* Away modal stats */
.away-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.away-grid .cell { background: var(--card); border: 2px solid var(--ink); padding: 6px; text-align: center; }
.away-grid .cell b { display: block; font: 800 16px var(--mono); }
.away-grid .cell span { font-size: 11px; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  #main { grid-template-columns: minmax(0, 1fr) 330px; }
  .hud-brand .title, .tag-test { display: none; }
}
@media (max-width: 820px) and (orientation: portrait), (max-width: 620px) {
  #hud { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "credits energy refill" "cargo cargo start" "status status menu"; gap: 5px 8px; padding: 6px 8px; min-height: 0; }
  .hud-brand { display: none; }
  .hud-credits { grid-area: credits; }
  .hud-credits small { display: none; }
  .hud-energy { grid-area: energy; min-width: 0; }
  .hud-energy .meter { width: auto; flex: 1; min-width: 60px; }
  #hud-refill { grid-area: refill; }
  .hud-energy #hud-refill { display: none; }
  .hud-cargo { grid-area: cargo; min-width: 0; }
  .hud-cargo .meter { width: auto; flex: 1; min-width: 60px; }
  #btn-start { grid-area: start; min-width: 108px; min-height: 32px; font-size: 14px; }
  .hud-status { grid-area: status; font-size: 12px; min-width: 0; }
  .hud-menu { grid-area: menu; }
  .hud-menu .btn.icon { min-width: 30px; min-height: 26px; }
  .hud-menu .btn.icon .pxi { width: 18px; height: 18px; }
  #main { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  #stage-inner { flex: none; }
  #panel { border-left: none; border-top: 2px solid var(--ink); box-shadow: inset 0 2px 0 var(--slate); padding-bottom: env(safe-area-inset-bottom); }
  .tabs button span { font-size: 11px; }
  .upg .buy .btn { min-width: 92px; }
  #tips { left: auto; right: 6px; max-width: min(400px, calc(100% - 12px)); align-items: stretch; top: 4px; bottom: auto; }
  .earnbar { padding: 6px 8px 7px; }
  .eb-inner { gap: 6px 8px; }
  .eb-stat { flex: 1; min-width: 0; padding: 3px 6px; }
  .eb-stat b { font-size: 13px; }
  .eb-next b { font-size: 12px; }
  .tip { font-size: 12px; padding: 5px 7px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  #hud { min-height: 40px; padding: 3px 8px; gap: 8px; }
  .hud-brand, .hud-credits small { display: none; }
  .hud-energy .meter { width: 110px; }
  .hud-cargo .meter { width: 96px; }
  #btn-start { min-width: 110px; min-height: 30px; font-size: 13px; }
  #main { grid-template-columns: minmax(0, 1fr) 300px; }
  .tabs button { flex-direction: row; justify-content: center; gap: 4px; padding: 4px 2px; }
  .tabs button .pxi { width: 18px; height: 18px; }
  .hud-status { font-size: 12px; }
  #tips { max-width: 46%; }
  .earnbar { padding: 4px 8px 5px; }
  #earnbar .eb-inner { flex-wrap: nowrap; gap: 8px; }
  #earnbar .eb-stats { grid-template-columns: repeat(2, minmax(84px, 1fr)); width: auto; margin-left: auto !important; gap: 3px; }
  .eb-tag, .eb-sub { display: none; }
  .eb-stat { min-width: 0; padding: 1px 6px; }
  .eb-stat span { font-size: 9px; }
  .eb-stat b { font-size: 12px; }
  .eb-next b { font-size: 11px; }
  .eb-prog { height: 3px; }
  .hud-energy .meter { width: 92px; }
  .hud-cargo .meter { width: 84px; }
}

/* ---------- Navigation (8 sections) ---------- */
.tabs { grid-template-columns: repeat(8, minmax(56px, 1fr)); overflow-x: auto; scrollbar-width: none; min-width: 0; }
#panel, #stage { min-width: 0; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { min-width: 56px; position: relative; }
@media (min-width: 1101px) {
  #main { grid-template-columns: minmax(0, 1fr) 456px; }
  #panel { display: grid; grid-template-columns: 70px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  #panel > .tabs { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; border-bottom: none; border-right: 2px solid var(--ink); position: static; overflow-y: auto; }
  #panel > .tabs button { border-right: none; border-bottom: 2px solid var(--ink); padding: 9px 2px 8px; flex: none; }
  #panel > .tabs button.active { box-shadow: inset 4px 0 0 var(--gold); }
  #panel > .tab-body { grid-column: 2; grid-row: 1; }
}
@media (max-width: 1100px) { .tabs { display: flex; } .tabs button { flex: 1 0 64px; } }

/* HUD boost chips */
.hud-boosts { display: inline-flex; gap: 4px; margin-left: 6px; flex: none; }
.boost-chip { display: inline-flex; align-items: center; gap: 3px; padding: 0 5px; height: 18px; font: 700 11px var(--mono); color: #10301a; background: var(--green2); border: 1px solid var(--ink); }

/* ---------- Store ---------- */
.chips { display: flex; gap: 4px; flex-wrap: wrap; margin: 8px 0; }
.chip { padding: 3px 9px; font: 700 12px var(--font); color: var(--muted); background: var(--card); border: 2px solid var(--ink); cursor: pointer; }
.chip.on { color: #2a1c00; background: var(--gold); box-shadow: inset 0 -2px 0 var(--gold2); }
.store-head h3 { font-size: 15px; }
.store-bal { display: inline-flex; align-items: center; gap: 4px; font: 800 14px var(--mono); color: #cdf6fb; }
.store-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 6px; }
.store-card { display: grid; grid-template-columns: 100px minmax(0, 1fr); grid-template-rows: auto auto 1fr auto; column-gap: 10px; row-gap: 2px; margin: 0 !important; padding: 8px; }
.store-card > :not(.store-prev-wrap) { grid-column: 2; }
.store-card.equipped { box-shadow: inset 0 0 0 2px var(--green2); }
.store-prev-wrap { grid-column: 1; grid-row: 1 / 5; display: flex; justify-content: center; align-items: center; min-height: 72px;
  background-color: #12101d; background-image: conic-gradient(#1a1729 25%, transparent 0 50%, #1a1729 0 75%, transparent 0); background-size: 4px 4px; border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px #2b2742; }
.store-prev { image-rendering: pixelated; display: block; }
.icon-prev { padding: 8px; }
.store-name { font-weight: 800; font-size: 14px; line-height: 1.2; }
.store-meta { display: flex; gap: 6px; align-items: baseline; font-size: 11px; }
.rarity { font: 800 9px var(--mono); letter-spacing: .08em; text-shadow: 1px 1px 0 #000; }
.store-desc { color: var(--muted); line-height: 1.3; font-size: 12px; }
.store-actions { margin-top: 4px; }
.price { display: inline-flex; align-items: center; gap: 4px; font: 800 14px var(--mono); color: #ffe9a6; }
.price.no { color: var(--red); }
.rarity-legendary .store-prev-wrap { box-shadow: inset 0 0 0 1px var(--gold2), 0 0 0 1px #5e300c; }
.rarity-epic .store-prev-wrap { box-shadow: inset 0 0 0 1px #8a5cc9; }
.rarity-rare .store-prev-wrap { box-shadow: inset 0 0 0 1px #2a8fb0; }
.title-plate { margin: 6px; padding: 5px 6px; text-align: center; font: 800 11px var(--mono); color: #2a1c00; background: var(--gold); border: 2px solid var(--ink); box-shadow: inset 0 -2px 0 var(--gold2); }
.gold { color: var(--gold); }

/* ---------- Ranks ---------- */
.notice { box-shadow: inset 0 0 0 2px #2a8fb0, inset 0 4px 0 var(--card2); }
.you-rank { display: flex; align-items: center; gap: 12px; }
.big-rank { font: 900 30px var(--mono); color: var(--gold); text-shadow: 2px 2px 0 #5e300c; }
.rank-list { display: flex; flex-direction: column; gap: 3px; }
.rank-row { display: grid; grid-template-columns: 38px 30px minmax(0, 1fr) 18px auto; gap: 6px; align-items: center; padding: 4px 6px; background: var(--card); border: 2px solid var(--ink); font-size: 12px; }
.rank-row.you { background: #2a2208; box-shadow: inset 0 0 0 2px var(--gold2); position: sticky; top: 0; bottom: 0; z-index: 2; }
.rank-row .rk { font: 800 12px var(--mono); color: var(--muted); display: flex; justify-content: center; }
.rank-row .av { width: 28px; height: 28px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #0d0c17; border: 1px solid var(--ink); }
.rank-row .av canvas { width: 26px !important; height: auto !important; }
.rank-row .av.framed { border: 2px solid var(--gold2); }
.rank-row .nm { min-width: 0; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.rank-row .nm b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .val { font-weight: 800; color: #ffe9a6; white-space: nowrap; }

/* ---------- Invite ---------- */
.ref-code { font: 900 26px var(--mono); letter-spacing: .08em; color: var(--gold); text-shadow: 2px 2px 0 #5e300c; margin: 4px 0 8px; }
.ref-link { margin-top: 6px; padding: 4px 6px; background: #0d0c17; border: 1px solid var(--line); font-family: var(--mono); word-break: break-all; color: var(--muted); }

/* ---------- Profile ---------- */
.profile-card { display: flex; gap: 12px; align-items: center; }
.avatar { flex: none; padding: 6px; background: #0d0c17; border: 3px solid var(--slate); line-height: 0; }
.avatar canvas { display: block; }
.profile-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.profile-name { font-size: 18px; font-weight: 900; }
.lvl { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.lvl-badge { font: 900 12px var(--mono); padding: 1px 6px; color: #2a1c00; background: var(--gold); border: 1px solid var(--ink); }
.lvl-bar { width: 110px; height: 8px; background: #0d0c17; border: 1px solid var(--ink); }
.lvl-bar i { display: block; height: 100%; background: var(--cyan); }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
.sg { display: flex; flex-direction: column; padding: 4px 6px; background: #0d0c17; border: 1px solid var(--line); }
.sg span { font-size: 11px; color: var(--muted); }
.sg b { font: 800 15px var(--mono); }
.ach-grid { display: grid; grid-template-columns: 1fr; gap: 4px; }
.ach { display: flex; gap: 8px; align-items: center; padding: 4px 6px; background: #0d0c17; border: 1px solid var(--line); opacity: .55; filter: grayscale(1); }
.ach.on { opacity: 1; filter: none; border-color: var(--gold2); }
.ach-t { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ach-bar { height: 4px; background: #222846; margin-top: 2px; }
.ach-bar i { display: block; height: 100%; background: var(--gold2); }
.ward-row { padding: 3px 0; border-bottom: 1px solid #222846; }

/* Short landscape phones: icon-only tabs so all eight sections fit the 300px panel. */
@media (max-height: 520px) and (orientation: landscape) {
  #panel .tabs button { flex: 1 0 34px; min-width: 34px; padding: 6px 2px; }
  #panel .tabs button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* very narrow earnings bar: keep "Next payout" on one line */
@container earnbar (max-width: 520px) {
  .eb-stat { padding: 3px 5px; }
  .eb-stat span { font-size: 9px; letter-spacing: .02em; }
  .eb-stat b { font-size: 12px; }
  .eb-next b { font-size: 10.5px; letter-spacing: -.02em; }
}

/* ---------- upgrade celebration ---------- */
.card.upg-celebrate { animation: upgglow 1s steps(8) 1; position: relative; }
@keyframes upgglow {
  0% { box-shadow: inset 0 0 0 2px var(--gold), 0 0 0 2px var(--gold); filter: brightness(1.6); }
  25% { box-shadow: inset 0 0 0 2px var(--gold4, #fff3a6), 0 0 0 3px var(--gold2); filter: brightness(1.25); }
  60% { box-shadow: inset 0 0 0 2px var(--gold2), 0 0 0 1px var(--gold2); filter: brightness(1.1); }
  100% { box-shadow: none; filter: none; }
}
.upg .pips i.fresh { background: #fff3a6; animation: pipglow .9s steps(6) 2; }
@keyframes pipglow { 50% { background: var(--gold2); box-shadow: 0 0 0 1px var(--gold); } }
.upg-float { position: absolute; right: 12px; top: 6px; pointer-events: none; font: 800 12px var(--mono); color: #8fdc6a; text-shadow: 1px 1px 0 #10301a, -1px -1px 0 #10301a; white-space: nowrap; animation: upgfloat 1.6s steps(14) forwards; z-index: 3; }
@keyframes upgfloat { 0% { transform: translateY(14px); opacity: 0; } 15% { opacity: 1; } 75% { opacity: 1; } 100% { transform: translateY(-26px); opacity: 0; } }
.lvlup { position: absolute; left: 50%; top: 14%; transform: translateX(-50%); z-index: 6; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 18px 9px; background: #1a1206f2; border: 2px solid #120b17; box-shadow: inset 0 0 0 2px var(--gold2), inset 0 0 0 4px #5e300c; animation: lvlup 1.8s steps(16) forwards; }
.lvlup b { font: 900 22px var(--mono); letter-spacing: .06em; color: var(--gold); text-shadow: 2px 2px 0 #5e300c, -1px -1px 0 #120b17; }
.lvlup span { font: 800 12px var(--mono); color: #ffe9a6; }
.lvlup i { font: 800 11px var(--mono); font-style: normal; color: #8fdc6a; }
.lvlup.max b { color: #fff3a6; }
.lvlup.max { box-shadow: inset 0 0 0 2px #c79cff, inset 0 0 0 4px #4e3380; }
@keyframes lvlup {
  0% { transform: translateX(-50%) translateY(8px) scale(.6); opacity: 0; }
  12% { transform: translateX(-50%) translateY(0) scale(1.12); opacity: 1; }
  20% { transform: translateX(-50%) scale(1); }
  80% { transform: translateX(-50%) translateY(0); opacity: 1; }
  100% { transform: translateX(-50%) translateY(-14px); opacity: 0; }
}
body.reduced-motion .lvlup, body.reduced-motion .card.upg-celebrate { animation-duration: .01s; }

/* Auto-refill: pixel switch in the Energy Refill card + AUTO badge on the HUD refill button */
.auto-refill { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding-top: 7px; border-top: 2px dashed var(--slate); cursor: pointer; user-select: none; }
.auto-refill b { font-size: 13px; }
.auto-refill .tiny { margin-left: auto; text-align: right; }
input.switch { appearance: none; -webkit-appearance: none; flex: none; width: 34px; height: 18px; margin: 0; position: relative; background: var(--navy); border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px var(--slate); cursor: pointer; }
input.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; background: var(--muted); border: 1px solid var(--ink); transition: left .12s steps(3); }
input.switch:checked { background: #1d5c2c; box-shadow: inset 0 0 0 1px var(--green2); }
input.switch:checked::after { left: 18px; background: var(--green2); }
input.switch:disabled { opacity: .5; cursor: not-allowed; }
.card.auto-on .auto-refill b { color: var(--green2); }
#hud-refill.auto { position: relative; }
#hud-refill.auto::after { content: 'AUTO'; position: absolute; top: -7px; right: -6px; font: 800 8px/1 var(--mono); letter-spacing: .04em; padding: 1px 3px; color: #10301a; background: var(--green2); border: 1px solid var(--ink); pointer-events: none; }

/* Hook control: AUTO / MANUAL switch on the scene (bottom-left: the ground the rig has already
   passed) with a throw hint, plus the Hook control card in the Mine tab */
.ctl { position: absolute; left: 8px; bottom: 8px; z-index: 4; display: flex; align-items: center; gap: 6px; pointer-events: none; max-width: calc(100% - 16px); }
.ctl-seg { display: flex; flex: none; pointer-events: auto; border: 2px solid var(--ink); box-shadow: 0 0 0 2px #5e300c, 0 0 0 4px var(--ink); background: var(--ink); }
.ctl-opt { display: flex; align-items: center; gap: 4px; padding: 3px 7px 3px 5px; min-height: 24px; font: 800 11px/1 var(--mono); letter-spacing: .08em; color: #8e96ad; background: #1a1c33; border: 0; cursor: pointer; }
.ctl-opt + .ctl-opt { border-left: 2px solid var(--ink); }
.ctl-opt .pxi { width: 16px; height: 16px; opacity: .55; }
.ctl-opt:hover:not(.on) { color: #cfd8e4; background: #26304f; }
.ctl-opt.on { color: #120b17; background: var(--gold); box-shadow: inset 0 2px 0 #fff3a6, inset 0 -2px 0 var(--gold2); cursor: default; }
.ctl-opt.on[data-mode="auto"] { background: var(--cyan); box-shadow: inset 0 2px 0 #c4f7ff, inset 0 -2px 0 #1f7f9c; }
.ctl-opt.on .pxi { opacity: 1; }
.ctl-opt:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
.ctl-opt:disabled { cursor: not-allowed; }
.ctl-hint { display: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 800 11px/1 var(--mono); letter-spacing: .1em; padding: 5px 7px; color: #8e96ad; background: #120b17e0; border: 2px solid var(--ink); }
.ctl.manual .ctl-hint { display: block; }
.ctl[data-state="ready"] .ctl-hint { color: #fff3a6; box-shadow: inset 0 0 0 1px var(--gold2); animation: ctlready 1.2s steps(2) infinite; }
.ctl[data-state="takeover"] .ctl-hint { color: var(--cyan); box-shadow: inset 0 0 0 1px #1f7f9c; }
.ctl.go .ctl-hint { animation: ctlgo .3s steps(3) 1; }
.ctl.no .ctl-hint { animation: shake .3s steps(3) 1; color: var(--red2); }
@keyframes ctlready { 50% { color: var(--gold2); box-shadow: inset 0 0 0 1px #5e300c; } }
@keyframes ctlgo { 0% { background: var(--gold); color: #120b17; } 100% { background: #120b17e0; } }
#stage-inner.throwing { cursor: pointer; }
#stage-inner #toasts { bottom: 46px; } /* above the control switch */
.ctl-card h3 .ctl-key { margin-left: auto; font-weight: 600; }
.ctl-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 6px 0 4px; }
.ctl-pick .btn { display: flex; align-items: center; justify-content: center; gap: 6px; }
.ctl-desc { margin: 6px 0 2px; line-height: 1.4; }
.ctl-stats:empty { display: none; }
body.reduced-motion .ctl-hint { animation: none !important; }
@media (max-width: 820px) and (orientation: portrait), (max-width: 620px) {
  .ctl { left: 5px; bottom: 5px; gap: 4px; }
  .ctl-opt { padding: 2px 6px 2px 4px; min-height: 22px; font-size: 10px; }
  .ctl-opt .pxi { width: 14px; height: 14px; }
  .ctl-hint { font-size: 10px; padding: 4px 5px; }
  #stage-inner #toasts { bottom: 38px; }
}

/* Ten miner tiers: recipe picker chips, fuse-all buttons, batch recruit */
.tier-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 4px; margin: 6px 0 2px; }
.tier-chip { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 4px; padding: 3px 5px; background: #0d0c17; border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px var(--slate); color: var(--muted); font: 700 11px/1.1 var(--mono); cursor: pointer; text-align: left; }
.tier-chip img { grid-row: 1 / span 2; width: 20px; height: 22px; image-rendering: pixelated; }
.tier-chip .tc-own { font-weight: 600; color: #8e96ad; }
.tier-chip:hover { box-shadow: inset 0 0 0 1px var(--cyan); }
.tier-chip.ready .tc-own { color: var(--green2); }
.tier-chip.ready { box-shadow: inset 0 0 0 1px #2e7d32; }
.tier-chip.on { color: #2a1c00; background: var(--gold); box-shadow: inset 0 -2px 0 var(--gold2); }
.tier-chip.on .tc-own { color: #5e300c; }
.fuse-all .fa-row { display: flex; margin: 6px 0; }
.fuse-all .fa-row .btn { flex: 1; justify-content: center; }
.recruit-more { gap: 6px; margin: 6px 0 2px; flex-wrap: wrap; align-items: center; }

/* Dollar prices (mock rate): dollars first, the charged credits on a small second line */
.cost small, .price small { display: block; font: 600 10px/1.2 var(--mono); color: var(--muted); letter-spacing: 0; }
.price { flex-direction: column; align-items: flex-start; gap: 0; line-height: 1.15; }
.store-bal small { font: 600 11px var(--mono); color: var(--muted); }
.hud-credits small { white-space: nowrap; }
.usd-note { border-left: 3px solid var(--gold2); padding-left: 8px; }

/* ---------- Quests, login calendar, museum, player level ---------- */
.tabs button.dot::after { content: ''; position: absolute; top: 4px; right: 8px; width: 8px; height: 8px; background: var(--green2); border: 2px solid var(--ink); animation: blink 1.4s steps(2) infinite; }
body.reduced-motion .tabs button.dot::after { animation: none; }
.hud-level { position: relative; display: inline-flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 2px; min-width: 50px; padding: 3px 6px; background: #0d0c17; border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px var(--gold2); cursor: pointer; color: var(--gold); }
.hud-level b { font: 900 12px/1 var(--mono); letter-spacing: .04em; text-align: center; }
.hud-xp { display: block; height: 4px; background: #222846; border: 1px solid var(--ink); }
.hud-xp i { display: block; height: 100%; width: 0; background: var(--cyan); }
.hud-level:hover { box-shadow: inset 0 0 0 1px var(--gold); }
.hud-level.dot::after { content: ''; position: absolute; top: -5px; right: -5px; width: 8px; height: 8px; background: var(--green2); border: 2px solid var(--ink); }
.level-card .row { align-items: center; gap: 10px; }
.level-card .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.level-card .lvl-bar { width: 100%; }
.lvl-badge.big { font-size: 16px; padding: 4px 8px; }
.quest { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 6px 0; border-top: 1px solid #222846; }
.card h3 + .quest { border-top: none; }
.quest .q-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.quest .q-main b { font-size: 13px; line-height: 1.25; }
.quest .q-bar { height: 6px; background: #0d0c17; border: 1px solid var(--ink); margin: 2px 0 1px; }
.quest .q-bar i { display: block; height: 100%; background: var(--gold2); box-shadow: inset 0 1px 0 var(--gold); }
.quest.ready .q-bar i { background: var(--green2); box-shadow: none; }
.quest.ready b { color: var(--green2); }
.quest.claimed { opacity: .55; }
.quest .btn.mini { min-width: 70px; justify-content: center; }
.login-cal .cal-tiles { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; margin: 6px 0; }
.cal-tile { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 4px 3px; background: #0d0c17; border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px var(--line); font-size: 9.5px; line-height: 1.2; color: var(--muted); text-align: center; overflow: hidden; }
.cal-tile b { font: 800 10px var(--mono); color: var(--text); }
.cal-tile span { overflow-wrap: anywhere; }
.cal-tile.next { box-shadow: inset 0 0 0 2px var(--green2); color: var(--text); animation: calnext 1.4s steps(2) infinite; }
.cal-tile.done { box-shadow: inset 0 0 0 2px var(--gold2); }
.cal-tile.done b::after { content: ' ✓'; color: var(--green2); }
@keyframes calnext { 50% { box-shadow: inset 0 0 0 2px #2e7d32; } }
body.reduced-motion .cal-tile.next { animation: none; }
.mine-quest h3 .spacer { flex: 1; }
.mine-quest .login-ready { gap: 6px; align-items: center; margin-top: 6px; padding-top: 6px; border-top: 2px dashed var(--slate); }
.museum-set.complete { box-shadow: inset 0 0 0 2px var(--gold2); }
.relic-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; margin: 6px 0 4px; }
.relic { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px; background: #0d0c17; border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px var(--line); min-width: 0; text-align: center; }
.relic img { width: 36px; height: 36px; image-rendering: pixelated; object-fit: contain; }
.relic img.missing { filter: brightness(0) opacity(.5); }
.relic span { font-size: 9.5px; line-height: 1.15; color: var(--muted); overflow-wrap: anywhere; }
.relic.have { box-shadow: inset 0 0 0 1px var(--gold2); }
.relic.have span { color: var(--text); }
.ach .btn.mini, .ach .pill { flex: none; }
.ach.ready { box-shadow: inset 0 0 0 2px var(--green2); }
.tool-inv { gap: 8px; align-items: center; flex-wrap: wrap; }
.report-text { width: 100%; min-height: 280px; font: 11px/1.45 var(--mono); color: var(--text); background: #0d0c17; border: 2px solid var(--ink); padding: 6px; resize: vertical; }

/* Dynamite button on the scene (bottom-right) */
.dyn { position: absolute; right: 8px; bottom: 8px; z-index: 4; display: flex; align-items: center; gap: 4px; padding: 3px 7px 3px 5px; min-height: 26px; font: 800 12px/1 var(--mono); color: #8e96ad; background: #1a1c33; border: 2px solid var(--ink); box-shadow: 0 0 0 2px #5e300c, 0 0 0 4px var(--ink); cursor: pointer; opacity: .82; }
.dyn .pxi { width: 18px; height: 18px; }
.dyn .dyn-n { color: #ffe9a6; }
.dyn .dyn-key { font-size: 9px; padding: 1px 3px; color: #8e96ad; border: 1px solid #3b4a6b; }
.dyn .dyn-key:empty { display: none; }
.dyn.armed { opacity: 1; color: #120b17; background: var(--orange, #ff8c2e); box-shadow: 0 0 0 2px #6e1a22, 0 0 0 4px var(--ink), inset 0 2px 0 #ffe28f; animation: dynarm .5s steps(2) infinite; }
.dyn.armed .dyn-n { color: #120b17; }
.dyn.armed.heavy { background: var(--red2); }
.dyn.empty { opacity: .55; }
.dyn.no { animation: shake .3s steps(3) 1; }
@keyframes dynarm { 50% { box-shadow: 0 0 0 2px #b8332c, 0 0 0 4px var(--ink), inset 0 2px 0 #fff3a6; } }
body.reduced-motion .dyn.armed { animation: none; }
@media (max-width: 820px) and (orientation: portrait), (max-width: 620px) {
  .dyn { right: 5px; bottom: 5px; min-height: 22px; padding: 2px 6px 2px 4px; font-size: 11px; }
  .dyn .pxi { width: 16px; height: 16px; }
  .hud-level { min-width: 44px; padding: 2px 4px; }
  .cal-tile { font-size: 8.5px; padding: 3px 2px; }
  .relic img { width: 30px; height: 30px; }
}
.lvlup.player { box-shadow: inset 0 0 0 2px var(--cyan), inset 0 0 0 4px #1f7f9c; }
.lvlup.player b { color: #c4f7ff; text-shadow: 2px 2px 0 #1f4d8f, -1px -1px 0 #120b17; }
.lvlup.set { box-shadow: inset 0 0 0 2px #c79cff, inset 0 0 0 4px #4e3380; }
.lvlup.set b { color: #e7d4ff; text-shadow: 2px 2px 0 #4e3380, -1px -1px 0 #120b17; }
.cal-tile { align-items: center; gap: 3px; }
.rw-chip { display: inline-flex; align-items: center; gap: 1px; font: 700 9.5px/1 var(--mono); color: var(--text); white-space: nowrap; }
.rw-chip .pxi { width: 14px; height: 14px; }
.rw-chip.xp { color: var(--cyan); font-size: 9px; }
.world-rules { color: #e8c46a; margin-top: 2px; }
.lvlup.world { top: 9%; box-shadow: inset 0 0 0 2px var(--green2), inset 0 0 0 4px #23602c; }
.lvlup.world b { font-size: 18px; color: #d8f7c0; text-shadow: 2px 2px 0 #23602c, -1px -1px 0 #120b17; }
.shift-chip { background: #cfd8e4; color: #1a1c33; }
.shift-chip.low { background: var(--gold); color: #3a2a00; animation: blink 1.4s steps(2) infinite; }
body.reduced-motion .shift-chip.low { animation: none; }
.shift-over { box-shadow: inset 0 0 0 2px var(--gold2); margin-bottom: 8px; }
.shift-over b { color: var(--gold); font-size: 15px; }
.next-reward { display: flex; align-items: center; gap: 4px; margin-top: 6px; padding-top: 5px; border-top: 1px solid #222846; color: #e8c46a; }
.next-reward .pxi { width: 12px; height: 12px; }
/* Deep Shaft card */
.shaft-view { display: block; width: 100%; max-width: 336px; height: auto; aspect-ratio: 112 / 40; margin: 6px auto 4px; image-rendering: pixelated; border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.shaft-stats { display: grid; grid-template-columns: auto 1fr; gap: 1px 8px; font-size: 12px; margin: 4px 0; }
.shaft-stats .k { color: var(--muted); }
.shaft-stats .v { font-family: var(--mono); color: var(--green2); }
.shaft-row { display: flex; align-items: center; gap: 8px; margin: 6px 0 2px; }
.shaft-pick { flex: 1; min-width: 0; font: 600 12px var(--font); color: var(--text); background: #0d0c17; border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px var(--line); padding: 3px 4px; }
.shaft-card.shaft-locked { opacity: .85; }

/* ---------- Live content: weekend event, season pass, league, Gold Race ---------- */
.live-event.on { box-shadow: inset 0 0 0 2px #c79cff, inset 0 4px 0 var(--card2); }
.live-event .row { gap: 6px; align-items: center; }
.season-card.premium { box-shadow: inset 0 0 0 2px var(--gold2); }
.season-card .row { gap: 6px; align-items: center; }
.season-row { margin: 4px 0 6px; }
.season-row .grow, .season-head .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.season-row .lvl-bar { width: 100%; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; margin: 8px 0; }
.shop-item { display: flex; flex-direction: column; gap: 4px; padding: 8px; background: var(--card); border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.shop-item.owned { opacity: .6; }
.shop-item .shop-ic { display: flex; justify-content: center; padding: 4px; background: #0d0c17; border: 1px solid var(--line); }
.shop-item .shop-ic .pxi { width: 32px; height: 32px; }
.shop-item .btn { margin-top: auto; }
.season-head { gap: 10px; align-items: center; margin-bottom: 8px; }
.pass-grid { display: grid; grid-template-columns: 34px 1fr 1fr; gap: 3px; max-height: 56vh; overflow: auto; }
.pass-h { font: 800 11px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 2px 4px; position: sticky; top: 0; background: var(--panel); z-index: 1; }
.pass-t { display: flex; align-items: center; justify-content: center; font: 800 12px var(--mono); color: var(--dim); background: #0d0c17; border: 1px solid var(--ink); }
.pass-t.on { color: #2a1c00; background: var(--gold); }
.pass-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 28px; padding: 3px 6px; background: var(--card); border: 1px solid var(--ink); }
.pass-cell.premium { background: #221a33; }
.pass-cell.locked { opacity: .55; }
.pass-cell.ready { box-shadow: inset 0 0 0 2px var(--green2); }
.pass-cell.claimed { opacity: .5; }
.pass-cell .btn.mini { margin-left: auto; }
.pass-cell .rw-chip { font-size: 11px; }
.league-head .row, .league-last .row { gap: 10px; align-items: center; }
.league-head .grow, .league-last .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.league-head .pxi, .league-last > .row > .pxi { width: 36px; height: 36px; }
.league-last { box-shadow: inset 0 0 0 2px var(--green2); }
.league-list .rank-row.up { border-left: 3px solid var(--green2); }
.league-list .rank-row.down { border-left: 3px solid var(--red2); }
.crews { opacity: .9; }
.race-card .race-medals { gap: 4px; flex-wrap: wrap; margin: 4px 0 6px; }
.race-card .row { align-items: center; }
.modal.race-modal { width: min(920px, 96vw); }
.race-wrap { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #08070f; display: flex; align-items: center; justify-content: center; overflow: hidden; border: 2px solid var(--ink); margin: 6px 0; }
.race-canvas { display: block; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: manipulation; cursor: pointer; }
.race-hud { gap: 16px; align-items: center; font: 700 13px var(--mono); }
.race-hud b { color: #ffe9a6; font-size: 16px; }
.race-combo { color: var(--gold); font-weight: 900; }
.race-msg { min-height: 18px; font: 800 13px var(--mono); color: var(--cyan); text-align: center; margin: 4px 0; }
.race-result { margin-top: 6px; }
.race-final { gap: 8px; align-items: center; margin-bottom: 6px; }
.race-final b { font: 900 20px var(--mono); color: var(--gold); }
.race-final .pxi { width: 28px; height: 28px; }
.race-board { max-height: 30vh; overflow: auto; }
.race-top { align-items: center; gap: 8px; }

/* ---------- Crew: rarities, recruit reveal, merge, Crew Mine ---------- */
:root { --r-N: #b9bbc6; --r-R: #8fdc6a; --r-SR: #4b86cf; --r-SSR: #c79cff; --r-UR: #f8cf45; }
.rar-chip { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 16px; padding: 0 4px; font: 900 10px/1 var(--mono); letter-spacing: .04em; color: #120b17; background: var(--r-N); border: 1px solid var(--ink); }
.rar-chip.r-R { background: var(--r-R); }
.rar-chip.r-SR { background: var(--r-SR); color: #fff; }
.rar-chip.r-SSR { background: var(--r-SSR); }
.rar-chip.r-UR { background: var(--r-UR); box-shadow: inset 0 -2px 0 #e0962a; }
.stars { color: var(--r-UR); font-size: 11px; letter-spacing: -1px; }
.recruit-card .row { gap: 8px; align-items: center; }
.recruit-card .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.recruit-card h3 { margin: 0; }
.recruit-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0 6px; }
.recruit-btns .btn { display: flex; flex-direction: column; align-items: center; gap: 1px; padding-block: 6px; }
.recruit-btns .btn small { font: 700 10px var(--mono); opacity: .85; }
.recruit-meta { flex-wrap: wrap; gap: 4px; }
.recruit-meta .pill .pxi { width: 12px; height: 12px; }
.mc { grid-template-columns: 60px minmax(0, 1fr) auto; border-left: 3px solid var(--r-N); }
.mc.r-R { border-left-color: var(--r-R); }
.mc.r-SR { border-left-color: var(--r-SR); }
.mc.r-SSR { border-left-color: var(--r-SSR); }
.mc.r-UR { border-left-color: var(--r-UR); box-shadow: inset 0 0 0 1px #5e300c; }
.mc-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mc-main .who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-main .small { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.mc-main .perk { color: #e8c46a; }
.tier-badge.sm { width: 13px; height: 14px; }
.mc-actions { display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.lock-btn { min-width: 0; padding-inline: 6px; }
.lock-btn .pxi { width: 12px; height: 12px; opacity: .45; }
.lock-btn.on .pxi { opacity: 1; }
.lock-btn.on { box-shadow: inset 0 0 0 1px var(--gold2); }
.collection > .btn { width: 100%; margin-top: 4px; }
.slot.filled { cursor: pointer; position: relative; }
.slot.lead { border-color: var(--gold) !important; box-shadow: inset 0 0 0 1px var(--gold2); }
.lead-tag { position: absolute; top: 2px; left: 2px; font: 900 9px var(--mono); padding: 1px 3px; color: #2a1c00; background: var(--gold); border: 1px solid var(--ink); }
.slot.r-SSR, .slot.r-UR { border-color: var(--r-SSR); }
/* reveal */
.reveal-modal.jackpot { animation: jackpot 1.2s steps(6) 1; }
@keyframes jackpot { 0%, 100% { box-shadow: inset 0 0 0 2px var(--line), 0 6px 0 #05040a; } 40% { box-shadow: inset 0 0 0 3px var(--r-UR), 0 0 0 4px #5e300c, 0 6px 0 #05040a; } }
.reveal-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.reveal-grid.one { grid-template-columns: minmax(0, 200px); justify-content: center; }
.reveal-card { position: relative; aspect-ratio: 3 / 4; perspective: 600px; animation: rcin .45s steps(5) both; }
.reveal-card .rc-back, .reveal-card .rc-front { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px; border: 2px solid var(--ink); text-align: center; }
.reveal-card .rc-back { background: #1a1c33; box-shadow: inset 0 0 0 2px var(--slate); font: 900 22px var(--mono); color: var(--muted); animation: rcback .45s steps(5) both; animation-delay: inherit; }
.reveal-card .rc-front { background: #0d0c17; box-shadow: inset 0 0 0 2px var(--r-N); animation: rcfront .45s steps(5) both; animation-delay: inherit; }
.reveal-card.done .rc-back { display: none; }
.reveal-card.done .rc-front { animation: none; opacity: 1; transform: none; }
.reveal-card.r-R .rc-front { box-shadow: inset 0 0 0 2px var(--r-R); }
.reveal-card.r-SR .rc-front { box-shadow: inset 0 0 0 2px var(--r-SR); }
.reveal-card.r-SSR .rc-front { box-shadow: inset 0 0 0 2px var(--r-SSR), 0 0 0 2px #4e3380; background: #1d1430; }
.reveal-card.r-UR .rc-front { box-shadow: inset 0 0 0 2px var(--r-UR), 0 0 0 2px #e0962a; background: #2a1c06; }
.rc-img { width: 60px; height: 78px; image-rendering: pixelated; object-fit: none; max-width: 100%; }
.reveal-card b { font-size: 12px; line-height: 1.15; }
.rc-new { font: 900 9px var(--mono); padding: 1px 4px; color: #10301a; background: var(--green2); border: 1px solid var(--ink); }
.rc-perk { color: #e8c46a; line-height: 1.2; font-size: 10px; }
.reveal-sum { margin-top: 8px; text-align: center; }
@keyframes rcin { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes rcback { 0%, 60% { opacity: 1; transform: scaleX(1); } 100% { opacity: 0; transform: scaleX(0); } }
@keyframes rcfront { 0%, 60% { opacity: 0; transform: scaleX(0); } 100% { opacity: 1; transform: scaleX(1); } }
body.reduced-motion .reveal-card, body.reduced-motion .reveal-card .rc-back, body.reduced-motion .reveal-card .rc-front { animation: none !important; }
body.reduced-motion .reveal-card .rc-back { display: none; }
@media (max-width: 620px) { .reveal-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .rc-img { width: 40px; height: 52px; } }
table.rates td { vertical-align: top; }
/* album */
.album { display: grid; gap: 10px; }
.album-row .row { gap: 6px; align-items: center; flex-wrap: wrap; }
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 4px; margin-top: 4px; }
.album-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px; background: #0d0c17; border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px var(--line); text-align: center; min-width: 0; }
.album-cell.have.r-R { box-shadow: inset 0 0 0 1px var(--r-R); }
.album-cell.have.r-SR { box-shadow: inset 0 0 0 1px var(--r-SR); }
.album-cell.have.r-SSR { box-shadow: inset 0 0 0 1px var(--r-SSR); }
.album-cell.have.r-UR { box-shadow: inset 0 0 0 1px var(--r-UR); }
.album-img { width: 40px; height: 52px; image-rendering: pixelated; object-fit: none; }
.album-img.missing { filter: brightness(0) opacity(.45); }
.album-cell span { overflow-wrap: anywhere; line-height: 1.15; }
/* merge */
.merge-card .chips .chip.ready { box-shadow: inset 0 0 0 1px #2e7d32; }
.merge-slots { display: grid; gap: 4px; margin: 6px 0; }
.mslot { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; background: #0d0c17; border: 2px dashed var(--slate); color: var(--muted); font: 800 14px var(--mono); cursor: pointer; padding: 0; overflow: hidden; }
.mslot.f { border-style: solid; border-color: var(--r-N); }
.mslot.f.r-R { border-color: var(--r-R); }
.mslot.f.r-SR { border-color: var(--r-SR); }
.ms-img { max-width: 92%; max-height: 92%; image-rendering: pixelated; }
.merge-cands { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 4px; margin-top: 6px; }
.mcand { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 3px 2px; background: #0d0c17; border: 2px solid var(--ink); color: var(--text); cursor: pointer; }
.mcand.on { box-shadow: inset 0 0 0 2px var(--gold); }
.mcand span { font-size: 9px; }
/* Crew Mine */
.crew-slots { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; margin: 4px 0 6px; }
.cslot { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; padding: 0; background: #0d0c17; border: 2px dashed var(--slate); color: var(--muted); font: 800 14px var(--mono); cursor: pointer; overflow: hidden; }
.cslot.f { border-style: solid; border-color: var(--r-N); }
.cslot.f.r-R { border-color: var(--r-R); }
.cslot.f.r-SR { border-color: var(--r-SR); }
.cslot.f.r-SSR { border-color: var(--r-SSR); }
.cslot.f.r-UR { border-color: var(--r-UR); }
.cs-img { width: 20px; height: 26px; image-rendering: pixelated; object-fit: none; }
.crew-btns { gap: 6px; align-items: center; flex-wrap: wrap; }
.picker { display: grid; gap: 4px; max-height: 60vh; overflow: auto; }
