:root {
  --bg-color: #f0f2f5;
  --text-color: #333;
  --grid-bg: #e0e0e0;
  --cell-off: #3a3a3a;
  --cell-on: #ffcc00;
  --cell-on-shadow: 0 0 15px #ffcc00, 0 0 30px #ffcc00;
  --cell-off-shadow: inset 0 0 10px rgba(0,0,0,0.5);
  --accent: #007bff;
  --btn-bg: #fff;
  --btn-text: #333;
  --border-radius: 12px;
  --font-family: 'Segoe UI', system-ui, sans-serif;
}

[data-theme="dark"] {
  --bg-color: #1a1a2e;
  --text-color: #e0e0e0;
  --grid-bg: #16213e;
  --cell-off: #0f3460;
  --cell-on: #e94560;
  --cell-on-shadow: 0 0 15px #e94560, 0 0 30px #e94560;
  --cell-off-shadow: inset 0 0 15px rgba(0,0,0,0.7);
  --accent: #e94560;
  --btn-bg: #16213e;
  --btn-text: #e0e0e0;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  transition: background-color 0.3s, color 0.3s;
  overflow-x: hidden;
}

header {
  margin-top: 2rem;
  text-align: center;
  margin-bottom: 1rem;
}

h1 {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  background: linear-gradient(45deg, var(--accent), #ffcc00);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  font-size: 1.2rem;
  margin-bottom: 1.5rem;
}

.game-container {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  padding: 20px;
  background: var(--grid-bg);
  border-radius: var(--border-radius);
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  margin-bottom: 2rem;
  touch-action: manipulation; /* Disable double-tap zoom */
}

.cell {
  width: 60px;
  height: 60px;
  background-color: var(--cell-off);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--cell-off-shadow);
  position: relative;
  overflow: hidden;
}

.cell.on {
  background-color: var(--cell-on);
  box-shadow: var(--cell-on-shadow);
  transform: scale(0.95);
}

.cell:hover {
  transform: scale(1.05);
  z-index: 1;
}

.cell:focus {
  outline: 2px solid var(--text-color);
  outline-offset: 2px;
}

.controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
}

button.btn {
  padding: 0.8rem 1.5rem;
  font-size: 1rem;
  background: var(--btn-bg);
  color: var(--btn-text);
  border: 1px solid var(--accent);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

button.btn:hover {
  background: var(--accent);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

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

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.8);
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s;
}

.modal.visible {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: var(--bg-color);
  padding: 2rem;
  border-radius: var(--border-radius);
  text-align: center;
  box-shadow: 0 0 50px rgba(0,0,0,0.5);
  transform: scale(0.8);
  transition: transform 0.3s;
  border: 2px solid var(--accent);
}

.modal.visible .modal-content {
  transform: scale(1);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.shake {
  animation: shake 0.5s;
}

/* Responsive adjustments */
@media (max-width: 500px) {
  .cell {
    width: 13vw;
    height: 13vw;
  }

  h1 {
    font-size: 2rem;
  }

  .game-container {
    padding: 10px;
    gap: 5px;
  }
}

/* Accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
