/* ========================================
   Connect Four - game4.fun
   Dark glassmorphism theme
======================================== */

:root {
  --bg-dark: #0a0a1a;
  --bg-card: rgba(255, 255, 255, 0.04);
  --primary-neon: #6366f1;
  --secondary-neon: #ec4899;
  --accent-cyan: #06b6d4;
  --text-main: #f0f0f5;
  --text-dim: rgba(240, 240, 245, 0.5);
  --border-glass: rgba(255, 255, 255, 0.08);
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 10px;

  --cell-size: min(52px, 12vw);
  --board-gap: 4px;
  --board-pad: 8px;
}

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

body {
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

/* ---- Header ---- */
.g4f-header {
  width: 100%;
  max-width: 600px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-main);
  font-size: 1.1rem;
  font-weight: 700;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary-neon), var(--secondary-neon));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.2rem;
  color: #fff;
}

.highlight-4 {
  color: var(--primary-neon);
  font-weight: 800;
}

.lang-switch {
  display: flex;
  gap: 6px;
}

.lang-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.25s ease;
}

.lang-btn.active {
  color: var(--text-main);
  border-color: var(--primary-neon);
  background: rgba(99, 102, 241, 0.15);
}

/* ---- Game Container ---- */
.game-container {
  width: 100%;
  max-width: 500px;
  padding: 0 20px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.game-header {
  text-align: center;
}

.game-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-neon), var(--secondary-neon));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 4px;
}

/* ---- Glass Panel ---- */
.glass-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 12px 16px;
  width: 100%;
}

/* ---- Mode Selector ---- */
.mode-selector {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-group,
.difficulty-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mode-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  min-width: 60px;
}

.mode-buttons {
  display: flex;
  gap: 6px;
  flex: 1;
}

.mode-btn,
.diff-btn {
  flex: 1;
  padding: 8px 4px;
  background: transparent;
  border: 1px solid var(--border-glass);
  color: var(--text-dim);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.25s ease;
}

.mode-btn.active {
  color: var(--text-main);
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.12);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.15);
}

.diff-btn.active {
  color: var(--text-main);
  border-color: var(--secondary-neon);
  background: rgba(236, 72, 153, 0.12);
  box-shadow: 0 0 12px rgba(236, 72, 153, 0.15);
}

/* ---- Status ---- */
.status {
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  padding: 10px 16px;
  transition: all 0.3s ease;
}

.status.p1-turn {
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.1);
}

.status.p2-turn {
  border-color: rgba(236, 72, 153, 0.3);
  box-shadow: 0 0 16px rgba(236, 72, 153, 0.1);
}

.status.game-over {
  border-color: rgba(6, 182, 212, 0.4);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.15);
}

/* ---- Board ---- */
.board-wrapper {
  position: relative;
  width: fit-content;
}

.board {
  display: flex;
  flex-direction: column;
  background: rgba(30, 30, 60, 0.6);
  border: 2px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: var(--board-pad);
  backdrop-filter: blur(8px);
}

/* Ghost row */
.ghost-row {
  display: grid;
  grid-template-columns: repeat(7, var(--cell-size));
  gap: var(--board-gap);
  margin-bottom: 4px;
  padding: 0 2px;
}

.ghost-disc {
  width: var(--cell-size);
  height: calc(var(--cell-size) * 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.ghost-disc::after {
  content: '';
  width: calc(var(--cell-size) * 0.7);
  height: calc(var(--cell-size) * 0.7);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.ghost-disc.show-p1::after {
  opacity: 0.35;
  background: var(--primary-neon);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.3);
}

.ghost-disc.show-p2::after {
  opacity: 0.35;
  background: var(--secondary-neon);
  box-shadow: 0 0 12px rgba(236, 72, 153, 0.3);
}

/* Board grid */
.board-grid {
  display: grid;
  grid-template-columns: repeat(7, var(--cell-size));
  grid-template-rows: repeat(6, var(--cell-size));
  gap: var(--board-gap);
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-glass);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}

.cell:hover:not(.taken):not(.game-over-cell) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Disc inside cell */
.cell .disc {
  width: 82%;
  height: 82%;
  border-radius: 50%;
  position: absolute;
}

.cell .disc.p1 {
  background: radial-gradient(circle at 35% 35%, #818cf8, var(--primary-neon));
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.5), inset 0 -2px 4px rgba(0, 0, 0, 0.3);
}

.cell .disc.p2 {
  background: radial-gradient(circle at 35% 35%, #f472b6, var(--secondary-neon));
  box-shadow: 0 0 12px rgba(236, 72, 153, 0.5), inset 0 -2px 4px rgba(0, 0, 0, 0.3);
}

/* Drop animation */
.cell .disc.dropping {
  animation: discDrop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes discDrop {
  0% {
    transform: translateY(calc(-100% - var(--drop-distance, 300px)));
    opacity: 0.7;
  }
  60% {
    opacity: 1;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Win glow */
.cell.win-cell .disc {
  animation: winPulse 1s ease-in-out infinite alternate;
}

.cell.win-cell .disc.p1 {
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.7), 0 0 40px rgba(99, 102, 241, 0.3);
}

.cell.win-cell .disc.p2 {
  box-shadow: 0 0 20px rgba(236, 72, 153, 0.7), 0 0 40px rgba(236, 72, 153, 0.3);
}

@keyframes winPulse {
  0% { transform: scale(1); filter: brightness(1); }
  100% { transform: scale(1.08); filter: brightness(1.3); }
}

/* ---- Scoreboard ---- */
.scoreboard {
  display: flex;
  justify-content: space-around;
  text-align: center;
  gap: 8px;
}

.score-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.score-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.score-value {
  font-size: 1.4rem;
  font-weight: 800;
}

.score-p1 .score-value { color: var(--primary-neon); }
.score-p2 .score-value { color: var(--secondary-neon); }
.score-draw .score-value { color: var(--text-dim); }

/* ---- Buttons ---- */
.actions {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 420px;
}

.btn {
  flex: 1;
  padding: 12px 12px;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
  background: var(--bg-card);
  color: var(--text-main);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(236, 72, 153, 0.2));
  border-color: rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.35), rgba(236, 72, 153, 0.35));
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.2);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
}

/* ---- Ad Container ---- */
.g4f-ad-container {
  width: 100%;
  max-width: 500px;
  margin: 8px auto;
  padding: 20px;
  text-align: center;
  background: var(--bg-card);
  border: 1px dashed var(--border-glass);
  border-radius: var(--radius-lg);
}

.ad-placeholder-content {
  color: var(--text-dim);
  font-size: 0.8rem;
}

/* ---- Footer ---- */
.footer {
  width: 100%;
  text-align: center;
  padding: 20px;
  color: var(--text-dim);
  font-size: 0.78rem;
}

/* ---- Responsive ---- */
@media (max-width: 400px) {
  :root {
    --cell-size: 11.5vw;
    --board-gap: 3px;
    --board-pad: 6px;
  }

  .game-header h1 {
    font-size: 1.3rem;
  }

  .actions {
    flex-wrap: wrap;
  }
}

@media (min-width: 520px) {
  :root {
    --cell-size: 60px;
    --board-gap: 5px;
    --board-pad: 10px;
  }
}
