/* Voxel Smash. Portrait only (R0.2): the object is tall and the frame is the
   shape of the thing you are aiming at. */
:root {
  --sky: #0a2740;
  --ink: #eaf2f8;
  --dim: #9fb6c9;
  --card: #113049;
  --line: #1f4d70;
  --hot: #ff7a3d;
  --good: #3ddc84;
}
:root {
  --card: #113049;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--sky); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; overflow: hidden;
  -webkit-text-size-adjust: 100%;
}
#app { display: flex; flex-direction: column; height: 100%; }

#hdr {
  display: flex; align-items: center; gap: 6px;
  padding: calc(env(safe-area-inset-top, 0px) + 6px) 8px 6px;
  background: #06192b; border-bottom: 1px solid #14364f;
}
#hdrTitle { font-weight: 700; font-size: 15px; }
/* The shared header shelf is a seventh child, and at 320 px the row was 355 px
   wide: the ❓ ran off the right edge where nothing could reach it. The title
   is the one thing in there that repeats what the tab already says. */
@media (max-width: 380px) { #hdrTitle { display: none; } }
#hud { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
#hud::before { content: "🪙 "; }
.pill {
  min-width: 44px; min-height: 44px; border: 0; border-radius: 12px;
  background: #12314a; color: var(--ink); font-size: 18px; cursor: pointer;
}
.pill:active { background: #1b4566; }

.scr { display: none; flex: 1; overflow-y: auto; padding: 12px; }
.scr.on { display: block; }
#scr-play.on { display: flex; padding: 0; }

h1 { font-size: 26px; margin: 8px 0 4px; }
.stat { color: var(--dim); font-size: 13px; }

#levelCard {
  background: #0d2c45; border: 1px solid #1b4566; border-radius: 14px;
  padding: 12px; margin-bottom: 12px;
}
#levelName { font-size: 20px; font-weight: 700; }
/* R70: the previews. A picture of the thing, not a paragraph about it. */
#menuView, #rigView {
  display: block; width: 100%; max-width: 420px; height: 240px; margin: 0 auto; border-radius: 10px;
  background: linear-gradient(#0e7ec9, #7fd4f5); margin-bottom: 10px; margin-top: 0;
}
#rigView { height: 170px; }
.garageHead { font-size: 15px; margin: 14px 0 4px; }
.swatch {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  border: 2px solid #1f4d70;
}
#levelAt { color: var(--dim); font-size: 13px; margin-bottom: 8px; }
#integrityWrap, #barWrap {
  height: 12px; background: #06192b; border-radius: 99px; overflow: hidden;
}
#integrityFill, #barFill {
  height: 100%; width: 100%; background: linear-gradient(90deg, var(--good), #7bf0b0);
  transition: width .25s ease;
}
#integrityText { color: var(--dim); font-size: 12px; margin-top: 6px; }

.big {
  display: block; width: 100%; min-height: 52px; margin: 8px 0;
  border: 1px solid #1f4d70; border-radius: 14px; background: #12314a;
  color: var(--ink); font-size: 17px; font-weight: 600; cursor: pointer;
}
.big.primary { background: var(--hot); border-color: #ff9e6b; color: #2a1206; }
.small {
  min-height: 44px; padding: 0 14px; border-radius: 10px;
  border: 1px solid #1f4d70; background: #12314a; color: var(--ink);
  font-size: 14px; cursor: pointer;
}
.small:disabled { opacity: .45; }

#garTitle { margin: 0; padding: 13px 12px 0; min-height: 48px; font-size: 16px; }
#custom, #garage {
  margin: 10px 0; border: 1px solid #1b4566; border-radius: 14px; background: #0d2c45;
}
#custom > summary { list-style: none; }
#custom > summary::-webkit-details-marker { display: none; }
#custom > summary::after { content: "▾"; margin-left: auto; color: var(--dim); }
#custom[open] > summary::after { content: "▴"; }
details { margin: 10px 0; border: 1px solid #1b4566; border-radius: 14px; background: #0d2c45; }
summary { min-height: 48px; display: flex; align-items: center; padding: 0 12px; cursor: pointer; font-weight: 600; }
.setBody { padding: 10px 12px 14px; }
.setRow { display: flex; align-items: center; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.setLbl { flex: 1 1 120px; font-size: 14px; }
.setNote { color: var(--dim); font-size: 12px; line-height: 1.4; }
.knob { display: flex; gap: 6px; flex-shrink: 0; }
.knobBtn {
  min-height: 44px; min-width: 56px; border-radius: 10px;
  border: 1px solid #1f4d70; background: #0a2740; color: var(--dim);
  font-size: 13px; cursor: pointer;
}
.knobBtn.on { background: var(--hot); color: #2a1206; border-color: #ff9e6b; font-weight: 700; }

.upRow { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.buy { min-width: 96px; font-variant-numeric: tabular-nums; }
.upName { flex: 1; font-size: 14px; }

#stage { position: relative; flex: 1; width: 100%; touch-action: none; }
#cvs { display: block; width: 100%; height: 100%; }
#glFail {
  position: absolute; inset: 20% 12% auto; padding: 14px; border-radius: 12px;
  background: #06192b; color: var(--ink); font-size: 14px; line-height: 1.5;
}

#playHud { position: absolute; top: 8px; left: 10px; right: 10px; pointer-events: none; }
#meters { display: flex; gap: 12px; margin-top: 6px; font-size: 13px; font-variant-numeric: tabular-nums; }
#meters b { margin-left: 3px; }
/* R63: the count, big, while the smash is happening */
#smashCount {
  position: absolute; top: 58px; left: 0; right: 0; text-align: center;
  font-size: 34px; font-weight: 900; color: #fff; pointer-events: none;
  text-shadow: 0 2px 0 #7a2a0b, 0 0 12px rgba(0, 0, 0, .45);
  font-variant-numeric: tabular-nums;
}
#smashCount.pop { animation: pop .22s ease-out; }
@keyframes pop { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }
#hud.pop { animation: pop .3s ease-out .6s; }
/* R63: one soft flash on impact -- warm white, under half strength, once */
#flash {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 45%, rgba(255, 248, 225, .95), rgba(255, 220, 160, .35) 60%, transparent);
}
#flash.go { animation: flash .35s ease-out; }
@keyframes flash { 0% { opacity: .45; } 100% { opacity: 0; } }
#replayTag {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); white-space: nowrap;
  min-height: 44px; padding: 0 16px; border-radius: 99px; border: 0;
  background: rgba(6, 25, 43, .8); color: var(--ink); font-size: 15px; font-weight: 700;
  cursor: pointer;
}
#btnHorn { position: absolute; right: 12px; bottom: 14px; background: rgba(6, 25, 43, .7); }
.flyCoin { position: fixed; z-index: 30; font-size: 20px; pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  #smashCount.pop, #hud.pop { animation: none; }
  #flash.go { animation: none; }
}
#holdHint {
  position: absolute; left: 50%; bottom: 18%; transform: translateX(-50%);
  background: rgba(6, 25, 43, .85); padding: 10px 16px; border-radius: 99px;
  font-size: 16px; pointer-events: none; animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { /* R63: the count, big, while the smash is happening */
#smashCount {
  position: absolute; top: 58px; left: 0; right: 0; text-align: center;
  font-size: 34px; font-weight: 900; color: #fff; pointer-events: none;
  text-shadow: 0 2px 0 #7a2a0b, 0 0 12px rgba(0, 0, 0, .45);
  font-variant-numeric: tabular-nums;
}
#smashCount.pop { animation: pop .22s ease-out; }
@keyframes pop { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }
#hud.pop { animation: pop .3s ease-out .6s; }
/* R63: one soft flash on impact -- warm white, under half strength, once */
#flash {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 45%, rgba(255, 248, 225, .95), rgba(255, 220, 160, .35) 60%, transparent);
}
#flash.go { animation: flash .35s ease-out; }
@keyframes flash { 0% { opacity: .45; } 100% { opacity: 0; } }
#replayTag {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); white-space: nowrap;
  min-height: 44px; padding: 0 16px; border-radius: 99px; border: 0;
  background: rgba(6, 25, 43, .8); color: var(--ink); font-size: 15px; font-weight: 700;
  cursor: pointer;
}
#btnHorn { position: absolute; right: 12px; bottom: 14px; background: rgba(6, 25, 43, .7); }
.flyCoin { position: fixed; z-index: 30; font-size: 20px; pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  #smashCount.pop, #hud.pop { animation: none; }
  #flash.go { animation: none; }
}
#holdHint { animation: none; opacity: .9; } }

/* R-C15a: an overlay is a SCROLL REGION, not a centring box. The card centres
   while it fits and pins to the top and scrolls when it does not, so its top
   is never permanently out of reach on a short screen. */
.ovl {
  position: absolute; inset: 0; display: none;
  align-items: flex-start; justify-content: center; overflow-y: auto;
  background: rgba(4, 16, 28, .72); padding: 16px;
}
.ovl.on { display: flex; }
/* R63: the result cards sit LOW and see-through, so the damage they are
   reporting stays in view above them. The auto top margin keeps R-C15a: when
   the card is taller than the screen the margin collapses to nothing and the
   card pins to the top and scrolls. */
.ovl.low { background: linear-gradient(transparent 45%, rgba(4, 16, 28, .55)); }
.ovl.low .ovlCard { margin: auto auto 0; background: rgba(13, 44, 69, .93); }
/* two buttons side by side: the card is half as tall, and the damage above
   it is that much more of the screen */
.btnRow { display: flex; gap: 8px; }
.btnRow .big { flex: 1; }
.btnRow .big[hidden] { display: none; }
.ovl.low .ovlCard p { margin: 4px 0; }
.ovl.low .ovlCard h2 { margin: 0 0 4px; }
#ovBest { color: #ffd23f; font-weight: 800; font-size: 15px; }
.ovlCard {
  width: 100%; max-width: 340px; margin: auto; background: #0d2c45;
  border: 1px solid #1f4d70; border-radius: 16px; padding: 16px; text-align: center;
}
.ovlCard h2 { margin: 4px 0 8px; font-size: 20px; }
.ovlCard p { color: var(--dim); font-size: 14px; line-height: 1.45; }
.big-score { font-size: 30px; font-weight: 800; color: var(--ink); margin: 6px 0; }

.card {
  background: #0d2c45; border: 1px solid #1b4566; border-radius: 14px;
  padding: 12px; margin-bottom: 10px; font-size: 14px; line-height: 1.5; color: var(--dim);
}
.card h2 { margin: 0 0 6px; font-size: 16px; color: var(--ink); }

footer { padding: 6px 10px calc(env(safe-area-inset-bottom, 0px) + 6px); text-align: center; }
.toast-host { position: fixed; left: 0; right: 0; bottom: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }

/* R74: Again fills over two seconds, then presses itself. The fill is the
   countdown; the number on the button says the same for anyone who has
   motion turned down. */
#btnAgain { position: relative; overflow: hidden; }
#btnAgain.auto::after {
  content: ''; position: absolute; inset: 0; background: rgba(255, 255, 255, .3);
  transform-origin: left center; animation: againFill 2s linear forwards; pointer-events: none;
}
@keyframes againFill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) { #btnAgain.auto::after { animation: none; transform: scaleX(0); } }

/* R79: the gallery. Tiles at least 44 px to tap; pixels drawn as pixels. */
.galTop { display: flex; align-items: center; gap: 10px; }
.galTop h2 { margin: 0; font-size: 20px; }
#galTabs { display: flex; gap: 6px; margin: 12px 0 4px; border-bottom: 1px solid var(--line); }
#galTabs button {
  min-height: 44px; padding: 0 14px; border: 0; border-radius: 10px 10px 0 0;
  background: transparent; color: var(--dim); font-size: 15px; font-weight: 600; cursor: pointer;
}
#galTabs button.on { background: var(--card); color: var(--ink); box-shadow: inset 0 -3px 0 var(--hot); }
/* R92.5: the round you are looking at, when there is more than one */
#galRound { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 6px 0 2px; }
#galRound[hidden] { display: none; }
#galRound button { min-width: 44px; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 16px; cursor: pointer; }
#galRound button:disabled { opacity: .35; cursor: default; }
#galRoundText { font-weight: 600; }
#galGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.galTile {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 44px; padding: 6px 4px 8px; border: 1px solid #1b4566; border-radius: 12px;
  background: #0d2c45; color: var(--ink); font: inherit; cursor: pointer;
}
.galTile:disabled { cursor: default; background: #0a2238; border-color: #143a57; }
.galTile.galNew { border-color: var(--hot); }
.galTile.galHere { box-shadow: 0 0 0 2px var(--good); }
.galPic {
  width: 100%; height: 88px; object-fit: contain; image-rendering: pixelated;
  background: linear-gradient(#0e7ec9, #7fd4f5); border-radius: 8px;
}
.galLocked .galPic { background: #16324a; }
.galName { font-size: 12px; font-weight: 600; line-height: 1.25; text-align: center; overflow-wrap: anywhere; }
.galState { font-size: 11px; color: var(--dim); }
.galPlus {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  font-size: 40px; background: #16324a; color: var(--dim);
}
#slotCards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 12px; }
.slotCard {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 44px; padding: 8px;
  border: 2px solid #1b4566; border-radius: 12px; background: #0d2c45; color: var(--ink); font: inherit; cursor: pointer;
}
.slotCard.on { border-color: var(--hot); }

/* the menu scrolls; the question about slots stays on the screen */
#slotAsk { position: fixed; z-index: 30; }

/* R80: the boost button, bottom left, big enough for a thumb held down */
#btnBoost {
  position: absolute; left: 14px; bottom: 16px; width: 84px; height: 84px; border-radius: 50%;
  border: 3px solid #ffb03b; background: rgba(120, 34, 8, .82); color: #fff;
  font-size: 34px; line-height: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  touch-action: none; -webkit-user-select: none; user-select: none;
}
#btnBoost[hidden] { display: none; }
#galTabs button[hidden] { display: none; }
#btnBoost span { font-size: 12px; font-weight: 700; margin-top: 2px; }
#btnBoost:active { background: rgba(200, 70, 10, .9); }
/* R80.1: the meters answer a tap */
#meters span { pointer-events: auto; cursor: help; padding: 6px 4px; margin: -6px -4px; }
#tip {
  position: absolute; top: 58px; left: 10px; right: 10px; max-width: 320px; padding: 8px 10px;
  border-radius: 10px; background: rgba(6, 25, 43, .92); color: var(--ink); font-size: 13px; line-height: 1.4;
  pointer-events: none;
}

/* R81: the garage in tabs, and the trial bar */
#garTabs { display: flex; gap: 4px; margin: 10px 0 8px; border-bottom: 1px solid var(--line); }
#garTabs button {
  flex: 1; min-height: 44px; padding: 0 6px; border: 0; border-radius: 10px 10px 0 0;
  background: transparent; color: var(--dim); font-size: 14px; font-weight: 600; cursor: pointer;
}
#garTabs button.on { background: var(--card); color: var(--ink); box-shadow: inset 0 -3px 0 var(--hot); }
.garPanel[hidden] { display: none; }
#trialBar {
  margin: 0 0 8px; padding: 10px; border-radius: 12px; border: 1px dashed var(--hot);
  background: rgba(255, 122, 61, .08); font-size: 14px;
}
#trialText { margin-bottom: 8px; line-height: 1.4; }
.tryBtn { margin-right: 6px; }

/* R82: the menu, reordered. The card holds the object and the way to every
   object; Play sticks to the bottom of the screen until the end of the page. */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#scr-menu > #levelCard:first-of-type { margin-top: 4px; }
#replayChip {
  display: inline-block; margin: 4px 0 2px; padding: 3px 10px; border-radius: 999px;
  background: rgba(255, 122, 61, .16); color: #ffb48a; font-size: 12px; font-weight: 700;
}
#replayChip[hidden] { display: none; }
#btnGallery { margin-top: 10px; }
#levelCard .stat { margin: 8px 0 0; }
#btnPlay {
  position: sticky; bottom: calc(env(safe-area-inset-bottom, 0px) + 8px); z-index: 5;
  margin-top: 10px; box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
}
#turntable { position: relative; }
#turntable #rigView { margin-bottom: 8px; }
#trialBar { min-height: 96px; display: flex; flex-direction: column; justify-content: center; }
#trialBar:not(.on) { border-style: solid; border-color: var(--line); background: transparent; color: var(--dim); text-align: center; }
#trialBtns[hidden] { display: none; }

/* R84: the Generated tab's + and the making bar */
#genAsk { position: fixed; z-index: 30; }
#genBarWrap { height: 14px; border-radius: 7px; background: #0a2238; overflow: hidden; margin: 10px 0; }
#genBar { height: 100%; width: 0; background: linear-gradient(90deg, var(--hot), #ffd23f); transition: width .2s; }
.galMake { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px; }
.galMake .galPlus { background: var(--hot); color: #fff; }
.galMake .galNote { font-size: 13px; color: var(--dim); text-align: center; }
.galMake .galLock { font-size: 13px; font-weight: 700; color: #ffb48a; text-align: center; }

