@font-face {
  font-family: "Lilita One";
  src: url("../fonts/lilita-one-latin.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Nunito;
  src: url("../fonts/nunito-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Nunito;
  src: url("../fonts/nunito-latin-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: Nunito, "Trebuchet MS", sans-serif;
  color: #fff8ee;
  background: radial-gradient(1200px 520px at 15% -10%, #3d2498, #140b5c 46%, #090720 100%);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
#app { height: 100%; position: relative; overflow: hidden; }
.sky { position: absolute; inset: 0; pointer-events: none; }
.sky i { position: absolute; border-radius: 50%; filter: blur(10px); opacity: 0.45; }

.rotate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  background: radial-gradient(circle at 50% 20%, #3d2498, #140b5c 70%);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  padding: 24px;
  gap: 16px;
}
@media (orientation: portrait) {
  .rotate { display: flex; }
  #app { display: none; }
}

.screen { height: 100%; position: relative; z-index: 1; overflow: hidden; }
.marquee, .tile, .btn, .step .block, h1, h2 {
  font-family: "Lilita One", Impact, "Arial Black", sans-serif;
  letter-spacing: 0.02em;
}
.marquee {
  display: inline-block;
  margin: 0;
  padding: 8px 22px 10px;
  background: linear-gradient(#ff4d4d, #c1121f);
  color: #fff6d8;
  border-radius: 14px;
  box-shadow: 0 0 0 3px #1a1208, 0 0 0 8px #f2c14e, 0 8px 0 #6a1018;
  position: relative;
  font-size: 42px;
  line-height: 1;
}
.marquee.small { font-size: 28px; padding: 6px 16px; }
.marquee.tiny { font-size: 22px; padding: 4px 12px; box-shadow: 0 0 0 2px #1a1208, 0 0 0 5px #f2c14e; }
.marquee::after {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 18px;
  padding: 7px;
  background: radial-gradient(circle, #fff6c2 42%, #f2c14e 52%, transparent 58%) 0 0 / 14px 14px;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.lede { font-size: 20px; max-width: 280px; margin: 14px 0; }
.quiet { color: #efe2c2; margin: 4px 0; font-size: 14px; }
h2 { margin: 0 0 6px; font-size: 20px; color: #ffe7a3; }
h3 { margin: 8px 0 4px; font-size: 16px; }

.btn {
  border: 3px solid #6b3a09;
  background: radial-gradient(circle at 35% 30%, #fff6c8, #f0b429 45%, #c4841d);
  color: #2a1600;
  border-radius: 999px;
  min-height: 42px;
  padding: 0 16px;
  box-shadow: 0 4px 0 #5a3008;
}
.btn.big { min-height: 52px; font-size: 22px; padding: 0 22px; }
.btn.small, .btn.tiny { min-height: 34px; font-size: 14px; padding: 0 10px; box-shadow: 0 3px 0 #5a3008; }
.btn.ghost { background: #fff1cf; }
.btn:disabled { opacity: 0.45; }
.btn.is-on, .choice .is-on, .pad button.is-on { outline: 3px solid #fff; }

.bunting { height: 12px; width: 220px; margin-bottom: 8px;
  background: linear-gradient(135deg, #e23d3d 33%, transparent 33%) 0 0 / 18px 12px,
    linear-gradient(225deg, #f0b429 33%, transparent 33%) 0 0 / 18px 12px,
    linear-gradient(#3d6fe0, #3d6fe0);
}

.start, .hub, .play, .curtain { height: 100%; }
.start { display: grid; grid-template-columns: 300px 1fr; gap: 18px; padding: 16px 18px; align-items: center; }
.start-players { min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.rows { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.prow { display: grid; grid-template-columns: 46px 1fr 36px; gap: 8px; align-items: center; }
.prow input, .fields input, .log-list input {
  background: #fff8ee; color: #2a1600; border: 3px solid #f2c14e; border-radius: 12px; min-height: 44px; padding: 0 10px;
}
.swatch { width: 46px; height: 44px; border-radius: 50%; border: 3px solid #fff6c8; box-shadow: 0 0 0 3px #6b3a09; }
.icon-x { width: 36px; height: 36px; border-radius: 50%; border: 2px solid #f2c14e; background: transparent; font-size: 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { border-radius: 999px; border: 2px solid #f2c14e; background: #2a1868; min-height: 32px; padding: 0 10px; }
.settings-fab { position: absolute; top: 12px; right: 12px; }

.hub { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 8px; padding: 8px 10px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.tools { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }
.hub-main { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 10px; min-height: 0; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: 1fr 1fr; gap: 8px; min-height: 0; }
.tile {
  border: 0; border-radius: 12px; background: var(--sign); color: var(--ink);
  box-shadow: 0 6px 0 #1a1208, 0 0 0 3px #f2c14e;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 8px; text-align: center; min-height: 0;
}
.tile span { font-size: 22px; line-height: 1.05; }
.tile small { font-family: Nunito, sans-serif; font-weight: 700; font-size: 13px; line-height: 1.2; }
.tile:nth-child(5) { grid-column: 1; }
.side-card {
  background: rgba(8, 6, 32, 0.55); border: 3px solid #f2c14e; border-radius: 16px; padding: 10px;
  min-height: 0; overflow: hidden; display: flex; flex-direction: column;
}
.mtable { list-style: none; margin: 0 0 8px; padding: 0; }
.mtable li { display: grid; grid-template-columns: 22px 14px minmax(0, 1fr) repeat(3, 28px); gap: 4px; align-items: center; min-height: 28px; }
.mtable:not(.compact) li { grid-template-columns: 28px 16px minmax(0, 1fr) repeat(3, 36px) 64px; min-height: 40px; font-size: 18px; }
.mtable .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: block; }
.disc { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #2a1600; font-weight: 800; font-size: 13px; }
.disc.gold { background: #f0b429; }
.disc.silver { background: #e6e8ee; }
.disc.bronze { background: #e0a36a; }
.played { list-style: none; margin: 0; padding: 0; }
.played li { font-size: 14px; padding: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.champ { background: rgba(240, 180, 41, 0.2); border-radius: 10px; }

.play {
  display: grid;
  grid-template-rows: 44px 74px minmax(0, 1fr) 34px 124px;
  gap: 6px;
  padding: 8px 10px;
}
.players { display: flex; gap: 6px; min-height: 0; }
.pcard {
  flex: 1 1 0; min-width: 0; border-radius: 12px; background: var(--pc); color: var(--ink);
  padding: 4px 8px; display: flex; flex-direction: column; justify-content: center;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.35);
}
.pcard.is-on { box-shadow: 0 0 0 3px #fff6c2, 0 0 0 6px #c4841d; }
.pcard.is-out { filter: grayscale(0.7); opacity: 0.7; }
.pcard-name, .pcard-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 800; font-size: 13px; }
.pcard-num { font-family: "Lilita One", Impact, sans-serif; font-size: clamp(20px, 3vw, 34px); line-height: 1; }
.stage { position: relative; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.banner {
  position: absolute; inset: auto 0 8px; margin: auto; width: max-content; max-width: 80%;
  background: #c1121f; color: #fff6d8; border: 3px solid #f2c14e; border-radius: 999px;
  padding: 4px 16px; font-family: "Lilita One", Impact, sans-serif; font-size: 28px;
}
.huge { font-family: "Lilita One", Impact, sans-serif; font-size: 72px; line-height: 0.9; margin: 0; text-align: center; }
.tower-scene, .shanghai-scene, .killer-scene, .duck-scene { text-align: center; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.tower-scene { flex-direction: row; gap: 18px; }
.tower { width: 74px; height: 80%; align-self: flex-end; display: flex; flex-direction: column-reverse; gap: 3px; transition: height 0.25s ease; }
.tower i { flex: 1; background: repeating-linear-gradient(90deg, #e23d3d 0 10px, #fff1cf 10px 20px); border: 2px solid #2a1600; border-radius: 3px; }
.lamps { display: flex; gap: 8px; }
.lamps span, .duck { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: #2a1868; border: 3px solid #f2c14e; }
.lamps span.on, .duck.down { background: #f0b429; color: #2a1600; }
.ducks { display: flex; gap: 12px; }
.duck svg { width: 64px; height: 40px; }
.duck.down svg { filter: grayscale(1) brightness(0.7); }

.limbo-scene { position: relative; width: min(100%, 520px); height: 100%; }
.post { position: absolute; bottom: 8px; width: 10px; top: 8px; background: repeating-linear-gradient(#fff1cf, #fff1cf 6px, #e23d3d 6px 12px); border-radius: 4px; }
.post.left { left: 18%; } .post.right { right: 18%; }
.bar {
  position: absolute; left: 16%; right: 16%; height: 16px; border-radius: 8px;
  background: repeating-linear-gradient(90deg, #e23d3d 0 14px, #fff1cf 14px 28px);
  border: 2px solid #2a1600; display: grid; place-items: center; color: #2a1600; font-weight: 800;
  transition: top 0.25s ease;
}
.limbo-copy { position: absolute; bottom: 4px; left: 0; right: 0; text-align: center; margin: 0; font-weight: 800; }

.track { width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: space-evenly; gap: 4px; }
.lane { position: relative; height: 22%; background: #1d4d28; border-radius: 8px; border: 2px solid #d8b15a; }
.lane-name { position: absolute; left: 6px; top: 2px; font-size: 12px; font-weight: 800; z-index: 1; }
.finish { position: absolute; right: 8px; top: 0; bottom: 0; width: 4px; background: repeating-linear-gradient(#fff, #fff 4px, #111 4px 8px); }
.donkey { position: absolute; top: 0; width: 70px; height: 100%; transition: left 0.25s ease; }
.donkey svg { width: 100%; height: 100%; }

.snake-scene { height: 100%; width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; }
.trophy { width: 72px; text-align: center; background: #f0b429; color: #2a1600; border-radius: 12px; padding: 8px 4px; font-weight: 800; }
.trophy b { display: block; font-family: "Lilita One", Impact, sans-serif; font-size: 28px; }
.sboard {
  height: 100%; aspect-ratio: var(--cols) / var(--rows); max-width: 100%;
  display: grid; grid-template-columns: repeat(var(--cols), 1fr); grid-template-rows: repeat(var(--rows), 1fr);
  position: relative; background: #12331f; border: 3px solid #f2c14e; border-radius: 8px;
}
.cell { position: relative; border: 1px solid rgba(255,255,255,0.15); font-size: 9px; color: #efe2c2; }
.cell b { position: absolute; left: 1px; top: 0; font-weight: 800; }
.cell i { position: absolute; width: 8px; height: 8px; border-radius: 50%; bottom: 1px; right: 1px; box-shadow: 0 0 0 1px #fff; }
.cell.is-ladder { background: rgba(240, 180, 41, 0.45); }
.cell.is-snake { background: rgba(47, 158, 68, 0.55); }
.cell.is-end { background: #c1121f; }
.board-art { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ladder-line { stroke: #f0b429; stroke-width: 0.12; }
.snake-line { fill: none; stroke: #39d36a; stroke-width: 0.16; }
.hood { fill: #146b32; stroke: #d8ffe4; stroke-width: 0.04; }

.visit { display: flex; align-items: center; gap: 8px; }
.slots { display: flex; gap: 6px; }
.slot {
  min-width: 64px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  background: #241552; border: 2px solid #f2c14e; font-weight: 800;
}
.slot.filled { background: #fff1cf; color: #2a1600; }
.hold-note { font-weight: 800; color: #ffe7a3; }
.pad { height: 100%; display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.pad-mods, .pad-nums { display: grid; gap: 4px; min-height: 0; }
.pad-mods { grid-template-columns: repeat(7, 1fr); flex: 0.9; }
.pad-nums { grid-template-columns: repeat(10, 1fr); flex: 1; }
.pad button { border-radius: 8px; border: 2px solid #6b3a09; background: #fff1cf; color: #2a1600; font-weight: 800; font-size: 15px; }
.omni-box {
  height: 100%; border: 3px solid #f2c14e; border-radius: 12px; display: flex; align-items: center; gap: 12px;
  padding: 0 12px; background: rgba(8, 6, 32, 0.45);
}
.omni-box p { margin: 0; }
.pill { border-radius: 999px; min-height: 34px; padding: 0 12px; border: 2px solid #fff; font-weight: 800; }
.pill[data-kind="connected"] { background: #2f9e44; }
.pill[data-kind="waiting"] { background: #f0b429; color: #2a1600; }
.pill[data-kind="error"] { background: #c1121f; }

.modal { position: absolute; inset: 0; z-index: 5; background: rgba(6, 4, 24, 0.62); display: flex; align-items: center; justify-content: center; padding: 12px; }
.tent { background: #1a103f; border: 4px solid #f2c14e; border-radius: 16px; padding: 0 16px 12px; max-width: 640px; width: min(640px, 100%); max-height: 100%; overflow: hidden; }
.tent.wide { max-width: 760px; }
.awning { height: 16px; margin: 0 -16px 8px; border-radius: 12px 12px 0 0; background: repeating-linear-gradient(90deg, #e23d3d 0 16px, #fff6e4 16px 32px); }
.tent h1, .tent h2 { margin: 0 0 6px; text-align: center; }
.tent p { margin: 4px 0; font-size: 15px; }
.choice { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.choice button { border-radius: 999px; border: 2px solid #f2c14e; background: #2a1868; min-height: 32px; padding: 0 10px; }
.result-actions { display: flex; justify-content: center; gap: 8px; margin-top: 8px; }
.curtain { display: flex; align-items: center; justify-content: center; padding: 8px 56px; }
.curtain::before, .curtain::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 46px;
  background: repeating-linear-gradient(#6d1020, #6d1020 10px, #9a2436 12px, #4a0b16 24px);
}
.curtain::before { left: 0; } .curtain::after { right: 0; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; height: 210px; }
.step { width: 150px; text-align: center; }
.step-names { display: flex; flex-direction: column; gap: 4px; margin-bottom: 4px; }
.step-names b { border-radius: 8px; padding: 2px 6px; color: #2a1600; }
.block { border-radius: 10px 10px 0 0; display: grid; place-items: center; color: #2a1600; font-size: 20px; }
.place-1 .block { height: 120px; background: #f0b429; }
.place-2 .block { height: 86px; background: #e4e7ee; }
.place-3 .block { height: 62px; background: #e0a36a; }
.step.empty { visibility: hidden; }
.fields { display: grid; grid-template-columns: 1fr 120px; gap: 6px; }
.fields .wide { grid-column: 1 / -1; }
.fields label { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.log-list { overflow: auto; max-height: 280px; display: flex; flex-direction: column; gap: 8px; }
.log-list pre { white-space: pre-wrap; word-break: break-word; background: #090720; padding: 6px; border-radius: 8px; margin: 0; font-size: 12px; }
.settings-tent, .log-tent, .card-tent { overflow: auto; }

@media (prefers-reduced-motion: reduce) {
  .tower, .bar, .donkey { transition: none; }
}
