:root {
  color-scheme: dark;
  --bg-color: #05060a;
  --panel-color: rgba(10, 14, 20, 0.85);
  --neon-red: #ff355d;
  --neon-blue: #32e3ff;
  --neon-cyan: #7afcff;
  --grid-line: rgba(120, 140, 160, 0.25);
  --text-color: #e6f1ff;
  --shadow-glow: 0 0 12px rgba(122, 252, 255, 0.6);
  font-family: "Orbitron", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #111827, #020409 60%);
  color: var(--text-color);
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  padding: 8px 16px;
  text-align: center;
}

.app-title {
  font-size: 1.4rem;
  letter-spacing: 0.3em;
  color: rgba(255, 255, 255, 0.35);
}

main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  overflow: hidden;
}

.scene {
  width: 100%;
  max-width: 960px;
  display: none;
  position: relative;
}

.scene.is-active {
  display: block;
}

#scene-game.is-active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.scene-content {
  position: relative;
  z-index: 2;
  background: var(--panel-color);
  border: 1px solid rgba(122, 252, 255, 0.2);
  padding: 32px;
  border-radius: 16px;
  box-shadow: var(--shadow-glow);
  text-align: center;
}

.scene-content.game-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  position: relative;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

.intro-card {
  max-width: 720px;
}

.intro-text {
  text-align: center;
  line-height: 1.8;
  font-size: 1rem;
  color: rgba(230, 241, 255, 0.9);
}

.intro-text p {
  margin-bottom: 8px;
}

.intro-text .intro-spacer {
  margin-top: 16px;
}

.learning-block {
  margin-top: 20px;
  padding: 16px;
  border: 1px solid rgba(255, 53, 93, 0.35);
  border-radius: 12px;
  background: rgba(6, 10, 18, 0.7);
}

.learning-title {
  font-size: 1.4rem;
  color: var(--neon-red);
  text-shadow: 0 0 12px rgba(255, 53, 93, 0.6);
  margin-bottom: 6px;
}

.learning-subtitle {
  font-size: 0.95rem;
  color: rgba(230, 241, 255, 0.8);
}

.game-top-bar {
  width: 100%;
  max-width: 900px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  padding: 4px 4px 0;
  gap: 12px;
  flex-wrap: wrap;
}

.learning-hud {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--neon-cyan);
  text-transform: uppercase;
  opacity: 0.9;
}

.game-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.control-hint {
  opacity: 0.8;
  font-size: 12px;
}

.scene-title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  margin-bottom: 24px;
}

.neon-text {
  color: var(--neon-red);
  text-shadow: 0 0 16px rgba(255, 53, 93, 0.8);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
}

.neon-button {
  background: transparent;
  color: var(--text-color);
  border: 2px solid rgba(122, 252, 255, 0.6);
  padding: 10px 24px;
  border-radius: 999px;
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 0 12px rgba(122, 252, 255, 0.15);
}

.neon-button:hover,
.neon-button:focus {
  outline: none;
  color: #020409;
  background: rgba(122, 252, 255, 0.8);
  box-shadow: 0 0 16px rgba(122, 252, 255, 0.7);
}

#title-canvas {
  width: 100%;
  height: 440px;
  display: block;
  border-radius: 18px;
  margin-bottom: -380px;
  background: #05060a;
  box-shadow: 0 0 24px rgba(50, 227, 255, 0.15);
}

.title-toast {
  position: absolute;
  bottom: 16px;
  right: 20px;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: rgba(230, 241, 255, 0.65);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.title-toast.is-visible {
  opacity: 1;
}

.rules-box {
  text-align: left;
  line-height: 1.7;
  font-size: 1rem;
  color: rgba(230, 241, 255, 0.9);
}

.score-display {
  font-size: 1.2rem;
  letter-spacing: 0.1em;
}

#game-canvas {
  width: 100%;
  max-width: 900px;
  max-height: calc(100vh - 180px);
  aspect-ratio: 1 / 1;
  background: #05060a;
  border-radius: 16px;
  box-shadow: 0 0 18px rgba(50, 227, 255, 0.25);
  display: block;
}

.start-hint {
  margin-top: 8px;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(230, 241, 255, 0.75);
  transition: opacity 0.2s ease;
}

.start-hint.is-hidden {
  opacity: 0;
  pointer-events: none;
}

#dpad-container {
  width: 100%;
  max-width: 900px;
  display: flex;
  justify-content: center;
  margin-top: 8px;
}

#dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.dpad-middle {
  display: flex;
  gap: 4px;
}

.dpad-btn {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: rgba(0, 255, 255, 0.08);
  border: 1px solid rgba(0, 255, 255, 0.4);
  color: #e0faff;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(122, 252, 255, 0.2);
  transition: transform 0.15s ease, background 0.15s ease;
}

.dpad-btn:active {
  transform: translateY(2px);
  background: rgba(50, 227, 255, 0.2);
}

.result-message {
  font-size: 1.4rem;
  margin-bottom: 16px;
}

.result-scores {
  font-size: 1.1rem;
  line-height: 1.6;
}

.result-metrics {
  margin-top: 20px;
  text-align: center;
  font-size: 1rem;
  line-height: 1.6;
  color: rgba(230, 241, 255, 0.9);
}

.result-subtitle {
  margin-top: 16px;
  font-size: 1.1rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--neon-cyan);
}

.metrics-list {
  margin-top: 8px;
  display: grid;
  gap: 4px;
  justify-items: center;
}

@media (max-width: 768px) {
  .scene-content {
    padding: 24px;
  }

  .neon-button {
    width: 100%;
  }

  #title-canvas {
    height: 320px;
    margin-bottom: -280px;
  }
}

@media (min-width: 900px) {
  #dpad-container {
    display: none;
  }

  .control-hint {
    display: inline;
  }
}

@media (max-width: 899px) {
  #dpad-container {
    display: flex;
  }

  .control-hint {
    display: none;
  }
}
