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

html, body {
  width: 100%;
  height: 100%;
  background: #0C0D14;
  font-family: 'Courier New', monospace;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}

.container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
  max-width: 480px;
  width: 100%;
}

/* -- Header -------------------------------------------------- */

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

.title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  color: #00ff88;
  text-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
}

.scores {
  display: flex;
  gap: 10px;
}

.score-box {
  background: #1a1b26;
  border: 1px solid #2a2b3a;
  border-radius: 8px;
  padding: 6px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
}

.score-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #888;
}

.score-value {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

/* -- Stats Row ----------------------------------------------- */

.stats-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 0 4px;
}

.stat {
  font-size: 13px;
  color: #888;
  letter-spacing: 0.5px;
}

/* -- Board --------------------------------------------------- */

.board {
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  gap: 2px;
  padding: 6px;
  background: #1a1b26;
  border-radius: 10px;
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid #2a2b3a;
}

.cell {
  border-radius: 3px;
  transition: background-color 0.25s ease;
  aspect-ratio: 1;
}

.cell.flooding {
  animation: cellFlood 0.3s ease;
}

@keyframes cellFlood {
  0% { transform: scale(1); }
  50% { transform: scale(0.85); }
  100% { transform: scale(1); }
}

/* -- Palette ------------------------------------------------- */

.palette {
  display: flex;
  gap: 10px;
  justify-content: center;
  width: 100%;
  padding: 8px 0;
}

.palette-btn {
  width: 48px;
  height: 48px;
  border: 3px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.palette-btn:hover {
  transform: scale(1.12);
}

.palette-btn:active {
  transform: scale(0.95);
}

.palette-btn.active {
  border-color: #fff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.3);
}

.palette-btn.disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
}

/* -- New Game Button ----------------------------------------- */

.new-game-btn {
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  background: #00ff88;
  color: #0C0D14;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  text-transform: uppercase;
}

.new-game-btn:hover {
  background: #33ffaa;
}

.new-game-btn:active {
  transform: scale(0.96);
}

/* -- Overlay ------------------------------------------------- */

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(12, 13, 20, 0.82);
  border-radius: 12px;
  z-index: 100;
  gap: 16px;
  animation: fadeIn 0.3s ease;
}

.overlay.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay-text {
  font-size: 32px;
  font-weight: 800;
  text-align: center;
  letter-spacing: -1px;
}

.overlay-sub {
  font-size: 16px;
  color: #aaa;
  text-align: center;
  line-height: 1.5;
}

.overlay-btn {
  padding: 12px 32px;
  border: none;
  border-radius: 8px;
  background: #00ff88;
  color: #0C0D14;
  font-family: 'Courier New', monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  text-transform: uppercase;
  transition: background 0.15s, transform 0.1s;
}

.overlay-btn:hover {
  background: #33ffaa;
}

.overlay-btn:active {
  transform: scale(0.96);
}

/* -- Responsive ---------------------------------------------- */

@media (max-width: 460px) {
  .container {
    padding: 12px;
    gap: 10px;
  }
  .title {
    font-size: 22px;
  }
  .board {
    gap: 1px;
    padding: 4px;
    border-radius: 8px;
  }
  .cell {
    border-radius: 2px;
  }
  .palette-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    gap: 8px;
  }
  .palette {
    gap: 8px;
  }
  .score-box {
    padding: 4px 10px;
    min-width: 56px;
  }
  .score-value {
    font-size: 16px;
  }
  .overlay-text {
    font-size: 26px;
  }
}

@media (max-width: 360px) {
  .palette-btn {
    width: 34px;
    height: 34px;
    border-width: 2px;
  }
  .palette {
    gap: 6px;
  }
  .title {
    font-size: 18px;
  }
}
