:root {
  --cyan: #58d9ff;
  --cyan-soft: rgba(88, 217, 255, 0.34);
  --cyan-dim: rgba(88, 217, 255, 0.16);
  --ink: #eaf9ff;
  --muted: rgba(234, 249, 255, 0.68);
  --panel: rgba(2, 17, 24, 0.76);
  --line: rgba(116, 218, 255, 0.32);
  --danger: #ff7a6f;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #02090d;
  color: var(--ink);
  font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  touch-action: none;
  user-select: none;
}

button,
a {
  font: inherit;
}

.game-shell {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 48% 76%, rgba(55, 167, 231, 0.22), transparent 31%),
    radial-gradient(circle at 82% 30%, rgba(80, 177, 255, 0.10), transparent 26%),
    linear-gradient(180deg, #02080b 0%, #031019 52%, #061623 100%);
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.back-to-teaching {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  top: max(14px, env(safe-area-inset-top));
  z-index: 12;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--ink);
  background: rgba(1, 12, 17, 0.58);
  text-decoration: none;
  text-shadow: 0 0 12px rgba(88, 217, 255, 0.6);
  box-shadow: 0 0 22px rgba(88, 217, 255, 0.08), inset 0 0 22px rgba(88, 217, 255, 0.06);
  backdrop-filter: blur(10px);
}

.hud {
  position: fixed;
  z-index: 10;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 22px;
  background: var(--panel);
  box-shadow: 0 0 28px rgba(88, 217, 255, 0.08), inset 0 0 34px rgba(88, 217, 255, 0.05);
  backdrop-filter: blur(12px);
}

.hud-top-left {
  left: max(72px, calc(env(safe-area-inset-left) + 72px));
  top: max(28px, calc(env(safe-area-inset-top) + 28px));
  width: min(54vw, 560px);
}

.hud-top-right {
  right: max(22px, env(safe-area-inset-right));
  top: max(28px, calc(env(safe-area-inset-top) + 28px));
  width: min(28vw, 280px);
}

.hud-bottom {
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  width: min(88vw, 900px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 34px;
  transform: translateX(-50%);
}

.hud-label {
  margin: 0;
  color: #b8f0ff;
  font-size: clamp(0.9rem, 1.6vw, 1.45rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-shadow: 0 0 14px rgba(88, 217, 255, 0.7);
}

.hud-value {
  margin: 12px 0 0;
  color: #f5fbff;
  font-size: clamp(1.45rem, 3.4vw, 2.6rem);
  font-weight: 900;
  line-height: 1;
}

.bar {
  height: 14px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(139, 204, 231, 0.11);
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.36);
}

.bar span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #42cdfd, #a4f0ff);
  box-shadow: 0 0 18px rgba(88, 217, 255, 0.9);
  transition: width 120ms linear;
}

#shield-bar.low,
#energy-bar.low {
  background: linear-gradient(90deg, var(--danger), #ffd0ca);
  box-shadow: 0 0 18px rgba(255, 122, 111, 0.85);
}

.mission-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 15;
  width: min(680px, calc(100vw - 38px));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: clamp(24px, 5vw, 42px);
  background: rgba(2, 18, 25, 0.82);
  text-align: center;
  box-shadow: 0 0 44px rgba(88, 217, 255, 0.18), inset 0 0 42px rgba(88, 217, 255, 0.07);
  transform: translate(-50%, -50%);
  backdrop-filter: blur(14px);
}

.mission-panel.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.98);
  transition: opacity 160ms ease, transform 160ms ease;
}

.panel-kicker {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: clamp(0.78rem, 1.8vw, 1rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.mission-panel h1 {
  margin: 0;
  color: var(--cyan);
  font-size: clamp(2rem, 8.4vw, 4.2rem);
  line-height: 0.95;
  letter-spacing: 0.03em;
  text-shadow: 0 0 24px rgba(88, 217, 255, 0.72);
}

.mission-panel p:last-of-type {
  max-width: 520px;
  margin: 20px auto 0;
  color: var(--muted);
  font-size: clamp(1rem, 3.5vw, 1.55rem);
  line-height: 1.45;
}

#start-button {
  margin-top: 24px;
  border: 1px solid rgba(88, 217, 255, 0.62);
  border-radius: 999px;
  padding: 12px 18px;
  color: #021018;
  background: linear-gradient(90deg, #56d9ff, #b7f5ff);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(88, 217, 255, 0.32);
}

#start-button:hover,
#start-button:focus-visible {
  transform: translateY(-1px);
}

@media (max-width: 720px) {
  .back-to-teaching {
    left: 12px;
    top: 10px;
    padding: 7px 10px;
    font-size: 0.78rem;
  }

  .hud {
    border-radius: 14px;
    padding: 12px 14px;
  }

  .hud-top-left {
    left: 12px;
    right: 12px;
    top: 52px;
    width: auto;
  }

  .hud-top-right {
    right: 12px;
    top: 150px;
    width: 142px;
  }

  .hud-bottom {
    width: calc(100vw - 24px);
    gap: 12px;
    padding: 12px;
  }

  .hud-value {
    margin-top: 7px;
  }

  .bar {
    height: 10px;
    margin-top: 11px;
  }

  .mission-panel {
    top: 48%;
  }
}

@media (max-height: 620px) {
  .hud-bottom {
    display: none;
  }

  .hud-top-left {
    width: min(56vw, 430px);
  }

  .mission-panel {
    top: 54%;
  }
}
