* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #07070f;
  --panel: rgba(13,16,33,0.7);
  --line: rgba(255,255,255,0.12);
  --accent: #e879f9;
  --black: #15152a;
  --white: #f3f4f6;
  --text: #eef2ff;
  --muted: rgba(238,242,255,0.5);
}
html, body {
  height: 100%;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(232,121,249,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 110%, rgba(34,211,238,0.10) 0%, transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
body { display: flex; justify-content: center; }

/* Screens */
.screen {
  display: none;
  width: 100%;
  max-width: 520px;
  min-height: 100vh;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 40px;
}
.screen.active { display: flex; }

/* Start */
#screen-start { justify-content: center; gap: 8px; }
.logo {
  font-weight: 800;
  font-size: 2.4rem;
  letter-spacing: .02em;
  background: linear-gradient(100deg, #e879f9, #818cf8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 14px rgba(232,121,249,0.45));
}
.logo-sub { color: var(--muted); margin-bottom: 28px; font-size: .95rem; }
.start-actions { display: flex; flex-direction: column; gap: 12px; width: 220px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 18px; border-radius: 12px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); font-size: 1rem; font-weight: 700;
  cursor: pointer; text-decoration: none; transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.96); }
.btn-primary {
  background: linear-gradient(120deg, rgba(232,121,249,0.18), rgba(129,140,248,0.18)), rgba(13,16,33,0.75);
  border-color: rgba(232,121,249,0.65);
  box-shadow: 0 0 14px rgba(232,121,249,0.3);
}
.btn-primary:hover { box-shadow: 0 0 20px rgba(232,121,249,0.5); border-color: #e879f9; }
.btn-primary:active { box-shadow: 0 0 24px rgba(232,121,249,0.6); }
.btn.back { margin-top: 20px; width: 200px; }

/* Mode */
#screen-mode { justify-content: center; }
.menu-title { font-weight: 800; font-size: 1.3rem; margin-bottom: 22px; }
.menu-list { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 320px; }
.menu-btn {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  cursor: pointer; transition: transform .08s;
}
.menu-btn:active { transform: scale(.97); }
.menu-btn .icon { font-size: 1.8rem; }
.menu-btn .labels { display: flex; flex-direction: column; align-items: flex-start; }
.label-main { font-weight: 800; font-size: 1.05rem; }
.label-sub { color: var(--muted); font-size: .82rem; }

/* Game */
.topbar {
  width: 100%; max-width: 460px;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.topbar .title { font-weight: 800; font-size: 1.15rem; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  font-size: 1.2rem; cursor: pointer;
}
.icon-btn:active { transform: scale(.94); }

.stocks { display: flex; gap: 12px; margin-bottom: 10px; }
.stock {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line);
  font-weight: 700; transition: box-shadow .2s, border-color .2s;
}
.stock.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(232,121,249,.25), 0 0 14px rgba(232,121,249,.3); }
.dot { width: 16px; height: 16px; border-radius: 50%; display: inline-block; }
.dot.black { background: #1b1b33; border: 1px solid rgba(232,121,249,.6); box-shadow: 0 0 6px rgba(232,121,249,.35); }
.dot.white { background: #f3f4f6; box-shadow: 0 0 6px rgba(34,211,238,.45); }
.stock .who { color: var(--muted); font-size: .85rem; }
.stock .num { font-variant-numeric: tabular-nums; min-width: 22px; text-align: right; }

.status {
  font-weight: 800; font-size: 1.05rem; margin-bottom: 14px;
  min-height: 1.4em; text-align: center;
}

/* Board frame: 9x9 grid (7 cells + control rings) */
.board-frame {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  width: min(94vw, 460px);
  aspect-ratio: 1 / 1;
  gap: 3px;
  touch-action: manipulation;
}
.cell, .ctrl, .corner {
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px;
}
.cell {
  background: var(--panel);
  border: 1px solid var(--line);
  position: relative;
}
.piece {
  width: 74%; height: 74%; border-radius: 50%;
  transition: transform .12s ease;
}
.piece.black {
  background: radial-gradient(circle at 35% 30%, #3a3356, #14122a);
  box-shadow: 0 0 0 1.5px rgba(232,121,249,.7), 0 0 10px rgba(232,121,249,.4), 0 1px 3px rgba(0,0,0,.5);
}
.piece.white {
  background: radial-gradient(circle at 35% 30%, #ffffff, #c7d6e8);
  box-shadow: 0 0 0 1.5px rgba(34,211,238,.55), 0 0 10px rgba(34,211,238,.4), 0 1px 3px rgba(0,0,0,.4);
}
.cell.flash { animation: flash .5s ease; }
.cell.win { background: rgba(232,121,249,.25); border-color: var(--accent); box-shadow: 0 0 12px rgba(232,121,249,.45); }
@keyframes flash {
  0% { background: rgba(34,211,238,.5); }
  100% { background: var(--panel); }
}
.cell.win.flash { animation: none; }

.ctrl {
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  background: transparent;
  border: none;
  transition: color .12s, transform .08s;
}
.ctrl:hover { color: var(--accent); text-shadow: 0 0 10px rgba(232,121,249,.6); }
.ctrl:active { transform: scale(.8); }
.ctrl.disabled { color: rgba(238,242,255,.18); pointer-events: none; }
.corner { background: transparent; }

.board-frame.locked .ctrl { pointer-events: none; opacity: .5; }

.hint {
  margin-top: 16px; max-width: 420px; text-align: center;
  color: var(--muted); font-size: .8rem; line-height: 1.5;
}

/* Overlays */
.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(4,4,15,.78);
  align-items: center; justify-content: center;
  padding: 24px; z-index: 50;
}
.overlay.show { display: flex; }
.result-box, .info-box {
  background: rgba(13,16,33,0.92);
  border: 1px solid var(--line);
  box-shadow: 0 0 24px rgba(232,121,249,.18);
  border-radius: 18px;
  padding: 28px 24px;
  width: 100%; max-width: 360px;
  text-align: center;
}
.result-icon { font-size: 3rem; margin-bottom: 6px; }
.result-text { font-weight: 800; font-size: 1.4rem; margin-bottom: 22px; }
.result-actions { display: flex; flex-direction: column; gap: 10px; }

.info-box { text-align: left; max-width: 400px; }
.info-title { font-weight: 800; font-size: 1.2rem; margin-bottom: 14px; text-align: center; }
.info-body { color: rgba(238,242,255,.8); font-size: .92rem; line-height: 1.6; margin-bottom: 18px; }
.info-body p { margin-bottom: 10px; }
.info-body ul { padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.info-box .btn-primary { width: 100%; }
