:root {
  --ink: #f6f1e4;
  --dim: #b9b6c9;
  --gold: #ffcf6a;
  --red: #ff5a6e;
  --panel: rgba(10, 14, 38, 0.78);
  --line: rgba(255, 220, 160, 0.28);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #050a1d; color: var(--ink);
  font-family: 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', 'Yu Gothic', sans-serif; user-select: none; -webkit-user-select: none; touch-action: manipulation; overscroll-behavior: none; }
canvas#c { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; }
button { font-family: inherit; color: var(--ink); cursor: pointer; border: 1px solid var(--line); background: rgba(20, 24, 60, 0.7);
  border-radius: 999px; transition: transform .12s, background .2s; }
button:active { transform: scale(0.96); }
button.big { font-size: 20px; font-weight: 900; padding: 14px 28px; min-width: 220px; letter-spacing: .08em;
  background: linear-gradient(180deg, rgba(255,90,110,.92), rgba(190,40,80,.92)); border-color: rgba(255,200,200,.5);
  box-shadow: 0 6px 24px rgba(255, 70, 110, .35); }
button.big.gold { background: linear-gradient(180deg, #ffd77a, #e59a2a); color: #3a1d00; border-color: #fff0c0; box-shadow: 0 6px 24px rgba(255, 190, 80, .35); }
button.big small { font-size: 12px; font-weight: 700; display: block; letter-spacing: 0; opacity: .85; }
button.small { font-size: 14px; padding: 9px 18px; font-weight: 700; }
button.icon { width: 42px; height: 42px; font-size: 24px; line-height: 1; padding: 0; display: grid; place-items: center; }
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); z-index: 10; }

/* title */
#title { justify-content: center; text-align: center; pointer-events: none; }
#title > * { pointer-events: auto; }
#title .logo { font-family: 'Yuji Syuku', serif; line-height: 1; display: flex; align-items: baseline; gap: .05em;
  text-shadow: 0 0 18px rgba(255,120,160,.8), 0 0 50px rgba(255,90,140,.5); animation: logoIn 1.1s cubic-bezier(.2,1.6,.4,1) both; pointer-events: none; }
#title .pon { font-size: clamp(72px, 19vw, 150px); color: #fff3f6; transform: rotate(-6deg); display: inline-block; }
#title .hanabi { font-size: clamp(64px, 16vw, 128px); color: #ffd98a; text-shadow: 0 0 18px rgba(255,190,90,.8), 0 0 50px rgba(255,150,60,.45); }
#title .catch { margin: 0 0 18px; font-size: clamp(15px, 4vw, 20px); font-weight: 700; letter-spacing: .12em; color: #fff; text-shadow: 0 2px 10px #000; pointer-events: none; }
#title .menu { display: flex; flex-direction: column; gap: 12px; align-items: center; }
#title .foot { position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); margin: 0; font-size: 12px; color: var(--dim); pointer-events: none; }
@keyframes logoIn { from { transform: scale(.3); opacity: 0; filter: blur(8px); } to { transform: none; opacity: 1; filter: none; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 22px 22px 18px; max-width: 520px; width: 100%;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.card h2 { margin: 0 0 10px; font-family: 'Yuji Syuku', serif; font-weight: 400; font-size: 28px; color: var(--gold); text-align: center; }
#how ol { padding-left: 1.3em; margin: 0 0 18px; line-height: 1.7; font-size: 15px; }
#how li { margin-bottom: 6px; }
#how b { color: var(--gold); }
#how .card { display: flex; flex-direction: column; align-items: center; }
#how ol { align-self: stretch; }

/* select */
#select { justify-content: flex-start; background: rgba(4, 7, 22, .55); overflow-y: auto; touch-action: pan-y; }
.selHead { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 1100px; }
.selHead h2 { flex: 1; margin: 0; font-family: 'Yuji Syuku', serif; font-weight: 400; font-size: 28px; color: var(--gold); }
#starTotal { font-weight: 900; color: var(--gold); }
#nights { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; width: 100%; max-width: 1100px; padding-bottom: 20px; }
.night { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 12px; }
.night h3 { margin: 2px 4px 10px; font-family: 'Yuji Syuku', serif; font-weight: 400; font-size: 18px; color: #ffe7c0; }
.night .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stBtn { border-radius: 14px; padding: 10px 4px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-weight: 900; font-size: 18px; }
.stBtn .st { font-size: 13px; letter-spacing: 1px; color: var(--gold); min-height: 1.2em; }
.stBtn .st i { font-style: normal; color: rgba(255,255,255,.18); }
.stBtn.locked { opacity: .35; pointer-events: none; }
.stBtn.cur { border-color: var(--gold); box-shadow: 0 0 14px rgba(255, 200, 100, .4); }

/* hud */
#hud { position: fixed; left: 0; right: 0; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 12px 6px; pointer-events: none; }
#hud > button { pointer-events: auto; }
#stageLabel { flex: 1; font-weight: 700; font-size: 14px; line-height: 1.2; text-shadow: 0 1px 6px #000; min-width: 0; }
#stageLabel small { display: block; color: var(--dim); font-size: 11px; font-weight: 500; }
#counter { font-weight: 900; font-size: 30px; text-shadow: 0 0 12px rgba(255,180,120,.6), 0 2px 6px #000; display: flex; align-items: baseline; gap: 2px; }
#counter .slash { color: var(--dim); font-size: 20px; }
#counter #cntN { font-size: 20px; color: var(--dim); }
#counter small { font-size: 12px; margin-left: 8px; color: var(--dim); font-weight: 700; }
#counter small b { color: var(--gold); font-size: 15px; }
#counter.pop { animation: pop .18s; }
@keyframes pop { 50% { transform: scale(1.18); } }
#progress { position: absolute; left: 12px; right: 12px; bottom: -4px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.12); }
#bar { height: 100%; width: 0; border-radius: 4px; background: linear-gradient(90deg, #ff6a8a, #ffd36e); transition: width .15s; box-shadow: 0 0 10px #ff9a6a; }
.mark { position: absolute; top: -4px; width: 2px; height: 12px; background: var(--gold); border-radius: 1px; }
.mark.s { background: #fff; opacity: .6; }

#shotBadge { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 5; pointer-events: none;
  font-size: 14px; padding: 6px 16px; border-radius: 999px; background: rgba(0,0,0,.45); border: 1px solid var(--line); letter-spacing: .1em; }
#shotBadge b { color: var(--red); font-size: 18px; }
#shotBadge.used { opacity: .4; }
#tip { position: fixed; left: 50%; bottom: calc(max(18px, env(safe-area-inset-bottom)) + 44px); transform: translateX(-50%); z-index: 5; pointer-events: none;
  width: min(92vw, 520px); text-align: center; font-size: 14px; line-height: 1.5; padding: 10px 14px; border-radius: 14px; background: rgba(0,0,0,.5); border: 1px solid var(--line); transition: opacity .4s; }

#banner { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 6; pointer-events: none; text-align: center; width: min(92vw, 480px);
  animation: bannerIn .5s cubic-bezier(.2,1.4,.4,1) both; transition: opacity .5s; }
#banner.out { opacity: 0; }
@keyframes bannerIn { from { transform: translate(-50%, -40%) scale(.8); opacity: 0; } }
#bnNight { font-size: 14px; color: var(--dim); letter-spacing: .2em; text-shadow: 0 1px 6px #000; }
#bnTitle { font-family: 'Yuji Syuku', serif; font-size: 52px; color: #fff; text-shadow: 0 0 20px rgba(255,140,170,.8), 0 2px 8px #000; line-height: 1.15; }
#bnGoal { font-size: 18px; font-weight: 900; text-shadow: 0 1px 8px #000; }
#bnGoal b { color: var(--gold); font-size: 24px; }
#bnNew { margin-top: 12px; display: flex; gap: 12px; align-items: center; text-align: left; background: var(--panel); border: 1px solid var(--gold); border-radius: 16px; padding: 10px 14px; }
#bnNew canvas { width: 56px; height: 56px; flex: none; }
#bnNew b { display: block; color: var(--gold); font-size: 17px; }
#bnNew b::before { content: 'NEW  '; color: var(--red); font-size: 12px; }
#bnNew span { font-size: 13px; line-height: 1.5; }

/* result */
#result { background: linear-gradient(180deg, rgba(3,5,18,0) 30%, rgba(3,5,18,.55)); justify-content: flex-end; padding-bottom: max(28px, env(safe-area-inset-bottom)); }
.result { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; animation: bannerIn2 .45s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes bannerIn2 { from { transform: translateY(30px) scale(.9); opacity: 0; } }
#rsHead { font-family: 'Yuji Syuku', serif; font-size: 44px; line-height: 1.1; color: #fff; text-shadow: 0 0 20px rgba(255,140,170,.8); }
#rsHead.all { color: #ffe08a; text-shadow: 0 0 24px rgba(255,200,90,.95); }
#rsHead.fail { color: #c7c9e6; text-shadow: none; }
#rsStars { font-size: 34px; letter-spacing: 6px; color: var(--gold); text-shadow: 0 0 12px rgba(255,200,90,.7); }
#rsStars i { font-style: normal; color: rgba(255,255,255,.15); text-shadow: none; }
#rsCount { font-size: 18px; font-weight: 700; }
#rsCount b { font-size: 30px; color: #fff; }
#rsScore { font-size: 15px; color: var(--dim); }
#rsScore b { font-size: 26px; color: var(--gold); }
#rsSub { font-size: 13px; color: var(--dim); min-height: 1.2em; white-space: pre-line; }
.result .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.result .row button.big { min-width: 160px; }

@media (max-width: 420px) {
  button.big { min-width: 200px; font-size: 18px; padding: 12px 22px; }
  .result .row button.big { min-width: 140px; }
  #counter { font-size: 26px; }
  #bnTitle { font-size: 44px; }
}
