/* Mind Games. A late-night dumpling counter: dark jade lacquer, rice-paper
   cards, bamboo steamer lids, one chili red for danger. */

:root {
  --night: #13201e;
  --night-2: #1a2c29;
  --jade: #1f5c50;
  --jade-2: #2b7a68;
  --rice: #fbf3e2;
  --rice-2: #f1e4c8;
  --ink: #1b1613;
  --mute: #6b5f52;
  --bamboo: #d8a95b;
  --bamboo-2: #b9873d;
  --bamboo-dark: #8a5d22;
  --chili: #e8412c;
  --chili-deep: #9e1d10;
  --gold: #ffc94a;
  --mint: #6fd8a6;
  --line: 2px solid var(--ink);
  --radius: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Avenir Next Condensed", "Arial Narrow", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--night);
  background-image:
    radial-gradient(circle at 20% -10%, rgba(43, 122, 104, 0.45), transparent 55%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.018) 0 2px, transparent 2px 22px);
  color: var(--rice);
  font: 500 16px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
code { font: 600 0.9em ui-monospace, "SF Mono", Menlo, Consolas, monospace; overflow-wrap: anywhere; }

.wrap {
  max-width: 520px;
  margin: 0 auto;
  padding: 8px 16px 40px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.plain { padding: 40px 0; font-weight: 700; }

/* ---------- top row ---------- */

.top { display: flex; align-items: center; gap: 10px; min-height: 48px; }
.mark {
  font: 800 19px/1 var(--display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bamboo);
  text-decoration: none;
  white-space: nowrap;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.spacer { flex: 1; }
.codechip {
  font: 800 15px/1 ui-monospace, Menlo, monospace;
  letter-spacing: 0.18em;
  background: var(--night-2);
  border: 1px solid rgba(251, 243, 226, 0.25);
  border-radius: 8px;
  padding: 7px 6px 7px 9px;
}
.chips {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 900 20px/1 var(--font);
  color: var(--ink);
  background: var(--gold);
  border-radius: 999px;
  padding: 6px 12px 6px 7px;
}
.chips i { width: 18px; height: 18px; border-radius: 50%; background: var(--chili); box-shadow: inset 0 0 0 3px var(--gold), inset 0 0 0 5px var(--chili); }

/* ---------- cards and text ---------- */

.card {
  background: var(--rice);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25), 0 10px 30px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.card h2 { font: 800 19px/1.2 var(--font); }
.card .h3 { font-size: 16px; color: var(--mute); }
.h1 { font: 900 26px/1.1 var(--font); }
.sub { color: var(--mute); font-size: 14px; }
.fine { color: rgba(251, 243, 226, 0.75); font-size: 14px; }
.note { background: var(--night-2); border-radius: 12px; padding: 12px 14px; font-weight: 600; }
.note.ok { background: rgba(111, 216, 166, 0.16); color: var(--mint); }
.note.warn { background: rgba(232, 65, 44, 0.2); color: #ffd1c9; }
.card .note { background: var(--rice-2); color: var(--ink); }

.hero { padding: 10px 2px 4px; display: flex; flex-direction: column; gap: 8px; }
.hero h1 { font: 900 34px/1.05 var(--font); letter-spacing: -0.01em; }
.hero p { color: rgba(251, 243, 226, 0.85); }
.gamehead { display: flex; gap: 12px; align-items: center; }
.gamehead .icon { width: 56px; height: 56px; flex: none; }
.gamehead h2 { font-size: 24px; }

/* ---------- controls ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 0;
  background: var(--chili);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  text-align: center;
  box-shadow: 0 3px 0 var(--chili-deep);
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--chili-deep); }
.btn[disabled] { opacity: 0.45; cursor: default; transform: none; }
.btn.alt { background: var(--jade); box-shadow: 0 3px 0 #123a32; }
.btn.ghost { background: transparent; color: inherit; border: 2px solid currentColor; box-shadow: none; }
.btn.big { min-height: 56px; font-size: 18px; width: 100%; }
.btn.small { min-height: 44px; padding: 6px 14px; }
.wrap > .btn.ghost { color: var(--rice); }
.row { display: flex; gap: 8px; }
.row > input { flex: 1; min-width: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
input[type='text'] {
  min-height: 48px;
  border-radius: 12px;
  border: 2px solid #cdbf9f;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  font-size: 18px;
}
.codein { text-transform: uppercase; letter-spacing: 0.3em; font-weight: 800; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.segb {
  min-height: 44px;
  border-radius: 10px;
  border: 2px solid #cdbf9f;
  background: #fff;
  font-weight: 800;
}
.segb.on { background: var(--ink); color: var(--rice); border-color: var(--ink); }
.segb[disabled] { opacity: 0.35; }

/* ---------- lobby ---------- */

.lobbyhead { text-align: center; align-items: center; }
.bigcode { font: 900 64px/1 ui-monospace, Menlo, monospace; letter-spacing: 0.16em; margin-right: -0.16em; color: var(--ink); }
.lobbyhead .row2 { width: 100%; }
.people { display: flex; flex-direction: column; gap: 4px; }
.who { display: flex; align-items: center; gap: 8px; min-height: 44px; border-bottom: 1px solid #eadcbc; flex-wrap: wrap; }
.who .nm { font-weight: 800; overflow-wrap: anywhere; }
.who.gone .nm { text-decoration: line-through; color: var(--mute); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #c6b99c; flex: none; }
.here .dot { background: #2fae6f; box-shadow: 0 0 0 3px rgba(47, 174, 111, 0.2); }
.tag { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; background: var(--rice-2); border-radius: 6px; padding: 2px 6px; color: var(--mute); }
.tag.host { background: var(--gold); color: var(--ink); }
.tag.you { background: var(--jade); color: #fff; }
.tally { margin-left: auto; font-weight: 800; color: var(--mute); }
.x { margin-left: auto; min-width: 44px; min-height: 44px; border: 0; background: transparent; font-size: 26px; color: var(--chili); }
.tally + .x { margin-left: 0; }
.claims { display: flex; flex-direction: column; gap: 8px; }
.claims .btn { justify-content: flex-start; }

details.card > summary { font-weight: 800; min-height: 44px; display: flex; align-items: center; cursor: pointer; }
.how p { font-size: 15px; }
.acts { display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
.acts b { margin-right: 6px; }
.cost { display: inline-block; font-size: 12px; font-weight: 900; background: var(--gold); color: var(--ink); border-radius: 6px; padding: 1px 6px; }

/* ---------- play ---------- */

.turnbar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--night-2);
  border-radius: 14px;
  padding: 10px 14px;
  border: 2px solid transparent;
}
.turnbar.mine { border-color: var(--gold); background: #2a2a12; }
.turnbar.mine b { color: var(--gold); font-size: 20px; }
.tb-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.clock { position: relative; width: 96px; height: 34px; border-radius: 10px; background: rgba(255, 255, 255, 0.08); overflow: hidden; flex: none; display: flex; align-items: center; justify-content: center; }
.clock.off { font-size: 13px; color: rgba(251, 243, 226, 0.7); }
.clock-bar { position: absolute; inset: 0; background: var(--jade-2); transform-origin: left; }
.clock.low .clock-bar { background: var(--chili); }
.clock-num { position: relative; font-weight: 900; }
.private .mystat { font-weight: 800; font-size: 17px; }
.mystat.hot { color: var(--chili-deep); }
.mystat.ok { color: #17694a; }
.fb { background: var(--rice-2); border-radius: 10px; padding: 10px 12px; font-weight: 600; }
.notes summary { font-weight: 700; min-height: 44px; display: flex; align-items: center; color: var(--mute); }
.know { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.know li { display: flex; flex-direction: column; background: #fff; border-radius: 8px; padding: 6px 8px; font-size: 14px; }
.know .nm { font-weight: 800; overflow-wrap: anywhere; }
.know .hot .kv { color: var(--chili-deep); font-weight: 800; }
.know .ok .kv { color: #17694a; font-weight: 800; }

.actgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.act {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 84px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: #fff;
  text-align: left;
  box-shadow: 0 3px 0 var(--ink);
}
.act:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.act[disabled] { opacity: 0.35; box-shadow: none; }
.act .al { font-weight: 900; font-size: 17px; }
.act .ac { font-size: 12px; font-weight: 900; background: var(--gold); border-radius: 6px; padding: 1px 6px; }
.act .ah { font-size: 13px; color: var(--mute); line-height: 1.2; }
.a-tip { background: #fdf0d2; }
.a-spin, .a-bigspin { background: #e6f3ee; }
.pairs { display: grid; grid-template-columns: 1fr; gap: 6px; }
.pairb { min-height: 48px; border-radius: 10px; border: 2px solid #cdbf9f; background: #fff; font-weight: 700; text-align: left; padding: 8px 12px; overflow-wrap: anywhere; }
.pairb.on { border-color: var(--ink); background: var(--ink); color: var(--rice); }

.table-card { padding: 10px; }
.ringbox svg { display: block; width: 100%; height: auto; }
.log { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.log li, .recap li { display: flex; gap: 8px; align-items: baseline; padding: 4px 2px; border-bottom: 1px solid #eadcbc; overflow-wrap: anywhere; min-width: 0; }
.tn { flex: none; font: 800 12px/1 ui-monospace, Menlo, monospace; color: var(--mute); min-width: 22px; }
.log .secret, .tv-log .secret { color: #6b4a8f; font-style: italic; }
.log .alert { color: var(--chili-deep); font-weight: 800; }
.recap { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.recap .swap { background: #ffe3dc; font-weight: 700; border-radius: 6px; }
.recap .tip { color: #7a4b00; }

/* ---------- the turntable (SVG) ---------- */

.ring .table { fill: #6b3f1e; stroke: #3c220e; stroke-width: 2; }
.ring .hub { fill: #4b2a12; stroke: #2a1608; stroke-width: 1.5; }
.ring .jar path { fill: rgba(255, 255, 255, 0.18); stroke: var(--bamboo); stroke-width: 1.4; }
.ring .jar text { fill: var(--gold); font: 900 10px var(--font); text-anchor: middle; }
.ring .seat { font: 800 11.5px var(--font); fill: var(--ink); }
.ring.big .seat { font-size: 12.5px; fill: var(--rice); }
.ring .seat.turn { fill: var(--chili); }
.ring.big .seat.turn { fill: var(--gold); }
.ring .seat.me { text-decoration: underline; }
.lid-base { fill: var(--bamboo); stroke: var(--bamboo-dark); stroke-width: 1.4; }
.lid-ring { fill: none; stroke: var(--bamboo-2); stroke-width: 1.1; }
.lid-weave { stroke: rgba(138, 93, 34, 0.45); stroke-width: 0.8; }
.lid-knob { fill: var(--bamboo-dark); }
.dish { fill: #fffaf0; stroke: #c9b48a; stroke-width: 1.2; }
.hot-dish { fill: #ffe0d6; stroke: var(--chili); stroke-width: 2; }
.dumpling { fill: #fff3d6; stroke: #c39a5a; stroke-width: 1.2; }
.pleat { stroke: #c39a5a; stroke-width: 1; fill: none; stroke-linecap: round; }
.steam { stroke: #9fb8b0; stroke-width: 1.2; fill: none; stroke-linecap: round; }
.pepper { fill: var(--chili); stroke: var(--chili-deep); stroke-width: 1; }
.stem { stroke: #2f8f3f; stroke-width: 2.4; fill: none; stroke-linecap: round; }
.cap { fill: #2f8f3f; }
.badge circle { stroke: #fff; stroke-width: 1.5; }
.badge text { font: 900 10px var(--font); text-anchor: middle; fill: #fff; }
.b-ok circle { fill: #1f8a5c; }
.b-hot circle { fill: var(--chili); }
.spinner, .plate { transform-box: view-box; }
.spinner { transform-origin: 0 0; }
.spinner.spinning { animation: spin-in 1.4s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
@keyframes spin-in { from { transform: rotate(var(--spin-from)); } to { transform: rotate(0deg); } }
.revealing .plate:not(.focus):not(.is-hot):not(.is-safe) { opacity: 0.5; }
.plate.suspense .lid { animation: tremble 0.18s linear infinite; transform-box: fill-box; transform-origin: center; }
@keyframes tremble { 0% { transform: rotate(-4deg) translateY(0); } 50% { transform: rotate(4deg) translateY(-1px); } 100% { transform: rotate(-4deg) translateY(0); } }
.plate.flip .food { animation: pop 0.9s cubic-bezier(0.2, 1.4, 0.4, 1) both; transform-box: fill-box; transform-origin: center; }
@keyframes pop { 0% { transform: scale(0.2) rotate(-25deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
.plate.is-hot .hot-dish { filter: drop-shadow(0 0 6px rgba(232, 65, 44, 0.9)); }

/* ---------- reveal and results on the phone ---------- */

.reveal-card { text-align: center; }
.cap-big { font: 900 26px/1.15 var(--font); }
.reveal-card.hot { background: #ffe3dc; }
.banner.ok { background: #dff5ea; }
.banner.hot { background: #ffe3dc; }
.results { display: flex; flex-direction: column; gap: 4px; }
.results li { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; padding: 6px 0; border-bottom: 1px solid #eadcbc; }
.results .nm { font-weight: 800; overflow-wrap: anywhere; }
.results .res { font-weight: 800; text-align: right; }
.results .out .res { color: var(--chili-deep); }
.results .safe .res { color: #17694a; }
.results .left, .results .tally { color: var(--mute); font-size: 14px; margin: 0; }
.fair { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.check[data-check='ok'] { color: #17694a; font-weight: 800; }
.check[data-check='bad'] { color: var(--chili-deep); font-weight: 800; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 120px);
  background: var(--ink);
  color: var(--rice);
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 700;
  max-width: calc(100vw - 32px);
  transition: transform 0.25s, visibility 0.25s;
  visibility: hidden;
  z-index: 10;
}
.toast.on { transform: translate(-50%, 0); visibility: visible; }

/* ---------- TV ---------- */

body.tv { overflow: hidden; }
.tvwrap {
  height: 100vh;
  width: 100vw;
  padding: 3.2vh 3.4vw;
  display: grid;
  gap: 2.4vw;
  color: var(--rice);
  font-size: 2.6vh;
}
.tv-brand { font: 800 2.4vh/1 var(--display); letter-spacing: 0.12em; text-transform: uppercase; color: var(--bamboo); }
.tv-title { font: 900 11vh/0.95 var(--display); letter-spacing: -0.01em; margin: 1.6vh 0; }
.tv-title.small { font-size: 6.4vh; }
.tv-tag { font-size: 3.4vh; color: rgba(251, 243, 226, 0.85); max-width: 32ch; }
.tv-small { font-size: 2.6vh; color: rgba(251, 243, 226, 0.75); }
.tv-h2 { font: 800 3.2vh/1.2 var(--font); margin-bottom: 1.2vh; color: var(--bamboo); }
.tvwrap.entry { place-content: center; justify-items: center; text-align: center; }
.tvwrap.entry form { display: flex; gap: 1vw; }
.tvcode { font-size: 6vh; min-height: 10vh; width: 14ch; text-align: center; }

.tvwrap.lobby { grid-template-columns: 1.15fr 1fr; align-items: center; }
.tv-join { display: flex; align-items: center; gap: 3vw; margin-top: 3vh; }
.qr { width: 30vh; height: 30vh; flex: none; border-radius: 1.6vh; overflow: hidden; box-shadow: 0 0 0 0.8vh var(--rice); }
.qr svg { width: 100%; height: 100%; display: block; }
.tv-url { font: 700 3.4vh/1.2 ui-monospace, Menlo, monospace; color: var(--rice); }
.tv-code { font: 900 13vh/1 ui-monospace, Menlo, monospace; letter-spacing: 0.12em; color: var(--gold); }
.tv-right { background: rgba(0, 0, 0, 0.22); border-radius: 2.4vh; padding: 4vh 2.6vw; align-self: stretch; display: flex; flex-direction: column; gap: 2vh; }
.tv-people { display: grid; grid-template-columns: 1fr; gap: 1.2vh; }
.tv-people li { display: flex; align-items: center; gap: 1vw; font: 800 3.6vh/1.2 var(--font); min-width: 0; }
.tv-people .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-people .dot { width: 1.6vh; height: 1.6vh; }
.tv-people .tag { font-size: 1.7vh; }

.tvwrap.rules { grid-template-rows: auto auto 1fr auto; }
.tv-rules { display: grid; grid-template-columns: 1fr 1fr; gap: 2.2vh 2.4vw; align-content: start; }
.tv-rules li { display: flex; flex-direction: column; gap: 0.6vh; background: rgba(0, 0, 0, 0.22); border-radius: 2vh; padding: 2.2vh 1.8vw; border-left: 0.8vh solid var(--bamboo); animation: rise 0.6s both; animation-delay: calc(var(--i) * 0.35s); }
.tv-rules b { font-size: 3.4vh; color: var(--gold); }
.tv-rules span { font-size: 3vh; line-height: 1.3; }
@keyframes rise { from { opacity: 0; transform: translateY(2vh); } to { opacity: 1; transform: none; } }
.rules-bar { position: relative; height: 5vh; border-radius: 1.4vh; background: rgba(255, 255, 255, 0.1); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.rules-bar .clock-num { font-size: 3vh; }

.tvwrap.play { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: stretch; }
.tv-ring { display: flex; align-items: center; justify-content: center; min-height: 0; }
.tv-ring svg { width: 100%; height: 100%; max-height: 94vh; }
.tv-side { display: flex; flex-direction: column; gap: 2.4vh; min-height: 0; }
.tv-turn { display: flex; align-items: center; gap: 1.4vw; background: rgba(0, 0, 0, 0.25); border-radius: 2vh; padding: 2vh 1.6vw; font-size: 3.8vh; }
.tv-turn p { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tv-turn b { color: var(--gold); }
.tv-turn .clock { width: 16vh; height: 6vh; border-radius: 1.4vh; }
.tv-turn .clock-num { font-size: 3vh; }
.tv-log { flex: 1; display: flex; flex-direction: column; gap: 1vh; overflow: hidden; font-size: 2.9vh; }
.tv-log li { display: flex; gap: 1vw; align-items: baseline; padding: 1.2vh 1.2vw; border-radius: 1.4vh; background: rgba(255, 255, 255, 0.05); }
.tv-log li.latest { background: rgba(255, 201, 74, 0.16); animation: rise 0.5s both; }
.tv-log .tn { color: var(--bamboo); font-size: 2vh; min-width: 3.4vh; }
.tv-log .secret { color: #d9c2ff; }
.tv-log .alert { color: #ffb4a8; font-weight: 800; }
.tv-log .peek { color: #fff; }
.tv-foot { display: flex; justify-content: space-between; gap: 1vw; font-size: 2vh; color: rgba(251, 243, 226, 0.6); flex-wrap: wrap; }

.tvwrap.reveal { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: center; background: radial-gradient(circle at 32% 50%, rgba(255, 201, 74, 0.12), transparent 60%); }
.tvwrap.reveal.hot { background: radial-gradient(circle at 32% 50%, rgba(232, 65, 44, 0.35), transparent 62%); }
.tv-caption { display: flex; flex-direction: column; gap: 3vh; }
.tv-caption .cap-big { font: 900 9vh/1.02 var(--display); animation: rise 0.5s both; overflow-wrap: anywhere; }
.tvwrap.reveal.hot .cap-big { color: #ffb4a8; text-shadow: 0 0 3vh rgba(232, 65, 44, 0.8); }
.tv-caption .cap-small { font-size: 4vh; color: var(--bamboo); }

.tvwrap.results { grid-template-rows: auto 1fr; gap: 3vh; }
.tv-hot { font-size: 4vh; color: #ffb4a8; font-weight: 800; }
.tv-res-grid { display: grid; grid-template-columns: 1fr 1.1fr 1fr; gap: 2vw; min-height: 0; }
.tv-panel { background: var(--rice); color: var(--ink); border-radius: 2vh; padding: 2.6vh 1.6vw; overflow: hidden; display: flex; flex-direction: column; gap: 1vh; font-size: 2.3vh; }
.tv-panel .tv-h2 { color: var(--jade); font-size: 2.8vh; margin: 0.6vh 0 0; }
.tv-panel .tv-small { color: var(--mute); font-size: 2.2vh; }
.tv-panel .results li { padding: 0.8vh 0; }
.tv-panel .results .left, .tv-panel .results .tally { font-size: 2vh; }
.tv-panel .recap { font-size: 2.1vh; }
.tv-panel .fair { font-size: 2.1vh; }
.tv-panel .tn { font-size: 1.6vh; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
