/* ── Bean & Brew ─────────────────────────────────────────── */

:root {
  --bg:        #17110d;
  --bg-2:      #1e1610;
  --panel:     #271c15;
  --panel-2:   #33251b;
  --line:      #4a3527;
  --cream:     #f6e8d4;
  --cream-dim: #c3ad94;
  --crema:     #e0a760;
  --crema-2:   #c07d3a;
  --good:      #86d495;
  --bad:       #e8746a;
  --gold:      #f3c85f;
  --radius:    14px;
  --shadow:    0 10px 30px #0008;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 700px at 78% -10%, #3a281c 0%, transparent 62%),
    radial-gradient(900px 600px at 8% 110%, #2a1d14 0%, transparent 60%),
    var(--bg);
  color: var(--cream);
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
h1, h2, h3 { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

/* ── shell ───────────────────────────────────────────────── */

.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: clamp(8px, 1.4vw, 18px);
  gap: clamp(8px, 1.2vw, 16px);
  max-width: 1560px;
  margin: 0 auto;
}

/* ── top bar ─────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px clamp(10px, 1.6vw, 18px);
  background: linear-gradient(180deg, #2e2118, #241a13);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { font-size: 22px; filter: drop-shadow(0 2px 4px #0006); }
.brand-name {
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: clamp(15px, 1.5vw, 20px);
  letter-spacing: .02em;
  white-space: nowrap;
}
.stats { display: flex; align-items: center; gap: clamp(10px, 1.8vw, 26px); margin-left: auto; }
.stat { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.stat .k {
  font-size: 10px; letter-spacing: .13em; text-transform: uppercase;
  color: var(--cream-dim); opacity: .8; white-space: nowrap;
}
.stat .v { font-size: clamp(14px, 1.5vw, 19px); font-variant-numeric: tabular-nums; font-weight: 600; }
.stat-streak .v { color: var(--gold); }
.stat-rep { min-width: 92px; }
.repbar {
  display: block; width: 100%; height: 9px; margin-top: 5px;
  background: #00000055; border-radius: 99px; overflow: hidden;
  box-shadow: inset 0 1px 2px #0009;
}
.repbar i {
  display: block; height: 100%; width: 70%;
  background: linear-gradient(90deg, var(--crema-2), var(--gold));
  border-radius: 99px; transition: width .35s ease, background .35s ease;
}
.repbar.low i { background: linear-gradient(90deg, #8b3a2f, var(--bad)); }
.icon-btn {
  font-size: 17px; line-height: 1; padding: 8px 10px; border-radius: 10px;
  background: #00000033; border: 1px solid var(--line);
}
.icon-btn:hover { background: #00000055; }

/* ── board ───────────────────────────────────────────────── */

.board {
  display: grid;
  grid-template-columns: minmax(190px, 235px) minmax(0, 1fr) minmax(200px, 260px);
  gap: clamp(8px, 1.2vw, 16px);
  min-height: 0;
}
.col { min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.col-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--cream-dim); padding: 0 4px;
}
.col-note { font-size: 10px; letter-spacing: .08em; opacity: .75; }

/* ── queue ───────────────────────────────────────────────── */

.queue { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 0; padding-right: 2px; }
.queue-empty { margin: 6px 4px; color: var(--cream-dim); font-size: 13px; opacity: .7; }

.cust {
  display: grid;
  grid-template-columns: 38px 1fr;
  grid-template-rows: auto auto;
  column-gap: 9px; row-gap: 5px;
  padding: 9px 10px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 12px;
  animation: slidein .3s ease both;
}
.cust.front { border-color: var(--crema); box-shadow: 0 0 0 1px #e0a76044, 0 6px 18px #0006; }
.cust.leaving { animation: leave .35s ease forwards; }
@keyframes slidein { from { opacity: 0; transform: translateX(-14px); } }
@keyframes leave   { to   { opacity: 0; transform: translateX(-22px) scale(.94); } }

.cust-face { grid-row: 1 / span 2; font-size: 25px; text-align: center; line-height: 1.25; }
.cust-name { font-size: 12px; color: var(--cream-dim); letter-spacing: .04em; }
.cust-drink { font-size: 13.5px; font-weight: 600; line-height: 1.25; }
.cust-extras { font-size: 11px; color: var(--crema); }
.cust-pat { grid-column: 1 / -1; height: 6px; background: #0006; border-radius: 99px; overflow: hidden; }
.cust-pat i { display: block; height: 100%; background: var(--good); border-radius: 99px; }
.cust-pat.warn i { background: var(--gold); }
.cust-pat.crit i { background: var(--bad); animation: pulse .5s steps(2) infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* ── the 3D stage ────────────────────────────────────────── */

.col-station { position: relative; }

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #1d1410;
  box-shadow: var(--shadow), inset 0 1px 0 #ffffff0a;
}
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage-fallback {
  position: absolute; inset: 0; margin: 0;
  display: grid; place-items: center; text-align: center;
  padding: 28px; color: var(--cream-dim); font-size: 14px;
}

.stage-ui {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: stretch;
  padding: clamp(9px, 1.3vw, 15px);
  gap: 8px;
  pointer-events: none;
}
.stage-ui::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 90px;
  background: linear-gradient(180deg, #100b07cc, transparent);
  pointer-events: none;
}
.stage-ui > * { position: relative; }

/* step rail */
.steprail { display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.steprail li { display: flex; align-items: center; gap: 7px; opacity: .34; transition: opacity .2s ease; }
.steprail li + li::before {
  content: ""; width: clamp(16px, 3vw, 44px); height: 2px; margin: 0 clamp(6px, 1vw, 12px);
  background: #ffffff33; border-radius: 2px;
}
.steprail .sr-n {
  width: 21px; height: 21px; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid #ffffff44;
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: #00000055;
}
.steprail .sr-t {
  font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase;
  text-shadow: 0 1px 4px #000;
}
.steprail li.done { opacity: .62; }
.steprail li.done .sr-n { background: #ffffff26; }
.steprail li.on { opacity: 1; }
.steprail li.on .sr-n { background: var(--crema); border-color: var(--crema); color: #241a13; box-shadow: 0 0 16px #e0a760aa; }
.steprail li.skip { opacity: .16; }
.steprail li.skip .sr-t { text-decoration: line-through; }

.stage-caption {
  margin: 0; align-self: flex-start;
  font-size: 12px; color: var(--cream-dim);
  text-shadow: 0 1px 6px #000;
  letter-spacing: .03em;
}

/* ── minigame panels, floating over the café ─────────────── */

.station { flex: 0 0 auto; display: flex; }
.station .panel { backdrop-filter: none; -webkit-backdrop-filter: none; background: linear-gradient(180deg, #2b1f17, #211812); border-color: var(--line); }

.panel {
  pointer-events: auto;
  flex: 1 1 auto;
  display: flex; flex-direction: column; gap: 9px;
  padding: 11px clamp(12px, 1.5vw, 18px) 13px;
  background: linear-gradient(180deg, #20170fdd, #140e09f5);
  border: 1px solid #5b4331;
  border-radius: 14px;
  box-shadow: 0 12px 34px #000a, inset 0 1px 0 #ffffff12;
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}
.panel-idle { align-items: center; }
.panel-idle .idle-text { margin: 0; color: var(--cream-dim); font-size: 13.5px; }

.panel-title {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px;
  font-size: clamp(14px, 1.5vw, 17px); font-weight: 600; letter-spacing: .01em;
}
.shot-count { color: var(--crema); font-size: .85em; }
.panel-hint { font-size: 12px; font-weight: 400; color: var(--cream-dim); }

.panel-row { display: flex; align-items: center; gap: clamp(10px, 1.6vw, 18px); }

.track {
  position: relative;
  flex: 1 1 0; min-width: 0;
  height: clamp(28px, 4.4vh, 40px);
  background: linear-gradient(180deg, #120d09, #221811);
  border: 1px solid #00000066;
  border-radius: 99px;
  box-shadow: inset 0 2px 6px #000a;
  overflow: hidden;
}
.track-wrap { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.track-wrap .track { flex: 0 0 auto; }
.band {
  position: absolute; top: 0; bottom: 0;
  background: linear-gradient(180deg, #86d49533, #86d49566);
  border-left: 2px solid var(--good); border-right: 2px solid var(--good);
}
.band-steam { background: linear-gradient(180deg, #e0a76033, #e0a76066); border-color: var(--crema); }
.fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: linear-gradient(90deg, #6b4326, var(--crema-2));
}
.needle, .marker {
  position: absolute; top: -4px; bottom: -4px; width: 4px;
  transform: translateX(-50%);
  background: #fff8ee; box-shadow: 0 0 10px #fff8ee99; border-radius: 2px;
}
.marker { background: var(--gold); box-shadow: 0 0 12px #f3c85fcc; }
.wand {
  position: absolute; top: 0; bottom: 0; width: 32px;
  transform: translateX(-50%);
  display: grid; place-items: center;
  background: #ffffff14; border-radius: 10px; border: 1px solid #ffffff33;
}
.wand-tip { font-size: 17px; line-height: 1; }
.track-steam { cursor: ew-resize; touch-action: none; }

.readout { display: flex; align-items: baseline; gap: 4px; font-variant-numeric: tabular-nums; }
.readout-v { font-size: clamp(19px, 2.4vw, 27px); font-weight: 700; color: var(--crema); }
.readout-u { font-size: 13px; color: var(--cream-dim); }

.timerbar { height: 5px; background: #0007; border-radius: 99px; overflow: hidden; }
.timerbar i { display: block; height: 100%; width: 100%; background: var(--crema); }

.shot-dots { display: flex; gap: 7px; flex: 0 0 auto; }
.shot-dots span { width: 10px; height: 10px; border-radius: 50%; background: #00000055; border: 1px solid var(--line); }
.shot-dots span.done { background: var(--crema); border-color: var(--crema); }

.big-btn {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 150px; padding: 9px 22px;
  background: linear-gradient(180deg, #6d452a, #4e2f1c);
  border: 1px solid #8a5a35; border-radius: 12px;
  box-shadow: 0 4px 0 #2c1a10, 0 9px 20px #0007;
  transition: transform .06s ease, box-shadow .06s ease;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.big-btn:active, .big-btn.held { transform: translateY(3px); box-shadow: 0 1px 0 #2c1a10, 0 4px 12px #0007; }
.big-btn-k { font-size: 10px; letter-spacing: .18em; color: #f0d3ae; }
.big-btn-l { font-size: 16px; font-weight: 600; }
.big-btn-go { background: linear-gradient(180deg, #3f7a4b, #2c5936); border-color: #57a066; box-shadow: 0 4px 0 #1b3a22, 0 9px 20px #0007; }
.big-btn-go:active { box-shadow: 0 1px 0 #1b3a22, 0 4px 12px #0007; }

/* ── extras ──────────────────────────────────────────────── */

.extras {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
  gap: 5px; flex: 1 1 0; min-width: 0;
}
.extra {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 9px; border-radius: 8px;
  background: #00000055; border: 1px solid var(--line);
  font-size: 12px; white-space: nowrap; transition: all .12s ease;
}
.extra:hover { border-color: var(--crema-2); }
.extra.on { background: linear-gradient(180deg, #7a5330, #5a3c22); border-color: var(--crema); color: #fff3e0; }
.extra-ic { font-size: 13px; }

/* ── toasts ──────────────────────────────────────────────── */

.toasts {
  position: absolute; left: 0; right: 0; bottom: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none;
}
.toast {
  padding: 7px 15px; border-radius: 99px;
  background: #120c08ee; border: 1px solid var(--line);
  font-size: 13.5px; font-weight: 600;
  animation: toast 2.1s ease forwards;
  box-shadow: var(--shadow);
}
.toast.good { border-color: #3f7a4b; color: var(--good); }
.toast.bad  { border-color: #8b3a2f; color: var(--bad); }
.toast.gold { border-color: var(--crema-2); color: var(--gold); }
@keyframes toast {
  0%   { opacity: 0; transform: translateY(14px) scale(.94); }
  12%  { opacity: 1; transform: none; }
  78%  { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-16px); }
}

/* ── ticket ──────────────────────────────────────────────── */

.ticket {
  background: linear-gradient(180deg, #f6e8d4, #e6d3ba);
  color: #2a1c12;
  border-radius: 10px;
  padding: 12px 14px 10px;
  box-shadow: var(--shadow);
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  position: relative;
}
.ticket::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -6px; height: 7px;
  background: radial-gradient(circle at 50% 0, transparent 0 5.5px, #e6d3ba 6px) repeat-x;
  background-size: 13px 13px;
}
.ticket-head { display: flex; justify-content: space-between; font-size: 11px; opacity: .7; letter-spacing: .04em; }
.ticket-drink { font-size: 16px; margin: 3px 0 8px; font-weight: 700; letter-spacing: -.01em; }
.ticket-steps { display: flex; flex-direction: column; gap: 3px; font-size: 12px; border-top: 1px dashed #2a1c1244; padding-top: 7px; }
.ticket-steps li { display: flex; gap: 7px; align-items: baseline; }
.ticket-steps li.done { opacity: .45; text-decoration: line-through; }
.ticket-steps li.now { font-weight: 700; }
.ticket-steps .tick { width: 12px; display: inline-block; }
.bin-btn {
  margin-top: 9px; width: 100%; padding: 6px; border-radius: 7px;
  background: #2a1c1214; border: 1px solid #2a1c1233;
  font-size: 11.5px; color: #2a1c12; letter-spacing: .03em;
}
.bin-btn:hover { background: #2a1c1226; }
.ticket-idle { margin: 4px; font-size: 13px; color: var(--cream-dim); opacity: .7; }

/* ── overlay ─────────────────────────────────────────────── */

.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  padding: 18px;
  background: #0d0906a0;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  overflow-y: auto;
}
.sheet {
  width: min(560px, 100%);
  background: linear-gradient(180deg, #2e2219f2, #1f1610fa);
  border: 1px solid #6b5030;
  border-radius: 20px;
  padding: clamp(20px, 3.4vw, 34px);
  box-shadow: 0 26px 70px #000b;
  text-align: center;
  animation: rise .3s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
.sheet-kicker { margin: 0; font-size: 11px; letter-spacing: .3em; text-transform: uppercase; color: var(--crema); }
.sheet-title {
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: clamp(34px, 6.5vw, 54px); font-weight: 400; line-height: 1.05;
  margin: 6px 0 10px; letter-spacing: -.015em;
}
.sheet-title span { color: var(--crema); font-style: italic; }
.sheet-title-sm { font-size: clamp(26px, 4.4vw, 38px); }
.sheet-lede { margin: 0 auto 18px; max-width: 40ch; color: var(--cream-dim); }
.rules { text-align: left; max-width: 42ch; margin: 0 auto 20px; display: flex; flex-direction: column; gap: 7px; font-size: 13.5px; color: var(--cream-dim); }
.rules li { padding-left: 20px; position: relative; }
.rules li::before { content: "•"; position: absolute; left: 6px; color: var(--crema); }
.rules b { color: var(--cream); }
.best { margin: 0 0 16px; font-size: 13px; color: var(--gold); }
.cta {
  width: 100%; padding: 14px; margin-top: 6px;
  background: linear-gradient(180deg, #7a5330, #5a3c22);
  border: 1px solid var(--crema-2); border-radius: 12px;
  font-size: 16px; font-weight: 600; letter-spacing: .02em;
  box-shadow: 0 5px 0 #33210f, 0 12px 26px #0008;
  transition: transform .06s ease, box-shadow .06s ease;
}
.cta:active { transform: translateY(4px); box-shadow: 0 1px 0 #33210f; }
.cta:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.books { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; text-align: left; font-size: 14px; margin: 4px 0 20px; padding: 14px 16px; background: #00000038; border-radius: 12px; border: 1px solid #ffffff0f; }
.books .lbl { color: var(--cream-dim); }
.books .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.books .num.pos { color: var(--good); }
.books .num.neg { color: var(--bad); }
.books .sep { grid-column: 1 / -1; height: 1px; background: #ffffff14; margin: 3px 0; }

.shop-title { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--cream-dim); text-align: left; margin-bottom: 8px; }
.shop { display: flex; flex-direction: column; gap: 7px; margin-bottom: 18px; }
.upg {
  display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 11px;
  padding: 9px 12px; text-align: left;
  background: #00000030; border: 1px solid var(--line); border-radius: 11px;
  transition: all .12s ease;
}
.upg:not(:disabled):hover { border-color: var(--crema); background: #00000055; }
.upg:disabled { opacity: .42; cursor: not-allowed; }
.upg-ic { font-size: 20px; }
.upg-name { font-size: 14px; font-weight: 600; }
.upg-desc { font-size: 11.5px; color: var(--cream-dim); }
.upg-lv { display: flex; gap: 3px; margin-top: 3px; }
.upg-lv i { width: 14px; height: 4px; border-radius: 2px; background: #ffffff1f; }
.upg-lv i.on { background: var(--crema); }
.upg-cost { font-size: 14px; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.upg-cost.max { color: var(--cream-dim); font-size: 12px; font-weight: 500; }

/* ── responsive ──────────────────────────────────────────── */

@media (max-width: 980px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100dvh; }
  .board { grid-template-columns: 1fr 1fr; }
  .col-station { grid-column: 1 / -1; order: -1; }
  .stage { min-height: 52vh; }
  .queue { max-height: 42vh; }
}
@media (max-width: 660px) {
  .board { grid-template-columns: 1fr; }
  .stats { gap: 12px; }
  .stat-rep { display: none; }
  .brand-name { display: none; }
  .stage { min-height: 46vh; }
  .col-queue { order: 2; }
  .panel-row { flex-wrap: wrap; }
  .big-btn { min-width: 130px; flex: 1 1 auto; }
  .readout { order: -1; }
  .steprail .sr-t { display: none; }
  .steprail li + li::before { width: 22px; }
  .stage-caption { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
