/* Checkmult — chunky pixel card-table theme */
:root {
  --px: 'Jersey 10', 'Micro 5', 'Courier New', monospace;
  --piece: 'Segoe UI Symbol', 'Noto Sans Symbols 2', 'Noto Sans Symbols', 'DejaVu Sans', 'Arial Unicode MS', serif;
  --ink: #1f1c18;
  --cream: #f4ecda;
  --text: #ffffff;
  --muted: #a9bec4;
  --dim: #6f878e;
  --panel: #33454b;
  --panel-2: #26363b;
  --panel-3: #1a262a;
  --edge: #4d6971;
  --edge-d: #11181b;
  --red: #fe5f55;
  --red-d: #a8372f;
  --blue: #1f9bff;
  --blue-d: #155f9e;
  --blue-l: #5ab8ff;
  --orange: #ff9a2e;
  --orange-d: #ad5f14;
  --green: #3fbf87;
  --green-d: #23774f;
  --gold: #f6b93b;
  --gold-d: #9c6a10;
  --purple: #8d6cf0;
  --purple-d: #563ca3;
  --slate: #4a6169;
  --slate-d: #263338;
  --sq-light: #e9e0ca;
  --sq-dark: #6f9286;
  --q-brilliant: #22c7dd;
  --q-best: #3fbf6a;
  --q-excellent: #8fc93a;
  --q-good: #8ea4ad;
  --q-forced: #7a8a92;
  --q-inaccuracy: #e8b21f;
  --q-mistake: #f0782a;
  --q-blunder: #e8463c;
  --r-common: #2f8ce8;
  --r-uncommon: #2fae6e;
  --r-rare: #a35ff0;
  --ts: 0 2px 0 rgba(0, 0, 0, 0.55);
  --ts-big: 0 3px 0 rgba(0, 0, 0, 0.6);
  --bw: min(calc(100vh - 270px), calc(100vw - 710px), 660px);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--px);
  font-size: 22px;
  line-height: 1.1;
  color: var(--text);
  background: radial-gradient(120% 90% at 50% 40%, #2c5d52 0%, #18352f 55%, #0b1715 100%) fixed;
  overflow-x: hidden;
  -webkit-font-smoothing: none;
}
body.font-micro { --px: 'Micro 5', 'Jersey 10', 'Courier New', monospace; }
body.has-bg { background: #14302c; }
b, strong, h1, h2, h3, h4 { font-weight: normal; }
button { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.red { color: var(--red); }
.blue { color: var(--blue-l); }
.gold { color: var(--gold); }
.orange { color: var(--orange); }
.num { text-shadow: var(--ts-big); font-variant-numeric: tabular-nums; }
.lbl { font-size: 18px; color: var(--muted); text-shadow: var(--ts); }

/* Description markup (on dark backgrounds; .desc-box overrides for light) */
c { color: var(--blue-l); }
m { color: #ff7a71; }
x { color: #fff; background: var(--red); padding: 0 5px 1px; border-radius: 4px; white-space: nowrap; text-shadow: none; }
g { color: var(--gold); }

#bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  display: block;
  image-rendering: pixelated;
}
#crt {
  position: fixed;
  inset: 0;
  z-index: 300;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0 2px, rgba(0, 0, 0, 0.13) 2px 3px, rgba(0, 0, 0, 0) 3px 4px),
    radial-gradient(130% 110% at 50% 50%, transparent 58%, rgba(0, 0, 0, 0.55) 100%);
}
body.no-crt #crt { display: none; }

/* ── Buttons ── */
.btn {
  --c: var(--orange);
  --cd: var(--orange-d);
  font-family: var(--px);
  font-size: 28px;
  line-height: 1;
  color: #fff;
  text-shadow: var(--ts);
  background: var(--c);
  border: 0;
  border-radius: 12px;
  padding: 8px 22px 10px;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--cd);
  transition: transform 0.06s, box-shadow 0.06s, filter 0.12s;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--cd); }
.btn.red { --c: var(--red); --cd: var(--red-d); }
.btn.blue { --c: var(--blue); --cd: var(--blue-d); }
.btn.green { --c: var(--green); --cd: var(--green-d); }
.btn.gold { --c: var(--gold); --cd: var(--gold-d); }
.btn.purple { --c: var(--purple); --cd: var(--purple-d); }
.btn.slate { --c: var(--slate); --cd: var(--slate-d); }
.btn.small { font-size: 22px; padding: 4px 14px 6px; border-radius: 9px; box-shadow: 0 4px 0 var(--cd); }
.btn.small:active { box-shadow: 0 1px 0 var(--cd); }
.btn small { display: block; font-size: 0.8em; opacity: 0.9; }
.btn:disabled { --c: #56656a; --cd: #323c40; color: #b6c1c4; cursor: not-allowed; filter: none; transform: none; box-shadow: 0 5px 0 var(--cd); }
.btn-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }

/* ── Layout ── */
#app { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 100vh; }
#main { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
#stage { position: relative; flex: 1; }

/* ── Sidebar ── */
#sidebar {
  --oc: var(--edge);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 10px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(30, 43, 48, 0.94);
  border-right: 5px solid var(--oc);
  box-shadow: 0 0 0 3px var(--edge-d), 8px 0 0 rgba(0, 0, 0, 0.25);
}
.logo-box {
  font-size: 50px;
  line-height: 0.8;
  letter-spacing: 2px;
  text-align: center;
  padding: 6px 0 2px;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.6);
}
.logo-box span { color: var(--red); }
.slab {
  background: var(--panel-2);
  border-radius: 14px;
  box-shadow: 0 0 0 3px var(--edge-d), 0 5px 0 3px rgba(0, 0, 0, 0.35);
}
.opp-panel, .score-panel, .hand-panel { background: var(--panel-2); border-radius: 14px; box-shadow: 0 0 0 3px var(--edge-d), 0 5px 0 3px rgba(0, 0, 0, 0.35); }
.opp-panel { overflow: hidden; }
.opp-banner { background: var(--oc); padding: 6px 12px 8px; text-align: center; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25); }
.opp-name { font-size: 36px; line-height: 0.95; text-shadow: var(--ts-big); }
.opp-title { font-size: 20px; color: rgba(255, 255, 255, 0.88); text-shadow: var(--ts); }
.opp-body { display: flex; gap: 10px; align-items: center; padding: 10px; }
.chip {
  --oc: var(--slate);
  flex: none;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--piece);
  font-size: 40px;
  color: #fff;
  -webkit-font-smoothing: antialiased;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.45);
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--oc) 70%, white), var(--oc) 58%, color-mix(in srgb, var(--oc) 60%, black));
  outline: 3px dashed rgba(255, 255, 255, 0.45);
  outline-offset: -9px;
  box-shadow: 0 0 0 3px var(--edge-d), 0 5px 0 3px rgba(0, 0, 0, 0.35);
}
.opp-goal { flex: 1; background: var(--panel-3); border-radius: 10px; padding: 4px 8px 6px; text-align: center; }
.opp-goal .num { font-size: 46px; line-height: 0.95; }
.reward { font-size: 19px; color: var(--muted); }
.opp-quirk {
  margin: 0 10px 10px;
  padding: 5px 10px 6px;
  border-radius: 9px;
  background: rgba(254, 95, 85, 0.14);
  box-shadow: inset 0 0 0 2px rgba(254, 95, 85, 0.55);
  font-size: 19px;
  line-height: 1.05;
  text-align: center;
}
.opp-quirk b { color: var(--red); }
.score-panel { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.score-panel > .lbl { width: 58px; font-size: 21px; text-align: center; line-height: 0.95; }
.score-val { flex: 1; background: var(--panel-3); border-radius: 10px; padding: 0 10px 8px; }
#round-score { font-size: 54px; line-height: 1; text-align: center; }
.bar { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--blue); transition: width 0.45s; }
.bar > div.full { background: var(--gold); }
.hand-panel { padding: 6px 10px 12px; }
.hand-name { min-height: 36px; display: flex; justify-content: center; align-items: baseline; gap: 10px; font-size: 32px; text-shadow: var(--ts-big); }
.hand-name .q { color: var(--qc); }
.hand-name .san { color: var(--muted); font-size: 26px; }
.hand-name .idle { color: var(--dim); font-size: 22px; }
.calc { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 6px; }
.chips, .mult {
  height: 64px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  padding: 0 12px 4px;
  font-size: 50px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.25), 0 0 0 3px var(--edge-d), 0 5px 0 3px rgba(0, 0, 0, 0.3);
}
.chips { background: var(--blue); justify-content: flex-end; }
.mult { background: var(--red); justify-content: flex-start; }
.calc .x { font-size: 38px; color: var(--red); text-shadow: var(--ts-big); padding: 0 2px; }
.pop-anim { animation: numpop 0.25s ease-out; }
@keyframes numpop { 40% { transform: scale(1.15); } }
.info-panel { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 10px; }
.side-btns { display: flex; flex-direction: column; gap: 12px; }
.sbtn { flex: 1; font-size: 25px; line-height: 0.9; padding: 6px 4px 8px; }
.counters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.counter { background: var(--panel-2); border-radius: 12px; padding: 3px 5px 6px; text-align: center; box-shadow: 0 0 0 3px var(--edge-d), 0 4px 0 3px rgba(0, 0, 0, 0.3); }
.counter .lbl { font-size: 17px; }
.counter .num { font-size: 36px; line-height: 1; background: var(--panel-3); border-radius: 8px; padding: 1px 0 3px; margin-top: 1px; }
.counter.wide { grid-column: span 2; padding: 5px; }
.counter.wide .num { font-size: 48px; margin: 0; }
.counter.low .num { color: var(--red); animation: pulse 1s ease-in-out infinite; }
.counter.free .num { color: var(--gold); font-size: 30px; padding: 4px 0 6px; }
@keyframes pulse { 50% { opacity: 0.55; } }

/* ── Card tray ── */
#tray { display: flex; gap: 20px; align-items: flex-start; padding: 12px 20px 2px; }
.tray-group { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.card-row {
  display: flex;
  gap: 10px;
  padding: 12px 12px 14px;
  min-height: 142px;
  align-items: center;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.3);
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.25);
}
.tray-count { font-size: 20px; color: var(--muted); padding-left: 8px; text-shadow: var(--ts); }
.tray-count span { color: #fff; }

/* ── Cards ── */
.card {
  --rc: var(--r-common);
  --hue: 200;
  position: relative;
  flex: none;
  width: 84px;
  height: 112px;
  cursor: pointer;
  user-select: none;
  transition: transform 0.14s ease;
}
.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  border-radius: 9px;
  padding: 5px 5px 0;
  background: var(--cream);
  box-shadow: 0 0 0 2px #15110d, inset 0 0 0 2px var(--rc), 0 6px 0 2px rgba(0, 0, 0, 0.35);
  transform-origin: 50% 90%;
  animation: sway 3.4s ease-in-out infinite alternate;
  animation-delay: var(--d, 0s);
}
@keyframes sway {
  from { transform: rotate(-2deg) translateY(0); }
  to { transform: rotate(2deg) translateY(-3px); }
}
.card-art {
  flex: 1;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: radial-gradient(circle at 50% 36%, hsl(var(--hue) 78% 74%), hsl(var(--hue) 62% 46%) 78%);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.3), inset 0 -6px 0 rgba(0, 0, 0, 0.12);
}
.card-icon {
  font-family: var(--piece);
  font-size: 42px;
  line-height: 1;
  color: #fff;
  -webkit-font-smoothing: antialiased;
  text-shadow: 2px 0 0 #1b1612, -2px 0 0 #1b1612, 0 2px 0 #1b1612, 0 -2px 0 #1b1612,
    2px 2px 0 #1b1612, -2px -2px 0 #1b1612, 2px -2px 0 #1b1612, -2px 2px 0 #1b1612, 0 5px 0 rgba(0, 0, 0, 0.35);
}
.card-name { height: 27px; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 17px; line-height: 0.82; color: var(--ink); }
.card:hover { transform: translateY(-6px) scale(1.06); z-index: 2; }
.card.selected { transform: translateY(-12px) scale(1.07); z-index: 3; }
.card.selected .card-face { box-shadow: 0 0 0 2px #15110d, inset 0 0 0 2px var(--rc), 0 0 0 6px #fff, 0 12px 0 2px rgba(0, 0, 0, 0.35); }
.card.r-common { --rc: var(--r-common); }
.card.r-uncommon { --rc: var(--r-uncommon); }
.card.r-rare { --rc: var(--r-rare); }
.card.scroll { --rc: var(--purple); }
.card.scroll .card-face { background: #34285c; }
.card.scroll .card-art { background: radial-gradient(circle at 50% 36%, #c2adff, #6a4bd1 78%); }
.card.scroll .card-name { color: #fff; text-shadow: var(--ts); }
.card.big { width: 112px; height: 150px; }
.card.big .card-icon { font-size: 60px; }
.card.big .card-name { height: 34px; font-size: 21px; }
.card.disabled .card-face { filter: grayscale(0.9) brightness(0.62); }
.card.disabled::after {
  content: '';
  position: absolute;
  inset: 10px;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(45deg, transparent 44%, var(--red) 44% 56%, transparent 56%),
    linear-gradient(-45deg, transparent 44%, var(--red) 44% 56%, transparent 56%);
}
.card.bump { animation: bump 0.45s cubic-bezier(.3, 1.6, .5, 1); }
.card.dragging { opacity: 0.4; }
@keyframes bump {
  30% { transform: scale(1.2) rotate(-7deg); }
  60% { transform: scale(0.96) rotate(4deg); }
}
.slot-empty { flex: none; width: 84px; height: 112px; border-radius: 9px; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.07); }

/* Tooltip + card action buttons */
.tooltip {
  position: fixed;
  z-index: 95;
  width: 260px;
  padding: 8px 8px 10px;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 0 0 3px var(--edge-d), 0 8px 0 3px rgba(0, 0, 0, 0.4);
  text-align: center;
  pointer-events: none;
}
.tip-name { font-size: 32px; line-height: 1; text-shadow: var(--ts-big); margin: 0 0 6px; }
.tip-sub { font-size: 18px; color: var(--muted); margin-top: 6px; }
.desc-box { background: #fff; color: var(--ink); border-radius: 10px; padding: 7px 10px 9px; font-size: 21px; line-height: 1.05; }
.desc-box c { color: #0a84e8; }
.desc-box m { color: #e8463c; }
.desc-box g { color: #c48600; }
.desc-box i { color: #77736d; font-style: normal; }
.desc-box b { color: var(--ink); }
.pill { display: inline-block; margin-top: 8px; padding: 1px 14px 4px; border-radius: 8px; font-size: 20px; color: #fff; text-shadow: var(--ts); background: var(--pc, var(--slate)); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35); }
.pill.r-common { --pc: var(--r-common); }
.pill.r-uncommon { --pc: var(--r-uncommon); }
.pill.r-rare { --pc: var(--r-rare); }
.pill.r-scroll { --pc: var(--purple); }
.pill.r-disabled { --pc: var(--red); }
.card-actions { position: fixed; z-index: 96; display: flex; flex-direction: column; gap: 8px; }
.card-actions .btn { font-size: 22px; line-height: 0.9; padding: 6px 12px 8px; min-width: 74px; }
.card-actions .row { display: flex; gap: 6px; }
.card-actions .row .btn { min-width: 0; flex: 1; padding: 4px 8px 6px; }

/* ── Table + board ── */
#table {
  display: grid;
  grid-template-columns: auto 280px;
  gap: 22px;
  justify-content: center;
  align-items: start;
  padding: 4px 20px 26px;
}
#center { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.status { min-height: 36px; padding-top: 4px; text-align: center; font-size: 28px; text-shadow: var(--ts-big); }
.status .spinner { display: inline-block; vertical-align: -1px; margin-right: 8px; }
.status.free { color: var(--gold); }
.status.warn { color: var(--red); }
.status.dim { color: var(--muted); }
.spinner {
  width: 16px;
  height: 16px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--gold);
  animation: spin 0.7s steps(8) infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#board-wrap {
  padding: 12px;
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 0 0 4px var(--edge-d), inset 0 0 0 3px var(--edge), 0 10px 0 4px rgba(0, 0, 0, 0.35);
}
#board {
  width: var(--bw);
  height: var(--bw);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 0 0 3px var(--edge-d);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.sq { position: relative; display: flex; align-items: center; justify-content: center; }
.sq.light { background-color: var(--sq-light); }
.sq.dark { background-color: var(--sq-dark); }
.sq.last { background-image: linear-gradient(rgba(246, 185, 59, 0.5), rgba(246, 185, 59, 0.5)); }
.sq.hint { background-image: linear-gradient(rgba(34, 199, 221, 0.55), rgba(34, 199, 221, 0.55)); box-shadow: inset 0 0 0 4px var(--q-brilliant); }
.sq.sel { background-image: linear-gradient(rgba(31, 155, 255, 0.55), rgba(31, 155, 255, 0.55)); }
.sq.check { background-image: radial-gradient(circle, rgba(254, 70, 60, 0.95) 0%, rgba(254, 70, 60, 0.55) 42%, transparent 72%); }
.sq.tgt::after {
  content: '';
  position: absolute;
  z-index: 3;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(17, 24, 27, 0.32);
  pointer-events: none;
}
.sq.cap::after {
  content: '';
  position: absolute;
  z-index: 3;
  inset: 3%;
  border-radius: 50%;
  border: calc(var(--bw) / 8 * 0.08) solid rgba(17, 24, 27, 0.35);
  pointer-events: none;
}
.coord { position: absolute; z-index: 1; font-size: 17px; pointer-events: none; }
.coord.f { right: 4px; bottom: 0; }
.coord.r { left: 4px; top: 0; }
.sq.light .coord { color: var(--sq-dark); }
.sq.dark .coord { color: var(--sq-light); }
.pc {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--piece);
  font-size: calc(var(--bw) / 8 * 0.78);
  line-height: 1;
  padding-bottom: calc(var(--bw) / 8 * 0.04);
  -webkit-font-smoothing: antialiased;
}
.pc.w {
  color: #fffaf0;
  text-shadow: 0 1.5px 0 #1d140c, 0 -1.5px 0 #1d140c, 1.5px 0 0 #1d140c, -1.5px 0 0 #1d140c,
    1.5px 1.5px 0 #1d140c, -1.5px -1.5px 0 #1d140c, 1.5px -1.5px 0 #1d140c, -1.5px 1.5px 0 #1d140c,
    0 4px 0 rgba(0, 0, 0, 0.3);
}
.pc.b { color: #17120e; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3), 0 4px 0 rgba(0, 0, 0, 0.3); }
.pc.w.mine { cursor: grab; }
.pc.ghost { position: fixed; z-index: 80; pointer-events: none; transform: translate(-50%, -50%) scale(1.14); width: calc(var(--bw) / 8); height: calc(var(--bw) / 8); }
.pc.moving { position: fixed; z-index: 80; pointer-events: none; }
.actions { display: flex; gap: 10px; min-height: 48px; align-items: center; }
.mini-hud { display: none; gap: 8px; width: 100%; justify-content: center; flex-wrap: wrap; }
.mini-hud span { background: rgba(26, 38, 42, 0.92); border-radius: 10px; padding: 3px 10px 5px; font-size: 20px; color: var(--muted); box-shadow: 0 0 0 3px var(--edge-d); }
.mini-hud b { font-size: 26px; color: #fff; text-shadow: var(--ts); }
.mini-hud b.gold { color: var(--gold); }

/* Score log panel */
.panel {
  background: rgba(30, 43, 48, 0.94);
  border-radius: 16px;
  padding: 8px 12px 12px;
  box-shadow: 0 0 0 4px var(--edge-d), 0 8px 0 4px rgba(0, 0, 0, 0.3);
}
.panel-title { font-size: 22px; color: var(--muted); margin: 2px 2px 6px; text-shadow: var(--ts); }
.breakdown { background: var(--panel-3); border-radius: 10px; padding: 8px 10px 10px; min-height: 140px; margin-bottom: 12px; }
.breakdown .idle { color: var(--dim); font-size: 20px; }
.bd-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 30px; text-shadow: var(--ts-big); }
.qbadge { display: inline-block; padding: 1px 9px 4px; border-radius: 7px; font-size: 20px; line-height: 1; color: #fff; background: var(--qc); text-shadow: var(--ts); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35); white-space: nowrap; }
.steps { list-style: none; margin: 8px 0 0; padding: 0; }
.steps li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 2px 0; font-size: 20px; animation: slideIn 0.2s ease-out; }
.steps .step-l { display: flex; align-items: center; gap: 6px; min-width: 0; }
.steps .step-ic { width: 20px; text-align: center; font-family: var(--piece); font-size: 16px; color: var(--gold); -webkit-font-smoothing: antialiased; }
.steps .step-r { white-space: nowrap; text-align: right; }
@keyframes slideIn { from { opacity: 0; transform: translateX(10px); } }
.t-c { color: var(--blue-l); }
.t-m { color: #ff7a71; }
.t-x { color: #fff; background: var(--red); padding: 0 5px 1px; border-radius: 4px; }
.t-note { color: var(--muted); }
.bd-total { margin-top: 8px; display: flex; justify-content: space-between; align-items: baseline; font-size: 22px; color: var(--muted); }
.bd-total b { font-size: 36px; color: #fff; text-shadow: var(--ts-big); }
.bd-total b.neg { color: var(--red); }
#log {
  list-style: none;
  margin: 0;
  padding: 4px;
  max-height: calc(100vh - 480px);
  min-height: 120px;
  overflow: auto;
  font-size: 20px;
  background: var(--panel-3);
  border-radius: 10px;
}
#log li { display: grid; grid-template-columns: 30px 1.3fr 1fr; gap: 4px; padding: 2px 6px; border-radius: 6px; }
#log li:nth-child(odd) { background: rgba(255, 255, 255, 0.04); }
#log .n { color: var(--dim); }
#log .pts { color: var(--muted); font-size: 17px; margin-left: 4px; }
.qdot { display: inline-block; width: 9px; height: 9px; background: var(--qc); margin-right: 6px; vertical-align: 2px; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4); }
.q-brilliant { --qc: var(--q-brilliant); }
.q-best { --qc: var(--q-best); }
.q-excellent { --qc: var(--q-excellent); }
.q-good { --qc: var(--q-good); }
.q-forced { --qc: var(--q-forced); }
.q-inaccuracy { --qc: var(--q-inaccuracy); }
.q-mistake { --qc: var(--q-mistake); }
.q-blunder { --qc: var(--q-blunder); }

/* ── Floating text ── */
.float {
  position: fixed;
  z-index: 90;
  pointer-events: none;
  transform: translate(-50%, -50%);
  font-size: 34px;
  line-height: 1;
  color: var(--qc, #fff);
  white-space: nowrap;
  text-shadow: 3px 0 0 #000, -3px 0 0 #000, 0 3px 0 #000, 0 -3px 0 #000,
    3px 3px 0 #000, -3px 3px 0 #000, 3px -3px 0 #000, -3px -3px 0 #000, 0 7px 0 rgba(0, 0, 0, 0.4);
  animation: floatUp 1.25s ease-out forwards;
}
.float.big { font-size: 54px; }
.float.huge { font-size: 92px; }
.float.gold { --qc: var(--gold); }
.float.badge {
  --bc: var(--slate);
  color: #fff;
  font-size: 24px;
  padding: 2px 10px 5px;
  border-radius: 8px;
  background: var(--bc);
  text-shadow: var(--ts);
  box-shadow: 0 0 0 2px var(--edge-d), 0 4px 0 2px rgba(0, 0, 0, 0.4);
}
.float.badge.multc { --bc: var(--red); }
.float.badge.base { --bc: var(--blue); }
.float.badge.gold { --bc: var(--gold-d); }
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.5); }
  14% { opacity: 1; transform: translate(-50%, -62%) scale(1.18); }
  28% { transform: translate(-50%, -72%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -175%) scale(1); }
}
body.shake #app { animation: shake 0.35s; }
@keyframes shake {
  20% { transform: translate(-5px, 2px); }
  40% { transform: translate(5px, -2px); }
  60% { transform: translate(-3px, 1px); }
  80% { transform: translate(2px, -1px); }
}

/* ── Screens over the table (opponent select, market, payout, game over) ── */
#screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px 20px 40px;
  overflow: auto;
  background: rgba(8, 14, 16, 0.74);
}
.sheet {
  width: min(620px, 100%);
  background: rgba(38, 54, 59, 0.98);
  border-radius: 18px;
  box-shadow: 0 0 0 4px var(--edge-d), 0 10px 0 4px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  text-align: center;
  animation: slideUp 0.35s cubic-bezier(.2, .9, .3, 1.15);
}
@keyframes slideUp { from { opacity: 0; transform: translateY(70px); } }
.sheet-head {
  --hc: var(--red);
  background: var(--hc);
  color: #fff;
  padding: 8px 16px 12px;
  font-size: 50px;
  line-height: 1;
  text-shadow: var(--ts-big);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.22);
}
.sheet-head small { display: block; font-size: 22px; opacity: 0.88; }
.sheet-head.blue { --hc: var(--blue); }
.sheet-head.green { --hc: var(--green); }
.sheet-head.orange { --hc: var(--orange); }
.sheet-head.purple { --hc: var(--purple); }
.sheet-body { padding: 14px 20px 20px; }
.sheet-body p { margin: 6px 0 12px; font-size: 22px; color: var(--muted); }
.inset { background: var(--panel-3); border-radius: 12px; padding: 10px 12px; }

/* Opponent select */
.select-wrap { width: min(900px, 100%); display: flex; flex-direction: column; align-items: center; gap: 16px; }
.ladder-dots { display: flex; gap: 6px; padding: 8px 12px; border-radius: 12px; background: rgba(0, 0, 0, 0.35); }
.ladder-dots .dot { width: 26px; height: 10px; border-radius: 3px; background: rgba(255, 255, 255, 0.14); }
.ladder-dots .dot.done { background: var(--green); }
.ladder-dots .dot.cur { background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.blinds { display: flex; gap: 18px; align-items: flex-end; justify-content: center; flex-wrap: wrap; width: 100%; }
.blind {
  --oc: var(--slate);
  width: 250px;
  border-radius: 16px;
  background: rgba(38, 54, 59, 0.98);
  box-shadow: 0 0 0 4px var(--edge-d), 0 8px 0 4px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  text-align: center;
  animation: slideUp 0.4s cubic-bezier(.2, .9, .3, 1.15) backwards;
}
.blind.current { width: 280px; }
.blind.upcoming { filter: brightness(0.62) saturate(0.55); transform: scale(0.93); transform-origin: bottom; }
.blind-top { padding: 10px; background: var(--panel-3); min-height: 66px; display: flex; align-items: center; justify-content: center; }
.blind-top .btn { width: 100%; font-size: 32px; }
.tag { display: inline-block; padding: 6px 14px 8px; border-radius: 10px; background: var(--slate); font-size: 24px; color: #d7e2e5; text-shadow: var(--ts); }
.blind-head { background: var(--oc); padding: 6px 10px 9px; font-size: 36px; line-height: 0.95; text-shadow: var(--ts-big); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25); }
.blind-head small { display: block; font-size: 20px; opacity: 0.88; }
.blind .chip { margin: 14px auto 10px; width: 100px; height: 100px; font-size: 58px; outline-offset: -12px; }
.blind-goal { margin: 0 14px; background: var(--panel-3); border-radius: 10px; padding: 4px 8px 8px; }
.blind-goal .num { font-size: 50px; line-height: 0.95; }
.blind-meta { display: flex; justify-content: space-around; margin: 10px 14px; font-size: 21px; color: var(--muted); }
.blind-meta b { color: #fff; }
.stars { color: var(--gold); letter-spacing: 1px; font-family: var(--piece); font-size: 16px; -webkit-font-smoothing: antialiased; }
.stars i { color: rgba(255, 255, 255, 0.18); font-style: normal; }
.blind .desc-box { margin: 0 12px 14px; font-size: 20px; }
.blind .desc-box b { color: #e8463c; }
.blind-blurb { margin: 0 14px 14px; font-size: 19px; color: var(--muted); line-height: 1.05; }

/* Market */
.shop { width: min(1080px, 100%); }
.shop-body { display: flex; gap: 18px; padding: 16px; align-items: stretch; }
.shop-left { flex: none; width: 138px; display: flex; flex-direction: column; gap: 14px; }
.shop-left .btn { padding: 14px 8px 16px; font-size: 32px; line-height: 0.9; }
.shop-left .btn small { margin-top: 4px; font-size: 26px; }
.shop-left .wallet { margin-top: auto; text-align: center; }
.shop-left .wallet .num { font-size: 48px; color: var(--gold); }
.shop-items { flex: 1; display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; align-items: flex-start; background: var(--panel-3); border-radius: 14px; padding: 18px 12px; }
.shop-divider { width: 4px; align-self: stretch; border-radius: 2px; background: rgba(255, 255, 255, 0.07); }
.shop-item { width: 150px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.shop-item.sold { opacity: 0.32; }
.price {
  position: relative;
  z-index: 1;
  margin-bottom: -4px;
  padding: 0 14px 3px;
  border-radius: 10px;
  font-size: 30px;
  color: var(--gold);
  text-shadow: var(--ts);
  background: var(--panel-2);
  box-shadow: 0 0 0 3px var(--edge-d);
}
.shop-item .item-name { font-size: 25px; text-shadow: var(--ts); }
.shop-item .desc-box { width: 100%; min-height: 92px; font-size: 20px; }
.shop-item .pill { margin-top: 0; }
.shop-note { padding: 0 18px 16px; font-size: 20px; color: var(--muted); text-align: left; }

/* Payout + stats */
.payout { list-style: none; margin: 12px 0 4px; padding: 0; text-align: left; }
.payout li { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 5px 4px 7px; font-size: 24px; border-bottom: 2px dotted rgba(255, 255, 255, 0.13); animation: slideIn 0.25s ease-out backwards; }
.payout li b { font-size: 30px; color: var(--gold); text-shadow: var(--ts); }
.cash-btn { width: 100%; font-size: 38px; padding: 12px 10px 14px; margin-top: 4px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 12px 0 16px; }
.stat-grid > div { background: var(--panel-3); border-radius: 10px; padding: 4px 10px 6px; text-align: left; }
.stat-grid span { display: block; font-size: 18px; color: var(--muted); }
.stat-grid b { font-size: 32px; color: #fff; text-shadow: var(--ts); }

/* ── Modal ── */
#modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(4, 8, 10, 0.55);
}
#modal .sheet { max-height: calc(100vh - 32px); overflow: auto; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 6px; }
.choice { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 10px 14px 14px; text-align: left; }
.choice b { font-size: 36px; }
.choice .amt { font-size: 44px; color: #fff; }
.choice small { font-size: 19px; opacity: 0.92; line-height: 1.05; }
.promo-row { display: flex; justify-content: center; gap: 12px; margin: 8px 0 4px; }
.promo-row button { width: 84px; height: 84px; border: 0; border-radius: 14px; background: var(--sq-light); cursor: pointer; box-shadow: 0 0 0 3px var(--edge-d), 0 5px 0 3px rgba(0, 0, 0, 0.35); }
.promo-row button:hover { transform: translateY(-3px); }
.promo-row .pc { font-size: 60px; }
.help { text-align: left; }
.help ol { margin: 4px 0 8px; padding-left: 26px; font-size: 22px; line-height: 1.12; }
.help li { margin-bottom: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.opt-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 2px; font-size: 26px; border-bottom: 2px solid rgba(255, 255, 255, 0.06); text-align: left; }
.opt-row small { display: block; font-size: 18px; color: var(--muted); }
.seg { display: flex; gap: 6px; flex: none; }
.seg .btn { min-width: 62px; padding: 4px 12px 6px; font-size: 24px; border-radius: 9px; box-shadow: 0 4px 0 var(--cd); }
.seg .btn:not(.on) { --c: var(--slate); --cd: var(--slate-d); color: #c4d0d3; }

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 97;
  padding: 6px 18px 9px;
  border-radius: 12px;
  font-size: 24px;
  background: var(--panel);
  box-shadow: 0 0 0 3px var(--edge-d), 0 6px 0 3px rgba(0, 0, 0, 0.4);
  text-shadow: var(--ts);
  animation: slideUp 0.2s ease-out;
}

/* ── Title ── */
#title {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  text-align: center;
}
#title:empty { display: none; }
body.on-title #app { visibility: hidden; }
.logo {
  font-size: clamp(96px, 17vw, 220px);
  line-height: 0.74;
  letter-spacing: 6px;
  text-shadow: 0 10px 0 rgba(0, 0, 0, 0.55);
  animation: bob 2.8s ease-in-out infinite alternate;
}
.logo span { color: var(--red); }
@keyframes bob { to { transform: translateY(-8px) rotate(-1deg); } }
.logo-glyphs { font-family: var(--piece); font-size: 34px; letter-spacing: 12px; color: var(--gold); text-shadow: 0 3px 0 rgba(0, 0, 0, 0.5); -webkit-font-smoothing: antialiased; }
.tagline { max-width: 660px; font-size: 27px; line-height: 1.05; text-shadow: var(--ts-big); margin: 0; }
.title-buttons { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.title-buttons .btn { font-size: 38px; padding: 12px 34px 14px; border-radius: 14px; box-shadow: 0 6px 0 var(--cd); }
.best-line { font-size: 23px; text-shadow: var(--ts); min-height: 24px; }

@media (prefers-reduced-motion: reduce) {
  .card-face, .logo, .counter.low .num { animation: none; }
}

/* ── Responsive ── */
@media (max-width: 1260px) {
  :root { --bw: min(calc(100vh - 270px), calc(100vw - 390px), 640px); }
  #table { grid-template-columns: auto; justify-items: center; }
  #right { width: calc(var(--bw) + 24px); }
  #log { max-height: 260px; }
}
@media (max-width: 900px) {
  :root { --bw: min(calc(100vw - 48px), 600px); }
  #app { display: flex; flex-direction: column; }
  #main { order: 1; min-height: 0; }
  #sidebar { order: 2; position: static; height: auto; border-right: 0; border-top: 5px solid var(--oc); }
  .mini-hud { display: flex; }
  #tray { flex-wrap: wrap; gap: 10px; padding: 10px 12px 0; }
  .tray-group { max-width: 100%; }
  .card-row { overflow-x: auto; min-height: 128px; }
  #table { padding: 4px 12px 20px; }
  .shop-body { flex-direction: column; }
  .shop-left { width: 100%; flex-direction: row; }
  .shop-left .btn { flex: 1; }
  .shop-left .wallet { margin: 0; align-self: center; }
}
@media (max-width: 560px) {
  .card, .slot-empty { width: 64px; height: 86px; }
  .card-icon { font-size: 30px; }
  .card-name { height: 22px; font-size: 14px; }
  .card-row { min-height: 108px; gap: 8px; padding: 10px 8px 12px; }
  .choices { grid-template-columns: 1fr; }
  .sheet-head { font-size: 40px; }
  .blind, .blind.current { width: 100%; }
  .blind.upcoming { display: none; }
}
