:root {
  --ink: #1d1a2b;
  --cream: #fff8ec;
  --pink: #ff5d8f;
  --yellow: #ffd23f;
  --blue: #2f7df6;
  --shadow: 0 6px 0 rgba(0, 0, 0, 0.25);
  --font: 'M PLUS Rounded 1c', system-ui, sans-serif;
  --logo: 'Dela Gothic One', 'M PLUS Rounded 1c', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #9fd0ff; color: var(--ink); font-family: var(--font); -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#game, #game canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }

#loading { position: fixed; inset: 0; display: grid; place-items: center; font: 800 24px var(--font); color: #fff; background: #2a3550; }

/* ---------- ボタン ---------- */
.btn {
  font: 800 20px var(--font); color: var(--ink); background: #fff; border: 3px solid var(--ink);
  border-radius: 999px; padding: 12px 34px; cursor: pointer; box-shadow: 0 5px 0 var(--ink);
  transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 7px 0 var(--ink); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--pink); color: #fff; font-size: 24px; padding: 14px 52px; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; text-decoration: underline; }
.btn:disabled { opacity: .45; cursor: default; transform: none; box-shadow: 0 5px 0 var(--ink); }
.btn:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }
.btns { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; align-items: center; margin-top: 22px; }

/* ---------- タイトル ---------- */
.screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; z-index: 20; }
#title { background: linear-gradient(180deg, rgba(20,30,60,.0) 30%, rgba(20,30,60,.45)); }
.title-card { text-align: center; animation: pop .5s cubic-bezier(.2,1.6,.4,1) both; }
.kicker { display: inline-block; margin: 0 0 6px; padding: 6px 16px; background: var(--ink); color: var(--yellow); font-weight: 800; border-radius: 999px; transform: rotate(-3deg); }
.logo { margin: 0; font: 400 clamp(52px, 12vw, 120px)/1 var(--logo); letter-spacing: .02em; }
.logo span { display: block; color: #fff; -webkit-text-stroke: 10px var(--ink); paint-order: stroke fill; text-shadow: 0 10px 0 var(--ink); }
.logo span:first-child { color: var(--yellow); transform: rotate(-4deg) translateX(-4%); }
.logo span:last-child { color: var(--pink); transform: rotate(2deg) translateX(6%); margin-top: -6px; }
.lead { margin: 18px auto 10px; max-width: 30em; font-weight: 800; font-size: clamp(15px, 2.4vw, 19px); color: #fff; text-shadow: 0 2px 0 var(--ink), 0 0 12px rgba(0,0,0,.4); }
.stage-pick { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.stage-pick button { font: 800 14px var(--font); color: var(--ink); background: rgba(255,255,255,.9); border: 3px solid var(--ink); border-radius: 12px; padding: 6px 12px; cursor: pointer; line-height: 1.3; }
.stage-pick button small { display: block; font-size: 11px; opacity: .75; }
.stage-pick button[aria-checked="true"] { background: var(--yellow); box-shadow: 0 4px 0 var(--ink); transform: translateY(-2px); }
.stage-chip { display: inline-block; padding: 6px 14px; border-radius: 10px; background: rgba(255,255,255,.9); border: 2px solid var(--ink); font-weight: 800; font-size: 14px; }

/* ---------- 遊び方・結果 ---------- */
.modal { background: rgba(15, 20, 40, .55); z-index: 30; }
.panel { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--cream); border: 4px solid var(--ink); border-radius: 26px; padding: 24px 26px; box-shadow: 0 10px 0 var(--ink); animation: pop .35s cubic-bezier(.2,1.5,.4,1) both; text-align: center; }
.panel h2 { margin: 0 0 14px; font: 400 34px var(--logo); }
.steps { list-style: none; margin: 0; padding: 0; text-align: left; display: grid; gap: 12px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 10px 12px; }
.steps .n { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--yellow); border: 2px solid var(--ink); font-weight: 800; }
.steps b { font-size: 17px; }
.steps p { margin: 2px 0 0; font-size: 14px; line-height: 1.55; }
.steps p b { font-size: inherit; color: #d6336c; }
.rule { margin: 14px 0 0; font-weight: 800; }
.rule b { color: #d6336c; }
#resTitle.win { color: #d6336c; }
#resTitle.lose { color: #5a5f7a; }
.stars { font-size: 56px; letter-spacing: 6px; min-height: 8px; }
.stars span { display: inline-block; color: #d9d4c7; -webkit-text-stroke: 3px var(--ink); animation: star .5s cubic-bezier(.2,1.8,.4,1) both; }
.stars span.on { color: var(--yellow); }
#resText { font-size: 18px; font-weight: 800; line-height: 1.6; }
#resText b { color: #d6336c; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.hud-left { position: absolute; top: 14px; left: 14px; }
.hud-right { position: absolute; top: 14px; right: 14px; display: flex; gap: 8px; align-items: center; }
.stage-badge, .hits { background: rgba(255,255,255,.92); border: 3px solid var(--ink); border-radius: 14px; padding: 6px 12px; box-shadow: var(--shadow); font-weight: 800; display: flex; align-items: baseline; gap: 8px; }
.stage-badge span { font-size: 13px; color: #d6336c; }
.stage-badge b { font-size: 18px; }
.hits span { font-size: 12px; }
.hits b { font: 400 22px var(--logo); color: #d6336c; }
.icon-btn { pointer-events: auto; width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--ink); background: #fff; font-size: 18px; cursor: pointer; box-shadow: var(--shadow); }
.hud-bottom { position: absolute; left: 14px; right: 14px; bottom: 16px; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.ammo { display: flex; gap: 4px; flex-wrap: wrap; max-width: 55vw; }
.burst { pointer-events: auto; display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.92); border: 3px solid var(--ink); border-radius: 16px; padding: 6px 8px 6px 12px; box-shadow: var(--shadow); font-weight: 800; }
.burst span { font-size: 13px; margin-right: 2px; white-space: nowrap; }
.burst button { width: 46px; height: 46px; border-radius: 12px; border: 3px solid var(--ink); background: #fff; font: 400 22px var(--logo); cursor: pointer; color: var(--ink); }
.burst button[aria-checked="true"] { background: var(--pink); color: #fff; box-shadow: 0 3px 0 var(--ink); transform: translateY(-2px); }
.ammo i { width: 16px; height: 14px; border-radius: 7px; background: linear-gradient(135deg, #fff, #f2dede); border: 2px solid var(--ink); box-shadow: 0 3px 0 rgba(0,0,0,.25); transition: transform .3s, opacity .3s; }
.ammo i.used { opacity: .2; transform: scale(.7); }

#hint { position: fixed; left: 50%; bottom: 12%; transform: translateX(-50%); z-index: 11; pointer-events: none; text-align: center; animation: fadeIn .4s both; }
#hint p { margin: 0; padding: 10px 18px; background: rgba(29,26,43,.85); color: #fff; border-radius: 14px; font-weight: 800; line-height: 1.5; }
#hint p b { color: var(--yellow); }
#hint small { font-size: 12px; opacity: .8; }
.hint-hand { font-size: 38px; animation: drag 1.4s ease-in-out infinite; }

/* ---------- スローモーション ---------- */
.bar { position: fixed; left: 0; right: 0; height: 0; background: #000; z-index: 8; transition: height .35s ease; pointer-events: none; }
.bar.top { top: 0; } .bar.bottom { bottom: 0; }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 7; opacity: 0; transition: opacity .35s; background: radial-gradient(ellipse at center, transparent 45%, rgba(10,20,60,.55) 100%); }
#slowTag { position: fixed; right: 20px; bottom: calc(9vh + 10px); z-index: 9; font: 400 28px var(--logo); color: #fff; letter-spacing: .3em; opacity: 0; transition: opacity .3s; text-shadow: 0 0 10px rgba(80,160,255,.9); }
body.slowmo .bar { height: 9vh; }
body.slowmo #vignette, body.slowmo #slowTag { opacity: 1; }
body.slowmo #slowTag { animation: blink 0.8s steps(2) infinite; }

/* ---------- 引っぱり表示 ---------- */
#pullLine { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 11; overflow: visible; }
#pullStart { fill: rgba(255,255,255,.5); stroke: var(--ink); stroke-width: 3; }
#pullBand { stroke: #c2462c; stroke-width: 6; stroke-linecap: round; stroke-dasharray: 2 10; }
#pullEnd { fill: #fff; stroke: var(--ink); stroke-width: 4; }
#pullLine.full #pullEnd { fill: var(--yellow); }

/* ---------- ポップアップ ---------- */
#popups { position: fixed; inset: 0; pointer-events: none; z-index: 12; }
.popup { position: absolute; transform: translate(-50%, -50%); font: 400 34px var(--logo); color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; white-space: nowrap; animation: popup 1.4s ease-out both; }
.popup.splat { color: #fff; }
.popup.near { color: var(--yellow); }
.popup.miss { color: #a9b3cc; font-size: 28px; }
#bang { position: fixed; left: 50%; top: 36%; z-index: 13; pointer-events: none; transform: translate(-50%, -50%) scale(0); font: 400 clamp(56px, 13vw, 150px) var(--logo); color: var(--yellow); -webkit-text-stroke: 12px var(--ink); paint-order: stroke fill; text-shadow: 0 12px 0 var(--ink); white-space: nowrap; opacity: 0; }
#bang.go { animation: bang 1.6s cubic-bezier(.2,1.6,.4,1) both; }

@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes star { from { transform: scale(0) rotate(-90deg); } to { transform: scale(1) rotate(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes drag { 0%, 15% { transform: translateY(-10px); opacity: 0; } 30% { opacity: 1; } 70% { transform: translateY(28px); opacity: 1; } 100% { transform: translateY(28px); opacity: 0; } }
@keyframes blink { 50% { opacity: .35; } }
@keyframes popup { 0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; } 15% { transform: translate(-50%, -60%) scale(1.15); opacity: 1; } 30% { transform: translate(-50%, -60%) scale(1); } 100% { transform: translate(-50%, -140%) scale(1); opacity: 0; } }
@keyframes bang {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-12deg); opacity: 1; }
  18% { transform: translate(-50%, -50%) scale(1.25) rotate(4deg); }
  30% { transform: translate(-50%, -50%) scale(1) rotate(-3deg); }
  80% { transform: translate(-50%, -50%) scale(1.05) rotate(-3deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.4) rotate(-3deg); opacity: 0; }
}
@media (max-width: 600px) {
  .btn.primary { padding: 12px 40px; }
  .stage-badge b { font-size: 15px; }
  .hits span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
