:root {
  color-scheme: light;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic UI",
    system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --sky: #7cc1ff;
  --grass: #5fbb46;
  --ink: #1c2a36;
  --warn: #ff5c5c;
  --ok: #2ec94a;
  --panel: rgba(255, 255, 255, 0.92);
  --shadow: 0 8px 22px rgba(13, 33, 64, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% 0%, #b8e1ff 0%, #82bff5 38%, #4f8fc4 100%);
}

body {
  display: flex;
  justify-content: center;
}

.shell {
  width: min(100vw, 440px);
  padding: max(8px, env(safe-area-inset-top)) 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.title-bar {
  text-align: center;
  margin: 2px 0 0;
}
.title-bar h1 {
  margin: 0;
  font-size: clamp(20px, 5.4vw, 26px);
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow:
    -2px 0 #1c2a36, 2px 0 #1c2a36, 0 -2px #1c2a36, 0 2px #1c2a36,
    3px 3px 0 #ffb43b, 0 4px 10px rgba(0, 0, 0, 0.25);
}
.title-bar h1 span {
  display: inline-block;
  margin-left: 4px;
  color: #ffe45c;
}

.stage {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  background: #cfeeff;
  border: 3px solid #1c2a36;
  box-shadow: var(--shadow);
}

.hud {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 6px;
  padding: 8px 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0.45));
  border-bottom: 2px solid rgba(28, 42, 54, 0.18);
}
.hud > div {
  background: var(--panel);
  border: 2px solid #1c2a36;
  border-radius: 14px;
  padding: 4px 8px;
  text-align: center;
  box-shadow: 0 2px 0 rgba(28, 42, 54, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 44px;
}
.hud-timer {
  grid-column: 1;
  min-width: 64px;
  background: #fff !important;
}
.hud-timer strong {
  color: #d63a2f;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}
.hud-label {
  font-size: 10px;
  color: #486075;
  letter-spacing: 0.06em;
}
.hud strong {
  font-size: 18px;
  font-weight: 900;
  line-height: 1.1;
}

.alert-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 8px;
  background: rgba(255, 255, 255, 0.55);
  border-bottom: 2px solid rgba(28, 42, 54, 0.18);
}
.alert-label {
  font-weight: 900;
  font-size: 12px;
  color: #1c2a36;
}
.alert-track {
  position: relative;
  height: 14px;
  background: #e7eef3;
  border: 2px solid #1c2a36;
  border-radius: 999px;
  overflow: hidden;
}
.alert-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #ffce4a 0%, #ff9a3c 45%, #ff3b3b 100%);
  transition: width 0.18s ease-out;
}
.alert-max {
  font-weight: 900;
  font-size: 11px;
  color: #d63a2f;
  letter-spacing: 0.06em;
  opacity: 0.45;
  transition: opacity 0.15s, transform 0.15s;
}
.alert-max.warn {
  opacity: 1;
  transform: scale(1.1);
  animation: blink 0.45s infinite alternate;
}
@keyframes blink {
  from { color: #d63a2f; }
  to { color: #ffd23a; }
}

#game {
  width: 100%;
  display: block;
  aspect-ratio: 390 / 600;
  background: linear-gradient(180deg, #8dd1ff 0%, #b9e3a8 62%, #6db352 100%);
  touch-action: none;
}

.beam-gauge {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 6px;
  background: rgba(255, 255, 255, 0.75);
  border-top: 2px solid rgba(28, 42, 54, 0.18);
}
.beam-label {
  font-weight: 900;
  font-size: 11px;
  color: #1c2a36;
}
.beam-track {
  position: relative;
  height: 12px;
  background: #e7eef3;
  border: 2px solid #1c2a36;
  border-radius: 999px;
  overflow: hidden;
}
.beam-fill {
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg, #4fd1ff 0%, #58e58a 50%, #ffe45c 100%);
  transition: width 0.12s ease-out;
}

.hint {
  margin: 0;
  padding: 6px 12px 10px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #1c2a36;
}
.hint-icon { font-size: 18px; }
.hint strong { color: #d63a2f; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(8, 17, 31, 0.4), rgba(8, 17, 31, 0.65));
  backdrop-filter: blur(2px);
  z-index: 5;
  padding: 20px;
}
.overlay[hidden] { display: none; }
.overlay-card {
  background: #fff;
  border: 3px solid #1c2a36;
  border-radius: 18px;
  padding: 16px 18px;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 320px;
}
.overlay-card h2 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 900;
  color: #1c2a36;
}
.overlay-card p {
  margin: 6px 0 10px;
  font-size: 13px;
  line-height: 1.5;
  color: #2c3d4f;
}
.overlay-score {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0 12px;
}
.overlay-score > div {
  background: #f4f8fb;
  border: 2px solid #1c2a36;
  border-radius: 10px;
  padding: 4px 0;
}
.overlay-score span {
  display: block;
  font-size: 10px;
  color: #486075;
  letter-spacing: 0.06em;
}
.overlay-score strong {
  font-size: 20px;
  color: #d63a2f;
}
.overlay-card button {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 12px 20px;
  font-weight: 900;
  font-size: 16px;
  color: #06101d;
  background: linear-gradient(180deg, #ffe45c, #ffb43b);
  box-shadow: 0 4px 0 #b9831f, 0 10px 20px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}
.overlay-card button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #b9831f, 0 4px 10px rgba(0, 0, 0, 0.18);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.legend-item {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid #1c2a36;
  background: #fff;
  color: #1c2a36;
  box-shadow: 0 2px 0 rgba(28, 42, 54, 0.25);
}
.legend-item.ok { background: #e7fbe2; }
.legend-item.ng { background: #ffe7e3; }

@media (max-height: 720px) {
  .title-bar h1 { font-size: 18px; }
  .legend-item { font-size: 11px; padding: 3px 8px; }
}
