/* ==========================================================
   GROUT EXPECTATIONS — tile pinball
   Cream subway wall, white glazed HUD tiles, slate table floor.
   ========================================================== */

:root {
  --ink: #1b2730;
  --ink-soft: #51606b;
  --grout: #c3bba6;
  --wall: #e8e2d2;
  --porcelain: #fbf9f3;
  --cream: #f4efe3;
  --edge: #a39b85;
  --cobalt: #2456c4;
  --cobalt-deep: #173b8c;
  --terracotta: #cf5a3c;
  --terracotta-deep: #96391f;
  --turq: #27b0a6;
  --brass: #c9a24a;
  --brass-deep: #7a5d1e;
  --tape: #f6c628;
  --slate: #24313b;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  --hud-h: 82px;
  --ctrl-h: 108px;
  --vh: 100vh;
}

@supports (height: 100dvh) {
  :root { --vh: 100dvh; }
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--wall);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='80'%3E%3Crect width='120' height='80' fill='%23e8e2d2'/%3E%3Cpath d='M0 1H120M0 41H120M1 0V40M61 40V80' stroke='%23c3bba6' stroke-width='2'/%3E%3Cpath d='M2 3H119M2 43H119' stroke='%23f4f0e4' stroke-width='2'/%3E%3C/svg%3E");
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: none;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  padding: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  touch-action: none;
}

button:focus-visible {
  outline: 3px solid var(--cobalt);
  outline-offset: 2px;
}

h1, h2, p, dl, dd, dt, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }

kbd {
  display: inline-block;
  min-width: 1.7em;
  padding: 2px 5px;
  font: 700 11px/1.3 var(--mono);
  text-align: center;
  color: var(--ink);
  background: var(--porcelain);
  border: 1px solid var(--edge);
  border-bottom-width: 3px;
  border-radius: 2px;
}

/* ==========================================================
   LAYOUT — phone portrait first
   ========================================================== */

.shop {
  height: var(--vh);
  display: grid;
  grid-template-columns: 100%;
  grid-template-rows: var(--hud-h) minmax(0, 1fr) var(--ctrl-h);
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
}

.panel { display: none; }

.stage {
  display: grid;
  place-items: center;
  min-height: 0;
  min-width: 0;
}

.table-frame {
  --table-w: min(
    calc(100vw - 16px - var(--safe-l) - var(--safe-r)),
    calc((var(--vh) - var(--hud-h) - var(--ctrl-h) - var(--safe-t) - var(--safe-b) - 14px) * 4 / 7)
  );
  position: relative;
  width: var(--table-w);
  height: calc(var(--table-w) * 7 / 4);
  border-radius: 10px;
  overflow: hidden;
  background: #12171c;
  box-shadow:
    0 0 0 2px #f0d68a,
    0 0 0 5px var(--brass),
    0 0 0 6px var(--brass-deep),
    0 10px 24px rgba(27, 39, 48, 0.45);
  touch-action: none;
}

.table, .fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.fx { pointer-events: none; }

/* ==========================================================
   HUD
   ========================================================== */

.hud {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: 44px 24px;
  grid-template-areas:
    "score stats buttons"
    "ticker ticker level";
  gap: 4px 10px;
  align-items: center;
  padding: 5px 10px;
  background: linear-gradient(#ffffff, var(--porcelain) 40%, #f1ecdf);
  border-bottom: 2px solid var(--edge);
  box-shadow: 0 2px 0 rgba(255, 255, 255, 0.6) inset, 0 3px 8px rgba(27, 39, 48, 0.18);
  z-index: 2;
}

.brand { display: none; }

.scorebox {
  grid-area: score;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 96px;
}

.label, .stat dt, .level-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.score {
  display: block;
  font: 800 27px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.best { display: none; font-size: 12px; color: var(--ink-soft); }
.best b { font-family: var(--mono); color: var(--ink); }

.stats {
  grid-area: stats;
  display: flex;
  gap: 6px;
  min-width: 0;
  justify-content: flex-end;
}

.stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 36px;
  height: 40px;
  padding: 3px 7px;
  background: var(--cream);
  border: 1px solid var(--grout);
  border-radius: 2px;
  box-shadow: inset 0 1px 0 #fff, inset 0 -2px 0 rgba(27, 39, 48, 0.06);
}

.stat dd {
  font: 800 15px/1.15 var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-job { min-width: 0; flex: 0 1 auto; }
.stat-job dd { font-family: var(--font); font-size: 13px; line-height: 1.3; color: var(--cobalt-deep); }
#bond { color: var(--terracotta-deep); }

.hud-buttons {
  grid-area: buttons;
  display: flex;
  gap: 6px;
}

.iconbtn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: linear-gradient(#fff, var(--cream));
  border: 1px solid var(--edge);
  border-radius: 2px;
  box-shadow: inset 0 1px 0 #fff, 0 3px 0 var(--edge);
  touch-action: manipulation;
  transition: transform 0.05s, box-shadow 0.05s;
}

.iconbtn:active { transform: translateY(3px); box-shadow: inset 0 1px 0 #fff, 0 0 0 var(--edge); }
.iconbtn svg { width: 22px; height: 22px; }
.iconbtn .ico-slash { display: none; }
#btn-mute[aria-pressed="true"] .ico-waves { display: none; }
#btn-mute[aria-pressed="true"] .ico-slash { display: inline; }
#btn-mute[aria-pressed="true"] { color: var(--terracotta-deep); }

.ticker {
  grid-area: ticker;
  height: 24px;
  padding: 0 9px;
  font: 700 12px/24px var(--mono);
  letter-spacing: 0.02em;
  color: var(--tape);
  background: var(--ink);
  border-radius: 2px;
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.level {
  grid-area: level;
  display: flex;
  align-items: center;
  gap: 6px;
}

.level-label { display: none; }

/* spirit level */
.vial {
  --tilt: 0;
  position: relative;
  width: 86px;
  height: 22px;
  border-radius: 11px;
  background: linear-gradient(#d9f277, #b5d63b 55%, #94b522);
  border: 2px solid var(--ink);
  box-shadow: inset 0 3px 4px rgba(255, 255, 255, 0.55), inset 0 -3px 4px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.vial i {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--ink);
  opacity: 0.75;
}
.vial i:nth-child(1) { left: calc(50% - 13px); }
.vial i:nth-child(2) { left: calc(50% + 11px); }

.bubble {
  position: absolute;
  top: 2px;
  left: calc(50% + var(--tilt) * 36%);
  width: 18px;
  height: 14px;
  margin-left: -9px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, rgba(255, 255, 255, 0.55) 45%, rgba(255, 255, 255, 0.15));
  box-shadow: 0 0 0 1px rgba(27, 39, 48, 0.35);
  transition: left 0.12s ease-out;
}

.vial.warn { animation: vial-warn 0.25s steps(2) 4; }
.vial.tilted { background: linear-gradient(#ff9a80, var(--terracotta) 55%, var(--terracotta-deep)); }

@keyframes vial-warn {
  50% { background: linear-gradient(#ffe27a, var(--tape)); }
}

/* word tiles (logo) */
.wordtiles { display: inline-flex; gap: 3px; }
.wordtiles b {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  font: 900 21px/1 var(--font);
  color: #fff;
  background: linear-gradient(160deg, #3a6fe0, var(--cobalt) 45%, var(--cobalt-deep));
  border-radius: 1px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45), inset 0 -3px 0 rgba(0, 0, 0, 0.22);
}
.wordtiles b:nth-child(even) {
  color: var(--cobalt-deep);
  background: linear-gradient(160deg, #ffffff, var(--porcelain) 45%, #e4decd);
  box-shadow: inset 0 2px 0 #fff, inset 0 -3px 0 rgba(0, 0, 0, 0.1), 0 0 0 1px var(--grout);
}
.wordtiles.big b { width: 42px; height: 42px; font-size: 26px; }

.wordsub {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ink);
}

/* ==========================================================
   TOUCH CONTROLS
   ========================================================== */

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px minmax(0, 1fr);
  gap: 8px;
  padding: 7px 8px 9px;
  min-height: 0;
}

.pad {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border-radius: 3px;
  transition: transform 0.04s, box-shadow 0.04s, filter 0.04s;
}

.pad-flip {
  height: 100%;
  color: #fff;
  background: linear-gradient(165deg, #4a7ef0, var(--cobalt) 40%, var(--cobalt-deep));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.5),
    inset 0 -4px 0 rgba(0, 0, 0, 0.22),
    0 5px 0 #0f2a66,
    0 8px 12px rgba(27, 39, 48, 0.3);
}
.pad-flip svg { width: 52px; height: 34px; }

.pad-mid {
  display: grid;
  grid-template-rows: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
}

.pad-launch {
  height: 100%;
  color: #fff;
  background: linear-gradient(165deg, #ea7b5e, var(--terracotta) 45%, var(--terracotta-deep));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.45),
    inset 0 -3px 0 rgba(0, 0, 0, 0.2),
    0 4px 0 #6d2814,
    0 6px 10px rgba(27, 39, 48, 0.3);
}

.pad-power {
  display: block;
  width: 78%;
  height: 6px;
  margin-top: 3px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 1px;
  overflow: hidden;
}
.pad-power b {
  display: block;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(90deg, var(--tape) 0 7px, #d9ab12 7px 8px);
  transform: scaleX(0);
  transform-origin: left center;
}

.pad-nudge {
  height: 100%;
  color: var(--ink);
  font-size: 11px;
  background: linear-gradient(165deg, #fff, var(--cream) 50%, #e2dbc8);
  box-shadow:
    inset 0 2px 0 #fff,
    inset 0 -3px 0 rgba(0, 0, 0, 0.08),
    0 4px 0 var(--edge),
    0 6px 10px rgba(27, 39, 48, 0.25);
}

.pad:active, .pad.is-down {
  transform: translateY(4px);
  filter: brightness(1.12);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), inset 0 -2px 0 rgba(0, 0, 0, 0.2), 0 1px 0 rgba(27, 39, 48, 0.6);
}

/* ==========================================================
   OVERLAYS AND CALLOUT
   ========================================================== */

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 6%;
  background: rgba(18, 23, 28, 0.62);
  z-index: 5;
}
.overlay[hidden] { display: none; }

.card {
  width: 100%;
  max-width: 330px;
  padding: 20px 18px 18px;
  text-align: center;
  background: linear-gradient(#ffffff, var(--porcelain) 50%, #efe9da);
  border: 3px solid var(--ink);
  border-radius: 3px;
  box-shadow: inset 0 0 0 3px var(--porcelain), inset 0 0 0 4px var(--grout), 0 14px 30px rgba(0, 0, 0, 0.5);
  animation: card-set 0.22s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}

@keyframes card-set {
  from { transform: scale(1.08); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.card-head {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

.card-tag {
  margin-top: 8px;
  font-size: 14px;
  font-style: italic;
  color: var(--ink-soft);
}

.card-rules {
  margin: 14px 0 2px;
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
  line-height: 1.45;
  background: var(--cream);
  border: 1px solid var(--grout);
}
.card-rules li { padding-left: 16px; position: relative; }
.card-rules li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.42em;
  width: 8px;
  height: 8px;
  background: var(--turq);
}

.cta {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 15px 10px;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(165deg, #ea7b5e, var(--terracotta) 45%, var(--terracotta-deep));
  border-radius: 2px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45), inset 0 -3px 0 rgba(0, 0, 0, 0.2), 0 5px 0 #6d2814;
  touch-action: manipulation;
  transition: transform 0.04s, box-shadow 0.04s;
}
.cta:active { transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45), 0 1px 0 #6d2814; }

.hint { margin-top: 14px; font-size: 12px; color: var(--ink-soft); line-height: 1.7; }
.hint-keys { display: none; }

.final-score {
  margin-top: 10px;
  font: 900 40px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--cobalt-deep);
}
.final-verdict {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--tape);
  transform: rotate(-2deg);
}
.final-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 16px;
}
.final-stats div { padding: 8px 4px; background: var(--cream); border: 1px solid var(--grout); }
.final-stats dt { font-size: 10px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.final-stats dd { font: 800 20px/1.3 var(--mono); }

.callout {
  position: absolute;
  left: 50%;
  top: 31%;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 46%;
  max-width: 88%;
  padding: 8px 14px;
  text-align: center;
  color: var(--ink);
  background: var(--porcelain);
  border: 2px solid var(--ink);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.45);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.8);
}
.callout span { font-size: clamp(15px, 5.200vw, 24px); font-weight: 900; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.callout small { font: 700 12px/1.2 var(--mono); color: var(--terracotta-deep); }
.callout small:empty { display: none; }
.callout.show { animation: callout-pop 1.4s both; }

@keyframes callout-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.25); }
  8% { opacity: 1; transform: translate(-50%, -50%) scale(0.97); }
  14% { transform: translate(-50%, -50%) scale(1); }
  82% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -62%) scale(1); }
}

/* ==========================================================
   TABLE (SVG)
   ========================================================== */

.table text {
  font-family: var(--font);
  font-weight: 800;
  text-anchor: middle;
  pointer-events: none;
}

.floor-word { font-size: 8.500px; letter-spacing: 3px; fill: #f4efe3; opacity: 0.34; }
.pencil { font-size: 6px; letter-spacing: 1.2px; fill: #f4efe3; opacity: 0.3; }
.table text.pencil[transform] { text-anchor: start; }
.chalk { fill: none; stroke: #7fc4ff; stroke-width: 1; stroke-dasharray: 5 4; opacity: 0.2; }
.chalk-2 { stroke: #ff9a80; opacity: 0.16; }
.table text.haze-value { font-family: var(--mono); font-size: 7.500px; fill: var(--tape); opacity: 0.85; text-anchor: end; }

.drain rect { fill: #7d8890; stroke: #0b0f13; stroke-width: 1.5; }
.drain path { stroke: #0b0f13; stroke-width: 2.4; stroke-linecap: square; }

/* walls */
.wall { fill: none; stroke: #f1ebde; stroke-width: 4; stroke-linecap: butt; stroke-linejoin: miter; }
.wall-shadow { fill: none; stroke: #0b0f13; stroke-width: 8; opacity: 0.55; }
.post { fill: #f1ebde; stroke: #0b0f13; stroke-width: 1; }
.gate { fill: none; stroke: url(#g-brass); stroke: var(--brass); stroke-width: 1.6; }
.divider { fill: #f1ebde; stroke: #0b0f13; stroke-width: 0.6; }
.block { fill: #d9d2c0; stroke: #f1ebde; stroke-width: 2; stroke-linejoin: miter; }
.apron { fill: #f1ebde; stroke: #0b0f13; stroke-width: 0.8; }
.table text.apron-text { font-size: 7.500px; letter-spacing: 1.3px; fill: var(--cobalt-deep); }

/* inserts */
.insert rect, .insert path { fill: #1a232b; stroke: #44525d; stroke-width: 1; transition: fill 0.08s, stroke 0.08s; }
.insert text { font-size: 6.200px; letter-spacing: 0.5px; fill: #5d6b76; transition: fill 0.08s; }
.bond text { font-size: 6px; letter-spacing: 0; }

.insert.lit rect, .insert.lit path { fill: var(--tape); stroke: #fff3bf; filter: drop-shadow(0 0 4px rgba(246, 198, 40, 0.9)); }
.insert.lit text { fill: var(--ink); }
.ins-level.lit rect { fill: #b5d63b; stroke: #eaffa0; filter: drop-shadow(0 0 4px rgba(181, 214, 59, 0.9)); }
.ins-rush.lit path { fill: var(--terracotta); stroke: #ffc2b0; filter: drop-shadow(0 0 4px rgba(207, 90, 60, 0.95)); animation: blink 0.5s steps(2) infinite; }
.ins-rush.lit text { fill: #ffc2b0; }
.ins-blade.lit path { fill: #ff8a2a; stroke: #ffd7ae; filter: drop-shadow(0 0 4px rgba(255, 138, 42, 0.95)); animation: blink 0.3s steps(2) infinite; }
.ins-kneepad path { fill: none; stroke-width: 1.6; }
.ins-kneepad.lit rect { fill: var(--turq); stroke: #b7fff9; filter: drop-shadow(0 0 4px rgba(39, 176, 166, 0.95)); }
.ins-kneepad.lit path { fill: none; stroke: var(--ink); filter: none; }
.ins-extra.lit rect { animation: blink 0.6s steps(2) infinite; }

@keyframes blink { 50% { opacity: 0.45; } }

/* the inset */
.inset-trim { fill: var(--brass); stroke: var(--brass-deep); stroke-width: 1; }
.inset-grout { fill: #0f1418; }
.tile .bed { fill: url(#p-ridges); stroke: #3b4c58; stroke-width: 0.8; stroke-dasharray: 3 2; }
.tile .face, .tile .glint {
  opacity: 0;
  transform: scale(0.8);
  transform-box: fill-box;
  transform-origin: center;
}
.tile .face { stroke: rgba(0, 0, 0, 0.35); stroke-width: 0.6; }
.tile.set .face { opacity: 1; transform: none; animation: tile-click 0.2s cubic-bezier(0.2, 1.8, 0.4, 1); }
.tile.set .glint { opacity: 1; transform: none; animation: tile-click 0.2s cubic-bezier(0.2, 1.8, 0.4, 1); }

@keyframes tile-click {
  0% { opacity: 0.4; transform: scale(1.22); }
  55% { opacity: 1; transform: scale(0.96); }
  100% { transform: scale(1); }
}

/* job palettes */
.job-1 .tile .face { fill: #fbf9f3; }
.job-1 .tile.alt .face { fill: #2456c4; }
.job-2 .tile .face { fill: #9dbf9a; }
.job-2 .tile.alt .face { fill: #f2ead3; }
.job-3 .tile .face { fill: #cf5a3c; }
.job-3 .tile.alt .face { fill: #e9c9a0; }
.job-4 .tile .face { fill: #27b0a6; }
.job-4 .tile.alt .face { fill: #12706f; }
.job-5 .tile .face { fill: #ecebe8; }
.job-5 .tile.alt .face { fill: #20242a; }
.job-5 .inset-trim { fill: #f0d68a; }

.inset.flash .tile .face { animation: job-flash 0.14s steps(2) 6; }
@keyframes job-flash { 50% { fill: #ffffff; } }

/* MIX lanes */
.lane rect { fill: #1a232b; stroke: #44525d; stroke-width: 1; transition: fill 0.08s; }
.lane text { font-size: 11px; fill: #5d6b76; }
.lane.lit rect { fill: var(--turq); stroke: #b7fff9; filter: drop-shadow(0 0 4px rgba(39, 176, 166, 0.95)); }
.lane.lit text { fill: #fff; }

/* GROUT bank */
.target { fill: var(--cobalt); stroke: #0b0f13; stroke-width: 0.8; transition: transform 0.05s, fill 0.05s; }
.target.down { fill: #33414c; transform: translateX(-4px); }
.letter rect { fill: #1a232b; stroke: #44525d; stroke-width: 1; }
.letter text { font-size: 9.500px; fill: #5d6b76; }
.letter.lit rect { fill: #fbf9f3; stroke: var(--cobalt); filter: drop-shadow(0 0 3px rgba(120, 165, 255, 0.95)); }
.letter.lit text { fill: var(--cobalt-deep); }

/* sponge */
.sponge rect { fill: var(--tape); stroke: #0b0f13; stroke-width: 0.8; }
.sponge path { stroke: #b88c06; stroke-width: 1.6; stroke-linecap: round; }
.sponge.hit rect { fill: #fff3bf; }

/* bucket */
.bucket-rim { fill: var(--brass); stroke: #0b0f13; stroke-width: 1; }
.bucket-handle { fill: none; stroke: #f0d68a; stroke-width: 1.6; }
.bucket.lit .bucket-rim { fill: var(--terracotta); filter: drop-shadow(0 0 5px rgba(207, 90, 60, 0.95)); }
.bucket.holding .bucket-rim { fill: #fff3bf; }

/* spinner */
.spinner-axle { stroke: #9aa5ad; stroke-width: 1.4; }
.spinner-blade { stroke: #0b0f13; stroke-width: 0.8; transform-box: fill-box; transform-origin: center; }

/* bumpers */
.bumper-base { fill: #0b0f13; stroke: var(--turq); stroke-width: 2; }
.bumper-cap { fill: #fbf9f3; stroke: #cfc8b6; stroke-width: 1; }
.bumper-cross { fill: var(--turq); stroke: #12706f; stroke-width: 0.8; stroke-linejoin: miter; }
.bumper.hit .bumper-base { stroke: #b7fff9; stroke-width: 4; }
.bumper.hit .bumper-cap { fill: #b7fff9; }
.bumper.hit .bumper-cross { fill: #fff; }

/* slingshots */
.sling-body { fill: var(--terracotta); stroke: #0b0f13; stroke-width: 1; }
.sling-inlay { fill: #e9c9a0; opacity: 0.9; }
.sling-band { stroke: #f1ebde; stroke-width: 3; stroke-linecap: round; }
.sling.hit .sling-body { fill: #ff9a80; }
.sling.hit .sling-band { stroke: #fff; stroke-width: 5; }

/* flippers */
.flipper-body { fill: #f7f3e8; stroke: #0b0f13; stroke-width: 1.2; stroke-linejoin: round; }
.flipper-stripe { stroke: var(--cobalt); stroke-width: 3.2; stroke-linecap: butt; }
.flipper-pin { fill: var(--brass); stroke: #0b0f13; stroke-width: 0.8; }

/* plunger and tape */
.plunger-spring { fill: none; stroke: #9aa5ad; stroke-width: 1.2; }
.plunger-rod { fill: #7d8890; }
.plunger-tip { fill: var(--terracotta); stroke: #0b0f13; stroke-width: 0.8; }
.tape-bg { fill: #3a3210; }
.tape-fill { fill: var(--tape); transform: scaleY(0); transform-box: fill-box; transform-origin: center bottom; }
.tape-ticks { stroke: #0b0f13; stroke-width: 0.8; opacity: 0.8; }

/* balls */
.ball { stroke: #0b0f13; stroke-width: 0.5; }
.ball.off { display: none; }

body.is-tilted .table { filter: saturate(0.35); }
body.is-tilted .flipper-stripe { stroke: #7d8890; }

/* ==========================================================
   PANELS (desktop)
   ========================================================== */

.panel {
  padding: 16px;
  background: linear-gradient(#ffffff, var(--porcelain) 40%, #f1ecdf);
  border: 2px solid var(--edge);
  border-radius: 3px;
  box-shadow: inset 0 2px 0 #fff, 0 6px 16px rgba(27, 39, 48, 0.2);
}

.panel h2 {
  margin-bottom: 8px;
  padding-bottom: 5px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 2px solid var(--grout);
}
.panel h2:not(:first-child) { margin-top: 18px; }

.job-list li {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 6px 6px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid #e6e0cf;
  color: var(--ink-soft);
}
.job-list em, .rates em { font: 700 12px var(--mono); font-style: normal; }
.job-list li.current { color: var(--ink); background: #fff7cf; box-shadow: inset 4px 0 0 var(--tape); font-weight: 800; }
.job-list li.done { color: var(--ink-soft); text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: var(--terracotta); }

.swatch { width: 18px; height: 18px; border: 1px solid var(--ink); }
.sw-1 { background: conic-gradient(#fbf9f3 25%, #2456c4 0 50%, #fbf9f3 0 75%, #2456c4 0); }
.sw-2 { background: conic-gradient(#9dbf9a 25%, #f2ead3 0 50%, #9dbf9a 0 75%, #f2ead3 0); }
.sw-3 { background: conic-gradient(#cf5a3c 25%, #e9c9a0 0 50%, #cf5a3c 0 75%, #e9c9a0 0); }
.sw-4 { background: conic-gradient(#27b0a6 25%, #12706f 0 50%, #27b0a6 0 75%, #12706f 0); }
.sw-5 { background: conic-gradient(#ecebe8 25%, #20242a 0 50%, #ecebe8 0 75%, #20242a 0); }

.fineprint { margin-top: 10px; font-size: 12px; line-height: 1.45; font-style: italic; color: var(--ink-soft); }

.keys div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
}

.rates li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  font-size: 13px;
  border-bottom: 1px dotted var(--grout);
}
.rates em { color: var(--terracotta-deep); text-align: right; }

.best-list { counter-reset: best; }
.best-list li {
  counter-increment: best;
  display: flex;
  gap: 10px;
  padding: 3px 0;
  font: 700 14px var(--mono);
  font-variant-numeric: tabular-nums;
}
.best-list li::before { content: counter(best) "."; color: var(--ink-soft); width: 1.6em; }
.best-list li:first-child { color: var(--cobalt-deep); }

/* ==========================================================
   SMALL PHONES
   ========================================================== */

@media (max-width: 359px) {
  .score { font-size: 22px; }
  .scorebox { min-width: 80px; }
  .stat { padding: 3px 5px; min-width: 30px; }
  .iconbtn { width: 36px; }
  .vial { width: 70px; }
}

@media (max-height: 640px) and (orientation: portrait) {
  :root { --ctrl-h: 92px; }
}

/* ==========================================================
   PHONE LANDSCAPE — pads move to the sides of the table
   ========================================================== */

@media (orientation: landscape) and (max-height: 560px) {
  .shop {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    column-gap: 12px;
    row-gap: 8px;
    padding: calc(6px + var(--safe-t)) calc(8px + var(--safe-r)) calc(8px + var(--safe-b)) calc(8px + var(--safe-l));
  }
  .hud {
    grid-column: 1;
    grid-row: 1;
    border: 2px solid var(--edge);
    border-radius: 3px;
  }
  .stage { grid-column: 2; grid-row: 1 / span 2; }
  .table-frame {
    --table-w: calc((var(--vh) - var(--safe-t) - var(--safe-b) - 16px) * 4 / 7);
  }
  .controls { display: contents; }
  .pad-left { grid-column: 1; grid-row: 2; height: 100%; max-height: 150px; align-self: end; }
  .pad-right { grid-column: 3; grid-row: 2; height: 100%; max-height: 150px; align-self: end; }
  .pad-mid { grid-column: 3; grid-row: 1; grid-template-rows: 46px 40px; align-content: start; }
}

/* ==========================================================
   DESKTOP / TABLET
   ========================================================== */

@media (min-width: 900px) and (min-height: 561px) {
  :root { --ctrl-h: 0px; }

  .shop {
    grid-template-columns: minmax(230px, 300px) auto minmax(230px, 300px);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "hud stage help"
      "job stage help"
      "ctrl ctrl ctrl";
    justify-content: center;
    column-gap: 30px;
    row-gap: 16px;
    padding: 20px;
  }

  .stage { grid-area: stage; }
  .table-frame {
    --table-w: min(
      calc((var(--vh) - 52px - var(--ctrl-h)) * 4 / 7),
      calc(100vw - 580px)
    );
    border-radius: 14px;
    box-shadow:
      0 0 0 3px #f0d68a,
      0 0 0 8px var(--brass),
      0 0 0 10px var(--brass-deep),
      0 22px 44px rgba(27, 39, 48, 0.5);
  }

  .hud {
    grid-area: hud;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 16px;
    border: 2px solid var(--edge);
    border-radius: 3px;
    box-shadow: inset 0 2px 0 #fff, 0 6px 16px rgba(27, 39, 48, 0.2);
  }

  .brand { display: block; }
  .brand h1 { font-size: inherit; line-height: 1; }
  .tagline { margin-top: 6px; font-size: 13px; font-style: italic; color: var(--ink-soft); }

  .scorebox {
    padding: 10px 12px;
    background: var(--ink);
    border-radius: 2px;
    box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.5);
  }
  .scorebox .label { color: #9fb0bc; }
  .score { font-size: 38px; color: var(--tape); margin: 3px 0; }
  .best { display: block; color: #9fb0bc; }
  .best b { color: #fff; }

  .stats { justify-content: stretch; gap: 8px; }
  .stat { flex: 0 0 auto; height: 50px; min-width: 52px; }
  .stat dd { font-size: 19px; }
  .stat-job { flex: 1 1 auto; }
  .stat-job dd { font-size: 15px; }

  .level { justify-content: space-between; }
  .level-label { display: block; }
  .vial { width: 150px; height: 26px; border-radius: 13px; }
  .bubble { top: 3px; height: 16px; width: 22px; margin-left: -11px; }
  .vial i:nth-child(1) { left: calc(50% - 16px); }
  .vial i:nth-child(2) { left: calc(50% + 14px); }

  .ticker { height: 30px; font-size: 13px; line-height: 30px; }
  .hud-buttons { justify-content: flex-end; }

  .panel { display: block; min-height: 0; overflow: auto; }
  .panel-job { grid-area: job; align-self: start; max-height: 100%; }
  .panel-help { grid-area: help; align-self: start; max-height: 100%; }

  .controls { grid-area: ctrl; display: none; }

  .hint-keys { display: block; }
  .hint-touch { display: none; }
  .callout span { font-size: 24px; }
}

/* touch tablets keep the pads */
@media (min-width: 900px) and (min-height: 561px) and (pointer: coarse) {
  :root { --ctrl-h: 124px; }
  .controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 140px minmax(0, 1fr);
    height: 108px;
    padding: 0;
    gap: 14px;
  }
  .hint-keys { display: none; }
  .hint-touch { display: block; }
}

/* short desktop windows: trim the side columns */
@media (min-width: 900px) and (min-height: 561px) and (max-height: 760px) {
  .brand .tagline, .fineprint { display: none; }
  .hud { gap: 8px; padding: 12px; }
  .score { font-size: 30px; }
  .panel { padding: 12px; }
  .panel h2:not(:first-child) { margin-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .callout.show, .tile.set .face, .tile.set .glint,
  .ins-rush.lit path, .ins-blade.lit path, .ins-extra.lit rect, .vial.warn {
    animation-duration: 0.01s;
    animation-iteration-count: 1;
  }
  .callout.show { opacity: 1; transform: translate(-50%, -50%); }
}
