:root {
  --bg-color: #06031a;
  --panel-color: rgba(255, 255, 255, 0.08);
  --accent-color: #2de1fc;
  --text-color: #f4f4f4;
  --danger-color: #ff6b6b;
  --control-bg: rgba(255, 255, 255, 0.12);
  --control-bg-active: rgba(45, 225, 252, 0.25);
  --control-text: #ffffff;
  font-family: "Segoe UI", Tahoma, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at top, #12063b, var(--bg-color));
  color: var(--text-color);
}

.game-container {
  width: min(90vw, 520px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 1rem;
  padding: 1rem;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  backdrop-filter: blur(8px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-inline: 0.5rem;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.hud-item {
  flex: 1;
  text-align: center;
}

.hud-item--align-left {
  text-align: left;
}

.hud-item--align-right {
  text-align: right;
}

.hud-button {
  padding: 0.45rem 0.8rem;
  background: var(--control-bg);
  color: var(--control-text);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  flex: 0 0 auto;
  align-self: center;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.hud-button:focus-visible {
  outline: 3px solid var(--accent-color);
  outline-offset: 3px;
}

.hud-button:hover {
  background-color: rgba(255, 255, 255, 0.18);
}

.hud-button:active {
  transform: translateY(1px);
}

.hud-button--muted,
.hud-button[aria-pressed="true"] {
  background-color: var(--control-bg-active);
  border-color: var(--accent-color);
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: linear-gradient(180deg, rgba(45, 225, 252, 0.15), rgba(6, 3, 26, 0.9));
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  overflow: hidden;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.message-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  background-color: rgba(0, 0, 0, 0.6);
  color: var(--text-color);
  font-size: 1.2rem;
  text-align: center;
  opacity: 1;
  transition: opacity 200ms ease;
}

.message-overlay.scoreboard {
  padding: 2rem;
  background: radial-gradient(circle at center, rgba(45, 225, 252, 0.12), rgba(5, 0, 26, 0.85));
  backdrop-filter: blur(10px);
  pointer-events: auto;
}

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

.scoreboard-card {
  position: relative;
  padding: 2rem 2.5rem;
  border-radius: 20px;
  background: rgba(11, 8, 43, 0.88);
  border: 1px solid rgba(45, 225, 252, 0.3);
  box-shadow:
    0 25px 45px rgba(0, 0, 0, 0.55),
    0 0 35px rgba(45, 225, 252, 0.35);
  max-width: 360px;
  width: 100%;
  text-align: center;
  overflow: hidden;
  animation: scoreboardFloat 1400ms ease-in-out infinite alternate;
}

.scoreboard-glow {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(45, 225, 252, 0.35), rgba(255, 107, 107, 0.2));
  opacity: 0.25;
  mix-blend-mode: screen;
  pointer-events: none;
}

.scoreboard-content {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  z-index: 1;
}

.scoreboard-title {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ffffff;
  text-shadow: 0 0 18px rgba(45, 225, 252, 0.75);
}

.scoreboard-subtitle {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.7);
}

.scoreboard-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.scoreboard-stat {
  padding: 0.75rem 0.5rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(45, 225, 252, 0.25);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.scoreboard-stat-label {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
}

.scoreboard-stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fefefe;
  text-shadow: 0 0 8px rgba(45, 225, 252, 0.45);
}

.scoreboard-instructions {
  margin: 0;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.65);
}

.game-over-card {
  border-color: rgba(255, 107, 107, 0.45);
  box-shadow:
    0 25px 45px rgba(0, 0, 0, 0.55),
    0 0 35px rgba(255, 107, 107, 0.28);
}

.game-over-glow {
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.35), rgba(45, 225, 252, 0.18));
}

.game-over-title {
  color: #ffffff;
  text-shadow: 0 0 18px rgba(255, 107, 107, 0.85);
}

.game-over-cta {
  margin-top: 0.25rem;
  padding: 0.95rem 1.5rem;
  background: linear-gradient(135deg, rgba(45, 225, 252, 0.28), rgba(255, 107, 107, 0.22));
  color: #ffffff;
  border: 1px solid rgba(45, 225, 252, 0.45);
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: none;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
  box-shadow: 0 0 18px rgba(45, 225, 252, 0.2);
}

.game-over-cta:hover {
  background: linear-gradient(135deg, rgba(45, 225, 252, 0.38), rgba(255, 107, 107, 0.3));
  border-color: var(--accent-color);
  box-shadow: 0 0 24px rgba(45, 225, 252, 0.35);
}

.game-over-cta:focus-visible {
  outline: 3px solid var(--accent-color);
  outline-offset: 3px;
}

.game-over-cta:active {
  transform: translateY(1px);
}

@keyframes scoreboardFloat {
  from {
    transform: translateY(3px);
  }
  to {
    transform: translateY(-6px);
  }
}


.touch-controls {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.control-btn {
  flex: 1;
  padding: 0.85rem 1rem;
  background: var(--control-bg);
  color: var(--control-text);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.control-btn:focus-visible {
  outline: 3px solid var(--accent-color);
  outline-offset: 3px;
}

.control-btn:active,
.control-btn[data-active="true"] {
  background-color: var(--control-bg-active);
  border-color: var(--accent-color);
  transform: translateY(1px);
}

@media (pointer: fine) and (min-width: 640px) {
  .touch-controls {
    display: none;
  }
}

@media (max-width: 420px) {
  .game-container {
    width: 100vw;
    min-height: 100vh;
    border-radius: 0;
    box-shadow: none;
  }

  .canvas-wrapper {
    border-radius: 0;
  }
}
