:root {
  --ink: #26222a;
  --panel: #fbf8f1;
  --accent: #458ead;
  --accent-ink: #ffffff;
  --muted: #7a7480;
  --pill: rgba(38, 36, 44, 0.92);
  --blue: #3d80f5;
  --red: #f25c57;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8cc7eb; color: var(--ink);
  font: 16px/1.4 "Trebuchet MS", "Segoe UI", system-ui, sans-serif; }
#view { position: fixed; inset: 0; }
#view canvas { display: block; width: 100%; height: 100%; filter: saturate(1.15); }
#vignette { position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(20, 16, 30, 0.28) 100%); }

/* ---------------- HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#orders { position: absolute; top: 16px; left: 16px; display: flex; gap: 12px; }
.ticket { background: var(--panel); border-radius: 12px; overflow: hidden; min-width: 84px;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.85); }
.ticket .head { background: var(--accent); height: 30px; display: flex; align-items: center; justify-content: center; }
.ticket .head i { width: 20px; height: 20px; border-radius: 50%; display: block; }
.ticket .ings { display: flex; gap: 6px; padding: 10px 12px; justify-content: center; }
.ticket .ings i { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--ink); display: block; }
.pill { position: absolute; background: var(--pill); color: #fff; border-radius: 16px; padding: 8px 18px;
  font-size: 28px; font-weight: bold; }
#timer { top: 16px; right: 16px; min-width: 120px; text-align: center; }
#timer.low { color: #ffb347; }
#score { bottom: 16px; left: 16px; display: flex; align-items: center; gap: 12px; min-width: 140px; }
#help { position: absolute; bottom: 20px; right: 16px; color: #fff; font-size: 13px;
  background: rgba(38, 36, 44, 0.6); padding: 6px 10px; border-radius: 8px; }
.coin { width: 34px; height: 34px; border-radius: 50%; display: inline-block;
  background: radial-gradient(circle, #ffe16e 0 45%, #fac428 47%); }

/* ---------------- panels */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; gap: 20px;
  flex-wrap: wrap; padding: 16px; overflow-y: auto; }
.panel { width: min(420px, 100%); background: var(--panel); border-radius: 18px; padding: 24px;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.85); }
#board { width: min(460px, 100%); }

/* ---------------- leaderboard tables */
table { width: 100%; border-collapse: collapse; font-size: 15px; margin: 8px 0 4px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
  padding: 4px 6px; border-bottom: 2px solid var(--ink); }
td { padding: 7px 6px; border-bottom: 1px solid #e6e0d6; vertical-align: middle; }
td:first-child { font-weight: bold; width: 2em; }
.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: bold; }
.date { color: var(--muted); font-size: 12px; white-space: nowrap; text-align: right; }
th.date { text-align: right; }
.chefs { display: flex; flex-direction: column; gap: 2px; }
.chef { display: flex; align-items: center; gap: 6px; }
.chef .dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); flex: none; }
.chef .ai { font-size: 11px; background: #e6e0d6; border-radius: 6px; padding: 0 5px; color: var(--muted); }
tr.mine td { background: #fff3c4; }
tr.empty td { color: var(--muted); text-align: center; font-style: italic; }
#end-rank { font-weight: bold; margin-bottom: 6px; min-height: 1.4em; }
#end-rank.top { color: #c47f00; }
#end table { margin-bottom: 16px; }
h1 { margin: 0 0 16px; font-size: 30px; text-align: center; }
h2 { margin: 0 0 8px; text-align: center; }
label { display: block; margin: 8px 0; font-weight: bold; font-size: 14px; }
label.check { font-weight: normal; display: flex; gap: 8px; align-items: center; }
label.check input { width: auto; margin: 0; flex: none; }
input, select, button { font: inherit; border-radius: 10px; border: 2px solid var(--ink); padding: 8px 12px; background: #fff; color: var(--ink); }
label input { width: 100%; margin-top: 4px; }
button { background: var(--accent); color: var(--accent-ink); font-weight: bold; cursor: pointer; }
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.5; cursor: default; }
.row { display: flex; gap: 8px; align-items: end; margin: 8px 0; flex-wrap: wrap; }
.row > select, .row > input { flex: 1; min-width: 0; }
.row label { flex: 1; margin: 0; }
.row label select { width: 100%; margin-top: 4px; }
#code { text-transform: uppercase; letter-spacing: 4px; }
.or { text-align: center; color: var(--muted); margin: 14px 0 4px; font-size: 14px; }
.code-line { font-size: 18px; text-align: center; margin-bottom: 8px; }
#room-code { font-size: 30px; letter-spacing: 6px; }
.muted { color: var(--muted); font-size: 14px; }
#slots { list-style: none; padding: 0; margin: 8px 0; }
#slots li { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-weight: bold; }
#slots li .dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--ink); }
#slots li.you::after { content: "(you)"; color: var(--muted); font-weight: normal; }
#start { width: 100%; margin-top: 8px; font-size: 18px; }
#error { color: #c0392b; text-align: center; margin-top: 8px; min-height: 1em; }
#end { text-align: center; }
#end td, #end th { text-align: left; }
#end .num, #end .date { text-align: right; }
#end .big { font-size: 48px; font-weight: bold; display: flex; gap: 14px; align-items: center; justify-content: center; margin: 12px 0 18px; }
#end .big .coin { width: 48px; height: 48px; }
[hidden] { display: none !important; }

/* ---------------- Let Him Cook additions */
#view { z-index: 0; }
#floaters { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
#menu { z-index: 2; }
#hud { z-index: 3; }
#end-wrap { z-index: 4; }
.overlay.top { z-index: 6; background: rgba(30, 26, 36, 0.35); }

.logo { font-size: 40px; letter-spacing: 0.01em; margin-bottom: 18px; color: var(--ink);
  text-shadow: 3px 3px 0 #ffcf4a; transform: rotate(-2deg); }
.center { text-align: center; }
.row.two > * { flex: 1; }
button.link { background: none; color: var(--accent); border: none; padding: 6px; text-decoration: underline;
  font-weight: bold; width: 100%; }
#home > button.link { margin-top: 10px; }
.mode-line { text-align: center; font-weight: bold; font-size: 18px; margin-bottom: 6px; }
.mode-line .tag { display: inline-block; background: var(--accent); color: #fff; border-radius: 8px; padding: 2px 10px; }
#room label { margin-top: 10px; }
#room > .muted.center { margin: 8px 0 0; }

/* tutorial */
.panel.wide { width: min(820px, 100%); }
#tutorial h2 { font-size: 28px; }
.steps { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr)); counter-reset: step; }
.steps li { background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 10px 10px 12px;
  display: flex; flex-direction: column; gap: 4px; position: relative; counter-increment: step; }
.steps li::before { content: counter(step); position: absolute; top: -10px; left: -10px; width: 26px; height: 26px;
  border-radius: 50%; background: #ffcf4a; border: 2px solid var(--ink); font-weight: bold; display: flex;
  align-items: center; justify-content: center; font-size: 14px; }
.steps b { font-size: 15px; }
.steps span { font-size: 13px; color: var(--muted); }
.art { height: 64px; display: flex; align-items: center; justify-content: center; gap: 6px; }
kbd { display: inline-block; min-width: 1.6em; padding: 1px 6px; border: 2px solid var(--ink); border-bottom-width: 4px;
  border-radius: 6px; background: #fff; font: bold 12px/1.4 inherit; text-align: center; color: var(--ink); }
.controls { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: center; margin: 4px 0 8px; font-size: 14px; }
.controls kbd { margin-right: 2px; }
.tip { font-size: 13px; }
#tutorial-ok { display: block; margin: 8px auto 0; font-size: 18px; padding: 10px 36px; }

.ic { display: inline-flex; align-items: center; justify-content: center; position: relative; flex: none; }
.ic.onion { width: 22px; height: 20px; border-radius: 50% 50% 46% 46%; background: #f0b857; border: 2px solid var(--ink); }
.ic.onion.sm { width: 13px; height: 12px; border-width: 1.5px; margin: 0 1px; }
.ic.crate { width: 58px; height: 40px; border-radius: 6px; background: #c78c4d; border: 2px solid var(--ink);
  box-shadow: inset 0 -8px 0 #9a6635; }
.ic.pot { width: 54px; height: 38px; border-radius: 6px 6px 18px 18px; background: #b3bac7; border: 2px solid var(--ink);
  align-items: flex-start; padding-top: 3px; }
.ic.soup { width: 38px; height: 10px; border-radius: 50%; background: #f8b23d; border: 1.5px solid var(--ink); }
.ic.bar { width: 18px; height: 40px; border-radius: 5px; background: #33333d; border: 2px solid #fff; outline: 2px solid var(--ink);
  overflow: hidden; align-items: flex-end; }
.ic.bar::after { content: ""; width: 100%; height: 60%; background: #fcbf38; }
.ic.plates { width: 46px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid #9ec7f0;
  box-shadow: 0 -6px 0 -1px #fff, 0 -6px 0 1px #9ec7f0, 0 -12px 0 -1px #fff, 0 -12px 0 1px #9ec7f0; margin-top: 14px; }
.ic.arrow-r { width: 0; height: 0; border-top: 8px solid transparent; border-bottom: 8px solid transparent;
  border-left: 12px solid var(--ink); }
.ic.hatch { width: 54px; height: 48px; border-radius: 6px; background: #33363d; border: 2px solid var(--ink);
  box-shadow: inset 0 0 0 4px #6b6f78; }
.ic.hatch::before { content: ""; position: absolute; top: 8px; border-left: 12px solid transparent; border-right: 12px solid transparent;
  border-bottom: 14px solid #52e673; }
.ic.hatch::after { content: ""; position: absolute; top: 21px; width: 8px; height: 16px; background: #52e673; }

/* floating leaderboards (home screen) */
.float-card { position: absolute; top: 0; left: 0; width: 280px; background: rgba(251, 248, 241, 0.94);
  border-radius: 14px; padding: 10px 14px 12px; box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.8); will-change: transform; }
.float-card h3 { margin: 0 0 6px; font-size: 16px; text-align: center; }
.float-card .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.float-card h4 { margin: 0 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
  border-bottom: 2px solid var(--ink); padding-bottom: 2px; }
.float-card ol { margin: 0; padding: 0; list-style: none; font-size: 12px; }
.float-card li { display: flex; justify-content: space-between; gap: 6px; padding: 2px 0; }
.float-card li .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.float-card li .pts { font-weight: bold; font-variant-numeric: tabular-nums; }
.float-card li.none { color: var(--muted); font-style: italic; }
label select { display: block; width: 100%; margin-top: 4px; }

/* ---------------- v3: home layout, custom dropdowns, solo styles */
body.at-home #menu { justify-content: flex-end; padding-right: max(5vw, 24px); }
@media (max-width: 900px) { body.at-home #menu { justify-content: center; padding-right: 16px; } }
.field-label { font-weight: bold; font-size: 14px; margin: 10px 0 4px; }
button.alt { background: #e98b2a; }


/* custom dropdown (replaces the native popup, which cannot be styled) */
select.dd-native { display: none !important; }
.dd { position: relative; margin-top: 4px; font-weight: normal; }
.row .dd { flex: 1; margin-top: 0; min-width: 0; }
.dd-btn { width: 100%; display: flex; align-items: center; gap: 10px; background: #fff; color: var(--ink);
  text-align: left; font-weight: bold; padding: 7px 12px; }
.dd-btn .dd-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-btn::after { content: ""; border: 6px solid transparent; border-top: 7px solid var(--ink); margin-top: 6px; flex: none; }
.dd.open .dd-btn::after { border-top-color: transparent; border-bottom: 7px solid var(--ink); margin: -6px 0 0; }
.dd-btn:disabled { background: #f1ede6; }
.dd-list { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20; background: var(--panel);
  border: 2px solid var(--ink); border-radius: 12px; padding: 6px; box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.85);
  max-height: 320px; overflow-y: auto; display: none; }
.dd.open .dd-list { display: block; }
.dd-opt { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-weight: bold; }
.dd-opt:hover, .dd-opt.kb { background: #fff3c4; }
.dd-opt.sel { background: var(--accent); color: #fff; }
.dd-opt.dis { opacity: 0.4; cursor: default; background: none; }
.dd-opt small { display: block; font-weight: normal; font-size: 11px; opacity: 0.75; }
canvas.minimap { flex: none; border-radius: 4px; border: 1.5px solid var(--ink); image-rendering: pixelated; background: #8cc76a; }

/* replay label (home screen) */
#replay-tag { position: fixed; top: 16px; left: 16px; z-index: 2; background: var(--pill); color: #fff; border-radius: 12px;
  padding: 6px 12px; font-size: 13px; display: flex; align-items: center; gap: 8px; }
#replay-tag .rec { width: 10px; height: 10px; border-radius: 50%; background: #ff5a4f; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

/* floating cards: 2x2 grid of modes */
.float-card { width: 300px; }
.float-card .cols { grid-template-columns: 1fr 1fr; row-gap: 8px; }

/* toast */
#toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 10; background: var(--pill); color: #fff;
  padding: 10px 18px; border-radius: 14px; font-weight: bold; box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.6); }
.dd-ico { display: flex; }
.dd-ico:empty { display: none; }

/* ---------------- v4: tabs, solo choices, easter eggs */
.tabs { display: grid; grid-template-columns: 1fr 1fr; margin: 16px 0 0; border-bottom: 2px solid var(--ink); }
.tab { background: none; color: var(--muted); border: 2px solid transparent; border-bottom: none; border-radius: 12px 12px 0 0;
  padding: 8px 4px; margin-bottom: -2px; font-size: 16px; }
.tab.on { background: #fff; color: var(--ink); border-color: var(--ink); }
.tab-pane { background: #fff; border: 2px solid var(--ink); border-top: none; border-radius: 0 0 14px 14px; padding: 12px; }
.pane-intro { margin: 0 0 10px; }
.choice { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.choice button { background: #fff; color: var(--ink); text-align: left; display: grid; grid-template-columns: 22px 1fr;
  column-gap: 10px; align-items: center; padding: 8px 12px; font-weight: normal; }
.choice button::before { content: ""; grid-row: span 2; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--ink); background: #fff; box-shadow: inset 0 0 0 3px #fff; }
.choice button b { font-size: 15px; }
.choice button span { font-size: 12px; color: var(--muted); }
.choice button.on { background: #eaf4f8; border-color: var(--accent); }
.choice button.on::before { background: var(--accent); }
.choice button:disabled { opacity: 0.45; }
button.big { width: 100%; font-size: 18px; padding: 10px; }
#timer.flash { animation: flash 0.25s 6 alternate; }
@keyframes flash { to { background: #ffcf4a; color: var(--ink); } }
#toast.pop { animation: pop 0.35s ease-out; }
@keyframes pop { from { transform: translateX(-50%) scale(0.6); } to { transform: translateX(-50%) scale(1); } }
#toast.big { font-size: 36px; padding: 14px 30px; bottom: 45%; background: #ff5a4f; }
.logo .him { color: #c47f00; }

/* ---------------- touch controls (phones / tablets) */
#touch { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
#stick-zone { position: absolute; left: 0; bottom: 0; width: 50%; height: 70%;
  pointer-events: auto; touch-action: none; }
#stick { position: absolute; left: calc(28px + env(safe-area-inset-left)); bottom: calc(28px + env(safe-area-inset-bottom));
  width: 140px; height: 140px; border-radius: 50%;
  background: rgba(38, 36, 44, 0.35); border: 3px solid rgba(255, 255, 255, 0.55); }
#stick.active { background: rgba(38, 36, 44, 0.5); }
#knob { position: absolute; left: 50%; top: 50%; width: 62px; height: 62px; margin: -31px 0 0 -31px;
  border-radius: 50%; background: rgba(255, 255, 255, 0.9); box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.6); }
#touch-btns { position: absolute; right: calc(28px + env(safe-area-inset-right)); bottom: calc(36px + env(safe-area-inset-bottom));
  display: flex; align-items: flex-end; gap: 18px; pointer-events: auto; touch-action: none; }
#touch-btns button { border-radius: 50%; border: 3px solid var(--ink, #26242c); color: var(--ink, #26242c);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.85); padding: 0; -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent; }
#t-act { width: 96px; height: 96px; font-size: 40px; background: var(--accent, #f5b83d); }
#t-swap { width: 64px; height: 64px; font-size: 28px; background: #fff; margin-bottom: 70px; }
#touch-btns button.on { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.85); filter: brightness(0.9); }
body.touch #help { display: none; }
body.touch #score { bottom: auto; top: 76px; right: 16px; left: auto; }
body.touch, body.touch #view { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
@media (max-width: 600px) {
  #stick { width: 120px; height: 120px; }
  #t-act { width: 84px; height: 84px; }
  .ticket { min-width: 64px; }
}
/* small / short screens: let the menu scroll from the top instead of clipping it, keep the replay tag clear */
@media (max-width: 900px), (max-height: 600px) {
  .overlay { align-items: flex-start; align-content: flex-start; }
  #replay-tag { display: none; }
}
@media (max-height: 600px) {
  .panel { padding: 16px 20px; }
  .logo { font-size: 30px; margin-bottom: 10px; }
}

/* ---------------- Soup Rush order queue */
.ticket.timed { transition: transform 0.35s cubic-bezier(.2,1.6,.4,1), opacity 0.35s; }
.ticket.timed.enter { transform: translateY(-90px); opacity: 0; }
.ticket.timed.served { transform: translateY(-40px) scale(1.1); opacity: 0; background: #d9f7df; }
.ticket.timed.expired { transform: translateY(40px) rotate(-8deg); opacity: 0; background: #ffd9d6; }
.ticket.hurry { animation: shake 0.5s infinite; }
@keyframes shake { 0%, 100% { translate: 0 0; } 25% { translate: -2px 0; } 75% { translate: 2px 0; } }
.tbar { height: 8px; background: #e4ddd0; }
.tbar i { display: block; height: 100%; width: 100%; transition-property: width, background; transition-timing-function: linear; }
.score-pop { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); font-size: 30px; font-weight: bold;
  color: #fff; padding: 6px 18px; border-radius: 14px; white-space: nowrap; animation: rise 1.5s ease-out forwards;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.85); }
.score-pop.ok { background: #3e9b55; }
.score-pop.tip { background: #e09a1c; }
.score-pop.bad { background: #d8463c; }
@keyframes rise { 0% { opacity: 0; transform: translate(-50%, 20px) scale(0.7); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.05); }
  75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -40px); } }

/* lobby: live games to watch */
#live { margin-bottom: 14px; }
#live .or { margin-top: 0; }
#live-rows { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 6px; }
#live-rows li { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border: 2px solid var(--ink);
  border-radius: 10px; }
#live-rows li > span { flex: 1; min-width: 0; }
#live-rows li b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#live-rows small { color: var(--muted); }
#live-rows button { padding: 6px 12px; }
.on-air { color: #c0392b; font-style: normal; font-weight: bold; }
.on-air::before { content: "\25CF "; animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.2; } }
