:root {
  --bg-deep: #0d1021;
  --bg-panel: #171c36;
  --bg-card: #202749;
  --bg-card-hover: #29325c;
  --text-main: #f8f9ff;
  --text-muted: #a6b0d8;
  --accent-gold: #ffd166;
  --accent-pink: #f15bb5;
  --accent-cyan: #00bbf9;
  --accent-green: #38b000;
  --accent-red: #ff595e;
  --border-subtle: rgba(255, 255, 255, 0.11);
  --shadow-lg: 0 14px 36px rgba(0, 0, 0, 0.45);
  --radius-lg: 18px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: radial-gradient(circle at 15% 15%, #1d2552 0%, var(--bg-deep) 65%);
  color: var(--text-main);
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  overflow-x: hidden;
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 150;
}

.hidden {
  display: none !important;
}

/* Top Bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: rgba(13, 16, 33, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
  gap: 12px;
  min-height: 62px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  font-size: 2rem;
  filter: drop-shadow(0 2px 8px rgba(241, 91, 181, 0.5));
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  background: linear-gradient(90deg, #ffd166, #ff595e, #f15bb5, #00bbf9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  display: block;
}

.topbar-center {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill, .room-pill {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
}

.room-pill {
  background: rgba(255, 209, 102, 0.16);
  color: var(--accent-gold);
  border-color: rgba(255, 209, 102, 0.4);
  letter-spacing: 0.08em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.12s, background 0.15s;
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}

#app-root {
  height: calc(100vh - 62px);
  padding: 16px 20px;
  overflow-y: auto;
}

/* LOBBY LAYOUT */
.lobby-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 18px;
  max-width: 1560px;
  margin: 0 auto;
  min-height: 100%;
}

@media (max-width: 1024px) {
  .lobby-grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: rgba(23, 28, 54, 0.92);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.panel-title {
  font-size: 1.15rem;
  font-weight: 800;
}

.panel-subtitle {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.btn-sm {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 7px 12px;
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
}

.btn-sm:hover {
  background: var(--bg-card-hover);
}

.btn-sm.active {
  background: var(--accent-cyan);
  color: #061224;
  border-color: transparent;
}

/* Dedicated Seat QR Cards */
.seats-qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 14px;
}

.seat-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 14px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: relative;
  transition: border-color 0.2s, transform 0.2s;
}

.seat-card.connected {
  border-color: #38b000;
  box-shadow: 0 0 22px rgba(56, 176, 0, 0.22);
}

.seat-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
}

.seat-top {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.avatar-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  font-size: 1.55rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.seat-name-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 7px 9px;
  color: var(--text-main);
  font-weight: 800;
  font-size: 0.96rem;
}

.qr-box {
  background: #ffffff;
  padding: 8px;
  border-radius: 12px;
  width: 148px;
  height: 148px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.qr-box svg, .qr-box img {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.seat-conn-badge {
  font-size: 0.78rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.seat-card.connected .seat-conn-badge {
  background: rgba(56, 176, 0, 0.22);
  color: #7bf1a8;
}

.seat-open-link {
  font-size: 0.74rem;
  color: var(--accent-cyan);
  text-decoration: none;
  opacity: 0.85;
}

.seat-open-link:hover {
  text-decoration: underline;
  opacity: 1;
}

.team-select-row {
  display: flex;
  gap: 5px;
  width: 100%;
  justify-content: center;
}

.team-chip {
  padding: 4px 8px;
  font-size: 0.74rem;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 700;
}

.team-chip.selected {
  color: #091124;
  font-weight: 800;
  border-color: transparent;
}

/* Settings & Categories */
.setting-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 800;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.seg-btn {
  flex: 1;
  min-width: 90px;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.83rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.seg-btn.active {
  background: linear-gradient(135deg, #00bbf9, #4361ee);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(0, 187, 249, 0.32);
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 7px;
}

.cat-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  opacity: 0.45;
  transition: all 0.15s;
}

.cat-toggle.enabled {
  opacity: 1;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
}

.cat-toggle .cat-icon {
  font-size: 1.15rem;
}

.start-game-btn {
  margin-top: auto;
  padding: 16px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, #38b000, #00c49a);
  color: #ffffff;
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(56, 176, 0, 0.4);
  transition: transform 0.15s;
}

.start-game-btn:hover {
  transform: scale(1.015);
}

/* IN-GAME LAYOUT */
.game-layout {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 18px;
  height: 100%;
  max-width: 1640px;
  margin: 0 auto;
}

@media (max-width: 980px) {
  .game-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
}

/* Winding Board */
.board-panel {
  background: rgba(23, 28, 54, 0.92);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.standings-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.standing-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 2px solid transparent;
  font-weight: 800;
  font-size: 0.92rem;
}

.standing-pill.active-turn {
  border-color: var(--accent-gold);
  box-shadow: 0 0 16px rgba(255, 209, 102, 0.35);
}

.board-snake {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: auto 0;
}

.board-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.board-tile {
  position: relative;
  min-height: 76px;
  border-radius: 13px;
  padding: 7px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  border: 2px solid rgba(255, 255, 255, 0.16);
  background: var(--bg-card);
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.board-tile.active-tile {
  transform: scale(1.05);
  border-color: #ffffff;
  box-shadow: 0 0 22px rgba(255, 255, 255, 0.45);
  z-index: 2;
}

.tile-num {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 0.66rem;
  font-weight: 900;
  opacity: 0.78;
}

.tile-icon {
  font-size: 1.35rem;
  margin-top: 4px;
}

.tile-label {
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
}

.tile-pawns {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 2px;
}

.pawn-token {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  border: 2px solid #ffffff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.55);
  animation: pawnBob 2s ease-in-out infinite;
}

@keyframes pawnBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

/* Quick Mode Scoreboard */
.quick-bars {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: auto 0;
}

.quick-row {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 14px 16px;
  border: 2px solid var(--border-subtle);
}

.quick-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.15rem;
  font-weight: 900;
  margin-bottom: 8px;
}

.quick-bar-track {
  height: 16px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  overflow: hidden;
}

.quick-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* RIGHT STAGE PANEL */
.stage-panel {
  background: linear-gradient(165deg, #1b2244 0%, #131731 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  box-shadow: var(--shadow-lg);
  gap: 14px;
}

.round-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-gold);
}

.final-round-alert {
  background: linear-gradient(90deg, #ff595e, #fb5607);
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  animation: pulseFast 0.9s infinite alternate;
}

@keyframes pulseFast {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

.actor-spotlight {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.06);
  padding: 12px 20px;
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  width: 100%;
  justify-content: center;
}

.actor-avatar-lg {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  font-size: 2.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

.category-banner {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  color: #fff;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3);
}

.category-banner .cat-b-icon {
  font-size: 2rem;
}

.category-banner .cat-b-pt {
  font-size: 1.3rem;
  font-weight: 900;
}

.category-banner .cat-b-en {
  font-size: 0.95rem;
  opacity: 0.9;
  font-weight: 600;
}

/* Dice Stage */
.dice-box {
  width: 104px;
  height: 104px;
  border-radius: 24px;
  background: linear-gradient(145deg, #ffffff, #dfe6ff);
  color: #131731;
  font-size: 3.4rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  margin: 10px auto;
}

/* Timer Circle */
.timer-wrap {
  position: relative;
  width: 196px;
  height: 196px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-svg {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}

.timer-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 12;
}

.timer-fg {
  fill: none;
  stroke: var(--accent-cyan);
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.2s linear, stroke 0.3s;
}

.timer-digits {
  font-size: 3.9rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.timer-wrap.urgent .timer-digits {
  color: var(--accent-red);
  animation: pulseFast 0.45s infinite alternate;
}

.hint-tv-pill {
  background: rgba(255, 209, 102, 0.18);
  border: 1px solid rgba(255, 209, 102, 0.5);
  color: var(--accent-gold);
  padding: 8px 14px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 0.95rem;
}

.buzz-toast-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.buzz-toast {
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  font-weight: 800;
  font-size: 0.95rem;
  animation: slidePop 0.25s ease-out;
}

@keyframes slidePop {
  from { transform: scale(0.88); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Turn Result Card Reveal */
.revealed-card-box {
  width: 100%;
  background: linear-gradient(145deg, #27305e, #1d2449);
  border: 2px solid var(--accent-gold);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
}

.rev-pt {
  font-size: 1.55rem;
  font-weight: 900;
  color: #ffffff;
  margin-bottom: 6px;
}

.rev-en {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.gain-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.gain-item {
  background: rgba(56, 176, 0, 0.18);
  border: 1px solid rgba(56, 176, 0, 0.45);
  padding: 9px 14px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 0.98rem;
}

.tablet-fallback-btn {
  padding: 12px 20px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: var(--bg-card-hover);
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
}

.tablet-fallback-btn.primary {
  background: linear-gradient(135deg, #00bbf9, #4361ee);
  border: none;
}

/* Podium / Game Over */
.podium-screen {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
  padding: 20px;
}

.champion-card {
  background: linear-gradient(145deg, #32285a, #1d1b3a);
  border: 3px solid var(--accent-gold);
  border-radius: 24px;
  padding: 26px 40px;
  box-shadow: 0 16px 45px rgba(255, 209, 102, 0.25);
}

.awards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  width: 100%;
}

.award-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 16px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 18, 0.82);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120;
  padding: 20px;
}

.modal-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 22px;
  max-width: 960px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.close-btn {
  background: var(--bg-card);
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
}

.modal-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.modal-qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
