:root {
  color-scheme: dark;
  --gold: #cdb57a;
  --pale: #efdda5;
  --muted: #baaa89;
  --floor: #15161c;
  --wall: #6a6a78;
  --card: #141316;
  --ruby-edge: #b3263e;
  --ruby-face: #b3263e;
  --ruby-light: #e0566e;
  --ruby-shadow: #7a1328;
  font-family: 'Times New Roman', 'Yu Mincho', serif;
  color: var(--gold);
  background: radial-gradient(ellipse at 50% 28%, #242126, #111014 53%, #0b0b0d 83%) fixed;
}
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; background-color: #0b0b0d; }
body { margin: 0; min-height: 100%; position: relative; }
/* Overhead vault spotlight exclusively on the title screen */
body:has(#home:not([hidden])) {
  background:
    radial-gradient(ellipse 68% 44% at 50% 6%, #45352158 0%, transparent 72%),
    radial-gradient(ellipse 80% 65% at 50% 42%, #231e24 0%, #100f13 58%, #08080a 92%) fixed;
}
body:has(#home:not([hidden]))::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    conic-gradient(from 160deg at 50% -12%, transparent 0deg, #f3d78c18 18deg, #ffe7a828 20deg, #f3d78c18 22deg, transparent 40deg);
}
[hidden] { display: none !important; }
/* Every screen fits one viewport height: the board takes whatever height is left. */
main {
  position: relative; z-index: 1; display: flex; flex-direction: column; justify-content: center;
  width: 100%; max-width: 544px; height: 100vh; height: 100dvh; margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
h1, h2, h3, p { margin: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
button {
  font: inherit; color: inherit;
  min-height: 44px; max-width: 100%; padding: 7px 12px; border: 1px solid #9c8455;
  border-radius: 3px; background: #18161a; color: var(--pale); cursor: pointer;
}
.primary { color: #20170e; background: linear-gradient(#e4cc92, #c4a465); font-weight: bold; }
button:focus-visible {
  outline: 2px solid #fff0bd; outline-offset: 2px;
}

/* ===== v1.4 Title Screen + v1.6 Subtle Privacy Footnote ===== */
.home {
  flex: 1 1 0; min-height: 0; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; text-align: center;
}
.vault-gate-wrap {
  width: 100%; max-width: 460px;
  flex: 1 1 0; min-height: 0; max-height: 604px;
  margin-top: 38px;
  display: flex; align-items: center; justify-content: center;
}
.vault-gate {
  position: relative; width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(9px, 1.8vh, 17px);
  padding: clamp(12px, 2.2vh, 24px) clamp(14px, 3.8vw, 26px);
  border-radius: 8px;
  background:
    radial-gradient(ellipse 92% 62% at 50% 24%, #2d252a 0%, #161419 56%, #0f0e12 100%);
  border: 2px solid #9e834f;
  box-shadow:
    0 18px 42px #000c,
    0 0 0 1px #2e2519,
    inset 0 0 0 6px #18151a,
    inset 0 0 0 7px #75603a,
    inset 0 18px 36px #f1cf7c10;
}
.vault-keystone {
  position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
  width: 68px; height: 14px; pointer-events: none;
  background: linear-gradient(180deg, #e7cb88, #8c703c);
  clip-path: polygon(10% 0, 90% 0, 100% 100%, 0 100%);
  box-shadow: 0 3px 8px #0009;
}
.vault-rivet {
  position: absolute; width: 8px; height: 8px; transform: rotate(45deg);
  background: linear-gradient(135deg, #fff1be, #c29e55 58%, #685128);
  box-shadow: 0 0 0 1px #1b1612, 0 1px 3px #000a;
  pointer-events: none;
}
.vault-rivet.tl { top: 10px; left: 10px; }
.vault-rivet.tr { top: 10px; right: 10px; }
.vault-rivet.bl { bottom: 10px; left: 10px; }
.vault-rivet.br { bottom: 10px; right: 10px; }
.crest {
  width: clamp(64px, 17vw, 86px); flex: 0 0 auto; color: var(--pale);
  filter: drop-shadow(0 5px 12px #000b) drop-shadow(0 0 10px #d8b56630);
}
.home-title-plate { display: grid; justify-items: center; gap: 6px; width: 100%; }
.logo {
  font-size: clamp(27px, 7.8vw, 42px); font-weight: 700; letter-spacing: .12em; text-indent: .12em;
  line-height: 1.08;
  background: linear-gradient(180deg, #fff8de 0%, #ebd18e 46%, #be984d 80%, #927133 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 #261b0e) drop-shadow(0 4px 10px #000c);
}
.home-divider {
  display: flex; align-items: center; gap: 8px; width: min(220px, 74%);
}
.home-divider::before, .home-divider::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, #c7a660 45%, #f5df9f 50%, #c7a660 55%, transparent);
}
.home-divider i {
  display: block; width: 5px; height: 5px; transform: rotate(45deg);
  border: 1px solid #f0d794; background: #9d233a;
}
.home-maze-card {
  position: relative; width: min(272px, 84%); padding: 6px;
  border-radius: 6px;
  background: linear-gradient(155deg, #3c332d, #19171e 42%, #111015 76%, #3f3328);
  border: 1px solid #967e50;
  box-shadow: 0 10px 22px #000b, inset 0 0 0 1px #57483266;
}
.home-maze-svg { width: 100%; height: auto; border-radius: 3px; }
.home-route-glow {
  animation: home-route-pulse 2.8s ease-in-out infinite;
}
.home-ruby-spark {
  animation: home-spark-twinkle 2.4s ease-in-out infinite;
  transform-origin: 130px 53px;
}
@keyframes home-route-pulse {
  0%, 100% { opacity: .72; filter: drop-shadow(0 0 2px #f2c866aa); }
  50% { opacity: 1; filter: drop-shadow(0 0 6px #ffe699ee); }
}
@keyframes home-spark-twinkle {
  0%, 100% { opacity: .82; transform: scale(.96); }
  50% { opacity: 1; transform: scale(1.06); }
}
.home-copy { display: grid; justify-items: center; gap: 5px; max-width: 100%; }
.home-rule {
  max-width: 24em; color: var(--pale); font-size: clamp(13.5px, 3.8vw, 16px);
  line-height: 1.52; text-wrap: balance;
}
.home-note {
  max-width: 100%; color: var(--muted); font-size: clamp(10.4px, 2.9vw, 13px);
  letter-spacing: -.012em; line-height: 1.4; text-wrap: balance;
}
.home .primary {
  position: relative; width: min(100%, 17.2rem); min-height: 50px;
  font-size: 1.18rem; letter-spacing: .16em; text-indent: .16em;
  color: #1c1309;
  background: linear-gradient(180deg, #f7e6b3 0%, #d8b870 46%, #b28c45 88%, #987433 100%);
  border: 1px solid #faeab9; border-radius: 3px;
  box-shadow:
    0 10px 22px #000c,
    0 0 0 3px #19161b,
    0 0 0 4px #887043,
    inset 0 1px 0 #fff9e3,
    inset 0 -2px 0 #765824;
  transition: transform 110ms ease, filter 140ms ease;
}
.home .primary::before {
  content: ''; position: absolute; inset: 4px; border: 1px solid #7d5f2966; pointer-events: none;
}
.home .primary:active { transform: translateY(2px) scale(.985); filter: brightness(1.07); }
.home-privacy {
  flex: 0 0 auto; max-width: 100%;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: clamp(9.5px, 2.5vw, 11.5px);
  line-height: 1.3; letter-spacing: -.01em;
  color: #968970;
}

/* ===== Play Screen (Unchanged from v1.2-v1.5) ===== */
.play {
  flex: 1 1 0; min-height: 0; display: grid; justify-items: center; gap: 6px; min-width: 0;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
}
.board-slot { width: 100%; min-height: 0; container-type: size; display: grid; place-items: center; }
.gem-area {
  --socket-size: clamp(16px, 5.8vw, 24px);
  display: flex; align-items: center; gap: 6px;
}
.crown { display: flex; gap: clamp(3px, 1.1vw, 7px); padding-bottom: 13px; }
.socket {
  position: relative; top: var(--arc, 0); display: grid; place-items: center;
  width: var(--socket-size); aspect-ratio: 1; isolation: isolate;
}
.socket:is(:nth-child(1), :nth-child(10)) { --arc: 13px; }
.socket:is(:nth-child(2), :nth-child(9)) { --arc: 8px; }
.socket:is(:nth-child(3), :nth-child(8)) { --arc: 4px; }
.socket:is(:nth-child(4), :nth-child(7)) { --arc: 1px; }
.socket::before, .socket::after {
  content: ''; position: absolute; z-index: -1; inset: 0;
  clip-path: polygon(28% 0, 72% 0, 100% 28%, 100% 72%, 72% 100%, 28% 100%, 0 72%, 0 28%);
}
.socket::before { background: #67574c; }
.socket::after { inset: 1px; background: #1d1b20; }
.socket.next { color: #fff0bd; }
.socket.next::before { background: var(--gold); }
.socket.next svg { width: 56%; }
.socket.collected { filter: drop-shadow(0 0 4px #e0566e88); }
.socket.collected::before, .socket.collected::after { display: none; }
.hud {
  display: grid; width: 100%; align-items: center; justify-items: start; column-gap: 6px;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}
.stage-number { grid-column: 1; color: var(--muted); font-size: .875rem; white-space: nowrap; }
.time, .score {
  font-variant-numeric: tabular-nums; color: #e7cc8e;
  letter-spacing: -.025em; text-shadow: 0 2px 12px #ddbd7740;
}
.time { grid-column: 2; font-size: clamp(40px, min(13vw, 8vh), 64px); line-height: 1.04; }
.penalty, .penalty-flight {
  padding: 3px 5px; border: 1px solid #b45d69;
  background: linear-gradient(#761e35, #491224); color: #fff0d9; font-size: .8rem; font-weight: bold;
}
.penalty { position: relative; z-index: 9; grid-column: 3; justify-self: end; white-space: nowrap; }

.vault-frame {
  position: relative; isolation: isolate; max-width: 100%;
  width: min(calc(100vw - 40px), 480px);
  width: min(calc(100cqw - 24px), calc(100cqh - 24px));
}
.vault-frame::before {
  content: ''; position: absolute; z-index: -1; inset: -11px; border-radius: 5px;
  background: linear-gradient(145deg, #51443a, #27232a 25%, #100f12 73%, #544334);
  box-shadow: inset 0 0 0 1px #665541, 0 9px 19px #0008;
}
.vault-frame::after { content: ''; position: absolute; inset: -2px; border: 1px solid #ad955f; }
.vault-frame.level-up-flash::after {
  animation: frame-gold-flash 780ms ease-out both;
}
@keyframes frame-gold-flash {
  0% { border-color: #fff6cf; box-shadow: 0 0 22px #f7db87dd, 0 0 8px #fff3c2aa; }
  30% { border-color: #ffe9a8; box-shadow: 0 0 16px #f0ca68b8, 0 0 5px #ffe9a877; }
  100% { border-color: #ad955f; box-shadow: 0 0 0 transparent, 0 0 0 transparent; }
}
.bezel-corner {
  position: absolute; width: 5px; height: 5px; transform: rotate(45deg);
  background: #d1ad64; box-shadow: 0 0 0 1px #18131a;
}
.bezel-corner:nth-child(1) { top: -8px; left: -8px; }
.bezel-corner:nth-child(2) { top: -8px; right: -8px; }
.bezel-corner:nth-child(3) { bottom: -8px; left: -8px; }
.bezel-corner:nth-child(4) { bottom: -8px; right: -8px; }
.board {
  position: relative; isolation: isolate; display: grid;
  width: 100%; aspect-ratio: 1;
  padding: 0; border: 0; touch-action: none; user-select: none;
  background: repeating-linear-gradient(45deg, transparent 0 7px, #ffffff04 7px 8px, transparent 8px 13px),
    repeating-linear-gradient(-45deg, transparent 0 7px, #ffffff04 7px 8px, transparent 8px 13px), var(--floor);
}
.countdown {
  position: absolute; z-index: 1; inset: 0; display: grid; place-items: center;
  pointer-events: none; color: var(--pale); font-size: clamp(56px, 18vw, 96px);
  font-weight: bold; line-height: 1; text-shadow: 0 2px 8px #000, 0 0 16px #000;
}
.countdown-in { animation: countdown-in 180ms ease-out; }
@keyframes countdown-in {
  from { transform: scale(.88); opacity: .65; }
}
.cell { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; }
.wall {
  background: linear-gradient(to top, var(--shadow-south, #22212a70), transparent 5px),
    linear-gradient(to left, var(--shadow-east, #22212a70), transparent 5px), var(--wall);
  box-shadow: inset 0 1px var(--edge-north, #c1a773), inset 1px 0 var(--edge-west, #b49b6b),
    inset 0 -1px var(--edge-south, #9a8256), inset -1px 0 var(--edge-east, #b49b6b);
}
.join-north { --edge-north: transparent; }
.join-east { --edge-east: transparent; --shadow-east: transparent; }
.join-south { --edge-south: transparent; --shadow-south: transparent; }
.join-west { --edge-west: transparent; }
.corner-nw { border-top-left-radius: 12%; }
.corner-ne { border-top-right-radius: 12%; }
.corner-se { border-bottom-right-radius: 12%; }
.corner-sw { border-bottom-left-radius: 12%; }
.special {
  appearance: none; min-height: 0; padding: 0; margin: 0; border: 0; border-radius: 0;
  background: radial-gradient(ellipse, #5f2531, #19161c 72%);
}
.special::before {
  content: ''; position: absolute; inset: 1px; pointer-events: none;
  background: repeating-linear-gradient(135deg, #f5a0b622 0 1px, transparent 1px 4px);
}
.special > svg { position: relative; width: 98%; }
.board.lockout { cursor: not-allowed; }
.board.lockout .special > svg { filter: saturate(.2) brightness(.55); }
.special:focus-visible { z-index: 5; outline-offset: -2px; }
.special.opened { background: transparent; outline: none; }
.special.opened > svg, .special.opened::before { visibility: hidden; }
.board.preview::after {
  content: ''; position: absolute; z-index: 5; left: var(--preview-left); top: var(--preview-top);
  width: var(--preview-size); height: var(--preview-size); border-radius: 50%; border: 1px solid #fff0bd;
  box-shadow: 0 0 4px #cdb57a80; pointer-events: none;
}
svg { display: block; width: 100%; }
.gem-edge { fill: var(--ruby-edge); }
.gem-face { fill: var(--ruby-face); }
.gem-light { fill: var(--ruby-light); }
.gem-shadow { fill: var(--ruby-shadow); }
.gem-glint { fill: none; stroke: #ffe4ea; stroke-width: 1.1; stroke-linecap: round; }
.marker {
  position: relative; z-index: 3; width: 78%; aspect-ratio: 1; display: grid; place-items: center;
  font-size: clamp(12px, 3.8vw, 24px); font-weight: bold; line-height: 1;
}
.start {
  border-radius: 50%; color: #19161c;
  background: radial-gradient(circle at 35% 30%, #fff, #c9c9d2 65%, #8e8d9c);
  box-shadow: 0 0 7px #ebedf270, inset 0 0 0 1px #eee;
}
.goal { width: 91%; color: #efdda5; background: radial-gradient(circle, #4c3b28b0, transparent 69%); }
.goal svg { position: absolute; inset: 0; }
.goal b { position: relative; }

.pickaxe-area {
  position: relative; isolation: isolate; width: 100%;
  display: flex; align-items: center; justify-content: center; min-height: 36px;
}
.pickaxe-area::before {
  content: ''; position: absolute; z-index: -1; inset: -2px 8%;
  border-radius: 999px; opacity: 0;
  background: radial-gradient(ellipse at 50% 50%, #f5d88266 0%, #e0ba582c 48%, transparent 76%);
  box-shadow: 0 0 18px #f5d88240;
}
.pickaxe-area.level-up-glow::before {
  animation: pickaxe-row-glow 780ms ease-out both;
}
@keyframes pickaxe-row-glow {
  0% { opacity: 0; transform: scaleX(.82); }
  20% { opacity: 1; transform: scaleX(1.03); }
  55% { opacity: .82; transform: scaleX(1); }
  100% { opacity: 0; transform: scaleX(1.04); }
}
.rack-wrap {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
}
.rack {
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.axe-slot { position: relative; display: grid; place-items: center; width: 36px; height: 36px; }
.pickaxe {
  display: block; width: 30px; height: 30px;
  transform: rotate(-34deg); transform-origin: center;
}
.pickaxe.armed { transform: translateY(-3px) rotate(14deg); }
.axe-slot:has(.armed)::after {
  content: ''; position: absolute; inset: -1px 0 1px; border: 1px solid var(--pale); border-radius: 50%;
}
.axe-slot.is-new::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid #ffe79e;
  box-shadow: 0 0 12px #f6d374cc, inset 0 0 8px #fff1b888;
  animation: axe-ring-ripple 740ms cubic-bezier(.16, 1, .3, 1) both;
}
@keyframes axe-ring-ripple {
  0% { opacity: 0; transform: scale(.5); }
  18% { opacity: .98; transform: scale(.92); }
  65% { opacity: .52; transform: scale(1.48); }
  100% { opacity: 0; transform: scale(1.76); }
}
.pickaxe.ready.new-drop {
  color: #fff3c2;
  filter: drop-shadow(0 0 9px #ffe28ee0);
  animation: axe-new-drop 720ms cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes axe-new-drop {
  0% { opacity: 0; transform: translateY(-20px) rotate(-52deg) scale(.62); filter: drop-shadow(0 0 4px #ffe28e88); }
  34% { opacity: 1; transform: translateY(3px) rotate(-20deg) scale(1.28); filter: drop-shadow(0 0 14px #fff4c4); }
  54% { opacity: 1; transform: translateY(-4px) rotate(-38deg) scale(.94); filter: drop-shadow(0 0 10px #f7d578cc); }
  74% { opacity: 1; transform: translateY(1px) rotate(-32deg) scale(1.06); filter: drop-shadow(0 0 7px #f0cb6899); }
  100% { opacity: 1; transform: translateY(0) rotate(-34deg) scale(1); filter: drop-shadow(0 0 3px #e4c16a55); }
}
.pickaxe-plus {
  position: absolute; left: calc(100% + 6px); top: 50%; z-index: 4;
  user-select: none; white-space: nowrap;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 1.05rem; font-weight: 800; letter-spacing: .02em; line-height: 1;
  color: #fff2be;
  text-shadow: 0 0 10px #f5cf6ee6, 0 1px 3px #000c;
  transform: translateY(-50%);
}
.pickaxe-plus.show {
  animation: pickaxe-plus-float 800ms cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes pickaxe-plus-float {
  0% { opacity: 0; transform: translateY(-10%) scale(.76); }
  18% { opacity: 1; transform: translateY(-58%) scale(1.18); }
  34% { opacity: 1; transform: translateY(-52%) scale(1); }
  74% { opacity: 1; transform: translateY(-64%) scale(1); }
  100% { opacity: 0; transform: translateY(-96%) scale(.96); }
}
.pickaxe.spent { animation: axe-swing var(--strike) ease-in both; }
@keyframes axe-swing {
  from { transform: translateY(-3px) rotate(14deg); }
  to { transform: translateY(3px) rotate(-75deg); opacity: 0; }
}
svg, .crest, .home-maze-card, .marker, .crown, .rack, .pickaxe-area::before, .axe-slot.is-new::before, .pickaxe-plus,
.socket::before, .socket::after, .vault-frame::before, .vault-frame::after, .bezel-corner,
.route, .tile-effect, .shard, .penalty-flight { pointer-events: none; }
.route { position: absolute; z-index: 2; inset: 0; height: 100%; overflow: visible; }
.route polyline {
  fill: none; stroke: #ffdf8d; stroke-width: .12; stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 0 2px #e7ab47);
}
.route.drawing polyline { stroke-dasharray: 1; }
.orb { fill: #f8f8ff; filter: drop-shadow(0 0 3px #fff7dd); }
.tile-effect { position: absolute; z-index: 4; inset: 0; display: grid; place-items: center; }
.strike { color: #ffe5a5; animation: strike var(--strike) ease-in-out both; }
.strike svg { width: 84%; filter: drop-shadow(0 1px 2px #16121a); }
.shard {
  grid-area: 1 / 1; width: 22%; aspect-ratio: 1; background: #e0566e;
  clip-path: polygon(0 9%, 100% 34%, 29% 100%); animation: scatter var(--shards) ease-out both;
}
.shard:nth-child(even) { background: #b3263e; }
.goal-flash .goal { animation: flash var(--sparkle) ease-out; }
.gem-pop { animation: pop var(--sparkle) ease-out both; }
.gem-pop svg { width: 58%; filter: drop-shadow(0 0 4px #fff0bd); }
.penalty-flight {
  position: fixed; z-index: 6; min-width: 36px; margin-left: -18px; text-align: center;
  animation: flight var(--penalty-flight) ease-out both;
}
@keyframes strike {
  from { transform: translate(38%, -42%) rotate(48deg); opacity: .4; }
  50% { transform: translate(8%, -3%) rotate(-19deg); opacity: 1; }
  to { transform: translate(-9%, 8%) rotate(-28deg); opacity: 0; }
}
@keyframes scatter { to { transform: translate(var(--dx), var(--dy)) rotate(85deg) scale(.4); opacity: 0; } }
@keyframes flash { from { filter: brightness(2.1) drop-shadow(0 0 5px #ffeabc); } }
@keyframes pop { from { transform: scale(.6); } to { transform: translateY(-65%) scale(1.2); opacity: 0; } }
@keyframes flight {
  from { transform: translateY(-50%); }
  65% { opacity: 1; }
  to { transform: translate(var(--dx), calc(var(--dy) - 50%)) scale(.68); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .strike, .shard, .goal-flash .goal, .gem-pop, .penalty-flight, .pickaxe.spent,
  .pickaxe.ready.new-drop, .axe-slot.is-new::before, .pickaxe-plus.show,
  .pickaxe-area.level-up-glow::before, .vault-frame.level-up-flash::after,
  .home-route-glow, .home-ruby-spark { animation: none; }
  .home .primary { transition: none; }
  .pickaxe.ready.new-drop { color: #fff3c2; filter: drop-shadow(0 0 7px #ffe28ecc); }
  .axe-slot.is-new::before { opacity: .75; transform: scale(1.06); }
  .pickaxe-plus.show { opacity: 1; transform: translateY(-50%); }
  .pickaxe-area.level-up-glow::before { opacity: .85; }
  .vault-frame.level-up-flash::after { border-color: #ffe9a8; box-shadow: 0 0 12px #f0ca6899; }
  .pickaxe.spent { visibility: hidden; }
  .route.drawing polyline { stroke-dasharray: none; }
  .orb, .strike, .burst, .gem-pop { display: none; }
}

/* ===== Result Screen (v1.7 Production Clean Vault Card) ===== */
.card { min-width: 0; padding: 14px; border: 1px solid #675744; background: var(--card); overflow-wrap: anywhere; }
.result-card {
  display: grid; justify-items: center; gap: clamp(10px, 2.2vh, 16px); text-align: center;
  padding: clamp(22px, 4vh, 34px) clamp(16px, 4vw, 28px);
  border-radius: 6px;
  border-color: var(--gold); outline: 1px solid #8e7749; outline-offset: -7px;
  background: radial-gradient(ellipse at 50% 16%, #2d242a, var(--card) 58%);
  box-shadow: 0 18px 36px #000b, inset 0 18px 32px #f1cf7c0d;
}
.result-title { font-size: .92rem; letter-spacing: .16em; text-indent: .16em; color: var(--muted); line-height: 1.2; }
.complete-banner {
  padding: 3px 12px; border-radius: 999px;
  border: 1px solid #f0cf7e; background: linear-gradient(180deg, #3c2e1f, #221912);
  color: #fff2c4; font-size: .86rem; font-weight: bold; letter-spacing: .08em; line-height: 1.3;
}
.scores {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 6px 20px;
  outline: none;
}
.score { font-size: clamp(26px, 6.8vw, 40px); font-weight: 700; line-height: 1.12; white-space: nowrap; }
.result-rank {
  display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px;
  color: var(--pale); font-size: clamp(.94rem, 3.2vw, 1.08rem); line-height: 1.3;
}
.best-badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  border: 1px solid #f0cf7e; background: linear-gradient(#8a1e36, #551121);
  color: #fff3cf; font-family: system-ui, -apple-system, sans-serif;
  font-size: .76rem; font-weight: 700; line-height: 1.35;
}
.copy-buffer { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; }
.resultline { color: var(--muted); font-size: .88rem; line-height: 1.4; }
.result-divider {
  display: flex; align-items: center; gap: 8px; width: min(260px, 78%); margin-block: 2px;
}
.result-divider::before, .result-divider::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, #c7a660 45%, #f5df9f 50%, #c7a660 55%, transparent);
}
.result-divider i {
  display: block; width: 5px; height: 5px; transform: rotate(45deg);
  border: 1px solid #f0d794; background: #9d233a;
}
.share-actions {
  width: min(100%, 24rem); display: grid; gap: 8px;
}
.share-sub-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.share-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap; line-height: 1.1; padding: 8px 10px;
}
.share-btn svg { width: 16px; height: 16px; flex: 0 0 auto; }
.share-primary {
  width: 100%; min-height: 48px; font-size: 1.04rem; letter-spacing: .06em;
  border-color: #f4dfa6;
  box-shadow: 0 6px 16px #0009, inset 0 1px 0 #fff7db;
}
.share-sub {
  min-height: 44px; font-size: .88rem;
  border-color: #8b7449; background: #1c1920; color: var(--pale);
}
.result-status { min-height: 1.2em; font-size: .82rem; color: var(--pale); }
.result-status:empty { display: none; }
.result-footer {
  width: min(100%, 24rem); display: flex; justify-content: center; margin-top: 2px;
}
.result-home-btn {
  width: min(100%, 14rem); min-height: 44px;
  border-color: #8b7449; background: #17151b; color: var(--pale);
  font-size: .94rem; letter-spacing: .12em; text-indent: .12em;
}
.time { min-width: 2.5em; text-align: center; }
.time.urgent { color: #ff879a; transform: scale(1.1); animation: urgency 800ms ease-in-out infinite; }
@keyframes urgency { 50% { transform: scale(1.16); } }
.gem-count {
  display: grid; grid-template-columns: calc(1.4 * var(--socket-size)) 3.5ch; align-items: center; gap: 4px;
  font-size: 1rem; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.gem-count .gem-edge { stroke: var(--gold); stroke-width: 1.1; }
.gem-count.empty { opacity: .55; }
.gem-count.carry svg { animation: carry 180ms ease-out; }
@keyframes carry {
  40% { transform: scale(1.15); filter: brightness(1.55); }
}
@media (prefers-reduced-motion: reduce) {
  .time.urgent, .gem-count.carry svg, .countdown-in { animation: none; }
}

#cancel { min-width: 6rem; }
#cancel:disabled { opacity: .45; cursor: default; }
#cancel.unused { visibility: hidden; }
.special.selected { box-shadow: inset 0 0 0 2px #ffefb5; }
.special.selected::after {
  content: '✓'; position: absolute; right: 1px; bottom: 1px;
  padding: 0 1px; color: #fff4cb; background: #211820; font: bold 12px/1 sans-serif;
  pointer-events: none;
}

@media (max-height: 560px) {
  main { padding-block: 6px; }
  .play { gap: 4px; }
  .gem-area { --socket-size: 15px; }
  .crown { padding-bottom: calc(13px * .54); }
  .socket { top: calc(var(--arc, 0px) * .54); }
  .vault-frame { width: min(calc(100cqw - 18px), calc(100cqh - 18px)); }
  .vault-frame::before { inset: -8px; }
  .home { gap: 5px; }
  .vault-gate-wrap { margin-top: 34px; }
  .vault-gate { gap: 7px; padding: 10px 14px; }
  .crest { width: 58px; }
  .logo { font-size: clamp(24px, 7vw, 31px); }
  .home-maze-card { width: min(218px, 82%); padding: 4px; }
  .home-copy { gap: 3px; }
  .home .primary { min-height: 44px; font-size: 1.06rem; }
  .home-privacy { font-size: 9.6px; line-height: 1.25; }
  .result-card { gap: 9px; padding: 18px 16px; }
  .result-title { font-size: .84rem; }
  .score { font-size: clamp(23px, 6.2vw, 32px); }
  .result-rank { font-size: .88rem; gap: 6px; }
  .best-badge { font-size: .7rem; padding: 1px 7px; }
  .resultline { font-size: .8rem; line-height: 1.3; }
  .share-actions { gap: 6px; }
  .share-sub-row { gap: 6px; }
  .share-primary { min-height: 44px; font-size: .96rem; padding: 6px 10px; }
  .share-sub { min-height: 40px; font-size: .82rem; padding: 5px 8px; gap: 5px; }
  .share-btn svg { width: 15px; height: 15px; }
  .result-home-btn { min-height: 40px; font-size: .88rem; }
  #cancel { min-height: 36px; }
}
/* Narrow compact viewport (320x480): guarantee >= 292px board (>= 18.25px per cell on 16x16), home & result noScroll. */
@media (max-width: 360px) and (max-height: 560px) {
  main {
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
  }
  .home { gap: 4px; }
  .vault-gate-wrap { margin-top: 32px; }
  .vault-gate { gap: 5px; padding: 8px 10px; }
  .crest { width: 50px; }
  .logo { font-size: 23px; }
  .home-maze-card { width: 194px; padding: 4px; }
  .home-rule { font-size: 12.6px; line-height: 1.42; }
  .home-note { font-size: 9.6px; letter-spacing: -.022em; }
  .home .primary { min-height: 42px; font-size: 1.02rem; }
  .home-privacy { font-size: 8.6px; letter-spacing: -.03em; line-height: 1.2; }
  .result-card { gap: 8px; padding: 16px 12px; }
  .result-title { font-size: .78rem; }
  .score { font-size: 22px; }
  .result-rank { font-size: .82rem; gap: 5px; }
  .best-badge { font-size: .66rem; padding: 1px 6px; }
  .resultline { font-size: .76rem; line-height: 1.25; }
  .share-primary { min-height: 42px; font-size: .92rem; }
  .share-sub { min-height: 38px; font-size: .78rem; padding: 4px 6px; }
  .share-btn svg { width: 14px; height: 14px; }
  .result-home-btn { min-height: 38px; font-size: .84rem; }
  .vault-frame { width: min(calc(100cqw - 12px), calc(100cqh - 12px)); }
  .vault-frame::before { inset: -6px; }
  .bezel-corner:nth-child(1) { top: -4px; left: -4px; }
  .bezel-corner:nth-child(2) { top: -4px; right: -4px; }
  .bezel-corner:nth-child(3) { bottom: -4px; left: -4px; }
  .bezel-corner:nth-child(4) { bottom: -4px; right: -4px; }
  .marker { font-size: clamp(10px, 3.2vw, 14px); }
  .special.selected::after { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .penalty-flight { transform: translateY(-50%); }
  .time.urgent { transform: none; }
}
/* Top-right MUTE toggle: zero impact on vertical flow or 320x480 board geometry */
.mute-toggle {
  position: absolute; z-index: 8;
  top: max(12px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 34px; height: 34px; padding: 3px 9px;
  border: 1px solid #7d6a45; border-radius: 3px;
  background: #18161ae6; color: var(--pale);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: .75rem; font-weight: bold; letter-spacing: .04em; line-height: 1;
  white-space: nowrap;
}
.mute-toggle svg { width: 15px; height: 15px; flex: 0 0 auto; }
.mute-toggle[aria-pressed="true"] {
  border-color: #5b5349; color: var(--muted); background: #141316d9;
}
@media (max-height: 560px) {
  .mute-toggle {
    top: max(10px, env(safe-area-inset-top));
    min-height: 30px; height: 30px; padding: 2px 7px; font-size: .7rem;
  }
  .mute-toggle svg { width: 13px; height: 13px; }
}
@media (max-width: 360px) and (max-height: 560px) {
  .mute-toggle {
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    min-height: 28px; height: 28px; padding: 2px 6px; font-size: .68rem; gap: 3px;
  }
  .mute-toggle svg { width: 12px; height: 12px; }
}
