/* Connect Four — tokens from /assets/base.css */

:root {
  --cols: 7;
  --rows: 6;
  --slot: 52px;
  --slot-gap: 6px;
  --red: #ff5d7a;
  --yellow: #ffc94a;
  --board-bg: rgba(60, 80, 180, 0.18);
  --slot-bg: rgba(0, 0, 0, 0.35);
  --win-glow: 0 0 12px 2px;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.app {
  width: 100%;
  max-width: 600px;
  padding: 0 16px;
  position: relative;
}

/* Header */
.top {
  text-align: center;
  padding: 28px 0 4px;
}
.top h1 {
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Screens */
.screen { margin-bottom: 24px; }
.hidden { display: none !important; }

/* Mode select */
.mode-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 0;
}
.mode-sub {
  color: var(--muted);
  margin-bottom: 28px;
  font-size: 15px;
}
.mode-buttons {
  display: flex;
  gap: 14px;
}
.mode-btn {
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius-md);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
}
.btn:hover {
  background: var(--surface-hover);
  transform: translateY(-1px);
}
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.primary:hover { opacity: 0.9; }
.btn.ghost {
  background: transparent;
  border-color: var(--line);
}
.btn.ghost:hover { background: var(--surface-hover); }

/* Options panels */
.ai-options, .local-options {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 24px;
  animation: pop 0.3s ease-out;
}
.option-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.option-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  min-width: 60px;
}
.option-pills { display: flex; gap: 6px; }
.btn.pill {
  padding: 6px 16px;
  font-size: 13px;
  border-radius: var(--radius-pill);
}
.btn.pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Toggle switches */
.toggles-row {
  display: flex;
  gap: 18px;
  justify-content: center;
}
.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--slot-bg);
  border-radius: 10px;
  transition: background 0.2s;
  display: inline-block;
  flex-shrink: 0;
}
.toggle-track input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  margin: 0;
  z-index: 1;
}
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s, background 0.2s;
  pointer-events: none;
}
.toggle-track input:checked ~ .toggle-thumb {
  transform: translateX(16px);
  background: var(--accent);
}
.toggle-track:has(input:checked) {
  background: rgba(138, 124, 255, 0.25);
}

/* Phase labels */
.phase-label {
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 2px;
}
.game-sub {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

/* Move label */
.move-label {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

/* Turn indicator colors */
.phase-label.red   { color: var(--red); }
.phase-label.yellow { color: var(--yellow); }

/* Score bar */
.score-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-bottom: 10px;
}
.score-player {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}
.score-disc {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}
.score-disc.red    { background: var(--red); }
.score-disc.yellow { background: var(--yellow); }
.score-val {
  font-size: 20px;
  font-weight: 800;
}
.score-sep {
  color: var(--muted);
  font-size: 16px;
}
.streak-badge {
  font-size: 12px;
  color: var(--muted);
}

/* Timer bar */
.timer-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}
.timer-track {
  width: 160px;
  height: 6px;
  background: var(--slot-bg);
  border-radius: 3px;
  overflow: hidden;
}
.timer-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 1s linear;
}
.timer-fill.urgent {
  background: var(--red);
}
.timer-text {
  font-size: 14px;
  font-weight: 700;
  min-width: 28px;
}

/* Board */
.board-area {
  display: flex;
  justify-content: center;
}
.board {
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--slot));
  grid-template-rows: repeat(var(--rows), var(--slot));
  gap: var(--slot-gap);
  padding: 12px;
  background: var(--board-bg);
  border-radius: 12px;
  border: 1px solid var(--line);
  touch-action: none;
  transition: transform 0.1s;
}

/* Slot */
.slot {
  width: var(--slot);
  height: var(--slot);
  border-radius: 50%;
  background: var(--slot-bg);
  cursor: pointer;
  transition: background 0.15s, transform 0.12s, box-shadow 0.2s;
  position: relative;
}
.slot:hover:not(.red):not(.yellow) {
  background: rgba(255, 255, 255, 0.08);
  transform: scale(1.06);
}

/* Column hover highlight */
.slot.col-highlight {
  background: rgba(255, 255, 255, 0.06);
}

/* Filled slots */
.slot.red {
  background: var(--red);
  cursor: default;
}
.slot.yellow {
  background: var(--yellow);
  cursor: default;
}

/* Drop animation */
@keyframes drop {
  0%   { transform: translateY(calc(-1 * (var(--drop-rows, 1) * (var(--slot) + var(--slot-gap))))); opacity: 0.7; }
  60%  { transform: translateY(4px); opacity: 1; }
  80%  { transform: translateY(-2px); }
  100% { transform: translateY(0); }
}
.slot.drop-anim {
  animation: drop 0.35s ease-out;
}

/* Win highlight */
.slot.win {
  box-shadow: var(--win-glow) currentColor;
  z-index: 1;
}
.slot.win.red   { box-shadow: var(--win-glow) var(--red); }
.slot.win.yellow { box-shadow: var(--win-glow) var(--yellow); }

@keyframes win-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.12); }
}
.slot.win {
  animation: win-pulse 0.8s ease-in-out infinite;
}

/* Column hover preview — ghost disc */
.slot.preview-red {
  background: rgba(255, 93, 122, 0.3);
  border: 2px dashed var(--red);
}
.slot.preview-yellow {
  background: rgba(255, 201, 74, 0.3);
  border: 2px dashed var(--yellow);
}

/* Bomb mode */
.slot.bombable {
  cursor: crosshair;
  animation: bomb-pulse 0.6s ease-in-out infinite;
}
@keyframes bomb-pulse {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.5); }
}

.bomb-btn {
  padding: 6px 16px;
  font-size: 13px;
  margin-top: 8px;
}

/* Disabled board */
.board.disabled .slot {
  pointer-events: none;
  cursor: default;
}

/* Board shake on draw */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 50%, 90% { transform: translateX(-4px); }
  30%, 70% { transform: translateX(4px); }
}
.board.shake {
  animation: shake 0.5s ease-in-out;
}

/* Game actions */
.game-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

@keyframes pop {
  0%   { opacity: 0; transform: scale(0.7) translateY(10px); }
  60%  { transform: scale(1.05) translateY(0); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Game over overlay text */
.game-result {
  text-align: center;
  margin-top: 20px;
  animation: pop 0.5s ease-out;
}
.result-title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 4px;
}
.result-title.red   { color: var(--red); }
.result-title.yellow { color: var(--yellow); }
.result-sub {
  font-size: 14px;
  color: var(--muted);
}
.result-sub.streak {
  margin-top: 4px;
  font-weight: 600;
}

/* Confetti canvas */
.confetti-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

/* Mobile */
@media (max-width: 520px) {
  :root { --slot: 40px; --slot-gap: 4px; }
  .mode-btn { padding: 12px 24px; font-size: 15px; }
  .option-group { flex-wrap: wrap; justify-content: center; }
}
@media (max-width: 380px) {
  :root { --slot: 34px; --slot-gap: 3px; }
}
