:root {
  --bg: #0a0e14;
  --bg-2: #0f1520;
  --panel: #131a26;
  --panel-2: #182234;
  --border: #263349;
  --border-soft: rgba(255,255,255,0.06);
  --text: #eef3fb;
  --muted: #8a95ab;
  --accent: #22d3ee;
  --accent-2: #0ea5c4;
  --gold: #f5c144;

  --red: #ef4444;
  --red-dark: #b91c1c;
  --green: #22c55e;
  --green-dark: #15803d;
  --yellow: #eab308;
  --yellow-dark: #a16207;
  --blue: #3b82f6;
  --blue-dark: #1d4ed8;

  --cell: #1a2233;
  --cell-light: #202b40;
  --shadow-lg: 0 20px 50px rgba(0,0,0,0.45);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(34,211,238,0.08), transparent 60%),
    radial-gradient(1000px 600px at 100% 0%, rgba(245,193,68,0.06), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ===== HEADER ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: 0 2px 0 rgba(0,0,0,0.3), var(--shadow-md);
  position: sticky; top: 0; z-index: 20;
}
.brand {
  font-family: 'Baloo 2', 'Inter', sans-serif;
  font-weight: 800; font-size: 20px; letter-spacing: 0.3px;
  display: flex; align-items: center; gap: 8px;
}
.brand::before {
  content: '🎲';
  font-size: 22px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
.brand span {
  background: linear-gradient(135deg, var(--gold), #ffe08a 45%, var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.whoami {
  font-size: 12px; color: var(--muted); font-weight: 600;
  background: var(--cell); border: 1px solid var(--border-soft);
  padding: 6px 12px; border-radius: 999px;
}

.status-banner {
  padding: 10px 16px; background: linear-gradient(90deg, rgba(248,113,113,0.14), rgba(248,113,113,0.05));
  color: #fca5a5; border-bottom: 1px solid rgba(248,113,113,0.35); font-size: 12px; font-weight: 600; text-align: center;
}

.view { flex: 1; padding: 24px; display: flex; flex-direction: column; gap: 18px; max-width: 1020px; width: 100%; margin: 0 auto; }

.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border); border-radius: 14px; padding: 20px;
  box-shadow: var(--shadow-md);
  position: relative; overflow: hidden;
}
.panel::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--gold), var(--accent));
  opacity: 0.7;
}
.panel h2 {
  margin: 0 0 14px; font-size: 13px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--accent);
}

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row label { font-size: 12px; color: var(--muted); font-weight: 600; }
select, input[type="text"] {
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 10px 12px; font-size: 13px; font-family: inherit;
}
select:focus, input[type="text"]:focus { outline: none; border-color: var(--accent); }

.btn {
  border: none; border-radius: 9px; padding: 11px 20px; font-size: 13px; font-weight: 700;
  cursor: pointer; transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.15s;
  font-family: inherit; letter-spacing: 0.2px;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, var(--gold), #ffcf5c);
  color: #1a1300;
  box-shadow: 0 6px 16px rgba(245,193,68,0.28);
}
.btn-primary:hover { box-shadow: 0 8px 20px rgba(245,193,68,0.4); }
.btn-ghost {
  background: var(--cell); border: 1px solid var(--border); color: var(--text);
}
.btn-ghost:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; box-shadow: none; }

.room-list { display: flex; flex-direction: column; gap: 10px; }
.room-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--cell); border: 1px solid var(--border-soft); border-radius: 10px; padding: 12px 16px; font-size: 13px;
  transition: border-color 0.15s;
}
.room-row:hover { border-color: var(--accent); }
.empty { color: var(--muted); font-size: 12px; text-align: center; padding: 24px; }

.player-slots { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.player-slot {
  display: flex; align-items: center; gap: 12px; background: var(--cell);
  border: 1px solid var(--border-soft); border-radius: 10px; padding: 10px 14px; font-size: 13px; font-weight: 600;
}
.color-dot {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,0.35), 0 0 0 3px rgba(255,255,255,0.06);
}
.hint { color: var(--muted); font-size: 11px; margin: 12px 0 0; }

/* ===== GAME LAYOUT ===== */
.game-layout { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; justify-content: center; }
.board-wrap {
  width: min(600px, 92vw);
  padding: 14px;
  background: linear-gradient(160deg, #1c2740, #10151f);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(255,255,255,0.03);
}
.board {
  position: relative; width: 100%; aspect-ratio: 1 / 1;
  display: grid; grid-template-columns: repeat(15, 1fr); grid-template-rows: repeat(15, 1fr);
  background: var(--bg-2);
  border: 3px solid #0c1017;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04), inset 0 2px 20px rgba(0,0,0,0.5);
}
.cell { border: 1px solid rgba(255,255,255,0.035); }
.cell.path { background: var(--cell-light); }
.cell.safe {
  background:
    radial-gradient(circle at 50% 45%, rgba(245,193,68,0.28), transparent 65%),
    var(--cell-light);
}
.cell.safe::after {
  content: '★'; display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; color: var(--gold); font-size: 62%;
  filter: drop-shadow(0 0 3px rgba(245,193,68,0.6));
}

.cell.yard-red    { background: radial-gradient(circle at 30% 20%, rgba(239,68,68,0.32), rgba(239,68,68,0.14) 70%); }
.cell.yard-green  { background: radial-gradient(circle at 30% 20%, rgba(34,197,94,0.32), rgba(34,197,94,0.14) 70%); }
.cell.yard-yellow { background: radial-gradient(circle at 30% 20%, rgba(234,179,8,0.32), rgba(234,179,8,0.14) 70%); }
.cell.yard-blue   { background: radial-gradient(circle at 30% 20%, rgba(59,130,246,0.32), rgba(59,130,246,0.14) 70%); }

.cell.home-red    { background: linear-gradient(180deg, rgba(239,68,68,0.65), rgba(239,68,68,0.4)); }
.cell.home-green  { background: linear-gradient(180deg, rgba(34,197,94,0.65), rgba(34,197,94,0.4)); }
.cell.home-yellow { background: linear-gradient(180deg, rgba(234,179,8,0.65), rgba(234,179,8,0.4)); }
.cell.home-blue   { background: linear-gradient(180deg, rgba(59,130,246,0.65), rgba(59,130,246,0.4)); }

.cell.center {
  background:
    conic-gradient(from 0deg, var(--red) 0 25%, var(--green) 0 50%, var(--yellow) 0 75%, var(--blue) 0 100%);
  position: relative;
}
.cell.center::after {
  content: '👑'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 140%; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.6));
}

/* quadrant frame accents around each yard */
.yard-box {
  position: absolute; width: 33.33%; height: 33.33%;
  display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 10%;
  padding: 15%;
}
.yard-box.tl { top: 0; left: 0; }
.yard-box.tr { top: 0; right: 0; }
.yard-box.br { bottom: 0; right: 0; }
.yard-box.bl { bottom: 0; left: 0; }
.yard-slot {
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.16), rgba(255,255,255,0.04) 70%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12), inset 0 3px 6px rgba(0,0,0,0.25);
  display: flex; align-items: center; justify-content: center;
}

.token {
  position: absolute; width: 6.2%; height: 6.2%; border-radius: 50% 50% 50% 4px;
  transform: translate(-50%, -50%) rotate(-45deg);
  box-shadow: 0 3px 6px rgba(0,0,0,0.55), inset 0 2px 3px rgba(255,255,255,0.35), inset 0 -3px 4px rgba(0,0,0,0.25);
  transition: left 0.4s cubic-bezier(.34,1.4,.64,1), top 0.4s cubic-bezier(.34,1.4,.64,1);
  cursor: default; z-index: 5; border: none;
}
.token::after {
  content: ''; position: absolute; inset: 18%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.55), transparent 60%);
  transform: rotate(45deg);
}
.token.movable {
  cursor: pointer;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.85), 0 4px 12px rgba(0,0,0,0.6);
  animation: pulse 0.9s infinite;
}
.token.red    { background: linear-gradient(145deg, #ff8a80, var(--red) 45%, var(--red-dark)); }
.token.green  { background: linear-gradient(145deg, #86efac, var(--green) 45%, var(--green-dark)); }
.token.yellow { background: linear-gradient(145deg, #fde68a, var(--yellow) 45%, var(--yellow-dark)); }
.token.blue   { background: linear-gradient(145deg, #93c5fd, var(--blue) 45%, var(--blue-dark)); }
@keyframes pulse {
  0%,100% { transform: translate(-50%,-50%) rotate(-45deg) scale(1); }
  50% { transform: translate(-50%,-50%) rotate(-45deg) scale(1.22); }
}

/* ===== SIDE PANEL ===== */
.side-panel { width: min(340px, 92vw); display: flex; flex-direction: column; gap: 16px; }
.turn-banner {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; text-align: center; font-weight: 800; font-size: 15px;
  box-shadow: var(--shadow-md);
  letter-spacing: 0.2px;
}
.dice-area {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border); border-radius: 14px; padding: 22px 16px;
  box-shadow: var(--shadow-md);
}
.dice {
  font-size: 52px; line-height: 1;
  width: 84px; height: 84px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #ffffff, #d7dee8);
  border-radius: 16px;
  box-shadow: 0 10px 22px rgba(0,0,0,0.45), inset 0 -4px 6px rgba(0,0,0,0.12), inset 0 3px 4px rgba(255,255,255,0.9);
  color: #10151f;
}
.dice.rolling { animation: diceroll 0.55s ease; }
@keyframes diceroll {
  0%   { transform: rotate(0deg) scale(1); }
  30%  { transform: rotate(140deg) scale(1.08); }
  60%  { transform: rotate(260deg) scale(0.94); }
  100% { transform: rotate(360deg) scale(1); }
}

.players-mini { display: flex; flex-direction: column; gap: 8px; }
.pm-row {
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-size: 12px; font-weight: 600;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.pm-row.active { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(245,193,68,0.3), 0 4px 10px rgba(245,193,68,0.12); }

.log {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px;
  font-size: 11px; color: var(--muted); max-height: 150px; overflow-y: auto;
  font-family: 'Inter', monospace;
}
.log div { margin-bottom: 5px; padding-bottom: 5px; border-bottom: 1px dashed var(--border-soft); }
.log div:last-child { border-bottom: none; }

.modal {
  position: fixed; inset: 0; background: rgba(4,6,10,0.82); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--gold); border-radius: 16px; padding: 34px 30px;
  text-align: center; box-shadow: var(--shadow-lg), 0 0 40px rgba(245,193,68,0.15);
}
.win-text { font-family: 'Baloo 2', sans-serif; font-size: 22px; font-weight: 800; margin-bottom: 20px; color: var(--gold); }

@media (max-width: 640px) {
  .view { padding: 12px; }
  .side-panel { width: 100%; }
  .board-wrap { padding: 8px; }
}
