/* ===========================================================
   Pizza Tycoon 3D — trattoria-flavoured UI
   =========================================================== */
:root {
  --cream: #fdf6e6;
  --ink: #221f1b;
  --red: #c8362c;
  --red-dark: #8e2018;
  --gold: #e8b23c;
  --green: #3f9d5e;
  --panel: rgba(28, 24, 21, 0.78);
  --panel-line: rgba(232, 178, 60, 0.45);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  overscroll-behavior: none;
  background: #14100e;
  color: var(--cream);
  font-family: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  touch-action: none;                 /* drag-to-look must not scroll the page */
}

.hidden { display: none !important; }

/* ---------------- HUD ---------------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }

#crosshair {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 22px; height: 22px;
}
#crosshair span {
  position: absolute; inset: 0; border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 50%; opacity: 0.55;
}
#crosshair::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 3px; height: 3px; background: #fff; border-radius: 50%;
  transform: translate(-50%, -50%);
}

.panel {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  padding: 10px 14px;
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow);
  min-width: 170px;
}
.panel h4 {
  margin: 0 0 6px; font-size: 12px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--gold); font-weight: 700;
}
.top-left { left: 16px; top: 16px; }
.top-right { right: 16px; top: 16px; max-width: 290px; }

/* The queue can outgrow the panel, so the list itself scrolls. */
#hud-orders {
  display: flex; flex-direction: column;
  max-height: 60vh;
  pointer-events: auto;              /* so a finger or wheel scrolls it */
}
#order-count { opacity: 0.6; letter-spacing: 0; }
#order-list {
  overflow-y: auto; min-height: 0; flex: 1 1 auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;               /* drag the list, do not turn the camera */
  scrollbar-width: thin;
  scrollbar-color: rgba(232, 178, 60, 0.5) transparent;
}
#order-list::-webkit-scrollbar { width: 5px; }
#order-list::-webkit-scrollbar-track { background: transparent; }
#order-list::-webkit-scrollbar-thumb {
  background: rgba(232, 178, 60, 0.5); border-radius: 3px;
}
#order-empty { border-left-color: #666 !important; opacity: 0.6; }
.bottom-right { right: 16px; bottom: 16px; min-width: 210px; }

.cash { font-size: 30px; font-weight: 800; color: #8fe3a5; letter-spacing: 0.02em; line-height: 1.05; }
.row { display: flex; gap: 6px; margin: 6px 0 4px; }
.chip {
  background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px; padding: 2px 10px; font-size: 12px;
}
.stars { color: var(--gold); font-size: 17px; letter-spacing: 2px; }
.timebar { margin-top: 7px; height: 6px; border-radius: 4px; background: rgba(255,255,255,0.14); overflow: hidden; }
.timebar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--gold), var(--red)); }

#hud-special {
  font-size: 12px; color: var(--gold); margin-bottom: 6px;
  background: rgba(232, 178, 60, 0.13); border-radius: 6px; padding: 3px 7px;
}
#hud-special:empty { display: none; }
#order-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
#order-list li {
  padding: 5px 7px; margin-bottom: 4px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  border-left: 3px solid var(--green);
  display: flex; justify-content: space-between; gap: 8px; align-items: baseline;
}
#order-list li.warn { border-left-color: var(--gold); }
#order-list li.crit { border-left-color: var(--red); animation: pulse 0.7s infinite alternate; }
#order-list li.delivery { background: rgba(226, 90, 42, 0.22); }
#order-list .who { font-weight: 700; }
#order-list .what { opacity: 0.85; font-size: 12px; }
#order-list .left { font-variant-numeric: tabular-nums; opacity: 0.8; font-size: 12px; }
@keyframes pulse { from { opacity: 0.65; } to { opacity: 1; } }

#oven-list { font-size: 13px; }
.oven-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.oven-row .name { width: 52px; opacity: 0.85; }
.oven-row .bar { flex: 1; height: 8px; border-radius: 4px; background: rgba(255,255,255,0.14); overflow: hidden; position: relative; }
.oven-row .bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--gold); }
.oven-row .bar u { position: absolute; top: 0; bottom: 0; background: rgba(80, 220, 120, 0.55); }
.oven-row .state { width: 60px; text-align: right; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.oven-row.locked { opacity: 0.35; }
.oven-row.burning .state { color: #ff8b6b; }
.oven-row.ready .state { color: #8fe3a5; }

/* What you are carrying, ingredient by ingredient, at the top of the screen. */
#held {
  position: absolute; left: 50%; top: 16px; transform: translateX(-50%);
  /* fixed, so the panel does not jump about as the heading text changes */
  width: 252px; min-width: 0;
}
#held h4 { display: flex; align-items: center; gap: 6px; margin-bottom: 7px; }
#held-icon { font-size: 15px; }
/* "top of 3" — only there when you are carrying a stack */
#held-count {
  margin-left: auto; flex: none;
  background: rgba(232, 178, 60, 0.18); color: var(--gold);
  border-radius: 999px; padding: 1px 7px; font-size: 10px; letter-spacing: 0.06em;
}
#held-list { list-style: none; margin: 0; padding: 0; font-size: 12px; line-height: 1.3; }
#held-list li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 1.5px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
#held-list li:last-child { border-bottom: none; }
#held-list .hi-name { opacity: 0.85; white-space: nowrap; }
#held-list .hi-val { font-weight: 700; text-align: right; overflow-wrap: anywhere; }

/* green once the pizza matches an order, amber while nobody wants it */
#held.matched { border-color: rgba(143, 227, 165, 0.55); }
#held.matched h4 { color: #8fe3a5; }
#held.unwanted { border-color: rgba(232, 178, 60, 0.5); }
#held.unwanted h4 { color: var(--gold); opacity: 0.9; }
#held-list li.done .hi-val { color: #8fe3a5; }
#held-list li.todo { opacity: 0.45; }
#held-list li.todo .hi-val { font-weight: 400; font-style: italic; }
#held-list li.warn .hi-val { color: var(--gold); }
#held-list li.bad .hi-val { color: #ff8b6b; }

#prompt {
  position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%);
  background: rgba(232, 178, 60, 0.94); color: #241a06;
  border-radius: 8px; padding: 8px 16px; font-size: 15px; font-weight: 700;
  box-shadow: var(--shadow); white-space: nowrap;
}
#prompt b { background: #241a06; color: var(--gold); border-radius: 5px; padding: 1px 7px; margin: 0 2px; }

/* ---------------- Minigames ---------------- */
.minigame {
  position: absolute; left: 50%; bottom: 190px; transform: translateX(-50%);
  width: min(560px, 82vw); text-align: center;
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 14px; padding: 14px 18px 18px; box-shadow: var(--shadow);
}
.mg-title { font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 10px; color: var(--gold); }
.mg-title b { background: var(--gold); color: #241a06; border-radius: 4px; padding: 0 6px; }
.mg-sub { margin-top: 8px; font-size: 13px; opacity: 0.85; }

.toss-track, .sauce-track, .hold-track {
  position: relative; height: 26px; border-radius: 13px;
  background: rgba(255, 255, 255, 0.12); overflow: hidden;
}
.toss-zone {
  position: absolute; top: 0; bottom: 0;
  background: linear-gradient(180deg, rgba(90,230,130,0.85), rgba(50,180,95,0.85));
}
.toss-marker {
  position: absolute; top: -4px; bottom: -4px; width: 5px; background: #fff;
  box-shadow: 0 0 10px #fff; border-radius: 3px;
}
.sauce-sweet { position: absolute; top: 0; bottom: 0; background: rgba(90, 230, 130, 0.75); }
.sauce-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0%; background: linear-gradient(90deg, #d84b36, #a3231a); }
.sauce-fill.over { background: linear-gradient(90deg, #ff5a3c, #ff9d3c); }
.hold-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0%; background: linear-gradient(90deg, var(--gold), #f6e0a0); }

#toppingbar {
  position: absolute; left: 50%; bottom: 190px; transform: translateX(-50%);
  display: flex; gap: 8px; background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow);
  pointer-events: auto;              /* the tubs are clickable, not just tappable */
}
.tb-item { cursor: pointer; }
.tb-item:hover .tb-swatch { border-color: rgba(255, 255, 255, 0.7); }
.tb-item:active .tb-swatch { transform: scale(0.93); }
.tb-item { text-align: center; width: 74px; font-size: 11px; opacity: 0.92; }
.tb-swatch {
  width: 46px; height: 46px; border-radius: 12px; margin: 0 auto 5px;
  border: 2px solid rgba(255,255,255,0.28); position: relative;
}
.tb-key {
  position: absolute; right: -6px; top: -6px; background: #241a06; color: var(--gold);
  border-radius: 6px; font-size: 11px; padding: 1px 5px; font-weight: 700;
}
.tb-item.on .tb-swatch { border-color: #fff; box-shadow: 0 0 12px rgba(255,255,255,0.6); }
.tb-count { color: var(--gold); font-weight: 700; }

/* --- "are you sure?", shown before a pizza is thrown away --- */
#confirm {
  pointer-events: auto; z-index: 2;
  border-color: rgba(255, 139, 107, 0.6);
  background: rgba(24, 19, 17, 0.94);      /* opaque: this is a question, not a readout */
}
/* while it is up, nothing else competes for the middle of the screen */
body.asking #held,
body.asking #prompt,
body.asking #lookhint,
body.asking #toppingbar { display: none !important; }
#confirm .mg-title { color: #ff8b6b; }
#confirm .mg-sub { margin-bottom: 12px; }
.cf-buttons { display: flex; gap: 10px; justify-content: center; }
.cf-btn {
  pointer-events: auto; touch-action: manipulation;
  font-family: inherit; font-size: 14px; font-weight: 700; letter-spacing: 0.04em;
  padding: 9px 20px; border-radius: 9px; cursor: pointer;
  border: 2px solid transparent; color: var(--cream);
  transition: transform 0.08s, filter 0.12s;
}
.cf-btn:active { transform: scale(0.95); }
.cf-btn b { opacity: 0.75; font-weight: 700; }
.cf-yes { background: linear-gradient(180deg, rgba(200, 54, 44, 0.95), rgba(142, 32, 24, 0.95)); border-color: rgba(255, 139, 107, 0.7); }
.cf-no  { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.28); }
.cf-yes:hover, .cf-no:hover { filter: brightness(1.15); }

/* ---------------- Toasts & banner ---------------- */
/* Tucked against the left edge, clear of the stick and the action buttons. */
#btn-hud {
  position: absolute;
  left: calc(12px + env(safe-area-inset-left, 0px));
  top: 50%;
  transform: translateY(-50%);
}
#btn-hud:active { transform: translateY(-50%) scale(0.92); }

/* Just under the eye button. Only exists once you employ a waiter, and dims
   until you are holding a box somebody in the queue actually ordered. */
#btn-waiter {
  position: absolute;
  left: calc(12px + env(safe-area-inset-left, 0px));
  top: 50%;
  transform: translateY(calc(-50% + 48px));
}
#btn-waiter:active { transform: translateY(calc(-50% + 48px)) scale(0.92); }
#btn-waiter.ready { border-color: rgba(143, 227, 165, 0.85); background: rgba(40, 88, 54, 0.8); }

/* what the eye button puts away */
body.panels-hidden #held,
body.panels-hidden #hud-ovens,
body.panels-hidden #hud-orders { display: none !important; }

#lookhint {
  position: absolute; left: 16px; bottom: 16px;
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: 10px;
  padding: 7px 13px; font-size: 12.5px; opacity: 0.85; box-shadow: var(--shadow);
}

#toasts {
  position: absolute; left: 50%; top: 46%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.toast {
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: 10px;
  padding: 7px 16px; font-size: 15px; font-weight: 700; box-shadow: var(--shadow);
  animation: rise 2.4s ease-out forwards;
}
.toast.good { color: #8fe3a5; border-color: rgba(143, 227, 165, 0.5); }
.toast.bad { color: #ff8b6b; border-color: rgba(255, 139, 107, 0.5); }
.toast.info { color: var(--gold); }
@keyframes rise {
  0% { opacity: 0; transform: translateY(14px) scale(0.94); }
  12% { opacity: 1; transform: translateY(0) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-26px); }
}

#banner {
  position: absolute; left: 50%; top: 36%; transform: translateX(-50%);
  font-size: 30px; font-weight: 900; letter-spacing: 0.1em;
  color: var(--gold); text-shadow: 0 4px 18px rgba(0,0,0,0.7);
  animation: bannerIn 0.5s ease-out;
}
@keyframes bannerIn { from { opacity: 0; transform: translate(-50%, -16px) scale(0.9); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

/* ---------------- Screens ---------------- */
#screens { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.screen {
  position: absolute; inset: 0; display: none;
  align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 35%, rgba(50, 30, 20, 0.78), rgba(10, 8, 7, 0.94));
  pointer-events: auto; padding: 24px; overflow: auto;
}
.screen.active { display: flex; }

.card {
  background: linear-gradient(180deg, #2a231d, #1d1815);
  border: 2px solid var(--panel-line); border-radius: 18px;
  padding: 26px 30px; max-width: 560px; width: 100%;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6); text-align: center;
  max-height: 92vh; overflow: auto;
}
.card.wide { max-width: 880px; }

h1 { font-size: 46px; margin: 0 0 4px; letter-spacing: 0.04em; color: var(--cream); }
h1 span { color: var(--red); }
h2 { font-size: 30px; margin: 0 0 10px; color: var(--gold); }
h3 { font-size: 15px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); margin: 22px 0 10px; }
.tagline { opacity: 0.86; line-height: 1.55; margin: 6px 0 16px; }
.fineprint { opacity: 0.5; font-size: 12px; margin-top: 14px; }

.howto {
  background: rgba(0,0,0,0.3); border-radius: 12px; padding: 12px 16px;
  font-size: 13.5px; line-height: 1.9; text-align: left; margin-bottom: 14px;
}
.howto b { background: var(--gold); color: #241a06; border-radius: 4px; padding: 1px 7px; font-size: 12px; }

.flow {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
  font-size: 12.5px; opacity: 0.85; margin-bottom: 20px;
}
.flow span { background: rgba(255,255,255,0.07); border-radius: 6px; padding: 4px 8px; }

button.big {
  pointer-events: auto; cursor: pointer;
  background: linear-gradient(180deg, var(--red), var(--red-dark));
  color: #fff; border: none; border-radius: 12px;
  padding: 14px 30px; font-size: 17px; font-weight: 800; letter-spacing: 0.08em;
  box-shadow: 0 8px 22px rgba(200, 54, 44, 0.42); transition: transform 0.12s, filter 0.12s;
  font-family: inherit;
}
button.big:hover { transform: translateY(-2px); filter: brightness(1.12); }
button.big:active { transform: translateY(1px); }

.briefing { list-style: none; padding: 0; margin: 0 0 18px; font-size: 14px; text-align: left; }
.briefing li { padding: 7px 12px; background: rgba(255,255,255,0.06); border-radius: 8px; margin-bottom: 6px; }

.ledger { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; font-size: 14.5px; text-align: left; }
.ledger .k { opacity: 0.8; }
.ledger .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.ledger .sep { grid-column: 1 / -1; height: 1px; background: var(--panel-line); margin: 7px 0; }
.ledger .pos { color: #8fe3a5; }
.ledger .neg { color: #ff8b6b; }

.priceline { background: rgba(0,0,0,0.3); border-radius: 12px; padding: 12px 16px; margin-bottom: 14px; text-align: left; }
.priceline label { font-size: 14px; }
.priceline input[type=range] { width: 100%; margin: 8px 0 4px; accent-color: var(--red); }
.priceline small { opacity: 0.6; font-size: 12px; }

.shop { display: block; margin-bottom: 20px; }
.shop-group {
  font-size: 11.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--gold); opacity: 0.8; text-align: left;
  margin: 16px 0 8px; padding-bottom: 5px;
  border-bottom: 1px solid rgba(232, 178, 60, 0.22);
}
.shop-group:first-child { margin-top: 4px; }
.shop-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 10px; }
.shop-item {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px; padding: 11px 13px; text-align: left; cursor: pointer;
  transition: transform 0.1s, border-color 0.1s, background 0.1s;
}
.shop-item:hover { transform: translateY(-2px); border-color: var(--gold); }
.shop-item.cant { opacity: 0.42; cursor: not-allowed; }
.shop-item.maxed { opacity: 0.6; cursor: default; border-color: var(--green); }
.shop-item .si-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.shop-item .si-name { font-weight: 700; font-size: 14px; }
.shop-item .si-cost { color: #8fe3a5; font-weight: 800; font-size: 14px; white-space: nowrap; }
.shop-item.cant .si-cost { color: #ff8b6b; }
.shop-item .si-desc { font-size: 12px; opacity: 0.72; margin-top: 5px; line-height: 1.45; }
.shop-item .si-lvl {
  font-size: 10.5px; color: var(--gold); letter-spacing: 0.1em; margin-top: 7px;
  display: flex; align-items: center; gap: 6px;
}
.si-pips { letter-spacing: 3px; font-size: 12px; }
.si-ladder {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px;
  margin-top: 5px; font-size: 11.5px; line-height: 1.35;
}
.si-gate {
  margin-top: 6px; font-size: 11.5px; font-weight: 700;
  color: var(--gold); opacity: 0.85;
}
.si-now { opacity: 0.62; }
.si-arrow { opacity: 0.45; }
.si-next { color: #8fe3a5; font-weight: 700; }
.shop-item.maxed .si-now { opacity: 0.85; color: #8fe3a5; }

.resume-note {
  background: rgba(143, 227, 165, 0.12);
  border: 1px solid rgba(143, 227, 165, 0.35);
  border-radius: 10px; padding: 9px 13px; margin: 0 0 14px;
  font-size: 13.5px; line-height: 1.5; color: #d6f5e0;
}
.linkish {
  background: none; border: none; padding: 0; margin-top: 4px;
  font-family: inherit; font-size: 12px; color: var(--gold);
  text-decoration: underline; cursor: pointer; opacity: 0.8;
}
.linkish:hover { opacity: 1; }

.recipe { text-align: left; font-size: 13px; opacity: 0.85; line-height: 1.7; margin-bottom: 18px; }
.recipe b { color: var(--gold); }

/* Shown only on a touch device held upright — the kitchen is a landscape room. */
#rotate-hint { display: none; }
@media (orientation: portrait) {
  body.touch-mode #rotate-hint {
    display: block;
    position: fixed; z-index: 25;
    left: 50%; transform: translateX(-50%);
    top: calc(56px + env(safe-area-inset-top, 0px));
    width: min(88vw, 320px); text-align: center;
    background: rgba(28, 24, 21, 0.86); border: 1px solid var(--panel-line);
    border-radius: 10px; padding: 8px 12px; font-size: 12.5px; line-height: 1.45;
    color: var(--gold); box-shadow: var(--shadow); pointer-events: none;
  }
}

#loading {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: #14100e; color: var(--gold); font-size: 20px; letter-spacing: 0.1em; z-index: 40;
}

@media (max-width: 720px) {
  .top-right { max-width: 190px; }
  h1 { font-size: 32px; }
  .minigame { bottom: 150px; }
}


/* ===========================================================
   Touch controls — phones and tablets
   Only rendered when the device's primary pointer is a finger.
   =========================================================== */
#touch { display: none; }

body.touch-mode {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
body.touch-mode #touch { display: block; }

/* --- left thumb: analogue stick --- */
#stick {
  position: absolute; pointer-events: auto; touch-action: none;
  left: calc(16px + env(safe-area-inset-left, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  width: 124px; height: 124px; border-radius: 50%;
  background: rgba(28, 24, 21, 0.42);
  border: 2px solid rgba(232, 178, 60, 0.42);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  transition: background 0.15s, border-color 0.15s;
}
#stick.active { background: rgba(28, 24, 21, 0.6); border-color: rgba(232, 178, 60, 0.75); }
#stick-knob {
  width: 54px; height: 54px; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #f0dcae, #c8362c 78%);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

/* --- right thumb: action buttons --- */
#touch-actions {
  position: absolute;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: auto auto;
  grid-template-areas: "throw bin" "act act";
  gap: 10px; align-items: end; justify-items: center;
}
#tb-throw { grid-area: throw; }
#tb-bin { grid-area: bin; }
#tb-act { grid-area: act; }

#touch-top {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex; gap: 10px;
}

.tbtn {
  pointer-events: auto; touch-action: none; padding: 0; line-height: 1;
  font-family: inherit; color: var(--cream);
  background: rgba(28, 24, 21, 0.72);
  border: 2px solid rgba(232, 178, 60, 0.5);
  border-radius: 50%;
  display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  transition: transform 0.08s, background 0.12s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.tbtn.tbtn-lg {
  width: 92px; height: 92px; border-radius: 50%; padding: 0; border-style: solid;
  font-size: 15px; font-weight: 800; letter-spacing: 0.06em;
  background: linear-gradient(180deg, rgba(200, 54, 44, 0.92), rgba(142, 32, 24, 0.92));
  border-color: rgba(255, 220, 150, 0.6);
}
.tbtn.tbtn-lg span { padding: 0 6px; text-align: center; line-height: 1.1; }
.tbtn.tbtn-lg.held { transform: scale(0.93); filter: brightness(1.25); }
.tbtn.tbtn-sm { width: 54px; height: 54px; font-size: 21px; padding: 0; }
.tbtn.tbtn-xs { width: 40px; height: 40px; font-size: 16px; border-width: 1px; padding: 0; }
.tbtn.off { opacity: 0.32; }
.tbtn:active { transform: scale(0.94); }

/* --- HUD reflow so the panels leave room for two thumbs --- */
body.touch-mode .panel { padding: 7px 10px; min-width: 0; border-radius: 10px; }
body.touch-mode .panel h4 { font-size: 10px; margin-bottom: 4px; }
body.touch-mode .top-left {
  left: calc(8px + env(safe-area-inset-left, 0px));
  top: calc(8px + env(safe-area-inset-top, 0px));
}
body.touch-mode .cash { font-size: 21px; }
body.touch-mode .chip { font-size: 10px; padding: 1px 7px; }
body.touch-mode .stars { font-size: 13px; }

body.touch-mode .top-right {
  right: calc(8px + env(safe-area-inset-right, 0px));
  top: calc(8px + env(safe-area-inset-top, 0px));
  max-width: 172px; max-height: 54vh; overflow: visible;
}
body.touch-mode #order-list { font-size: 11px; }
body.touch-mode #order-list li { padding: 3px 5px; margin-bottom: 3px; }
body.touch-mode #hud-special { font-size: 10px; }

/* ovens tuck under the stats panel, clear of both thumbs */
body.touch-mode #hud-ovens {
  right: auto; bottom: auto;
  left: calc(8px + env(safe-area-inset-left, 0px));
  top: calc(104px + env(safe-area-inset-top, 0px));
  min-width: 0; width: 158px; font-size: 11px;
}
body.touch-mode .oven-row .name { width: 40px; font-size: 10px; }
body.touch-mode .oven-row .state { width: 46px; font-size: 9px; }

/* prompts and the carried-item label sit above the thumb zone */
body.touch-mode #prompt {
  bottom: calc(150px + env(safe-area-inset-bottom, 0px));
  font-size: 13px; padding: 6px 12px;
  max-width: 62vw; white-space: normal; text-align: center;
}
body.touch-mode #held {
  top: calc(6px + env(safe-area-inset-top, 0px));
  min-width: 0; width: 158px; padding: 5px 8px; border-radius: 9px;
}
body.touch-mode #held h4 { font-size: 9px; margin-bottom: 3px; gap: 4px; }
body.touch-mode #held-icon { font-size: 11px; }
body.touch-mode #held-count { font-size: 8px; padding: 0 5px; }
body.touch-mode #held-list { font-size: 9.5px; line-height: 1.25; }
body.touch-mode #held-list li { padding: 1px 0; gap: 6px; }

/* The eye and waiter buttons are moved into the bottom strip on a phone, so
   they stop claiming the left edge the stick needs. The strip lays them out. */
body.touch-mode #btn-hud,
body.touch-mode #btn-waiter {
  position: static; left: auto; top: auto; transform: none;
}
body.touch-mode #btn-hud:active,
body.touch-mode #btn-waiter:active { transform: scale(0.92); }

/* The right thumb's buttons own the bottom of that corner, so the orders
   list stops short of them instead of running underneath. */
body.touch-mode #hud-orders { max-height: calc(100vh - 215px); }
#lookhint {
  left: 50%; bottom: auto; top: 44%; transform: translateX(-50%);
  font-size: 12px; text-align: center;
}
body.touch-mode #toasts { top: 46%; }
body.touch-mode .toast { font-size: 13px; padding: 5px 12px; }
body.touch-mode #banner { font-size: 19px; top: 34%; }

/* minigames move to the top third so the pizza stays visible */
body.touch-mode .minigame {
  bottom: auto; top: 15%; width: min(430px, 78vw); padding: 10px 12px 13px;
}
body.touch-mode .mg-title { font-size: 11px; margin-bottom: 7px; }
body.touch-mode .toss-track, body.touch-mode .sauce-track, body.touch-mode .hold-track { height: 20px; }
/* centred on a phone, where the usual minigame spot lands on the panels */
body.touch-mode #confirm {
  top: 50%; bottom: auto; left: 50%;
  transform: translate(-50%, -50%);
  width: min(400px, 88vw);
}
body.touch-mode .cf-btn { font-size: 13px; padding: 10px 18px; }
body.touch-mode .cf-btn b { display: none; }   /* no keyboard, no key hints */
body.touch-mode #confirm .mg-sub { font-size: 11.5px; margin-bottom: 9px; }

/* the topping bar becomes the picker: centred, big tap targets, two rows */
body.touch-mode #toppingbar {
  bottom: auto; top: 42%; left: 50%; transform: translate(-50%, -50%);
  flex-wrap: wrap; justify-content: center;
  max-width: min(92vw, 372px); gap: 6px; padding: 10px;
}
body.touch-mode .tb-item { width: 78px; font-size: 10px; }
body.touch-mode .tb-swatch { width: 52px; height: 52px; }
body.touch-mode .tb-item:active .tb-swatch { transform: scale(0.92); border-color: #fff; }

/* --- less room than a tablet: shrink every control and tuck it further into
       its corner, so nothing lands on top of a panel or another button --- */
@media (max-height: 470px), (max-width: 560px) {
  #stick {
    width: 94px; height: 94px;
    left: calc(10px + env(safe-area-inset-left, 0px));
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
  #stick-knob { width: 40px; height: 40px; }
  #touch-actions {
    right: calc(10px + env(safe-area-inset-right, 0px));
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    gap: 7px;
  }
  #touch-top { bottom: calc(9px + env(safe-area-inset-bottom, 0px)); gap: 7px; }
  .tbtn.tbtn-lg { width: 66px; height: 66px; font-size: 12px; }
  .tbtn.tbtn-sm { width: 38px; height: 38px; font-size: 15px; }
  .tbtn.tbtn-xs { width: 31px; height: 31px; font-size: 13px; }

  body.touch-mode #hud-orders { max-height: calc(100vh - 150px); }
  body.touch-mode #hud-ovens { top: calc(102px + env(safe-area-inset-top, 0px)); width: 146px; }
  body.touch-mode #held { width: 146px; }
  body.touch-mode .top-right { max-width: 158px; }
  body.touch-mode #prompt {
    bottom: calc(112px + env(safe-area-inset-bottom, 0px));
    font-size: 12px; padding: 5px 10px; max-width: 54vw;
  }
  body.touch-mode #lookhint { top: 34%; font-size: 11px; }
  body.touch-mode .cash { font-size: 18px; }
  body.touch-mode .toast { font-size: 12px; padding: 4px 10px; }
}

/* Three panels will not fit side by side across the top of a phone held
   upright, so the ingredient list drops into the left column under the ovens. */
@media (max-width: 460px) {
  body.touch-mode #held {
    left: calc(8px + env(safe-area-inset-left, 0px));
    top: calc(186px + env(safe-area-inset-top, 0px));
    transform: none;
  }
}

/* --- menu screens on small displays --- */
@media (max-width: 680px), (max-height: 560px) {
  .card { padding: 16px 18px; border-radius: 14px; }
  h1 { font-size: 28px; }
  h2 { font-size: 22px; }
  h3 { font-size: 13px; margin: 14px 0 8px; }
  .tagline { font-size: 13px; margin-bottom: 10px; }
  .howto { font-size: 12px; line-height: 1.7; padding: 9px 12px; }
  .flow { font-size: 11px; margin-bottom: 12px; }
  .briefing { font-size: 12.5px; }
  .ledger { font-size: 13px; }
  button.big { padding: 12px 22px; font-size: 15px; }
  .shop { grid-template-columns: 1fr; }
  .fineprint { font-size: 11px; }
}
