:root {
  --red: #e63946;
  --red-glow: #ff4d5a;
  --yellow: #ffd166;
  --yellow-glow: #ffe066;
  --board-blue: #10243d;
  --board-dark: #0a1727;
  --board-accent: #2a6fdb;
  --bg-dark: #050910;
  --bg-gradient: radial-gradient(circle at 20% 20%, rgba(42, 111, 219, 0.12), transparent 35%),
    radial-gradient(circle at 80% 0%, rgba(255, 209, 102, 0.08), transparent 30%), #060b15;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-strong: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --text-light: #f5f8ff;
  --text-muted: #a8b8d8;
  --win-glow: 0 0 30px currentColor, 0 0 60px currentColor;
  --drop-duration: 1.1s;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  background: var(--bg-gradient);
  font-family: "Space Grotesk", "Space Mono", sans-serif;
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: linear-gradient(rgba(69, 123, 157, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(69, 123, 157, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: -1;
}

.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
  max-width: 600px;
  width: 100%;
}

.header {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  animation: fadeSlideDown 0.8s ease-out;
}

@keyframes fadeSlideDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: center;
  text-align: left;
}

.logo {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.titles {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.title {
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(3rem, 10vw, 5rem);
  letter-spacing: 0.1em;
  background: linear-gradient(180deg, #ffffff 0%, #d7e3ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 4px 30px rgba(168, 218, 220, 0.3);
  line-height: 1;
}

.subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 5px;
  opacity: 0.8;
}

.header-actions {
  display: none;
}

.score-panel {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  display: grid;
  gap: 12px;
  animation: fadeSlideDown 0.8s ease-out 0.1s both;
}

.score-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.score-title {
  font-family: "Bebas Neue", sans-serif;
  letter-spacing: 0.12em;
  font-size: 1.1rem;
  text-transform: uppercase;
  margin: 0;
}

.score-meta {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
}

.score-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.player-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 22px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all 0.3s ease;
  min-width: 180px;
}

.player-score.active {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
  transform: scale(1.05);
}

.player-score.red .player-indicator {
  background: var(--red);
  box-shadow: 0 0 20px var(--red);
}

.player-score.yellow .player-indicator {
  background: var(--yellow);
  box-shadow: 0 0 20px var(--yellow);
}

.player-indicator {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  transition: box-shadow 0.3s ease;
}

.player-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
}

.score-value {
  font-family: "Bebas Neue", sans-serif;
  font-size: 2rem;
}

.turn-indicator {
  font-size: 1rem;
  padding: 12px 24px;
  background: var(--surface);
  border-radius: 30px;
  border: 1px solid var(--border);
  animation: fadeSlideDown 0.8s ease-out 0.2s both;
  transition: all 0.3s ease;
}

.turn-indicator.red {
  color: var(--red);
  border-color: rgba(230, 57, 70, 0.3);
  box-shadow: 0 0 20px rgba(230, 57, 70, 0.1);
}

.turn-indicator.yellow {
  color: var(--yellow);
  border-color: rgba(255, 209, 102, 0.3);
  box-shadow: 0 0 20px rgba(255, 209, 102, 0.1);
}

.turn-indicator.ended {
  color: var(--text-muted);
  border-color: var(--border);
  box-shadow: none;
}

.board-wrapper {
  position: relative;
  animation: fadeSlideUp 0.8s ease-out 0.3s both;
}

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.column-previews {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  padding: 0 12px;
  margin-bottom: 10px;
  height: 50px;
}

.preview-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.preview-disc {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.2s ease;
}

.preview-cell:hover .preview-disc {
  opacity: 0.6;
  transform: scale(1);
}

.preview-disc.red {
  background: var(--red);
  box-shadow: 0 0 15px var(--red);
}

.preview-disc.yellow {
  background: var(--yellow);
  box-shadow: 0 0 15px var(--yellow);
}

.board {
  background: linear-gradient(180deg, var(--board-blue) 0%, var(--board-dark) 100%);
  padding: 16px;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 0 4px var(--board-accent),
    inset 0 2px 10px rgba(0, 0, 0, 0.3);
  position: relative;
}

.board::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 18%;
  right: 18%;
  height: 4px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  border-radius: 2px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 8px;
}

.cell {
  width: clamp(48px, 10vw, 64px);
  height: clamp(48px, 10vw, 64px);
  background: var(--bg-dark);
  border-radius: 50%;
  position: relative;
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.6), inset 0 -2px 4px rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: box-shadow 0.2s ease;
}

.cell:hover {
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.6), inset 0 -2px 4px rgba(255, 255, 255, 0.05),
    0 0 15px rgba(255, 255, 255, 0.1);
}

.cell .disc {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  transform: translateY(var(--drop-distance, -700px));
  opacity: 0;
}

.cell .disc.dropped {
  opacity: 1;
  animation: dropDisc var(--drop-duration) cubic-bezier(0.22, 0.7, 0.12, 1) forwards;
}

@keyframes dropDisc {
  0% {
    transform: translateY(-700px);
    opacity: 1;
  }
  65% {
    transform: translateY(0);
  }
  78% {
    transform: translateY(-18px);
  }
  92% {
    transform: translateY(0);
  }
  97% {
    transform: translateY(-6px);
  }
  100% {
    transform: translateY(0);
  }
}

.cell .disc.red {
  background: radial-gradient(circle at 30% 30%, var(--red-glow), var(--red) 60%, #b71c1c);
  box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.3), inset 0 4px 8px rgba(255, 255, 255, 0.2),
    0 2px 10px rgba(230, 57, 70, 0.5);
}

.cell .disc.yellow {
  background: radial-gradient(circle at 30% 30%, #fff3b0, var(--yellow) 60%, #e6a700);
  box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.2), inset 0 4px 8px rgba(255, 255, 255, 0.4),
    0 2px 10px rgba(255, 209, 102, 0.5);
}

.cell .disc.winning {
  animation: winPulse 0.6s ease-in-out infinite alternate;
}

@keyframes winPulse {
  from {
    transform: scale(1);
    filter: brightness(1);
  }
  to {
    transform: scale(1.05);
    filter: brightness(1.3);
  }
}

.cell .disc.winning.red {
  box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.3), inset 0 4px 8px rgba(255, 255, 255, 0.2),
    0 0 30px var(--red), 0 0 60px var(--red);
}

.cell .disc.winning.yellow {
  box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.2), inset 0 4px 8px rgba(255, 255, 255, 0.4),
    0 0 30px var(--yellow), 0 0 60px var(--yellow);
}

.controls {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  justify-content: center;
  animation: fadeSlideUp 0.8s ease-out 0.4s both;
}

.btn {
  font-family: "Space Grotesk", "Space Mono", sans-serif;
  font-size: 0.85rem;
  padding: 12px 24px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-light);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.btn:active {
  transform: translateY(0);
}

.btn.primary {
  background: var(--board-accent);
  border-color: var(--board-accent);
}

.btn.primary:hover {
  background: #5a9ec7;
  border-color: #5a9ec7;
}

.btn.danger {
  background: #c13a3a;
  border-color: #c13a3a;
}

.btn.danger:hover {
  background: #d94848;
  border-color: #d94848;
}

.win-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s ease;
  z-index: 100;
}

.win-overlay.show {
  opacity: 1;
  visibility: visible;
}

.win-message {
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(3rem, 12vw, 6rem);
  letter-spacing: 0.1em;
  text-align: center;
  animation: winBounce 0.6s ease-out;
}

@keyframes winBounce {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.win-message.red {
  color: var(--red);
  text-shadow: 0 0 40px var(--red), 0 0 80px var(--red);
}

.win-message.yellow {
  color: var(--yellow);
  text-shadow: 0 0 40px var(--yellow), 0 0 80px var(--yellow);
}

.win-message.draw {
  color: var(--text-muted);
  text-shadow: 0 0 40px var(--text-muted);
}

.win-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.overlay-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.footer {
  margin-top: 20px;
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.5;
  text-align: center;
  animation: fadeSlideUp 0.8s ease-out 0.5s both;
}

@media (max-width: 500px) {
  .score-panel {
    gap: 20px;
  }

  .player-score {
    padding: 10px 15px;
  }

  .controls {
    flex-direction: column;
    width: 100%;
  }

  .btn {
    width: 100%;
  }
}

.thinking {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.thinking.show {
  display: flex;
}

.thinking-dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--yellow);
  border-radius: 50%;
  animation: thinkingDot 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.thinking-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes thinkingDot {
  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}
