:root {
  --bg: #07080f;
  --sq-light: #161a2e;
  --sq-dark: #0d1022;
  --ink: #e8ecff;
  --muted: #7d86ad;
  --cyan: #19f0ff;
  --magenta: #ff2bd6;
  --lime: #7dff6b;
  --red: #ff2d55;
  --purple: #b44dff;
  --amber: #ffb020;
  --board: min(94vw, 62vh, 560px);
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Sora', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 0 calc(env(safe-area-inset-bottom, 0px) + 18px);
}

.top {
  width: var(--board);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wordmark {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, var(--cyan), var(--magenta), var(--lime), var(--cyan));
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: flow 9s linear infinite;
  filter: drop-shadow(0 0 10px rgba(25, 240, 255, 0.35));
}

.status {
  margin: 0;
  min-height: 1.4em;
  font-size: 0.95rem;
  font-weight: 300;
  color: var(--muted);
}
.status.alert { color: var(--ink); }

.player {
  flex: none;
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
}
.player.you { color: var(--red); text-shadow: 0 0 12px rgba(255, 45, 85, 0.5); }
.player.opponent { color: var(--purple); text-shadow: 0 0 12px rgba(180, 77, 255, 0.5); }
.player.you.black-side { color: var(--purple); text-shadow: 0 0 12px rgba(180, 77, 255, 0.5); }
.player.opponent.black-side { color: var(--red); text-shadow: 0 0 12px rgba(255, 45, 85, 0.5); }

/* The one bold element: a slowly flowing RGB border around the board. */
.board-wrap {
  position: relative;
  width: var(--board);
  height: var(--board);
}

.board-glow {
  position: absolute;
  inset: -3px;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--cyan), var(--magenta), var(--lime), var(--cyan));
  background-size: 300% 100%;
  animation: flow 9s linear infinite;
  filter: blur(7px);
  opacity: 0.75;
}

.board {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 6px;
  overflow: hidden;
  background: var(--sq-dark);
  outline: 2px solid rgba(255, 255, 255, 0.08);
}

.sq {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }

.piece {
  font-size: calc(var(--board) / 8 * 0.78);
  line-height: 1;
  font-family: 'Segoe UI Symbol', 'Noto Sans Symbols 2', 'Apple Symbols', 'DejaVu Sans', sans-serif;
  pointer-events: none;
  user-select: none;
}
.piece.w { color: var(--red); text-shadow: 0 0 6px var(--red), 0 0 16px rgba(255, 45, 85, 0.75); }
.piece.b { color: var(--purple); text-shadow: 0 0 6px var(--purple), 0 0 16px rgba(180, 77, 255, 0.75); }

.sq.last::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(25, 240, 255, 0.14);
  animation: pulse 2.6s ease-in-out infinite;
  pointer-events: none;
}

.sq.selected { box-shadow: inset 0 0 0 2px var(--cyan), inset 0 0 14px rgba(25, 240, 255, 0.6); }

.sq.target::before {
  content: '';
  position: absolute;
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 12px var(--lime);
  opacity: 0.85;
  pointer-events: none;
}
.sq.target.capture::before {
  width: 84%;
  height: 84%;
  background: transparent;
  border: 2px solid var(--lime);
  box-shadow: 0 0 12px var(--lime), inset 0 0 10px rgba(125, 255, 107, 0.5);
}

.sq.in-check { animation: checkpulse 1.4s ease-in-out infinite; }

.actions {
  width: var(--board);
  display: flex;
  gap: 10px;
}

.btn {
  flex: 1;
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.btn.primary {
  border-color: var(--cyan);
  box-shadow: 0 0 14px rgba(25, 240, 255, 0.35), inset 0 0 12px rgba(25, 240, 255, 0.15);
  animation: glow 3s ease-in-out infinite;
}
.btn:disabled { opacity: 0.5; cursor: default; animation: none; }

[hidden] { display: none !important; }

@keyframes flow {
  from { background-position: 0% 0; }
  to { background-position: 300% 0; }
}
@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 10px rgba(25, 240, 255, 0.25), inset 0 0 10px rgba(25, 240, 255, 0.1); }
  50% { box-shadow: 0 0 22px rgba(25, 240, 255, 0.6), inset 0 0 16px rgba(25, 240, 255, 0.25); }
}
@keyframes checkpulse {
  0%, 100% { box-shadow: inset 0 0 0 2px rgba(255, 176, 32, 0.5), inset 0 0 12px rgba(255, 176, 32, 0.4); }
  50% { box-shadow: inset 0 0 0 2px rgba(255, 176, 32, 1), inset 0 0 24px rgba(255, 176, 32, 0.8); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}

/* Player rows with captured-piece trays */
.player-row {
  width: var(--board);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 30px;
}

.tray {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 1px;
  min-height: 1.3rem;
}

.mini {
  font-size: 1.05rem;
  line-height: 1;
  font-family: 'Segoe UI Symbol', 'Noto Sans Symbols 2', 'Apple Symbols', 'DejaVu Sans', sans-serif;
}
.mini.w { color: var(--red); text-shadow: 0 0 6px rgba(255, 45, 85, 0.7); }
.mini.b { color: var(--purple); text-shadow: 0 0 6px rgba(180, 77, 255, 0.7); }

.plus {
  margin-left: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

/* Capture effects */
.piece.ghost {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wash {
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: 6px;
  overflow: hidden;
  pointer-events: none;
  mix-blend-mode: screen;
}

.blob {
  position: absolute;
  filter: blur(10px);
  pointer-events: none;
  will-change: transform, opacity;
}
