* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: radial-gradient(circle at top, rgba(120, 150, 255, 0.18), transparent 25%),
              radial-gradient(circle at 20% 20%, rgba(255, 100, 240, 0.25), transparent 22%),
              radial-gradient(circle at 80% 10%, rgba(0, 255, 255, 0.18), transparent 20%),
              linear-gradient(180deg, #020214 0%, #05081c 45%, #090c22 100%);
  min-height: 100vh;
}

body {
  margin: 0;
  padding: 32px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  color: #e5f7ff;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.14) 1px, transparent 1px);
  background-size: 60px 60px;
  opacity: 0.25;
  pointer-events: none;
}

.page-shell {
  position: relative;
  width: min(100%, 720px);
  padding: 24px;
  border: 1px solid rgba(255,255,255,0.09);
  background: rgba(6, 10, 30, 0.82);
  box-shadow: 0 0 70px rgba(56, 109, 255, 0.16);
  border-radius: 28px;
  backdrop-filter: blur(18px);
}

.game-panel {
  display: grid;
  gap: 20px;
}

header {
  text-align: center;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 3.4vw, 3rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 0 24px rgba(120, 170, 255, 0.45);
}

.subtitle {
  margin: 0;
  color: #c1d8ff;
  opacity: 0.9;
}

.score-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.score-board div {
  padding: 16px 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  box-shadow: inset 0 0 25px rgba(15, 24, 75, 0.15);
}

.speed-settings {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  box-shadow: inset 0 0 25px rgba(15, 24, 75, 0.15);
}

.speed-settings label {
  display: block;
  font-size: 0.95rem;
  color: #d7e9ff;
}

#speedSlider {
  width: 100%;
  accent-color: #8c95ff;
  cursor: pointer;
}

.speed-labels {
  display: flex;
  justify-content: space-between;
  color: #a9c9ff;
  font-size: 0.88rem;
}

.score-board span {
  display: block;
  margin-top: 8px;
  font-size: 1.7rem;
  font-weight: 700;
  color: #74d6ff;
}

.board-shell {
  display: grid;
  gap: 16px;
  justify-items: center;
}

#gameCanvas {
  width: min(100%, 520px);
  height: auto;
  max-width: 100%;
  touch-action: none;
  border-radius: 22px;
  border: 2px solid rgba(111, 189, 255, 0.5);
  box-shadow: 0 0 25px rgba(68, 192, 255, 0.18), inset 0 0 24px rgba(30, 53, 118, 0.2);
  background: radial-gradient(circle at 30% 30%, rgba(116, 214, 255, 0.16), transparent 22%),
              linear-gradient(180deg, rgba(3, 12, 36, 0.9), rgba(0, 0, 0, 0.7));
}

.touch-controls {
  display: grid;
  gap: 12px;
  width: min(100%, 360px);
  justify-items: center;
}

.control-row {
  display: flex;
  gap: 12px;
}

.control-button {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(10, 24, 64, 0.88);
  color: #e9f4ff;
  font-size: 1.8rem;
  font-weight: 700;
  box-shadow: 0 12px 24px rgba(36, 96, 198, 0.18);
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease;
}

.control-button:active,
.control-button:hover {
  transform: translateY(-1px);
  background: rgba(29, 61, 109, 0.96);
}

.instructions {
  text-align: center;
  color: #d9edf4;
  opacity: 0.85;
  font-size: 0.97rem;
}

#restartButton {
  width: 100%;
  max-width: 240px;
  justify-self: center;
  padding: 14px 18px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(117,214,255,0.95), rgba(145,84,255,0.95));
  color: #040b1c;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 10px 25px rgba(93, 167, 255, 0.26);
}

#restartButton:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(93, 167, 255, 0.32);
}

.hint {
  text-align: center;
  font-size: 0.95rem;
  color: #a7c8ea;
}

@media (max-width: 540px) {
  body {
    padding: 14px;
  }

  .page-shell {
    padding: 16px;
  }

  .score-board {
    grid-template-columns: 1fr;
  }

  .touch-controls {
    width: 100%;
  }

  .control-button {
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
  }
}
