:root {
  color-scheme: dark;
  --bg: #12162c;
  --bg-glow: #1e2757;
  --panel-bg: linear-gradient(180deg, #232a52, #1c2244);
  --panel-bg-solid: #1e2444;
  --panel-border: #333c6e;
  --panel-border-soft: #4a5490;
  --text: #eef0ff;
  --text-dim: #9aa1c9;
  --accent: #4f7fe0;
  --accent-soft: rgba(79, 127, 224, 0.16);
  --accent-strong: #6a95f0;
  --gold: #f0c14b;
  --gold-strong: #ffd873;
  --gold-soft: rgba(240, 193, 75, 0.14);

  --square-light: #333a63;
  --square-dark: #222848;
  --table-felt: radial-gradient(ellipse at center, #232a52 0%, #12162c 70%);

  --white-piece: #f4f4f2;
  --white-text: #14151f;
  --black-piece: #17181f;
  --black-text: #f2f2f2;
  --red-piece: #e2503f;
  --red-text: #2a0505;
  --green-piece: #3fb06a;
  --green-text: #052a10;
}

* { box-sizing: border-box; }

.hidden { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 900px 500px at 50% -10%, var(--bg-glow), transparent),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 16px 56px;
}

h1 {
  font-size: 25px;
  font-weight: 800;
  letter-spacing: 0.01em;
  margin: 0 0 22px;
  color: var(--text);
}

.subtitle {
  display: block;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-dim);
  margin-top: 6px;
}

.layout {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: flex-start;
}

/* ---------- игровой стол ---------- */

.board {
  --cell: 56px;
  display: grid;
  grid-template-columns: repeat(8, var(--cell));
  grid-template-rows: repeat(8, var(--cell));
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  padding: 14px;
  background: var(--table-felt);
  border: 1px solid var(--panel-border);
  box-shadow:
    0 0 0 1px rgba(79, 127, 224, 0.3),
    0 12px 32px rgba(0, 0, 0, 0.5),
    inset 0 0 40px rgba(0, 0, 0, 0.4);
  max-width: 100%;
  margin: 0 auto;
}

.cell {
  width: var(--cell);
  height: var(--cell);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
}

/* Клетка ужимается на узких экранах, фигуры/кружки взятия/точки следуют
   за ней через calc() от --cell, поэтому пропорции не разъезжаются. */
@media (max-width: 600px) {
  .board { --cell: 42px; padding: 8px; }
}

@media (max-width: 400px) {
  .board { --cell: 34px; padding: 6px; }
}

@media (max-width: 340px) {
  .board { --cell: 30px; padding: 5px; }
}

.cell.light { background: var(--square-light); }
.cell.dark { background: var(--square-dark); }

.cell.selected {
  outline: 3px solid var(--accent-strong);
  outline-offset: -3px;
  box-shadow: inset 0 0 12px rgba(106, 149, 240, 0.5);
}

.cell.legal-move::after {
  content: "";
  position: absolute;
  width: calc(var(--cell) * 0.29);
  height: calc(var(--cell) * 0.29);
  border-radius: 50%;
  background: rgba(106, 149, 240, 0.6);
  box-shadow: 0 0 8px rgba(106, 149, 240, 0.5);
}

.cell.legal-capture::after {
  content: "";
  position: absolute;
  inset: calc(var(--cell) * 0.07);
  border-radius: 50%;
  border: 3px solid rgba(225, 75, 75, 0.85);
}

.piece {
  width: calc(var(--cell) * 0.75);
  height: calc(var(--cell) * 0.75);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: calc(var(--cell) * 0.46);
  line-height: 1;
  z-index: 1;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.25);
  user-select: none;
}

.piece-white { background: radial-gradient(circle at 35% 30%, #ffffff, var(--white-piece) 65%); color: var(--white-text); border: 2px solid #c9c9c9; }
.piece-black { background: radial-gradient(circle at 35% 30%, #2b2d3a, var(--black-piece) 65%); color: var(--black-text); border: 2px solid #45465a; }
.piece-red   { background: radial-gradient(circle at 35% 30%, #f0715f, var(--red-piece) 65%);   color: var(--red-text); border: 2px solid #8a1f1f; }
.piece-green { background: radial-gradient(circle at 35% 30%, #5cce87, var(--green-piece) 65%); color: var(--green-text); border: 2px solid #1f6b3a; }

.piece.king-immune {
  box-shadow: 0 0 0 3px var(--gold), 0 0 10px 2px rgba(240, 193, 75, 0.7), inset 0 1px 2px rgba(255, 255, 255, 0.25);
}

/* ---------- карточные панели ---------- */

.panel {
  flex: 1;
  min-width: 240px;
  background: var(--panel-bg), var(--panel-bg-solid);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.block {
  background: rgba(0, 0, 0, 0.16);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px 14px;
}

.block-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 8px;
}

/* ---------- кости ---------- */

.dice-pair {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.die {
  width: 44px;
  height: 44px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--panel-border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-dim);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
}

.die.rolled {
  color: #1a1406;
  background: linear-gradient(180deg, var(--gold-strong), var(--gold));
  border-color: var(--gold-strong);
  box-shadow: 0 3px 10px rgba(240, 193, 75, 0.45);
}

.dice-sum {
  font-size: 13px;
  color: var(--text-dim);
}

/* ---------- индикаторы ---------- */

.turn-indicator {
  font-size: 17px;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 999px;
  text-align: center;
  border: 2px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.16);
}

.turn-indicator.turn-white { color: var(--white-piece); border-color: var(--white-piece); box-shadow: 0 0 14px rgba(244,244,242,0.15); }
.turn-indicator.turn-black { color: #cfd0e0; border-color: #55586e; }
.turn-indicator.turn-red   { color: var(--red-piece); border-color: var(--red-piece); box-shadow: 0 0 14px rgba(226,80,63,0.2); }
.turn-indicator.turn-green { color: var(--green-piece); border-color: var(--green-piece); box-shadow: 0 0 14px rgba(63,176,106,0.2); }

.turn-timer {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.turn-timer.low-time {
  color: var(--red-piece);
}

.connection-status {
  font-size: 13px;
  color: var(--gold);
  background: var(--gold-soft);
  border: 1px solid rgba(240, 193, 75, 0.4);
  border-radius: 10px;
  padding: 10px 12px;
}

.connection-status.hidden { display: none; }

.big-number {
  font-size: 32px;
  font-weight: 700;
  color: var(--gold);
}

.captured {
  font-size: 14px;
  color: var(--text-dim);
}

/* ---------- кнопки ---------- */

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  display: block;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
  transition: transform 0.1s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(79, 127, 224, 0.4);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 127, 224, 0.5);
}

.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--panel-border-soft);
  color: var(--text-dim);
}

.btn-secondary:hover {
  border-color: var(--accent-strong);
  color: var(--text);
}

/* ---------- лобби ---------- */

.lobby {
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lobby .or {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.join-input {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--panel-border-soft);
  color: var(--text);
  border-radius: 10px;
  padding: 12px;
  font-size: 18px;
  text-align: center;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 700;
}

.join-input:focus {
  outline: none;
  border-color: var(--accent-strong);
}

.lobby-status {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}

.tutorial-link {
  margin-top: 4px;
}

/* ---------- баннеры/модалки ---------- */

.winner-banner {
  background: linear-gradient(180deg, rgba(63,176,106,0.18), rgba(63,176,106,0.06));
  border: 1px solid var(--green-piece);
  color: #7de3a4;
  padding: 14px;
  border-radius: 10px;
  font-weight: 700;
  text-align: center;
}

.winner-banner.hidden { display: none; }

.legend {
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px solid var(--panel-border);
  padding-top: 12px;
}

.legend-title {
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}

.promotion-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.promotion-modal.hidden { display: none; }

.promotion-box {
  background: var(--panel-bg-solid);
  border: 1px solid var(--panel-border-soft);
  border-radius: 16px;
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 260px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.6);
}

.promotion-title {
  font-size: 14px;
  color: var(--text-dim);
  text-align: center;
}

.feedback-box {
  max-width: 420px;
  width: 100%;
}

.feedback-label {
  font-size: 13px;
  color: var(--text-dim);
  margin: 4px 0 -4px;
}

.feedback-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--panel-border-soft);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

.feedback-input:focus {
  outline: none;
  border-color: var(--accent-strong);
}

/* ---------- настройка игры против ботов ---------- */

.bot-setup-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bot-setup-options {
  display: flex;
  gap: 8px;
}

.bot-setup-options .btn {
  padding: 10px 8px;
  font-size: 13px;
}

.bot-setup-options .btn.active {
  background: var(--accent-soft);
  border-color: var(--accent-strong);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--accent-strong) inset;
}

/* ---------- обучение ---------- */

.tutorial-step-counter {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tutorial-title {
  margin: 4px 0 0;
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

.tutorial-text {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
}

.tutorial-nav {
  display: flex;
  gap: 10px;
}

.turn-cycle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
  flex-wrap: wrap;
}

.turn-cycle .dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-block;
}
