/* The arcade cabinet: palette, fonts, frame, panels, CRT overlay. Extracted from Jev Frogger (the reference).
   Games may ADD tokens in their own stylesheet (e.g. a warm playfield or felt); they may not redefine these.
   Colour rules: --lime is only ever the player; --hot is reserved for the decision being made right now. */
:root {
  --ink:   #0d0f1c;  /* outlines, page */
  --navy:  #1a1f3d;  /* cabinet, deep background */
  --road:  #4a4450;  /* warm grey surface */
  --stone: #8d8478;  /* kerbs, paint, labels, idle bars */
  --river: #2459d9;  /* saturated hazard field */
  --foam:  #5fc6f7;  /* ripples, glass */
  --lime:  #a6f03e;  /* the player */
  --moss:  #2c9a4a;  /* safe ground, friendly objects */
  --cream: #fff1d0;  /* highlights, type */
  --gold:  #ffc53d;  /* score, accents */
  --red:   #e3414f;  /* danger */
  --bark:  #a15d34;  /* wood */
  --hot:   #ff3d9a;  /* RESERVED: the chosen decision */
  --display: 'Press Start 2P', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --board: 416px;    /* playfield CSS size; set by cabinet.fit() */
  --art-w: 208;      /* playfield width in art pixels; set by createCabinet() */
  --aspect: 1;       /* playfield height / width; set by createCabinet() */
}
/* sprite symbols (tools/make-sprites.mjs) fill by class */
.c-ink{fill:var(--ink)} .c-navy{fill:var(--navy)} .c-road{fill:var(--road)} .c-stone{fill:var(--stone)}
.c-river{fill:var(--river)} .c-foam{fill:var(--foam)} .c-lime{fill:var(--lime)} .c-moss{fill:var(--moss)}
.c-cream{fill:var(--cream)} .c-gold{fill:var(--gold)} .c-red{fill:var(--red)} .c-bark{fill:var(--bark)}
.c-hot{fill:var(--hot)} .c-cur{fill:currentColor}
/* text tones for readings panels */
.tone-lime{color:var(--lime)} .tone-gold{color:var(--gold)} .tone-red{color:var(--red)} .tone-road{color:var(--road)}
.tone-cream{color:var(--cream)} .tone-stone{color:var(--stone)} .tone-foam{color:var(--foam)} .tone-hot{color:var(--hot)}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--ink); color: var(--cream);
  font: 12px/1 var(--display); display: grid; place-items: center;
  -webkit-font-smoothing: none; overflow-x: hidden;
}
svg { shape-rendering: crispEdges; display: block; }
#sprites { position: absolute; width: 0; height: 0; }

/* frame: 3-px two-colour bevel + ink ring; wells are the bevel reversed */
.cab {
  display: grid; grid-template-columns: var(--board) 236px;
  grid-template-areas: "head head" "board log" "strip log";
  gap: 6px 8px; padding: 8px; background: var(--navy);
  border: 3px solid; border-color: var(--stone) var(--road) var(--road) var(--stone);
  box-shadow: 0 0 0 3px var(--ink), 0 0 0 4px var(--road);
}
.well { border: 2px solid; border-color: var(--ink) var(--road) var(--road) var(--ink); background: var(--ink); }

/* title bar */
.cab-head { grid-area: head; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.cab-head h1 { margin: 0; font-size: 16px; font-weight: normal; color: var(--lime); text-shadow: 2px 2px 0 var(--moss), 4px 4px 0 var(--ink); letter-spacing: 1px; }
.cab-head h1 + p { margin: 4px 0 0; font-size: 8px; color: var(--stone); }
.cab-stats { display: flex; gap: 14px; align-items: flex-end; font-size: 12px; }
.cab-stats label { display: block; font-size: 8px; color: var(--stone); margin-bottom: 4px; }
.cab-icons { display: flex; gap: 2px; height: 16px; } .cab-icons svg { width: 16px; height: 16px; }
.cab-icons svg.gone { opacity: .18; }
.cab-timebar { width: 84px; height: 12px; padding: 2px; }
.cab-timebar i { display: block; height: 100%; background: var(--lime); }
.cab-timebar.low i { background: var(--red); }

/* playfield + overlays */
.cab-board { grid-area: board; position: relative; width: var(--board); height: calc(var(--board) * var(--aspect)); box-sizing: content-box; }
.cab-board canvas { display: block; width: var(--board); height: calc(var(--board) * var(--aspect)); image-rendering: pixelated; }
.cab-crt { position: absolute; inset: 0; pointer-events: none; --px: calc(var(--board) / var(--art-w));
  background:
    repeating-linear-gradient(0deg, color-mix(in srgb, var(--ink) 9%, transparent) 0 var(--px), transparent var(--px) calc(var(--px) * 2)),
    radial-gradient(ellipse at center, transparent 58%, color-mix(in srgb, var(--ink) 45%, transparent) 100%); }
.cab-crt.off { display: none; }
.badge { position: absolute; top: 6px; font-size: 8px; padding: 4px 5px 3px; color: var(--ink); display: none; }
.badge.right { right: 6px; } .badge.left { left: 6px; }
.badge.blink { animation: blink 1s steps(2) infinite; }
.show { display: block !important; }
@keyframes blink { 50% { opacity: .35; } }
.cab-card {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: none;
  padding: 16px 18px; text-align: center; background: var(--navy); white-space: nowrap;
  border: 3px solid; border-color: var(--stone) var(--road) var(--road) var(--stone); box-shadow: 0 0 0 3px var(--ink);
}
.cab-card b { display: block; font-size: 16px; font-weight: normal; color: var(--red); margin-bottom: 10px; }
.cab-card.pause b { color: var(--cream); } .cab-card.pause span:empty { display: none; } .cab-card.pause b:has(+ span:empty) { margin: 0; }
.cab-card span { font-size: 8px; color: var(--stone); line-height: 1.8; }

/* bottom strip: action bars + side readouts/meters */
.cab-strip { grid-area: strip; display: grid; grid-template-columns: 1fr 138px; gap: 12px; padding: 6px 8px; height: 86px; }
.bar { display: grid; grid-template-columns: 12px 50px 1fr 40px; align-items: center; gap: 5px; height: 14px; font-size: 10px; color: var(--stone); }
.bar svg { width: 8px; height: 8px; margin-left: 2px; }
.bar .pct { text-align: right; }
.track { position: relative; height: 10px; width: 100%; width: round(down, 100%, 8px); --c: var(--stone);
  background: repeating-linear-gradient(90deg, var(--navy) 0 6px, transparent 6px 8px); }
.track i { position: absolute; inset: 0; width: 0; background: repeating-linear-gradient(90deg, var(--c) 0 6px, transparent 6px 8px); }
.bar.on { color: var(--cream); } .bar.on .track { --c: var(--hot); } .bar.on svg { color: var(--hot); }
.cab-side { display: grid; grid-template-rows: auto auto 1fr 1fr; gap: 3px; font-size: 8px; color: var(--stone); }
.cab-side .big { font-size: 16px; color: var(--cream); } .cab-side .big + span { font-size: 8px; }
.cab-side .meter { display: grid; grid-template-columns: 58px 1fr; align-items: center; }
.cab-side .track { height: 8px; }

/* right-hand log column: stream, readings, sparkline, legend */
.cab-log { grid-area: log; padding: 8px; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.cab-log h2 { margin: 0 0 6px; font-size: 8px; font-weight: normal; color: var(--stone); display: flex; justify-content: space-between; }
.cab-log ol { list-style: none; margin: 0 0 12px; padding: 0; min-height: 152px; font: 12px/19px var(--mono); color: var(--stone); white-space: pre; }
.cab-log li:last-child { color: var(--cream); } .cab-log li:last-child b { color: var(--hot); }
.cab-log li b { font-weight: normal; } .cab-log li.err { color: var(--red); }
.readings { margin: 0 0 12px; font: 12px/19px var(--mono); color: var(--stone); white-space: pre; }
.spark { display: flex; align-items: flex-end; gap: 2px; height: 40px; margin-bottom: 8px; border-bottom: 2px solid var(--road); }
.spark i { width: 3px; background: var(--stone); } .spark i:last-child { background: var(--cream); } .spark i.err { background: var(--red); }
.cab-custom { margin: 0 0 12px; image-rendering: pixelated; }
.cab-keys { margin-top: auto; font-size: 8px; line-height: 2; color: var(--road); }
.cab-keys b { color: var(--stone); font-weight: normal; }

@media (max-width: 760px) {
  body { place-items: start center; padding: 8px 0; }
  .cab { grid-template-columns: var(--board); grid-template-areas: "head" "board" "strip" "log"; }
  .cab-keys { display: none; }
}
