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

:root {
  --cell-size: 50px;
  --bg: #1a0a2e;
  --grid-bg: #2d1b69;
  --cell-bg: linear-gradient(135deg, #2d1b69, #1a0a2e);
  --cell-border: #6b3fa0;
  --accent: #ff71ce;
  --accent2: #01cdfe;
  --danger: #ff3860;
  --safe: #05ffa1;
  --text: #f0e0ff;
  --sunset1: #ff6b6b;
  --sunset2: #ee5a24;
  --sunset3: #f368e0;
  --sunset4: #a55eea;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Scanline overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 4px
  );
  pointer-events: none;
  z-index: 999;
}

/* HUD */
#hud {
  display: flex;
  justify-content: space-between;
  padding: 12px 20px;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-shadow: 0 0 10px var(--accent);
}

/* Timer bar */
#timer-wrap {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0 16px;
  border-radius: 2px;
}

#timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 2px;
  box-shadow: 0 0 8px var(--accent);
}

/* Grid container */
#grid-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  padding: 16px;
}

#grid {
  display: grid;
  gap: 3px;
  position: relative;
}

/* Cells */
.grid-cell {
  width: var(--cell-size);
  height: var(--cell-size);
  background: linear-gradient(135deg, #2d1b69, #1a0a2e);
  border: 1px solid var(--cell-border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.grid-cell:active {
  background: linear-gradient(135deg, #3d2b79, #2a1a3e);
  box-shadow: inset 0 0 12px rgba(255, 113, 206, 0.3);
}

.grid-cell.player {
  background: linear-gradient(135deg, var(--accent), var(--sunset4));
  box-shadow: 0 0 16px var(--accent), 0 0 32px rgba(255, 113, 206, 0.3);
  border-color: var(--accent);
}

.grid-cell.hit {
  background: linear-gradient(135deg, var(--danger), var(--sunset2));
  box-shadow: 0 0 20px var(--danger), 0 0 40px rgba(255, 56, 96, 0.4);
  animation: pulse 0.3s ease 2;
  border-color: var(--danger);
}

.grid-cell.safe {
  background: linear-gradient(135deg, var(--safe), var(--accent2));
  box-shadow: 0 0 16px var(--safe), 0 0 32px rgba(5, 255, 161, 0.3);
  border-color: var(--safe);
}

@keyframes pulse {
  50% { transform: scale(1.15); }
}

/* Shooter cells */
.shooter-cell {
  width: var(--cell-size);
  height: var(--cell-size);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell-size) * 0.5);
  color: rgba(255, 255, 255, 0.15);
}

.shooter-cell.has-shooter {
  color: var(--sunset1);
  text-shadow: 0 0 10px var(--sunset1), 0 0 20px rgba(255, 107, 107, 0.4);
  animation: shooterGlow 2s ease-in-out infinite alternate;
}

@keyframes shooterGlow {
  from { text-shadow: 0 0 10px var(--sunset1), 0 0 20px rgba(255, 107, 107, 0.4); }
  to { text-shadow: 0 0 14px var(--sunset3), 0 0 28px rgba(243, 104, 224, 0.5); }
}

.corner {
  width: var(--cell-size);
  height: var(--cell-size);
}

/* Bullets */
.bullet {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--sunset1);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--sunset1), 0 0 16px rgba(255, 107, 107, 0.5);
  pointer-events: none;
  z-index: 10;
}

/* Overlay */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 12, 41, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 100;
  transition: opacity 0.3s;
}

#overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

#overlay h1 {
  font-size: 2.5rem;
  background: linear-gradient(90deg, var(--accent), var(--accent2), var(--sunset3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 0 20px rgba(255, 113, 206, 0.5));
}

#overlay p {
  font-size: 1.1rem;
  color: rgba(240, 224, 255, 0.7);
  letter-spacing: 0.05em;
}

#start-btn {
  margin-top: 12px;
  padding: 14px 48px;
  font-size: 1.2rem;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--sunset4));
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 0 20px rgba(255, 113, 206, 0.4);
  letter-spacing: 0.05em;
  transition: transform 0.1s, box-shadow 0.1s;
}

#start-btn:active {
  transform: scale(0.95);
  box-shadow: 0 0 12px rgba(255, 113, 206, 0.3);
}

/* Layout */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}
