:root {
  --sky: #60beff;
  --sky-deep: #2d6fd6;
  --ink: #1d2340;
  --balloon: #ff4d5e;
  --sun: #ffd23f;
  --paper: #fffdf6;
  --display: "Dela Gothic One", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  --body: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Noto Sans JP", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #0e1a3a;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  font-family: var(--body);
  color: var(--ink);
}
#stage {
  position: fixed; top: 0; bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  overflow: hidden;
  touch-action: none;
  background: var(--sky);
}
canvas { display: block; touch-action: none; }

/* HUD */
#hud {
  position: absolute; left: 0; right: 0; top: 0;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 0;
  pointer-events: none;
  color: #fff;
  text-shadow: 0 2px 0 rgba(20, 24, 60, 0.55);
}
#hud[hidden] { display: none; }
.alt { font-family: var(--display); font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; }
.alt small { font-size: 16px; margin-left: 2px; }
.score { font-family: var(--display); font-size: 12px; letter-spacing: 0.06em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.hud-mid { display: flex; gap: 4px; padding-top: 4px; }
.hud-mid i {
  width: 16px; height: 20px; border-radius: 50%;
  background: var(--balloon);
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.18), 0 2px 0 rgba(20, 24, 60, 0.4);
}
.hud-mid i.off { background: rgba(255, 255, 255, 0.25); box-shadow: none; }
.icon-btn {
  pointer-events: auto;
  width: 44px; height: 44px; border-radius: 50%;
  border: 3px solid #fff; background: rgba(20, 24, 60, 0.35);
  color: #fff; font: 700 16px var(--display);
  touch-action: manipulation;
}

#hint {
  position: absolute; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom, 0px) + 18%);
  text-align: center; pointer-events: none;
  color: #fff; font-weight: 800; font-size: 15px;
  text-shadow: 0 2px 0 rgba(20, 24, 60, 0.6);
  animation: hint 1.4s ease-in-out infinite;
}
#hint p { margin: 4px 0; }
#hint b { color: var(--sun); }
@keyframes hint { 50% { opacity: 0.55; } }

/* パネル */
.panel {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
  text-align: center;
  overflow-y: auto;
  touch-action: pan-y;
}
.panel[hidden] { display: none; }
#title { background: linear-gradient(#60beff 0%, #a9dcff 60%, #d9f1ff 100%); }
#pause, #over { background: rgba(14, 26, 58, 0.72); color: #fff; }

.logo { position: relative; padding-top: 58px; }
.logo h1 {
  margin: 0;
  font: 400 clamp(44px, 14vw, 64px)/0.92 var(--display);
  color: #fff;
  letter-spacing: 0.02em;
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 0 6px 0 var(--ink);
}
.kana { margin: 12px 0 0; font-weight: 800; letter-spacing: 0.35em; color: var(--ink); }
.logo-balloons { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 70px; height: 60px; }
.logo-balloons i {
  position: absolute; top: 0; width: 34px; height: 42px; border-radius: 50%;
  background: var(--balloon);
  box-shadow: inset -5px -6px 0 rgba(0, 0, 0, 0.16), inset 5px 5px 0 rgba(255, 255, 255, 0.35);
  animation: bob 2.2s ease-in-out infinite;
}
.logo-balloons i:first-child { left: 0; }
.logo-balloons i:last-child { right: 0; animation-delay: -1.1s; }
@keyframes bob { 50% { transform: translateY(-6px); } }

.rules {
  margin: 0; padding: 14px 16px 14px 32px;
  max-width: 360px; text-align: left;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 14px;
  font-size: 13px; line-height: 1.6; font-weight: 500;
}
.rules li + li { margin-top: 4px; }
.rules b { color: #d8263a; }
.best { margin: 0; font-weight: 800; font-variant-numeric: tabular-nums; }
.note { margin: 0; font-size: 11px; line-height: 1.6; color: #2b3a66; max-width: 340px; }

.big-btn {
  min-width: 220px; padding: 14px 28px;
  font: 400 24px var(--display);
  color: #fff; background: var(--balloon);
  border: 3px solid var(--ink); border-radius: 999px;
  box-shadow: 0 6px 0 var(--ink);
  touch-action: manipulation;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.sub-btn {
  min-width: 180px; padding: 10px 20px;
  font: 800 16px var(--body);
  color: var(--ink); background: #fff;
  border: 3px solid var(--ink); border-radius: 999px;
  touch-action: manipulation;
}
button:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; }

.panel h2 { margin: 0; font: 400 32px var(--display); text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35); }
.result { margin: 0; display: grid; gap: 8px; min-width: 230px; }
.result div {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 8px 16px; border-radius: 12px; background: rgba(255, 255, 255, 0.12);
}
.result dt { font-weight: 800; font-size: 14px; }
.result dd { margin: 0; font: 400 24px var(--display); font-variant-numeric: tabular-nums; }
.new { margin: 0; color: var(--sun); font: 400 20px var(--display); animation: hint 0.8s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  .logo-balloons i, #hint, .new { animation: none; }
}
