/* ============================================================
   Golden Arches — a 1994 ordering experience
   Period UI language: warm reds, marigold, cream, wood trim.
   ============================================================ */
:root {
  --red: #c8102e;
  --red-deep: #9b0c23;
  --gold: #ffc72c;
  --gold-soft: #f5b800;
  --cream: #fff7e6;
  --cream-dim: #f3e6c8;
  --wood: #6b4a2a;
  --ink: #2e1f14;
  --tile: #efe4cf;
  --shadow: 0 10px 30px rgba(46, 20, 8, .45);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: #101018; }
body {
  font-family: "Trebuchet MS", "Verdana", "Helvetica Neue", sans-serif;
  color: var(--ink);
  user-select: none;
  touch-action: none;
}
canvas#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
canvas#scene.dragging { cursor: grabbing; }
.hidden { display: none !important; }

/* ---------- generic panel chrome ---------- */
.panel {
  position: fixed; z-index: 60;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(1060px, 94vw);
  max-height: min(86vh, 92svh);
  display: flex; flex-direction: column;
  background:
    linear-gradient(180deg, rgba(255,255,0,0) 0, rgba(0,0,0,0) 100%),
    repeating-linear-gradient(180deg, var(--cream) 0 26px, var(--cream-dim) 26px 28px);
  border: 3px solid var(--wood);
  border-radius: 10px;
  box-shadow: var(--shadow), inset 0 0 0 4px rgba(255, 199, 44, .25);
  overflow: hidden;
}
.close-x {
  margin-left: auto; align-self: flex-start;
  width: 40px; height: 40px; flex: 0 0 auto;
  font-size: 19px; line-height: 1;
  color: var(--cream); background: var(--red);
  border: 2px solid rgba(0,0,0,.25); border-radius: 8px; cursor: pointer;
}
.close-x:hover { background: var(--red-deep); }

/* ============ HUD ============ */
#hud { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
#hud > * { pointer-events: auto; }
#crosshair {
  position: absolute; left: 50%; top: 50%;
  width: 8px; height: 8px; margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: rgba(255, 247, 230, .85);
  box-shadow: 0 0 4px rgba(0,0,0,.8);
  pointer-events: none;
}
#topbar { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; align-items: center; gap: 8px; }
.hud-btn {
  min-width: 40px; height: 40px;
  padding: 0 10px; font-weight: bold; font-size: 17px;
  color: var(--cream); background: var(--red);
  border: 2px solid rgba(0,0,0,.28); border-radius: 9px;
  box-shadow: 0 3px 0 rgba(0,0,0,.35); cursor: pointer;
}
.hud-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.hud-btn-wide { letter-spacing: .12em; font-family: Georgia, serif; }
#station-caption {
  margin-left: auto;
  padding: 8px 16px;
  max-width: 60vw;
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: clamp(13px, 1.8vw, 17px);
  text-align: right;
  text-shadow: 0 1px 2px rgba(0,0,0,.9), 0 0 14px rgba(0,0,0,.6);
  opacity: 0; transition: opacity .35s ease;
  pointer-events: none;
}
#station-caption.show { opacity: 1; }
#hint {
  position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%);
  padding: 9px 18px;
  color: var(--cream); font-size: 15px; letter-spacing: .04em;
  background: rgba(28, 14, 6, .82);
  border: 1px solid rgba(255,199,44,.45); border-radius: 999px;
  text-shadow: 0 1px 2px #000;
  opacity: 0; transition: opacity .3s ease; white-space: nowrap; pointer-events: none;
}
#hint.show { opacity: 1; }

/* ---------- running ticket ---------- */
#ticket {
  position: absolute; right: 14px; top: 64px; width: 228px;
  background: repeating-linear-gradient(180deg, #fffdf4 0 22px, #f7f1dd 22px 23px);
  border-left: 4px dotted rgba(0,0,0,.22);
  border-radius: 4px 0 0 4px;
  box-shadow: -6px 8px 18px rgba(0,0,0,.5);
  transform-origin: top right;
  transition: transform .25s ease, opacity .25s ease;
  font-family: "Courier New", monospace;
}
#ticket:not(.has-items) footer button, #ticket:not(.has-items) header { opacity: .55; }
#ticket.collapsed { transform: translateX(calc(100% + 20px)); }
#ticket.collapsed #ticketTab { transform: translateX(-38px); }
#ticketTab {
  position: absolute; left: 0; top: 34px;
  width: 26px; height: 56px; transform: translateX(-26px);
  writing-mode: vertical-rl;
  background: var(--red); color: var(--cream);
  border-radius: 6px 0 0 6px; border: none; cursor: pointer;
  font-family: inherit; letter-spacing: .1em; font-weight: bold;
}
#ticketTab:focus-visible { outline: 2px solid var(--gold); }
#ticket header {
  display: flex; justify-content: space-between;
  padding: 7px 10px 5px;
  font-weight: bold; letter-spacing: .08em; font-size: 12.5px;
  border-bottom: 1px dashed rgba(0,0,0,.35);
}
#ticket ul { list-style: none; padding: 6px 10px; max-height: 168px; overflow-y: auto; }
#ticket li { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12.5px; padding: 2px 0; }
#ticket li .qtyx { color: rgba(0,0,0,.55); margin-right: 4px; }
#ticket li .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ticket li.empty { color: rgba(0,0,0,.45); font-style: italic; }
#ticket .rm-line {
  flex: 0 0 auto; width: 17px; height: 17px; line-height: 1;
  font-size: 11px; font-family: inherit;
  color: #fff; background: rgba(155, 12, 35, .78);
  border: none; border-radius: 4px; cursor: pointer; padding: 0;
}
#ticket .rm-line:hover { background: var(--red-deep); }
#ticket footer { border-top: 1px dashed rgba(0,0,0,.35); padding: 6px 10px 10px; }
#ticket footer .row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 1px 0; }
#ticket footer .row.total { font-weight: bold; font-size: 14.5px; border-top: 1px solid rgba(0,0,0,.4); margin-top: 3px; padding-top: 3px; }
#ticket footer em { font-style: normal; opacity: .65; font-size: 11px; }
#btnPay {
  width: 100%; margin-top: 7px; padding: 9px 0;
  font-family: inherit; font-weight: bold; letter-spacing: .06em; font-size: 13.5px;
  color: var(--cream); background: var(--red);
  border: 2px solid rgba(0,0,0,.25); border-radius: 7px; cursor: pointer;
  box-shadow: 0 3px 0 rgba(120, 8, 25, .9);
}
#btnPay:hover { filter: brightness(1.07); }
#btnPay:disabled { opacity: .45; cursor: default; box-shadow: none; }
/* on small screens a dialog covers the ticket; let it step aside (menu footer carries PAY) */
@media (max-width: 900px) {
  body.panel-open #ticket { opacity: 0; pointer-events: none; }
}

/* ---------- minimap ---------- */
#minimap {
  position: absolute; right: 14px; bottom: 18px;
  width: min(300px, 42vw); height: auto; aspect-ratio: 460 / 400;
  background: transparent;
  border-radius: 12px;
  box-shadow: 0 8px 22px rgba(0,0,0,.5);
  transition: opacity .3s ease, transform .3s ease;
}
#minimap.hide-map { opacity: 0; transform: translateY(24px); pointer-events: none; }
#btnMap { position: absolute; right: 14px; bottom: 18px; }
#minimap:not(.hide-map) ~ #btnMap { bottom: auto; top: unset; }
body.map-open #btnMap { position: static; margin-right: 14px; }

/* ============ Menu boards overlay ============ */
#menuHeader {
  background: linear-gradient(180deg, var(--red) 0%, var(--red-deep) 100%);
  color: var(--cream); padding: 14px 18px 0;
  border-bottom: 4px solid var(--gold);
}
.menu-title-row { display: flex; align-items: center; gap: 14px; }
.menu-title-row h2 {
  font-family: Georgia, "Palatino", serif;
  font-size: clamp(19px, 3vw, 27px); letter-spacing: .09em;
  text-transform: uppercase; color: var(--gold);
  text-shadow: 0 2px 0 rgba(80,0,10,.7);
}
.menu-note { font-size: 12px; font-style: italic; opacity: .85; flex: 1; }
#menuTabs { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
#menuTabs button {
  padding: 8px 14px; font-size: 13px; font-weight: bold; letter-spacing: .05em;
  color: var(--cream); background: rgba(0,0,0,.28);
  border: 1px solid rgba(255,255,255,.25); border-bottom: none;
  border-radius: 7px 7px 0 0; cursor: pointer;
}
#menuTabs button[aria-selected="true"] { background: var(--gold); color: var(--ink); }
#menuBody { padding: 16px; overflow-y: auto; flex: 1; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.menu-card {
  --glow: 0;
  position: relative; text-align: left;
  background: linear-gradient(180deg, #ffffff, #fdf3dc);
  border: 2px solid var(--wood); border-radius: 9px;
  padding: 11px 12px 12px; cursor: pointer;
  box-shadow: 0 3px 0 rgba(107,74,42,.5), 0 0 calc(var(--glow) * 22px) rgba(255, 199, 44, calc(var(--glow) * .95));
  transition: box-shadow .15s ease, transform .12s ease;
  font-family: inherit; color: var(--ink); width: 100%;
}
.menu-card:hover, .menu-card:focus-visible { --glow: 1; transform: translateY(-2px); outline: none; }
.menu-card .num {
  position: absolute; top: -9px; left: 10px;
  background: var(--red); color: var(--gold);
  font-family: Georgia, serif; font-weight: bold; font-size: 12px;
  padding: 2px 8px; border-radius: 6px; box-shadow: 0 2px 4px rgba(0,0,0,.35);
}
.menu-card h3 { font-size: 15.5px; line-height: 1.25; }
.menu-card p { font-size: 11.5px; color: #6d5940; margin-top: 3px; min-height: 2.4em; }
.menu-card .price-row { display: flex; align-items: baseline; justify-content: space-between; margin-top: 7px; }
.menu-card .price { font-family: Georgia, serif; font-weight: bold; font-size: 19px; color: var(--red-deep); }
.menu-card .add-tag { font-size: 11px; letter-spacing: .1em; color: #8a6a33; }
/* item detail / customizer */
.item-detail { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.item-detail h3 { font-family: Georgia, serif; font-size: 24px; margin-bottom: 4px; }
.item-detail .desc { color: #6d5940; font-size: 13.5px; margin-bottom: 14px; }
.opt-group { margin-bottom: 16px; }
.opt-group > legend, .opt-group > .opt-label {
  font-weight: bold; font-size: 12.5px; letter-spacing: .1em; color: var(--red-deep);
  text-transform: uppercase; margin-bottom: 7px; display: block;
}
.opt-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.opt-chip {
  padding: 8px 14px; font-size: 13.5px;
  background: #fff; border: 2px solid #caa96b; border-radius: 999px; cursor: pointer;
}
.opt-chip[aria-pressed="true"], .opt-chip.selected {
  background: var(--gold); border-color: var(--wood); font-weight: bold;
  box-shadow: 0 0 0 3px rgba(255,199,44,.35);
}
.detail-side { background: rgba(255,255,255,.75); border: 2px dashed #caa96b; border-radius: 10px; padding: 14px; }
.detail-side .big-price { font-family: Georgia, serif; font-size: 30px; font-weight: bold; color: var(--red-deep); }
.detail-side ul { list-style: none; margin: 10px 0; font-size: 12.5px; color: #6d5940; }
.detail-side li::before { content: "• "; color: var(--red); }
.btn-solid {
  width: 100%; padding: 12px 0; font-family: inherit;
  font-weight: bold; letter-spacing: .07em; font-size: 15px;
  color: var(--cream); background: var(--red);
  border: 2px solid rgba(0,0,0,.25); border-radius: 9px; cursor: pointer;
  box-shadow: 0 4px 0 var(--red-deep);
}
.btn-solid:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--red-deep); }
.btn-back {
  background: none; border: none; color: var(--red-deep);
  font-weight: bold; font-size: 13px; cursor: pointer; padding: 6px 0 10px;
}
#menuFoot {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px; font-size: 12px; font-style: italic; color: #6d5940;
  border-top: 3px solid var(--gold); background: rgba(155,12,35,.08);
}
#menuPayBtn {
  margin-left: auto; font-style: normal; font-weight: bold; letter-spacing: .05em;
  padding: 10px 18px; color: var(--cream); background: var(--red);
  border: 2px solid rgba(0,0,0,.25); border-radius: 8px; cursor: pointer;
}

/* ============ Receipt ============ */
#receiptPanel { width: auto; max-width: 94vw; background: none; border: none; box-shadow: none; overflow: visible; }
#receiptPaperWrap { display: flex; justify-content: center; align-items: center; min-height: 40vh; perspective: 900px; }
#receiptPaper {
  width: 340px; max-width: 88vw; max-height: 68vh; overflow-y: auto;
  background: linear-gradient(90deg, #e8e2d2, #fffef8 6%, #fffef8 94%, #e8e2d2);
  padding: 26px 20px 30px;
  box-shadow: 0 20px 50px rgba(0,0,0,.6);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 6px), 97% 100%, 94% calc(100% - 6px), 91% 100%, 88% calc(100% - 6px), 85% 100%, 82% calc(100% - 6px), 79% 100%, 76% calc(100% - 6px), 73% 100%, 70% calc(100% - 6px), 67% 100%, 64% calc(100% - 6px), 61% 100%, 58% calc(100% - 6px), 55% 100%, 52% calc(100% - 6px), 49% 100%, 46% calc(100% - 6px), 43% 100%, 40% calc(100% - 6px), 37% 100%, 34% calc(100% - 6px), 31% 100%, 28% calc(100% - 6px), 25% 100%, 22% calc(100% - 6px), 19% 100%, 16% calc(100% - 6px), 13% 100%, 10% calc(100% - 6px), 7% 100%, 4% calc(100% - 6px), 0 100%);
}
#receiptText {
  font-family: "Courier New", monospace;
  font-size: 12.5px; line-height: 1.5; color: #222;
  white-space: pre-wrap; word-break: break-word;
}
#receiptActions { display: flex; justify-content: center; margin-top: 18px; }
#receiptDone { padding: 12px 34px; }
.printing #receiptText::after { content: "▌"; animation: blink .5s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ============ Help ============ */
.help-body { padding: 20px 24px 24px; overflow-y: auto; }
.help-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.help-table td { padding: 6px 10px; border-bottom: 1px dashed rgba(107,74,42,.35); }
.help-table td:nth-child(odd) { font-weight: bold; color: var(--red-deep); white-space: nowrap; }
.help-tip { margin-top: 14px; font-size: 13px; font-style: italic; color: #6d5940; }

/* ============ Splash ============ */
#splash {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 50% 22%, rgba(255,199,44,.16), transparent 60%),
    repeating-conic-gradient(from 0deg at 50% -20%, #7c0a1d 0deg 24deg, #9b0c23 24deg 48deg);
}
#splashCard {
  width: min(600px, 92vw); max-height: 92vh; overflow-y: auto;
  text-align: center; color: var(--cream);
  background: linear-gradient(180deg, #ad0f29, #8e0c21);
  border: 4px solid var(--gold); border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0,0,0,.65), inset 0 0 60px rgba(60,0,10,.5);
  padding: 30px 34px 26px;
}
#splashArches { width: clamp(140px, 32vw, 220px); filter: drop-shadow(0 6px 12px rgba(0,0,0,.4)); }
#splashCard h1 {
  font-family: Georgia, "Palatino", serif;
  font-size: clamp(26px, 5.4vw, 40px); letter-spacing: .12em;
  color: var(--gold); text-shadow: 0 3px 0 rgba(60,0,10,.8); margin-top: 2px;
}
.splash-sub {
  font-family: Georgia, serif; font-style: italic;
  color: #ffd977; letter-spacing: .2em; text-transform: lowercase; font-size: clamp(13px, 2.4vw, 16px);
  margin: 4px 0 14px;
}
.splash-copy { font-size: 14px; line-height: 1.65; color: #ffeacc; margin-bottom: 20px; }
#btnStart {
  padding: 15px 36px; font-family: inherit; font-size: clamp(16px, 2.8vw, 19px);
  font-weight: bold; letter-spacing: .1em;
  color: var(--red-deep); background: var(--gold);
  border: 3px solid #fff3cf; border-radius: 999px; cursor: pointer;
  box-shadow: 0 6px 0 #b98700, 0 14px 30px rgba(0,0,0,.5);
}
#btnStart:hover { filter: brightness(1.06); }
#btnStart:active { transform: translateY(3px); box-shadow: 0 3px 0 #b98700; }
.splash-keys { margin-top: 16px; font-size: 12.5px; color: #ffcca6; line-height: 1.8; }
.fineprint { font-size: 10px; color: rgba(255, 220, 170, .6); letter-spacing: .03em; }

/* ============ Touch controls ============ */
#touchUI { position: fixed; inset: 0; z-index: 45; pointer-events: none; display: none; }
body.touch #touchUI { display: block; }
#joyBase {
  position: absolute; left: 22px; bottom: 26px;
  width: 118px; height: 118px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.14) 0 62%, rgba(255,255,255,.09) 63% 100%);
  border: 2px solid rgba(255,247,230,.4); pointer-events: auto;
}
#joyKnob {
  position: absolute; left: 50%; top: 50%;
  width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%;
  background: rgba(255,199,44,.85); box-shadow: 0 4px 12px rgba(0,0,0,.45);
}
@media (hover: hover) and (pointer: fine) { #touchUI { display: none !important; } }

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  #ticket { width: 196px; top: 58px; }
  #ticket ul { max-height: 108px; }
  #minimap { right: 10px; bottom: 150px; }
  #btnMap { right: 10px; bottom: 150px; }
  body.map-open #btnMap { margin-right: 8px; }
  .panel { width: 96vw; max-height: 88svh; }
  .item-detail { grid-template-columns: 1fr; }
  .menu-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  #station-caption { display: none; }
  #hint { font-size: 13px; max-width: 92vw; white-space: normal; text-align: center; }
  .help-table td { padding: 5px 6px; font-size: 12px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  #ticket, #receiptPaper, .menu-card { transition: none; }
}
