/* Ludo — dark, mobile-first UI. No frameworks, no build step. */
:root {
  --bg: #0b0f14;
  --panel: #121821;
  --panel-2: #182130;
  --line: #24303f;
  --text: #e8eef6;
  --muted: #93a3b5;
  --red: #ef5350;
  --green: #43a047;
  --yellow: #fdd835;
  --blue: #42a5f5;
  --safe: #33465c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100dvh; }

.wrap { max-width: 1020px; margin: 0 auto; padding: 16px 16px 40px; }

header.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand h1 { font-size: 20px; margin: 0; letter-spacing: .3px; }
.brand span { color: var(--muted); font-size: 13px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 220px; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

input {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font-size: 16px; outline: none;
}
input:focus { border-color: #3b6ea5; }
input.code { text-transform: uppercase; letter-spacing: 4px; font-weight: 600; }

button {
  font: inherit; font-size: 15px; font-weight: 600;
  padding: 12px 18px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent; background: #2f7fd1; color: #fff;
  transition: filter .15s, transform .05s;
}
button:hover:not(:disabled) { filter: brightness(1.08); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost { background: transparent; border-color: var(--line); color: var(--text); }
button.warn { background: #b4433f; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tabs button { flex: 1; }
.tabs button.on { background: var(--panel-2); border-color: var(--line); color: var(--text); }

.hint { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 10px 0 0; }

/* ---------- board ---------- */

.layout { display: grid; grid-template-columns: minmax(280px, 1fr) 320px; gap: 18px; }
@media (max-width: 820px) { .layout { grid-template-columns: 1fr; } }

.board-shell { position: relative; }

svg.board { width: 100%; height: auto; display: block; border-radius: 16px; background: var(--panel); }
.cell { fill: #1c2836; stroke: #0b0f14; stroke-width: 1.2; }
.cell.safe { fill: var(--safe); }
.cell.start-red { fill: #7a2b2a; }
.cell.start-green { fill: #245c2a; }
.cell.start-yellow { fill: #7a6a1e; }
.cell.start-blue { fill: #1f4f78; }
.cell.homecol-red { fill: #8d3433; }
.cell.homecol-green { fill: #2c6b32; }
.cell.homecol-yellow { fill: #8b7a22; }
.cell.homecol-blue { fill: #255b88; }
.cell.home { fill: #2b3a4d; }
.cell.lane { fill: #26313f; }

.token { cursor: default; }
.token.sel { cursor: pointer; }
.token circle.body { stroke: #0b0f14; stroke-width: 2; }
.token circle.ring { fill: none; stroke: rgba(255,255,255,.65); stroke-width: 1.4; }
.token.pickable circle.ring { stroke: #fff; stroke-width: 3; animation: pulse 1.1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* ---------- panel ---------- */

.side { display: flex; flex-direction: column; gap: 14px; }

.turnbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line);
}
.dot { width: 16px; height: 16px; border-radius: 50%; flex: 0 0 auto; }
.turnbar .who { font-weight: 600; }
.turnbar .sub { color: var(--muted); font-size: 12px; }

.dice {
  width: 74px; height: 74px; border-radius: 16px; background: #f4f7fb; color: #111;
  display: grid; place-items: center; font-size: 40px; font-weight: 800;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.15);
}
.dice.rolling { animation: shake .5s infinite; }
@keyframes shake {
  0%,100% { transform: rotate(0) }
  25% { transform: rotate(-14deg) scale(1.03) }
  75% { transform: rotate(14deg) scale(1.03) }
}

.players { display: flex; flex-direction: column; gap: 8px; }
.pl {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; background: var(--panel-2);
  border: 1px solid transparent;
}
.pl.active { border-color: #3b6ea5; background: #17273a; }
.pl .nm { flex: 1; font-size: 14px; }
.pl .pips { display: flex; gap: 4px; }
.pip { width: 8px; height: 8px; border-radius: 50%; background: #3a4757; }
.pip.done { background: #e8eef6; }

.log {
  height: 190px; overflow: auto; font-size: 13px; line-height: 1.6; color: var(--muted);
  background: var(--panel-2); border-radius: 10px; padding: 10px 12px;
}
.log div:last-child { color: var(--text); }

.code-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 6px 10px; border-radius: 8px; font-weight: 700; letter-spacing: 3px;
  cursor: pointer; user-select: all;
}
.code-badge small { font-weight: 400; letter-spacing: 0; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: #23303f; border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0;
  transition: opacity .2s; pointer-events: none; z-index: 9; max-width: 90vw;
}
.toast.show { opacity: 1; }

.win {
  padding: 14px; border-radius: 12px; background: #12301c; border: 1px solid #1f6b39;
  color: #bff5cf; font-weight: 600;
}

.hidden { display: none !important; }

footer.foot { margin-top: 22px; color: #5f7183; font-size: 12px; text-align: center; }
