:root {
  --room: #2a1d14;
  --chassis: #cfc6ad;
  --chassis-dark: #b7ad92;
  --edge: #8f866d;
  --ink: #2b241b;
  --paper: #f3ead2;
  --amber: #ffb020;
  --red: #e23b2e;
  --green: #46c26a;
}
* { box-sizing: border-box; }
html { background: var(--room); }
body {
  margin: 0; padding: 20px 16px 48px; color: var(--ink);
  font-family: "Special Elite", "Courier New", monospace;
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.12) 0 2px, transparent 2px 9px),
    linear-gradient(#3b2a1d, #22160f);
  min-height: 100vh;
}
h1, h2 { font-family: "Bebas Neue", Impact, sans-serif; font-weight: 400; margin: 0; letter-spacing: .08em; }
code { background: rgba(0,0,0,.08); padding: 0 4px; border-radius: 3px; }

.machine {
  max-width: 1080px; margin: 0 auto; padding: 22px;
  background: linear-gradient(180deg, #d8cfb6, var(--chassis) 30%, var(--chassis-dark));
  border: 3px solid var(--edge); border-radius: 22px;
  box-shadow: 0 0 0 6px #5a3f2a, 0 0 0 9px #3b2a1d, 0 30px 60px rgba(0,0,0,.6), inset 0 2px 0 rgba(255,255,255,.5);
}
.plate {
  display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: end; justify-content: space-between;
  padding: 10px 18px 14px; margin-bottom: 18px;
  background: linear-gradient(#2f2a22, #1c1813); color: #e8dcc0; border-radius: 10px;
  box-shadow: inset 0 0 0 2px #6b604a, inset 0 3px 8px rgba(0,0,0,.6);
}
.plate h1 { font-size: 3.4rem; line-height: 1; color: var(--amber); text-shadow: 0 0 14px rgba(255,176,32,.55); }
.plate .sub { margin: 0; letter-spacing: .3em; font-size: .8rem; color: #b8ab8b; }
.plate .tag { margin: 0; max-width: 34ch; font-size: .85rem; color: #cfc2a3; }

.deck { display: grid; grid-template-columns: 220px 1fr 220px; gap: 16px; }
.panel {
  padding: 14px; border-radius: 12px;
  background: linear-gradient(#c3b99f, #b3a98d);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.35), inset 0 -3px 8px rgba(0,0,0,.18), 0 2px 0 rgba(0,0,0,.15);
}
.panel h2 { font-size: 1.05rem; margin: 14px 0 8px; color: #3a3126; border-bottom: 2px solid rgba(0,0,0,.2); }
.panel h2:first-child { margin-top: 0; }
.hint { font-size: .78rem; margin: 6px 0 0; color: #4a4030; }

/* translucent glowing buttons */
.buttons { display: grid; gap: 12px; }
.glow {
  position: relative; font: inherit; cursor: pointer; padding: 12px 10px 10px; text-align: center;
  color: #2a1a00; border: 3px solid #6b5a2e; border-radius: 12px;
  background: radial-gradient(ellipse at 50% 30%, rgba(255,240,180,.9), rgba(255,176,32,.7) 55%, rgba(190,110,0,.75));
  box-shadow: 0 0 14px rgba(255,176,32,.55), inset 0 2px 6px rgba(255,255,255,.7), inset 0 -6px 10px rgba(120,60,0,.4), 0 5px 0 #6b5a2e;
  transition: transform .08s, box-shadow .15s;
}
.glow span { display: block; font-family: "Bebas Neue", Impact, sans-serif; font-size: 1.5rem; letter-spacing: .1em; line-height: 1; }
.glow small { font-size: .7rem; opacity: .75; }
.glow.red {
  border-color: #6b2a24; color: #2a0500;
  background: radial-gradient(ellipse at 50% 30%, rgba(255,205,190,.9), rgba(226,59,46,.72) 55%, rgba(140,20,10,.8));
  box-shadow: 0 0 14px rgba(226,59,46,.55), inset 0 2px 6px rgba(255,255,255,.6), inset 0 -6px 10px rgba(100,10,0,.45), 0 5px 0 #6b2a24;
}
.glow:active, .glow.on { transform: translateY(4px); box-shadow: 0 0 26px rgba(255,200,60,.95), inset 0 2px 10px rgba(255,255,255,.9), 0 1px 0 #6b5a2e; }
.glow.red:active, .glow.red.on { box-shadow: 0 0 26px rgba(255,90,70,.95), inset 0 2px 10px rgba(255,255,255,.8), 0 1px 0 #6b2a24; }
.glow:focus-visible, button:focus-visible { outline: 3px solid #1d5fd6; outline-offset: 3px; }

/* rotary defence knob */
.knob-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; background: none; border: 0; cursor: pointer; font: inherit; padding: 4px; }
.knob {
  position: relative; width: 84px; height: 84px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #5b5346, #17130e 70%);
  box-shadow: 0 6px 10px rgba(0,0,0,.5), inset 0 2px 3px rgba(255,255,255,.25), 0 0 0 5px #8f866d;
  transition: transform .35s cubic-bezier(.5,1.6,.5,1);
  transform: rotate(40deg);
}
.knob i { position: absolute; top: 6px; left: 50%; width: 6px; height: 26px; margin-left: -3px; background: var(--amber); border-radius: 3px; box-shadow: 0 0 8px var(--amber); }
.knob-wrap[aria-pressed="false"] .knob { transform: rotate(-40deg); }
.knob-labels { display: flex; justify-content: space-between; width: 130px; font-family: "Bebas Neue", Impact, sans-serif; letter-spacing: .1em; }
.knob-labels b { opacity: .45; }
.knob-wrap[aria-pressed="true"] .on, .knob-wrap[aria-pressed="false"] .off { opacity: 1; color: #7a1a10; }

/* approval lever */
.lever { display: block; width: 100%; padding: 8px; background: none; border: 0; font: inherit; cursor: not-allowed; text-align: center; }
.lever .slot { position: relative; display: block; height: 96px; width: 34px; margin: 0 auto 4px; border-radius: 17px; background: #1c1813; box-shadow: inset 0 3px 8px #000, 0 0 0 4px #8f866d; }
.lever .handle { position: absolute; left: 50%; top: 6px; width: 46px; height: 30px; margin-left: -23px; border-radius: 15px; background: radial-gradient(circle at 35% 30%, #e85a4b, #8a1a10); box-shadow: 0 4px 6px rgba(0,0,0,.6); transition: top .45s cubic-bezier(.4,1.4,.5,1); }
.lever small { font-size: .7rem; letter-spacing: .06em; }
.lever:not(:disabled) { cursor: pointer; }
.lever:not(:disabled) .handle { animation: pulse 1s infinite; }
.lever.pulled .handle { top: 60px; animation: none; }
@keyframes pulse { 50% { box-shadow: 0 0 18px 6px rgba(255,120,90,.9), 0 4px 6px rgba(0,0,0,.6); } }
.small { margin-top: 14px; width: 100%; font: inherit; padding: 6px; cursor: pointer; background: #a89e84; border: 2px solid #6f664f; border-radius: 6px; color: var(--ink); }

/* paper tape */
.tape-head { display: flex; justify-content: space-between; align-items: center; }
.badge { font-size: .7rem; padding: 2px 8px; border-radius: 10px; background: #2f2a22; color: #e8dcc0; letter-spacing: .1em; }
.badge.real { background: #1f5f36; color: #d5f7e0; }
.badge.live { background: #b3261a; color: #fff; }
.badge.scripted { background: #7a4a0c; color: #ffe6b8; }
.tape-wrap { display: flex; flex-direction: column; }
.tape {
  flex: 1 1 0; min-height: 360px; overflow-x: hidden; overflow-y: auto; padding: 14px 16px; margin-top: 8px;
  background: repeating-linear-gradient(#f6eed8 0 27px, #efe5c8 27px 28px);
  border-radius: 4px; box-shadow: inset 0 6px 14px rgba(0,0,0,.25), 0 0 0 3px #8f866d;
  font-size: .86rem; line-height: 28px; color: var(--ink);
}
.line { animation: feed .35s ease-out; white-space: pre-wrap; word-break: break-word; line-height: 1.35; padding: 4px 0; border-bottom: 1px dashed rgba(0,0,0,.12); }
@keyframes feed { from { opacity: 0; transform: translateY(14px); } }
.line b { font-weight: normal; padding: 0 5px; margin-right: 6px; border-radius: 3px; font-size: .74rem; letter-spacing: .06em; background: #2f2a22; color: #f3ead2; }
.line.dim { opacity: .6; }
.line.ok b { background: #1f6b3a; }
.line.bad { color: #7a1a10; } .line.bad b { background: #b3261a; }
.line.tool b { background: #4a4030; }
.line.model b { background: #24506f; }
.stamp { display: block; margin: 12px auto 6px; width: max-content; max-width: 88%; text-align: center; padding: 4px 14px; border: 4px solid; border-radius: 6px; font-family: "Bebas Neue", Impact, sans-serif; font-size: 1.45rem; letter-spacing: .1em; transform: rotate(-4deg); animation: slam .35s cubic-bezier(.3,1.7,.5,1); }
.stamp.bad { color: #b3261a; border-color: #b3261a; }
.stamp.ok { color: #1f6b3a; border-color: #1f6b3a; }
@keyframes slam { from { transform: rotate(-4deg) scale(2.4); opacity: 0; } }
.blurb { margin: 10px 2px 0; font-size: .82rem; min-height: 2.6em; }

/* gauges */
.counter { display: flex; align-items: baseline; justify-content: center; gap: 4px; font-family: "Bebas Neue", Impact, sans-serif; font-size: 2.4rem; }
.counter span { background: #1c1813; color: #f3ead2; padding: 0 12px; border-radius: 4px; box-shadow: inset 0 3px 6px #000; }
.counter em { font-style: normal; color: #4a4030; }
.dial { width: 100%; background: #f3ead2; border-radius: 8px; box-shadow: inset 0 0 0 3px #8f866d; }
#needle { transform-origin: 100px 100px; transition: transform 1s cubic-bezier(.3,1.6,.5,1); transform: rotate(-80deg); }
.lamps { display: grid; gap: 8px; }
.lamps div { display: flex; align-items: center; gap: 10px; font-size: .8rem; }
.lamp { width: 22px; height: 22px; border-radius: 50%; background: #5d564a; box-shadow: inset 0 3px 5px rgba(0,0,0,.6), 0 0 0 3px #8f866d; transition: all .2s; }
.lamp.green.lit { background: radial-gradient(circle at 35% 30%, #c8ffd8, var(--green)); box-shadow: 0 0 14px 3px rgba(70,194,106,.85), 0 0 0 3px #8f866d; }
.lamp.red.lit { background: radial-gradient(circle at 35% 30%, #ffd3cc, var(--red)); box-shadow: 0 0 16px 4px rgba(226,59,46,.9), 0 0 0 3px #8f866d; animation: blink .5s 4; }
@keyframes blink { 50% { opacity: .35; } }

/* results */
.results { margin-top: 20px; padding: 16px; border-radius: 12px; background: rgba(0,0,0,.08); }
.results h2 { font-size: 1.1rem; margin-bottom: 8px; }
.lede { margin: 0 0 12px; font-size: .84rem; line-height: 1.5; }
.tablewrap { overflow-x: auto; }
#rt-table { width: 100%; border-collapse: collapse; font-size: .84rem; background: var(--paper); border-radius: 6px; }
#rt-table th, #rt-table td { padding: 8px 10px; text-align: left; border-bottom: 1px dashed rgba(0,0,0,.2); }
#rt-table th { font-family: "Bebas Neue", Impact, sans-serif; font-weight: 400; letter-spacing: .06em; background: #2f2a22; color: #f3ead2; }
#rt-table td.num { font-variant-numeric: tabular-nums; }
#rt-table td.bad { color: #b3261a; font-weight: bold; }
#rt-table td.good { color: #1f6b3a; font-weight: bold; }
.honest.small { font-size: .76rem; }

/* live mode */
.livebanner { margin-left: auto; margin-right: 10px; padding: 2px 10px; border-radius: 10px; font-size: .72rem; letter-spacing: .12em; background: #b3261a; color: #fff; animation: blink 1.6s infinite; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { font: inherit; font-size: .74rem; padding: 4px 9px; cursor: pointer; color: var(--ink); background: var(--paper); border: 1.5px solid #6f664f; border-radius: 12px; text-align: left; }
.chip:hover { background: #fff6dc; }
.live.primary { outline: 3px solid var(--amber); box-shadow: 0 0 18px rgba(255,176,32,.5); }
.live { margin-top: 12px; padding: 12px; border-radius: 8px; background: rgba(0,0,0,.1); }
.live label { display: block; font-family: "Bebas Neue", Impact, sans-serif; letter-spacing: .08em; margin-bottom: 6px; }
.live .row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.live input, .filters input, .filters select {
  flex: 1; min-width: 0; font: inherit; padding: 8px 10px; color: var(--ink);
  background: var(--paper); border: 2px solid #6f664f; border-radius: 6px;
}
.live .small { width: auto; margin-top: 0; padding: 8px 12px; }
.small.wide { width: auto; padding: 8px 18px; margin-top: 8px; }
#decline { margin-top: 8px; }

/* database check + order book */
.dbcheck, .book { margin-top: 20px; padding: 16px; border-radius: 12px; background: rgba(0,0,0,.08); }
.dbcheck h2, .book h2 { font-size: 1.1rem; margin-bottom: 8px; }
#dbview { margin-top: 12px; }
#dbview h3 { margin: 12px 0 6px; font-family: "Bebas Neue", Impact, sans-serif; font-weight: 400; letter-spacing: .06em; }
#dbview .src { font-size: .78rem; margin: 0 0 6px; }
#dbview .none { padding: 10px; background: var(--paper); border-radius: 6px; font-size: .84rem; }
.filters { display: flex; gap: 8px; margin: 10px 0; }
.filters select { flex: 0 0 auto; }
#bk-table, #db-refunds, #db-orders { width: 100%; border-collapse: collapse; font-size: .8rem; background: var(--paper); border-radius: 6px; }
#bk-table th, #bk-table td, #db-refunds th, #db-refunds td, #db-orders th, #db-orders td { padding: 6px 8px; text-align: left; border-bottom: 1px dashed rgba(0,0,0,.2); white-space: nowrap; }
#bk-table td:last-child { white-space: normal; min-width: 150px; }
#bk-table th, #db-refunds th, #db-orders th { font-family: "Bebas Neue", Impact, sans-serif; font-weight: 400; letter-spacing: .06em; background: #2f2a22; color: #f3ead2; }
#bk-table tr.demo td:first-child { font-weight: bold; color: #7a1a10; }
.st-refunded { color: #b3261a; font-weight: bold; } .st-cancelled { opacity: .6; } .st-delivered { color: #1f6b3a; }

/* legend */
.legend { margin-top: 20px; padding: 16px; border-radius: 12px; background: rgba(0,0,0,.08); }
.legend h2 { font-size: 1.1rem; margin-bottom: 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px 22px; }
.grid div { font-size: .82rem; line-height: 1.35; }
.grid b { display: block; font-family: "Bebas Neue", Impact, sans-serif; font-weight: 400; letter-spacing: .06em; font-size: 1rem; }
.honest { margin: 14px 0 0; padding-top: 12px; border-top: 2px solid rgba(0,0,0,.18); font-size: .8rem; line-height: 1.5; }

.deck > * { min-width: 0; }
@media (max-width: 860px) {
  body { padding: 10px 8px 32px; }
  .machine { padding: 12px; }
  .deck { grid-template-columns: minmax(0, 1fr); }
  .buttons { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .glow { padding: 10px 4px 8px; }
  .glow span { font-size: 1.15rem; }
  .glow small { font-size: .6rem; }
  .tape { flex: none; height: 320px; min-height: 0; }
  .plate h1 { font-size: 2.6rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
