* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #1d2024;
  color: #e8e6e0;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
}

.screen { display: none; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }

.btn {
  font: inherit; font-weight: 700; font-size: 17px;
  background: #33373d; color: #e8e6e0;
  border: none; border-radius: 8px;
  padding: 14px 18px; cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: #f5c518; color: #17181a; }
.btn.primary:disabled { background: #4a4d52; color: #8a8d92; }
.btn.slim { padding: 10px 14px; font-size: 15px; font-weight: 600; }
.btn.toggle.on { background: #f5c518; color: #17181a; }

input {
  font: inherit; font-size: 17px;
  background: #2a2d32; color: #e8e6e0;
  border: 2px solid #3a3e44; border-radius: 8px;
  padding: 13px 14px; outline: none; width: 100%;
}
input:focus { border-color: #f5c518; }

.err { color: #e0574e; font-size: 14px; min-height: 18px; text-align: center; }
.hint { color: #8a8d92; font-size: 13px; text-align: center; }
.hidden { display: none !important; }

/* -------- home -------- */
.home-wrap {
  margin: auto; width: min(92vw, 380px);
  display: flex; flex-direction: column; gap: 14px;
  padding: 24px 0 40px;
}
.logo { text-align: center; margin-bottom: 10px; }
.logo-bus { font-size: 64px; filter: drop-shadow(0 6px 12px rgba(245,197,24,.25)); }
.logo h1 {
  font-size: 44px; letter-spacing: 4px; color: #f5c518;
  font-weight: 900; text-shadow: 3px 3px 0 #17181a;
}
.tagline { color: #b9b6ae; font-size: 15px; line-height: 1.45; margin-top: 6px; }
.join-row { display: flex; gap: 10px; }
.join-row input { width: 110px; text-transform: uppercase; text-align: center; letter-spacing: 4px; font-weight: 800; }
.join-row .btn { flex: 1; }

/* -------- lobby -------- */
.lobby-wrap {
  margin: auto; width: min(92vw, 380px);
  display: flex; flex-direction: column; gap: 14px; padding: 24px 0;
}
.lobby-label { color: #8a8d92; text-align: center; font-size: 14px; }
.lobby-code {
  text-align: center; font-size: 56px; font-weight: 900;
  letter-spacing: 12px; color: #f5c518; padding-left: 12px;
}
.players { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.players li {
  background: #2a2d32; border-radius: 8px; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px; font-weight: 600;
}
.players .dot { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.players .tag { margin-left: auto; font-size: 12px; color: #8a8d92; font-weight: 500; }
.lobby-actions { display: flex; gap: 10px; }
.lobby-actions .primary { flex: 1; }

/* -------- game -------- */
#scr-game { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.game-top {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 4px;
}
.g-round { font-weight: 800; font-size: 15px; }
.g-event { font-size: 13px; color: #f5c518; font-weight: 600; flex: 1; text-align: center; }
.g-timer { font-weight: 800; font-size: 15px; min-width: 34px; text-align: right; color: #b9b6ae; }
.g-timer.low { color: #e0574e; }

.standings {
  display: flex; gap: 6px; overflow-x: auto; padding: 2px 12px 6px;
  scrollbar-width: none;
}
.standings::-webkit-scrollbar { display: none; }
.st-chip {
  flex: none; display: flex; align-items: center; gap: 5px;
  background: #2a2d32; border-radius: 6px; padding: 4px 8px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.st-chip .dot { width: 10px; height: 10px; border-radius: 3px; }
.st-chip.me { outline: 2px solid #f5c518; }
.st-chip .stall { color: #e0574e; }

.canvas-wrap { position: relative; width: 100%; }
#board { display: block; width: 100%; height: auto; }
.g-log {
  position: absolute; left: 8px; bottom: 8px; right: 56px;
  display: flex; flex-direction: column; gap: 3px;
  pointer-events: none; font-size: 12.5px; font-weight: 600;
}
.g-log div {
  background: rgba(23, 24, 26, .82); border-radius: 6px;
  padding: 4px 8px; width: fit-content; max-width: 100%;
}
.btn-fast {
  position: absolute; right: 8px; bottom: 8px;
  width: 40px; height: 40px; border-radius: 8px; border: none;
  background: rgba(23,24,26,.82); color: #e8e6e0; font-size: 18px;
}
.btn-fast.on { background: #f5c518; }

.my-panel {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; min-height: 34px; flex-wrap: wrap;
}
.my-money { font-weight: 900; font-size: 18px; color: #f5c518; }
.my-dmg { color: #e0574e; font-size: 14px; letter-spacing: 1px; }
.pax-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: #2a2d32; border-radius: 6px; padding: 3px 7px;
  font-size: 12px; font-weight: 700;
}
.pax-chip .to { width: 10px; height: 10px; border-radius: 50%; }
.pax-chip.standing { border: 1px dashed #f5c518; }

.prog-area { padding: 4px 12px 12px; }
.slots { display: flex; gap: 8px; margin-bottom: 8px; }
.slot {
  flex: 1; height: 64px; border: 2px dashed #3a3e44; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.slot .slot-n { position: absolute; top: 3px; left: 7px; font-size: 11px; color: #6a6d72; font-weight: 700; }
.slot.filled { border-style: solid; border-color: #f5c518; background: #2a2d32; }

.hand {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px;
  scrollbar-width: none; min-height: 76px;
}
.hand::-webkit-scrollbar { display: none; }
.card {
  flex: none; width: 84px; height: 68px;
  background: #2f3237; border-radius: 10px; border: 2px solid #3a3e44;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-weight: 700; cursor: pointer; position: relative;
}
.card.used { opacity: .25; pointer-events: none; }
.card .ic { font-size: 20px; line-height: 1; }
.card .nm { font-size: 10.5px; color: #b9b6ae; }
.card .pr { position: absolute; top: 3px; right: 6px; font-size: 10px; color: #6a6d72; font-weight: 800; }
.card.spec { border-color: #a15fd0; }
.slot .card { width: 100%; height: 100%; border: none; background: transparent; }

.prog-actions { display: flex; gap: 10px; margin-top: 4px; }
.prog-actions .primary { flex: 1; }

.wait-note {
  text-align: center; color: #8a8d92; padding: 18px; font-weight: 600;
}

.event-banner {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(23,24,26,.78); z-index: 50; flex-direction: column; gap: 8px;
  text-align: center; padding: 20px;
}
.event-banner .ev-name { font-size: 34px; font-weight: 900; color: #f5c518; }
.event-banner .ev-desc { font-size: 16px; color: #d8d5cd; }

/* -------- game over -------- */
.over-wrap {
  margin: auto; width: min(92vw, 400px);
  display: flex; flex-direction: column; gap: 14px; padding: 24px 0;
}
.over-wrap h2 { text-align: center; font-size: 34px; color: #f5c518; font-weight: 900; }
.over-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.over-list li {
  background: #2a2d32; border-radius: 8px; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px; font-weight: 700;
}
.over-list .place { width: 26px; text-align: center; font-size: 18px; }
.over-list .dot { width: 14px; height: 14px; border-radius: 4px; }
.over-list .cash { margin-left: auto; color: #f5c518; font-weight: 900; }
.over-list li.winner { outline: 2px solid #f5c518; }
