:root {
  --bg: #0e1420;
  --bg-elevated: #161e2e;
  --text: #eef2f8;
  --text-dim: #8b96a8;
  --accent: #3ea6ff;
  --success: #34c759;
  --danger: #ff453a;
  --warning: #ffb020;
  --border: #263248;
  --board-light: #eddcc4;
  --board-dark: #a5896a;
  --bar-bg: #0a0f18;
  --point-hi: #f3e29b;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, sans-serif;
  overscroll-behavior: none;
  user-select: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 14px;
  display: flex;
  flex-direction: column;
}

.screen { display: flex; flex-direction: column; align-items: center; flex: 1; }
.screen.hidden { display: none; }

h1 { font-size: 22px; margin: 8px 0; text-align: center; }
h2 { font-size: 24px; margin: 12px 0; text-align: center; }

.balance { font-size: 16px; color: var(--text-dim); margin: 4px 0 16px; }
.balance span { color: var(--warning); font-weight: 700; }

.hint { font-size: 13px; color: var(--text-dim); text-align: center; margin-bottom: 20px; line-height: 1.7; }

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

.stake-btn {
  width: 100%;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.stake-btn:active { background: var(--accent); border-color: var(--accent); }
.stake-btn .sub { font-size: 12px; font-weight: 400; color: var(--text-dim); }

.error-text { color: var(--danger); font-size: 14px; margin-top: 16px; text-align: center; min-height: 20px; }

.spinner {
  width: 44px; height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin: 60px 0 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn {
  padding: 12px 28px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 700;
  margin-top: 16px;
}
.btn.hidden { display: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-small { padding: 8px 20px; font-size: 13px; margin-top: 0; }

.player-row {
  width: 100%;
  max-width: 400px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px;
}
.player-name { font-size: 14px; color: var(--text-dim); font-weight: 600; }
.dice-mini { font-size: 18px; min-height: 22px; }
.off-count { font-size: 13px; color: var(--text-dim); }

.turn-banner {
  width: 100%;
  max-width: 400px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 0;
  color: var(--text-dim);
  min-height: 20px;
}
.turn-banner.mine { color: var(--warning); }

/* ── board: 2 rows of 12 points + a bar column between the 6/7 split ── */
.board-wrap {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 4px 0;
}

.board {
  display: grid;
  grid-template-columns: repeat(6, 1fr) 0.5fr repeat(6, 1fr);
  grid-template-rows: 1fr 1fr;
  width: 100%;
  aspect-ratio: 13 / 9;
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #3a2a1a;
}

.point {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: visible;
  cursor: pointer;
}
.point.row-top { justify-content: flex-start; }
.point.row-bottom { justify-content: flex-end; }

.point .triangle {
  position: absolute;
  top: 0; bottom: 0; left: 0; right: 0;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.point.row-bottom .triangle { clip-path: polygon(0 100%, 100% 100%, 50% 0); }
.point.light .triangle { background: var(--board-light); }
.point.dark .triangle { background: var(--board-dark); }
.point.selected .triangle { background: var(--point-hi); }
.point.destination::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 22%; height: 22%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(62, 166, 255, 0.55);
  z-index: 3;
  pointer-events: none;
}

.point .point-label {
  position: absolute;
  font-size: 9px;
  color: rgba(255,255,255,0.35);
  z-index: 1;
}
.point.row-top .point-label { top: 2px; }
.point.row-bottom .point-label { bottom: 2px; }

.checker-stack {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
  width: 100%;
}
.point.row-top .checker-stack { flex-direction: column; }
.point.row-bottom .checker-stack { flex-direction: column-reverse; }

.checker {
  width: 82%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  margin: 1px auto -4%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}
.checker.white { background: radial-gradient(circle at 34% 28%, #ffffff 0%, #c7c7c7 80%); color: #1a1a1a; box-shadow: inset 0 0 0 1.5px #333; }
.checker.black { background: radial-gradient(circle at 34% 28%, #4a4a4a 0%, #0c0c0c 80%); box-shadow: inset 0 0 0 1.5px #000; }

.bar-col {
  grid-row: 1 / 3;
  background: var(--bar-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  cursor: pointer;
}
.bar-col.destination { box-shadow: inset 0 0 0 2px var(--accent); }
.bar-half { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 30%; }
.bar-count { font-size: 11px; color: var(--text-dim); font-weight: 700; }

.bearoff {
  position: absolute;
  top: 0; bottom: 0;
  width: 8%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  writing-mode: vertical-rl;
}
.bearoff-mine { right: -10%; }
.bearoff.destination { box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent); }
@media (max-width: 420px) { .bearoff { display: none; } }

.dice-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  min-height: 48px;
}
.dice-display { display: flex; gap: 6px; }
.die {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: #fff;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}
.die.used { opacity: 0.28; }

.result-multiplier {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  background: var(--warning);
  color: #1a1a1a;
}

#result-title { font-size: 26px; }
#result-title.win { color: var(--success); }
#result-title.lose { color: var(--danger); }
#result-detail { color: var(--text-dim); font-size: 15px; text-align: center; }

.disconnect-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 22, 0.96);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  z-index: 100;
  text-align: center;
  padding: 20px;
}
.disconnect-overlay.hidden { display: none; }
.disconnect-overlay p { font-size: 17px; font-weight: 700; margin: 4px 0; }
.disconnect-overlay .sub { font-size: 14px; font-weight: 400; color: var(--text-dim); }
