@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap');

:root {
  --bg-dark: url('https://images.unsplash.com/photo-1506744038136-46273834b3fb?auto=format&fit=crop&w=1350&q=80')
    no-repeat center center fixed;
  --bg-light-color: #f4f4f8;
  --text-dark: #ffffff;
  --text-light: #222222;
  --accent: #29a3a3;
  --accent-dark: #1e7a7a;
  --panel-dark: rgba(0, 0, 0, 0.6);
  --panel-light: rgba(255, 255, 255, 0.9);
}

/* THEMES */
body.dark-theme {
  background: var(--bg-dark);
  background-size: cover;
  color: var(--text-dark);
}

body.light-theme {
  background: var(--bg-light-color);
  color: var(--text-light);
}

/* General layout */
body {
  margin: 0;
  padding: 0;
  height: 100vh;
  font-family: 'Poppins', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

h1 {
  margin-bottom: 10px;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.7);
}

/* Screens */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.screen.active {
  display: flex;
}

.menu-panel {
  background: var(--panel-dark);
  padding: 20px 30px;
  border-radius: 20px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 250px;
}

body.light-theme .menu-panel {
  background: var(--panel-light);
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.15);
}

.menu-panel button {
  padding: 10px 20px;
  font-size: 1rem;
  background-color: var(--accent);
  color: #fff;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  box-shadow: 0 0 12px var(--accent);
  transition: background-color 0.3s, box-shadow 0.3s, transform 0.1s;
}

.menu-panel button:hover {
  background-color: var(--accent-dark);
  box-shadow: 0 0 18px var(--accent-dark);
  transform: translateY(-1px);
}

.grid-options label {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
}

.menu-buttons-row {
  margin-top: 12px;
  display: flex;
  gap: 10px;
}

/* Bottom-left credit */
.made-by {
  position: fixed;
  bottom: 12px;
  left: 14px;
  font-size: 0.95rem;
  color: #d0d0d0;
  font-weight: 400;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
  letter-spacing: 0.5px;
}

/* Top controls row */
.top-controls {
  display: flex;
  gap: 15px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

#modeSelect {
  background: var(--panel-dark);
  padding: 10px 20px;
  border-radius: 30px;
  display: flex;
  gap: 15px;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.8);
}

body.light-theme #modeSelect {
  background: var(--panel-light);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

#modeSelect label {
  font-weight: 600;
  font-size: 0.98rem;
}

#modeSelect input[type='radio'] {
  margin-right: 6px;
  accent-color: var(--accent);
}

/* AI Difficulty */
#aiDifficulty {
  background: var(--panel-dark);
  padding: 10px 16px;
  border-radius: 20px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.7);
  font-size: 0.95rem;
}

body.light-theme #aiDifficulty {
  background: var(--panel-light);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

#aiDifficulty select {
  margin-left: 6px;
  padding: 3px 6px;
  border-radius: 8px;
  border: none;
  outline: none;
}

/* Theme toggle switch */
#themeToggleWrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-dark);
  padding: 6px 14px;
  border-radius: 20px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.7);
  font-size: 0.85rem;
}

body.light-theme #themeToggleWrapper {
  background: var(--panel-light);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.theme-label {
  opacity: 0.9;
}

/* Toggle switch design */
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #ccc;
  border-radius: 34px;
  transition: 0.3s;
}

.slider::before {
  position: absolute;
  content: '';
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.3s;
}

input:checked + .slider {
  background-color: var(--accent);
}

input:checked + .slider::before {
  transform: translateX(18px);
}

/* Board */
#board {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
  background: var(--panel-dark);
  padding: 20px;
  border-radius: 15px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
}

body.light-theme #board {
  background: var(--panel-light);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
}

.cell {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid #444;
  font-size: 3rem;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

body.light-theme .cell {
  background: rgba(0, 0, 0, 0.04);
  color: #222;
  border-color: #999;
}

.cell:hover:not(.disabled) {
  transform: scale(1.1);
  background-color: rgba(255, 255, 255, 0.2);
}

body.light-theme .cell:hover:not(.disabled) {
  background-color: rgba(0, 0, 0, 0.09);
}

.cell.disabled {
  cursor: default;
  color: #888;
}

#status {
  font-size: 1.2rem;
  margin-bottom: 8px;
  min-height: 30px;
  text-shadow: 0 0 5px rgba(0, 0, 0, 0.6);
}

/* Scoreboard as cards (inside Performance modal) */
#scoreboard {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin: 10px 0;
}

.score-card {
  min-width: 90px;
  background: var(--panel-dark);
  padding: 8px 14px;
  border-radius: 16px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.7);
}

body.light-theme .score-card {
  background: var(--panel-light);
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.15);
}

.score-title {
  font-size: 0.85rem;
  opacity: 0.9;
}

.score-value {
  font-size: 1.4rem;
  font-weight: 700;
}

/* Buttons row in game */
#buttonsRow {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 4px;
  flex-wrap: wrap;
}

#buttonsRow button {
  padding: 9px 20px;
  font-size: 0.95rem;
  background-color: var(--accent);
  color: #fff;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  box-shadow: 0 0 12px var(--accent);
  transition: background-color 0.3s, box-shadow 0.3s, transform 0.1s;
}

#buttonsRow button:hover {
  background-color: var(--accent-dark);
  box-shadow: 0 0 18px var(--accent-dark);
  transform: translateY(-1px);
}

/* Win animation */
@keyframes winPulse {
  0% {
    transform: scale(1);
    background-color: rgba(0, 255, 200, 0.3);
    box-shadow: 0 0 10px #00ffc3;
  }
  50% {
    transform: scale(1.2);
    background-color: rgba(0, 255, 200, 0.6);
    box-shadow: 0 0 25px #00ffc3;
  }
  100% {
    transform: scale(1);
    background-color: rgba(0, 255, 200, 0.3);
    box-shadow: 0 0 10px #00ffc3;
  }
}

.win-cell {
  animation: winPulse 1.2s infinite;
  font-weight: bold;
  color: #00fff7;
}

/* Modal (used for how to play, performance, custom players) */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden {
  display: none;
}

.modal.show {
  display: flex;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
}

.modal-content {
  position: relative;
  z-index: 101;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--panel-dark);
  padding: 20px 24px;
  border-radius: 18px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.9);
  text-align: left;
}

body.light-theme .modal-content {
  background: var(--panel-light);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

.modal-content h2 {
  margin-top: 0;
  margin-bottom: 10px;
}

.modal-content ul {
  padding-left: 20px;
}

.modal-content button {
  margin-top: 12px;
  padding: 8px 18px;
  border: none;
  border-radius: 20px;
  background-color: var(--accent);
  color: #fff;
  cursor: pointer;
}

/* Player inputs inside Custom Players modal */
#playersConfig {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-input {
  background: var(--panel-dark);
  padding: 10px 16px;
  border-radius: 20px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.7);
  font-size: 0.9rem;
}

body.light-theme .player-input {
  background: var(--panel-light);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.player-input input {
  margin-left: 6px;
  padding: 3px 6px;
  border-radius: 8px;
  border: none;
  outline: none;
}
