:root {
  --bg: #08111f;
  --panel: rgba(12, 21, 38, 0.96);
  --panel-2: #111b2f;
  --text: #e5edf8;
  --muted: #9fb0c8;
  --accent: #4cc9f0;
  --accent-2: #8ecae6;
  --border: #2a3953;
  --good: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, sans-serif;
  background: linear-gradient(180deg, #040914, var(--bg));
  color: var(--text);
}
.app-shell { max-width: 1580px; margin: 0 auto; padding: 18px; }
.topbar, .panel, .dice-card, .log-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.24);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  margin-bottom: 18px;
}
.topbar h1, .panel h2, .panel h3 { margin: 0 0 6px; }
.topbar p, .muted, #gameStatus { margin: 0; color: var(--muted); }
.topbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.layout { display: grid; grid-template-columns: 330px 1fr 320px; gap: 18px; }
.panel { padding: 18px; }
.sidebar { align-self: start; }
.stack { display: grid; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inline-input { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
input, select {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
}
.btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  background: var(--accent);
  color: #072132;
  font-weight: 800;
  cursor: pointer;
}
.btn.secondary { background: #334155; color: var(--text); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn.large { width: 100%; font-size: 18px; padding: 14px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 11px;
  background: #0b1324;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  max-width: 100%;
}
.note {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #0b1324;
  color: var(--muted);
  font-size: 14px;
}
.note.success { border-color: rgba(34,197,94,.45); color: #b7f3c9; }
.note.warn { border-color: rgba(245,158,11,.45); color: #fde7b2; }
.hidden { display: none; }
.space-top { margin-top: 20px; }
.rooms-list, .history-list { display: grid; gap: 10px; max-height: 280px; overflow: auto; }
.room-card, .history-card, .stat-card, .profile-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #0b1324;
  padding: 12px;
}
.room-card { display: grid; gap: 8px; }
.room-card .meta, .history-card .meta { color: var(--muted); font-size: 13px; }
.room-card .actions { display: flex; gap: 8px; }
.profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
}
.avatar-badge {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #4cc9f0, #3b82f6);
  color: #062033;
  font-weight: 900;
  font-size: 18px;
}
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-card span { display: block; color: var(--muted); font-size: 12px; }
.stat-card strong { font-size: 22px; }
.game-panel { min-height: 860px; }
.game-header, .players-bar, .action-row, .room-meta, .share-strip {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
}
.wrap { flex-wrap: wrap; }
.players-bar, .room-meta, .share-strip { flex-wrap: wrap; margin: 14px 0 12px; }
.player-pill {
  background: #0b1324;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  min-width: 150px;
}
.player-pill.active { outline: 2px solid var(--accent); }
.player-pill.me { box-shadow: inset 0 0 0 1px rgba(76,201,240,.5); }
.player-color-red { border-left: 6px solid #ef4444; }
.player-color-green { border-left: 6px solid #22c55e; }
.player-color-yellow { border-left: 6px solid #eab308; }
.player-color-blue { border-left: 6px solid #3b82f6; }
.board-wrap { display: flex; justify-content: center; margin: 16px 0; }
.board {
  width: min(74vw, 820px);
  height: min(74vw, 820px);
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  gap: 2px;
  background: #030812;
  padding: 6px;
  border-radius: 20px;
  border: 1px solid var(--border);
}
.cell {
  background: #0a1322;
  border-radius: 6px;
  position: relative;
  border: 1px solid rgba(159,176,200,.07);
  transition: transform 0.12s ease, outline-color 0.12s ease;
}
.cell.track { background: #111827; }
.cell.safe::after {
  content: "★";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--warn);
  font-size: 12px;
}
.cell.home-red { background: rgba(239,68,68,.23); }
.cell.home-green { background: rgba(34,197,94,.23); }
.cell.home-yellow { background: rgba(234,179,8,.24); }
.cell.home-blue { background: rgba(59,130,246,.24); }
.cell.path-red { background: rgba(239,68,68,.40); }
.cell.path-green { background: rgba(34,197,94,.40); }
.cell.path-yellow { background: rgba(234,179,8,.42); }
.cell.path-blue { background: rgba(59,130,246,.40); }
.cell.center { background: linear-gradient(135deg, #ef4444 0 25%, #22c55e 25% 50%, #eab308 50% 75%, #3b82f6 75%); }
.cell.clickable {
  outline: 2px solid var(--accent);
  cursor: pointer;
  transform: scale(1.03);
}
.token {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid white;
  position: absolute;
  box-shadow: 0 2px 10px rgba(0,0,0,.4);
}
.token.red { background: #ef4444; }
.token.green { background: #22c55e; }
.token.yellow { background: #eab308; }
.token.blue { background: #3b82f6; }
.token.t0 { top: 4px; left: 4px; }
.token.t1 { top: 4px; right: 4px; }
.token.t2 { bottom: 4px; left: 4px; }
.token.t3 { bottom: 4px; right: 4px; }
.token.selectable {
  cursor: pointer;
  outline: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(76,201,240,.5), 0 2px 10px rgba(0,0,0,.4);
}
.action-row { align-items: stretch; }
.dice-card, .log-card { padding: 16px; }
.dice-card { min-width: 280px; }
.log-card { flex: 1; }
.log {
  max-height: 260px;
  overflow: auto;
  display: grid;
  gap: 8px;
  font-size: 14px;
}
.log-entry {
  padding: 8px 10px;
  border-radius: 10px;
  background: #0b1324;
  color: var(--muted);
}
.notes-list { padding-left: 18px; color: var(--muted); }
#shareLinkLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; max-width: 400px; }
@media (max-width: 1180px) {
  .layout { grid-template-columns: 1fr; }
  .board { width: min(94vw, 790px); height: min(94vw, 790px); }
}


.list {
  display: grid;
  gap: 8px;
  min-height: 44px;
}
.friend-row, .history-row {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0b1324;
}
.friend-row .row-top, .history-row .row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.mini-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn.small {
  padding: 7px 10px;
  font-size: 12px;
  border-radius: 10px;
}
.history-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}


.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--warn);
  display: inline-block;
  margin-right: 8px;
}
.status-dot.online { background: var(--good); }
.status-dot.offline { background: var(--danger); }


.rule-list {
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}
