/* ========================================
   Simon Says - game4.fun UI System
   Dark glassmorphism with neon accents
======================================== */

:root {
  --bg-dark: #050510;
  --bg-card: rgba(20, 20, 35, 0.8);
  --primary-neon: #6366f1;
  --secondary-neon: #ec4899;
  --accent-cyan: #06b6d4;
  --text-main: #f1f5f9;
  --text-dim: rgba(148, 163, 184, 0.7);
  --border-glass: rgba(255, 255, 255, 0.1);
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;

  /* Simon button colors */
  --simon-green: #22c55e;
  --simon-green-lit: #4ade80;
  --simon-red: #ef4444;
  --simon-red-lit: #f87171;
  --simon-yellow: #eab308;
  --simon-yellow-lit: #facc15;
  --simon-blue: #3b82f6;
  --simon-blue-lit: #60a5fa;
}

* {
  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: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Background ambient glow */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(circle at 30% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(236, 72, 153, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(6, 182, 212, 0.04) 0%, transparent 60%);
  z-index: -1;
  animation: ambientDrift 20s ease-in-out infinite alternate;
}

@keyframes ambientDrift {
  0% { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(-2%, -1%) rotate(3deg); }
}

/* ========== Game Container ========== */
.game-container {
  flex: 1;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px 32px;
}

.game-header {
  text-align: center;
  padding: 24px 0 8px;
}

.game-header h1 {
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  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.95rem;
  margin-top: 4px;
}

/* ========== Controls ========== */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  flex-wrap: wrap;
}

.mode-selector {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mode-selector label {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mode-btns {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 3px;
  border: 1px solid var(--border-glass);
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.25s ease;
}

.mode-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.mode-btn.active {
  background: var(--primary-neon);
  color: #fff;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

.start-btn {
  background: linear-gradient(135deg, var(--primary-neon), var(--secondary-neon));
  border: none;
  color: #fff;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.45);
}

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

/* ========== Stats Bar ========== */
.stats-bar {
  display: flex;
  justify-content: space-around;
  gap: 8px;
  padding: 14px 20px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-glass);
  backdrop-filter: blur(16px);
  margin-bottom: 20px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent-cyan);
  font-variant-numeric: tabular-nums;
}

.status-text {
  font-size: 0.9rem !important;
  white-space: nowrap;
}

/* ========== Simon Board ========== */
.simon-board {
  display: flex;
  justify-content: center;
  padding: 16px 0;
}

.simon-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  width: min(90vw, 360px);
  height: min(90vw, 360px);
  position: relative;
}

.simon-btn {
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
}

.simon-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.15s ease;
}

/* Green - top-left */
.simon-btn[data-color="green"] {
  background: rgba(34, 197, 94, 0.35);
  border: 2px solid rgba(34, 197, 94, 0.4);
  border-radius: var(--radius-xl) var(--radius-sm) var(--radius-sm) var(--radius-sm);
}

.simon-btn[data-color="green"]:hover {
  background: rgba(34, 197, 94, 0.45);
}

.simon-btn[data-color="green"].lit,
.simon-btn[data-color="green"]:active {
  background: var(--simon-green-lit);
  box-shadow:
    0 0 30px rgba(74, 222, 128, 0.6),
    0 0 60px rgba(74, 222, 128, 0.3),
    inset 0 0 20px rgba(255, 255, 255, 0.2);
  border-color: var(--simon-green-lit);
}

/* Red - top-right */
.simon-btn[data-color="red"] {
  background: rgba(239, 68, 68, 0.35);
  border: 2px solid rgba(239, 68, 68, 0.4);
  border-radius: var(--radius-sm) var(--radius-xl) var(--radius-sm) var(--radius-sm);
}

.simon-btn[data-color="red"]:hover {
  background: rgba(239, 68, 68, 0.45);
}

.simon-btn[data-color="red"].lit,
.simon-btn[data-color="red"]:active {
  background: var(--simon-red-lit);
  box-shadow:
    0 0 30px rgba(248, 113, 113, 0.6),
    0 0 60px rgba(248, 113, 113, 0.3),
    inset 0 0 20px rgba(255, 255, 255, 0.2);
  border-color: var(--simon-red-lit);
}

/* Yellow - bottom-left */
.simon-btn[data-color="yellow"] {
  background: rgba(234, 179, 8, 0.35);
  border: 2px solid rgba(234, 179, 8, 0.4);
  border-radius: var(--radius-sm) var(--radius-sm) var(--radius-sm) var(--radius-xl);
}

.simon-btn[data-color="yellow"]:hover {
  background: rgba(234, 179, 8, 0.45);
}

.simon-btn[data-color="yellow"].lit,
.simon-btn[data-color="yellow"]:active {
  background: var(--simon-yellow-lit);
  box-shadow:
    0 0 30px rgba(250, 204, 21, 0.6),
    0 0 60px rgba(250, 204, 21, 0.3),
    inset 0 0 20px rgba(255, 255, 255, 0.2);
  border-color: var(--simon-yellow-lit);
}

/* Blue - bottom-right */
.simon-btn[data-color="blue"] {
  background: rgba(59, 130, 246, 0.35);
  border: 2px solid rgba(59, 130, 246, 0.4);
  border-radius: var(--radius-sm) var(--radius-sm) var(--radius-xl) var(--radius-sm);
}

.simon-btn[data-color="blue"]:hover {
  background: rgba(59, 130, 246, 0.45);
}

.simon-btn[data-color="blue"].lit,
.simon-btn[data-color="blue"]:active {
  background: var(--simon-blue-lit);
  box-shadow:
    0 0 30px rgba(96, 165, 250, 0.6),
    0 0 60px rgba(96, 165, 250, 0.3),
    inset 0 0 20px rgba(255, 255, 255, 0.2);
  border-color: var(--simon-blue-lit);
}

/* Disabled state during playback */
.simon-btn.disabled {
  pointer-events: none;
  opacity: 0.5;
}

/* Center circle */
.simon-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(160deg, rgba(25, 25, 45, 0.95), rgba(15, 15, 30, 0.98));
  border: 2px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.center-round {
  font-size: 1.8rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary-neon), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ========== Game Over Modal ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: linear-gradient(160deg, rgba(25, 25, 45, 0.95), rgba(15, 15, 30, 0.98));
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 40px;
  text-align: center;
  max-width: 420px;
  width: 90%;
  transform: scale(0.8) translateY(20px);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5), 0 0 40px rgba(99, 102, 241, 0.1);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal h2 {
  font-size: 2rem;
  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;
  margin-bottom: 12px;
}

.modal-sub {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-bottom: 16px;
}

/* Correct sequence display */
.sequence-display {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 20px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
  max-height: 120px;
  overflow-y: auto;
}

.seq-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.seq-dot.green { background: var(--simon-green); }
.seq-dot.red { background: var(--simon-red); }
.seq-dot.yellow { background: var(--simon-yellow); }
.seq-dot.blue { background: var(--simon-blue); }

.win-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 28px;
}

.win-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.win-stat-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.win-stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent-cyan);
}

.play-again-btn {
  background: linear-gradient(135deg, var(--primary-neon), var(--secondary-neon));
  border: none;
  color: #fff;
  padding: 14px 40px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.35);
}

.play-again-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(99, 102, 241, 0.5);
}

/* ========== Ad Container ========== */
.g4f-ad-container {
  max-width: 800px;
  margin: 20px auto;
  padding: 24px;
  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.85rem;
}

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

/* ========== Responsive ========== */
@media (max-width: 480px) {
  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .mode-selector {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .mode-btns {
    width: 100%;
  }

  .mode-btn {
    flex: 1;
    text-align: center;
  }

  .start-btn {
    width: 100%;
  }

  .stats-bar {
    padding: 10px 12px;
    gap: 4px;
  }

  .stat-label {
    font-size: 0.6rem;
  }

  .stat-value {
    font-size: 0.95rem;
  }

  .simon-wrapper {
    gap: 8px;
  }

  .simon-center {
    width: 60px;
    height: 60px;
  }

  .center-round {
    font-size: 1.4rem;
  }

  .modal {
    padding: 28px 24px;
  }

  .sequence-display {
    max-height: 80px;
  }

  .seq-dot {
    width: 16px;
    height: 16px;
  }
}

/* ========== Animations ========== */
@keyframes pulse-border {
  0%, 100% { border-color: var(--accent-cyan); }
  50% { border-color: var(--primary-neon); }
}

.simon-wrapper.playing .simon-center {
  animation: pulse-border 2s ease-in-out infinite;
}
