:root {
  --ink: #2b1d2e;
  --pink: #ff5ea8;
  --yellow: #ffe14d;
  --mint: #5fe0b7;
  --sky: #5ecbff;
  --red: #ff4d6d;
  --cream: #fff8ec;
  --pop: 'Dela Gothic One', 'M PLUS Rounded 1c', sans-serif;
  --round: 'M PLUS Rounded 1c', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #bfe3ff; font-family: var(--round); color: var(--ink); user-select: none; -webkit-user-select: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
kbd { display: inline-block; font-family: var(--round); font-weight: 900; font-size: .8em; padding: 1px 7px; margin: 0 2px; border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 7px; background: #fff; color: var(--ink); line-height: 1.3; }
.hidden { display: none !important; }

/* ---------- 共通の太字ポップ文字 ---------- */
.pop, .banner .bt, #score, #countdown, #combo, .rank, .rscore, .logo .l2 span {
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s; }
#hud.on { opacity: 1; }
#scorePanel { position: absolute; left: 18px; top: 14px; }
#scorePanel .lbl { font-family: var(--pop); font-size: 14px; color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; letter-spacing: .1em; }
#score { font-family: var(--pop); font-size: 46px; line-height: 1; color: var(--yellow); text-shadow: 0 5px 0 var(--ink); }
body.fever #score { animation: rainbowText .5s linear infinite; }
#comboBox { margin-top: 8px; display: flex; align-items: baseline; gap: 6px; opacity: 0; transform: scale(.6); transform-origin: left center; transition: opacity .15s, transform .2s cubic-bezier(.2,1.8,.4,1); position: relative; padding-bottom: 8px; }
#comboBox.on { opacity: 1; transform: scale(1); }
#comboBox.burst { animation: comboBurst .45s cubic-bezier(.2,1.8,.4,1); }
#combo { font-family: var(--pop); font-size: 40px; color: var(--pink); text-shadow: 0 4px 0 var(--ink); }
#comboBox span { font-family: var(--pop); font-size: 18px; color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }
#mult { font-style: normal; font-family: var(--pop); font-size: 20px; color: var(--mint); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }
#comboBar { position: absolute; left: 0; bottom: 0; width: 170px; height: 7px; border: 2px solid var(--ink); border-radius: 6px; background: #fff; overflow: hidden; }
#comboBar i { display: block; height: 100%; background: linear-gradient(90deg, var(--pink), var(--yellow)); transform-origin: left; }

#gauges { position: absolute; right: 18px; top: 14px; width: min(340px, 42vw); display: flex; flex-direction: column; gap: 8px; }
.gauge { background: rgba(255,255,255,.92); border: 3px solid var(--ink); border-radius: 16px; padding: 6px 10px 8px; box-shadow: 0 4px 0 var(--ink); }
.gl { display: flex; justify-content: space-between; font-weight: 900; font-size: 15px; margin-bottom: 4px; }
.bar { height: 16px; border: 3px solid var(--ink); border-radius: 10px; background: #eee3f0; overflow: hidden; }
.bar i { display: block; height: 100%; transform-origin: left; transition: transform .15s; }
#sleepBar { background: linear-gradient(90deg, #8f7bff, #c48bff 60%, #ff9ad5); }
#sleepG.drain .bar i { animation: drainBlink .5s steps(2) infinite; }
#sleepG.low { animation: shakeX .3s infinite; background: #ffe3ea; }
#neckBar { background: linear-gradient(90deg, #ffe9c7, #ffc76b); }
body.fever #neckBar { background: linear-gradient(90deg, #ff5e7e, #ffb84d, #ffe14d, #6ee787, #5ecbff, #b48cff); }
#neckG.taut { background: #ffe3ea; animation: shakeX .25s infinite; }
#neckG.taut #neckBar { background: var(--red); }
#stats { display: flex; justify-content: flex-end; gap: 10px; font-weight: 900; font-size: 15px; }
#stats span { background: rgba(255,255,255,.92); border: 3px solid var(--ink); border-radius: 12px; padding: 2px 10px; box-shadow: 0 3px 0 var(--ink); }

#missions { position: absolute; left: 18px; top: 150px; margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
#missions li { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.9); border: 3px solid var(--ink); border-radius: 14px; padding: 4px 12px 4px 8px; font-weight: 900; font-size: 14px; box-shadow: 0 3px 0 var(--ink); max-width: 300px; }
#missions .mi { font-size: 18px; }
#missions .ms { margin-left: auto; font-family: var(--pop); }
#missions .m-hidden { opacity: .55; }
#missions .m-active { background: #fff3a8; animation: missionPulse .8s ease-in-out infinite alternate; }
#missions .m-active .ms { color: var(--red); }
#missions .m-done { opacity: .6; background: #d9f7e6; }
#missions .m-done .ml { text-decoration: line-through; text-decoration-thickness: 3px; }
#missions .m-done .ms { color: #1aa36b; }

#help { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); font-weight: 800; font-size: 13px; background: rgba(255,255,255,.85); border: 3px solid var(--ink); border-radius: 14px; padding: 6px 12px; white-space: nowrap; }
#itemBtn { position: absolute; right: 18px; bottom: 14px; pointer-events: auto; width: 60px; height: 60px; font-size: 30px; border: 3px solid var(--ink); border-radius: 50%; background: var(--yellow); box-shadow: 0 5px 0 var(--ink); cursor: pointer; transition: transform .1s; }
#itemBtn:hover { transform: translateY(-2px) rotate(-8deg); }
#itemBtn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }

/* ---------- 演出レイヤー ---------- */
#popups, #indicators { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.pop { position: absolute; left: 0; top: 0; white-space: nowrap; font-family: var(--pop); will-change: transform, opacity; }
.pop.score { font-size: 26px; color: var(--yellow); text-shadow: 0 3px 0 var(--ink); }
.pop.big { font-size: 38px; color: var(--pink); text-shadow: 0 4px 0 var(--ink); }
.pop.score.big { color: var(--yellow); font-size: 40px; }
.pop.quack { font-size: 24px; color: #fff; text-shadow: 0 3px 0 var(--ink); }
.pop.ring { font-size: 22px; color: var(--red); -webkit-text-stroke: 3px #fff; text-shadow: none; }
.pop.warn { font-size: 26px; color: var(--red); text-shadow: 0 3px 0 var(--ink); }
.pop.zzz { font-size: 28px; color: #8f7bff; -webkit-text-stroke: 3px #fff; }
.pop.note { font-family: var(--round); font-weight: 900; font-size: 20px; color: #fff; -webkit-text-stroke: 4px var(--ink); }
.pop.bubble { font-family: var(--round); font-weight: 900; font-size: 22px; color: var(--ink); -webkit-text-stroke: 0; background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 8px 16px; box-shadow: 0 4px 0 var(--ink); }

#center { position: fixed; left: 0; right: 0; top: 16%; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
.banner { text-align: center; animation: slam 2s cubic-bezier(.2,1.6,.4,1) forwards; }
.banner.long { animation-duration: 3.5s; }
.banner .bt { font-family: var(--pop); font-size: clamp(30px, 5.5vw, 68px); line-height: 1.05; color: #fff; text-shadow: 0 6px 0 var(--ink); letter-spacing: .02em; }
.banner .bs { display: inline-block; margin-top: 4px; font-weight: 900; font-size: clamp(14px, 1.8vw, 22px); background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 3px 14px; box-shadow: 0 3px 0 var(--ink); }
.banner.clear .bt { color: var(--yellow); }
.banner.warn .bt { color: #ffcf3d; }
.banner.danger .bt { color: var(--red); }
.banner.info .bt { color: #fff; font-size: clamp(26px, 4.5vw, 56px); }
.banner.mile .bt { color: var(--sky); }
.banner.bonus .bt { color: #ff8cf0; font-size: clamp(26px, 4.5vw, 54px); }
.banner.combo .bt { color: var(--pink); font-size: clamp(28px, 5vw, 60px); }
.banner.duck .bt { color: var(--yellow); font-size: clamp(22px, 3.5vw, 40px); }
.banner.fever .bt { animation: rainbowText .4s linear infinite; font-size: clamp(48px, 9vw, 110px); }
.banner.win .bt { color: var(--yellow); font-size: clamp(48px, 9vw, 120px); animation: rainbowText .8s linear infinite; }
.banner.over .bt { color: #a9b8ff; font-size: clamp(44px, 8vw, 100px); }

#countdown { position: fixed; left: 50%; top: 9%; transform: translateX(-50%); font-family: var(--pop); font-size: 110px; color: var(--red); text-shadow: 0 8px 0 var(--ink); pointer-events: none; opacity: 0; }
#countdown.on { opacity: 1; animation: countPop .5s cubic-bezier(.2,1.8,.4,1); }
#countdown.hot { color: #fff; -webkit-text-stroke: 4px var(--red); }

#toasts { position: fixed; right: 18px; top: 190px; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast { display: flex; gap: 12px; align-items: center; background: linear-gradient(#fff, #ffe9f3); border: 4px solid var(--ink); border-radius: 20px; box-shadow: 0 6px 0 var(--ink); padding: 10px 18px 10px 12px; animation: toastIn .5s cubic-bezier(.2,1.6,.4,1), toastOut .4s 4.3s forwards; max-width: 360px; }
.toast .ti { font-size: 46px; line-height: 1; animation: wobble .6s ease-in-out infinite alternate; }
.toast .tn { font-weight: 800; font-size: 13px; opacity: .8; }
.toast .tl { font-family: var(--pop); font-size: 24px; color: var(--pink); }
.toast .td { font-weight: 800; font-size: 13px; }

.ind { position: absolute; left: 0; top: 0; will-change: transform; }
.ind .ib { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); display: flex; align-items: center; gap: 4px; background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 2px 10px 2px 6px; box-shadow: 0 3px 0 var(--ink); animation: bob .6s ease-in-out infinite alternate; white-space: nowrap; }
.ind .ii { font-size: 22px; }
.ind .id { font-weight: 900; font-size: 13px; }
.ind .ia { display: none; position: absolute; left: 0; top: 0; width: 0; height: 0; }
.ind.edge .ib { transform: translate(-50%, -50%); }
.ind.edge .ia { display: block; }
.ind.edge .ia::after { content: ''; position: absolute; left: 30px; top: -12px; border-left: 20px solid var(--ink); border-top: 12px solid transparent; border-bottom: 12px solid transparent; }
.ind.urgent .ib { background: #ffe3ea; animation: bob .6s ease-in-out infinite alternate, urgentGlow .5s ease-in-out infinite alternate; }
.ind.urgent .ia::after { border-left-color: var(--red); }

#vignette { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s; }
#vignette.alarm { opacity: 1; background: radial-gradient(ellipse at center, transparent 55%, rgba(255,80,110,.35) 100%); animation: vigPulse .6s ease-in-out infinite alternate; }
#vignette.danger { opacity: 1; background: radial-gradient(ellipse at center, transparent 45%, rgba(255,30,60,.6) 100%); animation: vigPulse .3s ease-in-out infinite alternate; }
#feverFrame { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s; border: 10px solid transparent; border-image: linear-gradient(90deg, #ff5e7e, #ffb84d, #ffe14d, #6ee787, #5ecbff, #b48cff, #ff5e7e) 1; animation: hue 1s linear infinite; }
body.fever #feverFrame { opacity: 1; }
#flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; background: #fff; }

/* ---------- アイテムパネル ---------- */
#itemPanel { position: fixed; right: 18px; bottom: 86px; width: 330px; background: var(--cream); border: 4px solid var(--ink); border-radius: 20px; box-shadow: 0 6px 0 var(--ink); padding: 12px; z-index: 20; }
#itemPanel .ph { font-family: var(--pop); font-size: 18px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: baseline; }
#itemPanel .ph small { font-family: var(--round); font-weight: 800; font-size: 12px; opacity: .7; }
#fromName { width: 100%; font: inherit; font-weight: 800; border: 3px solid var(--ink); border-radius: 12px; padding: 6px 10px; margin-bottom: 8px; }
#itemButtons { display: grid; gap: 6px; }
.ibtn { display: flex; align-items: center; gap: 10px; font: inherit; text-align: left; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 6px 10px; box-shadow: 0 3px 0 var(--ink); cursor: pointer; }
.ibtn:hover { background: #fff3a8; }
.ibtn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.ibtn .iic { font-size: 26px; }
.ibtn .ilb { font-weight: 900; font-size: 15px; display: flex; flex-direction: column; }
.ibtn .ilb small { font-weight: 700; font-size: 11px; opacity: .7; }
.ibtn kbd { margin-left: auto; }
.pfoot { margin-top: 8px; font-size: 12px; font-weight: 800; opacity: .8; }

/* ---------- 画面 ---------- */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 30; }
#loading { background: #bfe3ff; }
#loading .ld { font-family: var(--pop); font-size: 34px; color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.ldbar { width: min(360px, 70vw); height: 22px; border: 4px solid var(--ink); border-radius: 14px; background: #fff; overflow: hidden; margin-top: 12px; }
.ldbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--pink), var(--yellow)); transform: scaleX(0); transform-origin: left; transition: transform .2s; }

#title { background: radial-gradient(ellipse at center, rgba(255,248,236,.0) 30%, rgba(255,214,231,.55) 100%); cursor: pointer; padding: 16px; }
.logo { text-align: center; animation: float 2.4s ease-in-out infinite alternate; }
.logo .l1 { font-family: var(--pop); font-size: clamp(26px, 5vw, 54px); color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); }
.logo .l2 { display: flex; justify-content: center; gap: .02em; }
.logo .l2 span { display: inline-block; font-family: var(--pop); font-size: clamp(58px, 13vw, 150px); line-height: 1; color: var(--yellow); text-shadow: 0 10px 0 var(--ink); animation: jelly 1.2s ease-in-out infinite; }
.logo .l2 span:nth-child(2) { color: var(--pink); animation-delay: .1s; }
.logo .l2 span:nth-child(3) { color: var(--sky); animation-delay: .2s; }
.logo .l2 span:nth-child(4) { color: var(--mint); animation-delay: .3s; }
.logo .l2 span:nth-child(5) { color: #b48cff; animation-delay: .4s; }
.sub { font-weight: 900; font-size: clamp(15px, 2vw, 20px); text-align: center; background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 8px 18px; box-shadow: 0 4px 0 var(--ink); }
.btn { font-family: var(--pop); font-size: 26px; color: var(--ink); background: var(--yellow); border: 4px solid var(--ink); border-radius: 20px; padding: 10px 30px; box-shadow: 0 6px 0 var(--ink); cursor: pointer; text-decoration: none; display: inline-block; transition: transform .1s; }
.btn:hover { transform: translateY(-2px) scale(1.03); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.btn.sub { background: #fff; font-size: 20px; }
#startBtn { margin-top: 18px; animation: pulse 1s ease-in-out infinite alternate; }
.howto { margin-top: 18px; display: grid; grid-template-columns: repeat(2, auto); gap: 6px 18px; font-weight: 800; font-size: 14px; background: rgba(255,255,255,.88); border: 3px solid var(--ink); border-radius: 16px; padding: 10px 16px; }

.pcnote { margin-top: 10px; font-weight: 900; font-size: 13px; color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
#result, #over { background: rgba(43,29,46,.25); padding: 16px; }
.rbox { background: var(--cream); border: 5px solid var(--ink); border-radius: 26px; box-shadow: 0 10px 0 var(--ink); padding: 18px 26px 22px; text-align: center; width: min(440px, 94vw); max-height: 94vh; overflow: auto; animation: boxIn .6s cubic-bezier(.2,1.6,.4,1); }
.rtitle { font-family: var(--pop); font-size: 34px; color: var(--pink); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }
.rankwrap { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 4px 0; }
.rank { font-family: var(--pop); font-size: 92px; line-height: 1; text-shadow: 0 8px 0 var(--ink); animation: rankIn .9s cubic-bezier(.2,1.8,.4,1) .3s both; }
.rank-S { color: var(--yellow); animation: rankIn .9s cubic-bezier(.2,1.8,.4,1) .3s both, rainbowText 1s linear 1.2s infinite; }
.rank-A { color: var(--pink); } .rank-B { color: var(--sky); } .rank-C { color: var(--mint); } .rank-D { color: #b8a9c9; }
.rankname { font-weight: 900; font-size: 20px; background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 4px 12px; }
.rscore { font-family: var(--pop); font-size: 50px; color: var(--yellow); text-shadow: 0 5px 0 var(--ink); }
.rstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0 14px; }
.rstats .st { background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 4px 2px; display: flex; flex-direction: column; align-items: center; }
.rstats .st b { font-family: var(--pop); font-weight: 400; font-size: 18px; line-height: 1.2; }
.rstats .st span { font-weight: 800; font-size: 11px; opacity: .7; }
.rbtns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.rbox.over .rtitle { color: #7b8cff; }
.osub { font-weight: 900; margin: 6px 0; }
.otips { font-weight: 800; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 8px 12px; margin: 10px 0 16px; }
#pause { background: rgba(43,29,46,.4); }
.ptxt { font-family: var(--pop); font-size: 80px; color: #fff; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; }
.psub { font-weight: 900; color: #fff; }

/* ---------- アニメーション ---------- */
@keyframes slam {
  0% { transform: scale(3) rotate(-8deg); opacity: 0; }
  12% { transform: scale(.88) rotate(2deg); opacity: 1; }
  20% { transform: scale(1.06) rotate(-1deg); }
  28% { transform: scale(1) rotate(0); }
  82% { transform: scale(1); opacity: 1; }
  100% { transform: translateY(-40px) scale(.95); opacity: 0; }
}
@keyframes rainbowText { from { filter: hue-rotate(0deg); } to { filter: hue-rotate(360deg); } }
@keyframes hue { from { filter: hue-rotate(0deg); } to { filter: hue-rotate(360deg); } }
@keyframes comboBurst { 0% { transform: scale(1.8) rotate(-6deg); } 100% { transform: scale(1); } }
@keyframes shakeX { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes drainBlink { 50% { filter: brightness(1.4) saturate(1.4); } }
@keyframes missionPulse { from { transform: translateX(0); } to { transform: translateX(6px); } }
@keyframes countPop { 0% { transform: translateX(-50%) scale(2.2); } 100% { transform: translateX(-50%) scale(1); } }
@keyframes toastIn { 0% { transform: translateX(120%) rotate(8deg); } 100% { transform: translateX(0) rotate(0); } }
@keyframes toastOut { to { transform: translateX(120%); opacity: 0; } }
@keyframes wobble { from { transform: rotate(-12deg) scale(1); } to { transform: rotate(12deg) scale(1.12); } }
@keyframes bob { from { margin-top: 0; } to { margin-top: -8px; } }
@keyframes urgentGlow { from { box-shadow: 0 3px 0 var(--ink), 0 0 0 0 rgba(255,77,109,.0); } to { box-shadow: 0 3px 0 var(--ink), 0 0 0 8px rgba(255,77,109,.45); } }
@keyframes vigPulse { from { opacity: .65; } to { opacity: 1; } }
@keyframes float { from { transform: translateY(0) rotate(-1deg); } to { transform: translateY(-10px) rotate(1deg); } }
@keyframes jelly { 0%,100% { transform: scale(1,1); } 30% { transform: scale(1.15,.85) translateY(6px); } 50% { transform: scale(.9,1.12) translateY(-10px); } 70% { transform: scale(1.04,.96); } }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.07); } }
@keyframes boxIn { 0% { transform: scale(.4) rotate(-6deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes rankIn { 0% { transform: scale(4) rotate(-30deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }

@media (max-width: 760px) {
  #help { display: none; }
  #missions { top: 130px; }
  #missions li { font-size: 12px; max-width: 46vw; }
  #score { font-size: 34px; }
}
