:root {
  --bg: #1d1430;
  --bg2: #2a1d49;
  --card: #2f2350;
  --accent: #f1c40f;
  --accent2: #e67e22;
  --text: #f3eefc;
  --muted: #b8a9d9;
  --danger: #e74c3c;
  --ok: #2ecc71;
  --border: #4a3a72;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, var(--bg2), var(--bg));
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.brand { font-size: 20px; font-weight: 700; letter-spacing: .5px; }
.brand span { color: var(--accent); }
.admin-link {
  font-size: 13px; color: var(--muted); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 8px;
}

.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }
.center-narrow { max-width: 480px; }

.hero { text-align: center; padding: 28px 12px 8px; }
.hero h1 { font-size: 34px; margin: 0 0 6px; }
.hero p { color: var(--muted); margin: 0; }

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .grid.cols-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px; box-shadow: 0 8px 30px rgba(0,0,0,.25);
}
.card h2 { margin: 0 0 14px; font-size: 19px; }
.card h3 { margin: 18px 0 8px; font-size: 15px; color: var(--muted); }

label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--border); background: #241a40; color: var(--text);
  font-size: 15px;
}
input:focus, select:focus { outline: 2px solid var(--accent); }

.btn {
  display: inline-block; cursor: pointer; border: none; border-radius: 9px;
  padding: 11px 16px; font-size: 15px; font-weight: 600;
  background: var(--accent); color: #2a1d49; transition: filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: #3c2f63; color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 10px; font-size: 13px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 14px; min-height: 18px; }
.pill { display:inline-block; padding:2px 8px; border-radius:20px; font-size:12px; }
.pill.ok { background: rgba(46,204,113,.2); color: var(--ok); }
.pill.off { background: rgba(231,76,60,.2); color: var(--danger); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }

/* ---- Лендинг: входы ---- */
.entries { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
@media (max-width: 720px) { .entries { grid-template-columns: 1fr; } }

/* ---- Игровой экран ---- */
.game-layout { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: 18px; }
@media (max-width: 900px) { .game-layout { grid-template-columns: 1fr; } }

.board {
  position: relative; width: 100%; aspect-ratio: 3 / 2;
  background-size: 100% 100%; background-repeat: no-repeat;
  border-radius: 10px; overflow: hidden;
}
/* Слой фишек поверх изображения доски (выровнен по области клеток). */
.token-layer {
  position: absolute;
  display: grid; grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(8, 1fr);
}
.cell-slot { display: flex; align-items: center; justify-content: center; cursor: pointer; }
.sq {
  position: relative; border: 1px solid var(--border); border-radius: 6px;
  background: #271c47; padding: 3px; font-size: 10px; overflow: hidden;
  display: flex; flex-direction: column; min-height: 0;
}
.sq .num { font-weight: 700; color: var(--accent); font-size: 11px; }
.sq .nm { color: var(--muted); line-height: 1.1; font-size: 9px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sq.goal { background: #3a2f12; border-color: var(--accent); }
.sq.arrow-cell { box-shadow: inset 0 0 0 1px rgba(46,204,113,.55); }
.sq.snake-cell { box-shadow: inset 0 0 0 1px rgba(231,76,60,.55); }
.sq .jump { position: absolute; right: 2px; bottom: 1px; font-size: 9px; font-weight: 700; }
.sq .jump.up { color: var(--ok); }
.sq .jump.down { color: var(--danger); }
.tokens { display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; }
.token { width: 15px; height: 15px; border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 0 5px rgba(0,0,0,.85); }

.players-list { list-style: none; padding: 0; margin: 0; }
.players-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0;
  border-bottom: 1px solid var(--border); }
.players-list .dot { width: 14px; height: 14px; border-radius: 50%; }
.players-list .turn { margin-left: auto; font-size: 11px; color: var(--accent); }

.dice {
  width: 64px; height: 64px; border-radius: 12px; background: #fff; color: #2a1d49;
  font-size: 34px; font-weight: 800; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.35);
}
.dice.rolling { animation: dice-shake .35s linear infinite; }
@keyframes dice-shake {
  0%   { transform: rotate(0)     scale(1);   }
  25%  { transform: rotate(-18deg) scale(1.06); }
  50%  { transform: rotate(12deg)  scale(.97); }
  75%  { transform: rotate(-9deg)  scale(1.04); }
  100% { transform: rotate(0)     scale(1);   }
}
.die-face {
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  width: 100%; height: 100%; padding: 9px; box-sizing: border-box;
}
.die-face span { display: block; }
.die-face .pip {
  width: 11px; height: 11px; border-radius: 50%; background: #2a1d49;
  align-self: center; justify-self: center;
}
.log, .chat-box { height: 180px; overflow-y: auto; background: #241a40;
  border: 1px solid var(--border); border-radius: 9px; padding: 8px; font-size: 13px; }
.log div, .chat-box div { padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.chat-box .me { color: var(--accent); }

.notice { background: rgba(241,196,15,.12); border: 1px solid var(--accent);
  border-radius: 9px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.videos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.vtile { position: relative; background: #000; border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden; aspect-ratio: 4 / 3; }
.vtile video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.vtile .label { position: absolute; left: 4px; bottom: 4px; font-size: 11px;
  background: rgba(0,0,0,.55); padding: 1px 6px; border-radius: 6px; }
.vtile .muted-badge { position: absolute; right: 4px; top: 4px; font-size: 12px; }
.hidden { display: none !important; }
