:root {
  color-scheme: dark;
  --bg: #151a2d;
  --panel: #202743;
  --panel-soft: #293052;
  --text: #f7f3df;
  --muted: #bfc6df;
  --green: #78d66b;
  --yellow: #ffd166;
  --pink: #ff6b9d;
  --cyan: #57d5ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 10%, rgba(87, 213, 255, 0.18), transparent 28rem),
    linear-gradient(180deg, #101527 0%, var(--bg) 100%);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.game-shell {
  width: min(100vw - 24px, 1040px);
}

.hud,
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 4px;
}

h1 {
  margin: 0 0 4px;
  font-size: clamp(1.5rem, 4vw, 2.35rem);
}

p {
  margin: 0;
  color: var(--muted);
}

.stats,
.controls {
  color: var(--muted);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px 18px;
  min-width: 240px;
}

.stats strong {
  color: var(--yellow);
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 3px solid #39436d;
  border-radius: 8px;
  background: #78b8ff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  image-rendering: pixelated;
}

.controls {
  flex-wrap: wrap;
  justify-content: center;
  font-size: 0.95rem;
}

kbd {
  display: inline-block;
  min-width: 1.7em;
  padding: 0.12em 0.42em;
  border: 1px solid #65719f;
  border-bottom-width: 3px;
  border-radius: 5px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  text-align: center;
}

.game-shell {
  position: relative;
}

#sound-ctrl {
  position: absolute;
  right: 12px;
  bottom: 58px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
}

#mute-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: 2px solid #65719f;
  border-radius: 8px;
  background: rgba(32, 39, 67, 0.85);
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s;
}

#mute-btn:hover {
  background: rgba(57, 67, 109, 0.95);
}

#vol-slider {
  width: 0;
  opacity: 0;
  pointer-events: none;
  transition: width 0.2s ease, opacity 0.2s ease;
  accent-color: var(--cyan);
  cursor: pointer;
}

#sound-ctrl.expanded #vol-slider {
  width: 90px;
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 720px) {
  body {
    align-items: start;
    padding-top: 10px;
  }

  .hud {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats {
    justify-content: flex-start;
    min-width: 0;
  }
}
