@font-face { font-family: "DotGothic16"; src: url("./assets/fonts/DotGothic16-subset.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Zen Maru Gothic"; font-weight: 700; src: url("./assets/fonts/ZenMaruGothic-Bold-subset.woff2") format("woff2"); font-display: swap; }
:root { --pix: "DotGothic16", "MS Gothic", "Osaka-Mono", monospace; --pop: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif; --disp: "Dela Gothic One", "Hiragino Kaku Gothic StdN", sans-serif;
  --ink: #060a14; --gold: #ffcf4a; --ok: #58e08a; --warn: #ff5a3c; --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--ink); color: #fff; overflow: hidden; overscroll-behavior: none; font-family: var(--pop); }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
#app { position: fixed; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.fx { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
#fx-white { background: #fff; z-index: 30; } #fx-black { background: #000; z-index: 31; }

/* ---- 上部バー ---- */
#topbar { position: absolute; z-index: 40; top: calc(8px + var(--sat)); left: 10px; right: 10px; display: flex; gap: 8px; align-items: center; pointer-events: none; }
#topbar > * { pointer-events: auto; } #topbar .spacer { flex: 1; pointer-events: none; }
#topbar a, #topbar button { font-family: var(--pix); font-size: 14px; line-height: 1; padding: 9px 11px; color: #fff; text-decoration: none; background: rgba(6, 10, 20, .72); border: 2px solid rgba(255, 255, 255, .75); border-radius: 6px; cursor: pointer; }
#topbar button[aria-pressed="true"] { opacity: .6; }
#app[data-state="play"] #back, #app[data-state="count"] #back { opacity: .45; }

/* ---- 漫画風の吹き出し ---- */
#bubbles { position: absolute; inset: 0; z-index: 10; pointer-events: none; overflow: hidden; }
.bubble { position: absolute; left: 0; top: 0; max-width: min(46vw, 260px); padding: 7px 12px 8px; font: 700 clamp(12px, 3.4vmin, 17px)/1.3 var(--pop); color: #14141c; background: #fff; border: 3px solid #14141c; border-radius: 18px; white-space: nowrap; transform-origin: 50% 120%; animation: pop .22s cubic-bezier(.3, 1.6, .5, 1) both; will-change: transform; box-shadow: 3px 4px 0 rgba(0, 0, 0, .35); }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -11px; width: 14px; height: 14px; margin-left: -7px; background: #fff; border-right: 3px solid #14141c; border-bottom: 3px solid #14141c; transform: rotate(45deg) skew(12deg, 12deg); }
.bubble.shout { border-radius: 4px; background: #fff36b; clip-path: none; font-family: var(--disp); font-weight: 400; letter-spacing: .02em; transform: rotate(-3deg); }
.bubble.shout::after { background: #fff36b; }
.bubble.think { border-style: dashed; color: #444; background: #f1f1f6; font-size: clamp(11px, 3vmin, 15px); }
.bubble.think::after { display: none; }
.bubble.out { animation: fadeout .25s ease-in both; }
@keyframes pop { from { scale: .3; opacity: 0; } to { scale: 1; opacity: 1; } }
@keyframes fadeout { to { opacity: 0; scale: .9; } }

/* ---- レトロRPG風メッセージウィンドウ ---- */
.rpg-win { position: absolute; z-index: 20; left: 50%; bottom: calc(14px + var(--sab)); width: min(94vw, 720px); transform: translateX(-50%); padding: 18px 20px 22px; font: 400 clamp(17px, 4.6vmin, 24px)/1.6 var(--pix); letter-spacing: .04em; color: #fff; background: #05060d; border: 4px solid #fff; border-radius: 9px; box-shadow: 0 0 0 4px #05060d, inset 0 0 0 2px #05060d, inset 0 0 0 4px #8a8fa8; image-rendering: pixelated; }
#msg { min-height: 5.6em; cursor: pointer; }
#msg-name { position: absolute; top: -1.25em; left: 14px; padding: 2px 12px 3px; font-size: .78em; line-height: 1.4; background: #05060d; border: 3px solid #fff; border-radius: 7px; }
#msg-name:empty { display: none; }
#msg-text { margin: 0; white-space: pre-wrap; min-height: 3.2em; }
#msg-next { position: absolute; right: 16px; bottom: 6px; font-size: .7em; animation: blink .7s steps(2) infinite; visibility: hidden; }
#msg.wait #msg-next { visibility: visible; }
@keyframes blink { 50% { opacity: 0; } }
#choice { width: auto; min-width: min(60vw, 300px); left: auto; right: max(3vw, calc(50% - 360px)); transform: none; bottom: calc(14px + var(--sab) + 7.4em); padding: 12px 18px 12px 12px; display: flex; flex-direction: column; gap: 2px; }
#choice button { all: unset; display: block; padding: 6px 10px 6px 1.6em; position: relative; cursor: pointer; font: inherit; letter-spacing: .04em; }
#choice button::before { content: "▶"; position: absolute; left: .2em; opacity: 0; }
#choice button.on::before { opacity: 1; animation: blink .6s steps(2) infinite; }
.rpg-btn { display: inline-block; font: 400 clamp(16px, 4.2vmin, 21px)/1 var(--pix); letter-spacing: .06em; padding: 14px 22px; color: #fff; text-decoration: none; text-align: center; background: #05060d; border: 3px solid #fff; border-radius: 8px; box-shadow: 0 0 0 3px #05060d, 0 6px 0 3px rgba(0, 0, 0, .5); cursor: pointer; }
.rpg-btn.primary { background: #c8321e; border-color: #ffe9a8; color: #fff7d6; }
.rpg-btn.small { font-size: 15px; padding: 10px 14px; }
.rpg-btn:active { translate: 0 3px; box-shadow: 0 0 0 3px #05060d, 0 3px 0 3px rgba(0, 0, 0, .5); }
.rpg-btn:focus-visible, #choice button:focus-visible, .link:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.rpg-btn[disabled] { opacity: .45; cursor: default; }
.link { all: unset; cursor: pointer; font: 400 14px var(--pix); text-decoration: underline; text-underline-offset: 4px; color: #e8ecff; padding: 8px; }

/* ---- タイトル ---- */
.screen { position: absolute; inset: 0; z-index: 15; }
#title { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(10px, 3vmin, 26px); padding: calc(54px + var(--sat)) 16px calc(18px + var(--sab)); background: radial-gradient(ellipse at 50% 38%, rgba(6, 10, 20, .25), rgba(6, 10, 20, .0) 60%), linear-gradient(180deg, rgba(6, 10, 20, .55), rgba(6, 10, 20, 0) 30%, rgba(6, 10, 20, 0) 62%, rgba(6, 10, 20, .8)); }
.title-lead { margin: 0; font: 700 clamp(15px, 3.6vmin, 22px)/1.5 var(--pop); text-align: center; text-shadow: 0 2px 0 #060a14, 0 0 12px #060a14; }
.title-lead .sp { display: none; }
.title-actions { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.title-actions .primary { animation: nudge 1.6s ease-in-out infinite; }
@keyframes nudge { 50% { translate: 0 -4px; } }
.title-foot { margin: 0; display: flex; gap: 10px; }

/* ---- HUD ---- */
#hud { position: absolute; z-index: 12; top: calc(52px + var(--sat)); left: 0; right: 0; padding: 0 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; font-family: var(--pix); }
.hud-row { display: flex; gap: 10px; width: min(96vw, 620px); justify-content: space-between; }
.hud-box { display: flex; align-items: baseline; gap: 8px; padding: 6px 12px 7px; background: rgba(5, 6, 13, .78); border: 3px solid #fff; border-radius: 8px; font-size: clamp(20px, 5.4vmin, 30px); line-height: 1; min-width: 4.6em; justify-content: space-between; font-variant-numeric: tabular-nums; }
.hud-label { font-size: .5em; opacity: .85; }
#gauge { width: min(96vw, 620px); }
.gauge-track { position: relative; height: clamp(26px, 6.4vmin, 38px); background: #05060d; border: 3px solid #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 0 0 3px #05060d; }
.gauge-band, .gauge-best, .gauge-danger { position: absolute; top: 0; bottom: 0; display: grid; place-items: center; font-size: clamp(11px, 2.8vmin, 14px); letter-spacing: .1em; }
.gauge-band { left: var(--lo); width: calc(var(--hi) - var(--lo)); background: repeating-linear-gradient(135deg, rgba(88, 224, 138, .55) 0 6px, rgba(88, 224, 138, .35) 6px 12px); border-left: 2px solid var(--ok); border-right: 2px solid var(--ok); color: #eafff1; }
.gauge-best { left: var(--blo); width: calc(var(--bhi) - var(--blo)); background: linear-gradient(180deg, #fff3a8, var(--gold)); color: #05060d; box-shadow: 0 0 10px rgba(255, 207, 74, .8); font-size: clamp(13px, 3.4vmin, 18px); letter-spacing: 0; }
.gauge-danger { left: var(--danger); right: 0; background: repeating-linear-gradient(135deg, rgba(255, 90, 60, .55) 0 6px, rgba(255, 90, 60, .3) 6px 12px); border-left: 2px solid var(--warn); color: #ffe9e4; }
#gauge-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; transform-origin: 0 50%; transform: scaleX(0); background: linear-gradient(90deg, rgba(255, 207, 74, .2), rgba(255, 207, 74, .75)); mix-blend-mode: screen; }
#gauge-needle { position: absolute; top: -3px; bottom: -3px; left: 0; width: 6px; margin-left: -3px; background: #fff; box-shadow: 0 0 0 2px #05060d, 0 0 10px #fff; border-radius: 3px; }
.gauge-legend { display: flex; justify-content: space-between; margin-top: 5px; font-size: clamp(12px, 3vmin, 15px); text-shadow: 0 1px 0 #000, 0 0 6px #000; }
#gauge-state { font-size: 1.25em; padding: 1px 10px 2px; border-radius: 5px; background: rgba(5, 6, 13, .8); }
#hud[data-zone="in"] #gauge-state { color: #05060d; background: var(--ok); }
#hud[data-zone="in"][data-best="1"] #gauge-state { background: var(--gold); box-shadow: 0 0 12px var(--gold); }
#hud[data-zone="in"][data-best="1"] .gauge-track { border-color: var(--gold); }
#hud[data-zone="over"] #gauge-state { color: #fff; background: var(--warn); animation: blink .3s steps(2) infinite; }
#hud[data-zone="over"] .gauge-track { border-color: var(--warn); animation: shake .12s linear infinite; }
#hud[data-zone="hot"] .gauge-track { border-color: #fff; animation: shake .06s linear infinite; }
#hud[data-zone="hot"] #gauge-state { color: #fff; background: #d400ff; animation: blink .15s steps(2) infinite; }
@keyframes shake { 0% { translate: -2px 1px; } 50% { translate: 2px -1px; } 100% { translate: -1px -1px; } }

/* ---- なぞるリング ---- */
#pad { position: absolute; z-index: 13; right: max(3vw, 16px); bottom: calc(max(4vh, 16px) + var(--sab)); width: min(44vmin, 300px); aspect-ratio: 1; touch-action: none; cursor: grab; border-radius: 50%; }
#pad::before { content: ""; position: absolute; inset: -22%; border-radius: 50%; }   /* 少しはみ出しても反応する当たり判定 */
.pad-ring { position: absolute; inset: 0; border-radius: 50%; border: 4px dashed rgba(255, 255, 255, .8); background: radial-gradient(circle, rgba(5, 6, 13, 0) 36%, rgba(5, 6, 13, .5) 38%, rgba(5, 6, 13, .5) 100%); box-shadow: 0 0 0 4px rgba(5, 6, 13, .55), inset 0 0 26px rgba(255, 207, 74, .25); animation: spin 9s linear infinite; }
.pad-ring > * { animation: spin 9s linear infinite reverse; }
@keyframes spin { to { rotate: 360deg; } }
.pad-hint { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font: 400 clamp(12px, 3.2vmin, 16px)/1.3 var(--pix); opacity: .9; text-shadow: 0 1px 0 #000; pointer-events: none; }
#pad.active .pad-hint { opacity: 0; } #pad.active .pad-ring { border-color: var(--gold); animation-play-state: paused; }
.pad-arrow { position: absolute; inset: 9%; border-radius: 50%; border: 5px solid transparent; border-top-color: rgba(255, 207, 74, .9); border-right-color: rgba(255, 207, 74, .35); rotate: 0deg; }
#pad.active .pad-arrow { display: none; }
#pad-knob { position: absolute; left: 0; top: 0; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, var(--gold) 55%, #e07a1a); box-shadow: 0 0 0 3px #05060d, 0 0 18px var(--gold); opacity: 0; pointer-events: none; animation: none !important; }
#pad.active #pad-knob { opacity: 1; } #pad.active #pad-knob.off { opacity: .35; }
#count { position: absolute; z-index: 25; inset: 0; display: grid; place-items: center; font: 400 clamp(90px, 30vmin, 220px)/1 var(--disp); color: #fff; -webkit-text-stroke: 6px #14183a; paint-order: stroke fill; pointer-events: none; text-shadow: 0 8px 0 #14183a; }
#count.tick { animation: count .9s ease-out both; } @keyframes count { from { scale: 1.6; opacity: 0; } 20% { opacity: 1; } to { scale: .9; opacity: .0; } }
#banner { position: absolute; z-index: 24; left: 50%; top: 34%; translate: -50% -50%; padding: 10px 26px 14px; font: 400 clamp(22px, 6.4vmin, 44px)/1.25 var(--disp); text-align: center; color: #fff; background: #c8321e; border: 4px solid #fff; border-radius: 10px; box-shadow: 0 0 0 4px #05060d, 0 8px 0 4px rgba(0, 0, 0, .5); rotate: -2deg; pointer-events: none; white-space: nowrap; animation: pop .25s cubic-bezier(.3, 1.6, .5, 1) both; }
#banner small { display: block; margin-top: 6px; font: 700 .45em/1.4 var(--pop); }
#banner.info { background: #05060d; }

/* ---- 結果 ---- */
#result { z-index: 22; overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch; padding: calc(56px + var(--sat)) 12px calc(24px + var(--sab)); background: linear-gradient(180deg, rgba(6, 10, 20, .35), rgba(6, 10, 20, .82) 40%); animation: rise .5s ease-out both; user-select: text; -webkit-user-select: text; }
@keyframes rise { from { opacity: 0; translate: 0 30px; } }
.result-inner { width: min(100%, 560px); margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
#res-headline { margin: 0; text-align: center; font: 400 clamp(26px, 8vmin, 44px)/1.15 var(--disp); color: var(--gold); -webkit-text-stroke: 6px #14183a; paint-order: stroke fill; rotate: -2deg; }
.sns { background: #fff; color: #14141c; border-radius: 16px; padding: 12px 12px 10px; box-shadow: 0 10px 0 rgba(0, 0, 0, .35); font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", sans-serif; }
.sns header { display: flex; align-items: center; gap: 10px; } .sns header b { display: block; font-size: 15px; } .sns header small { color: #6a6f80; font-size: 12px; }
.sns-avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; background: #ffe2a8; flex: none; }
.sns-app { margin-left: auto; font: 400 13px var(--disp); color: #e2562f; }
#sns-text { margin: 8px 2px 10px; font-size: clamp(16px, 4.4vmin, 19px); line-height: 1.55; font-weight: 600; }
#sns-photo { display: block; width: 100%; height: auto; aspect-ratio: 16/9; border-radius: 10px; background: #060a14; }
.sns footer { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12.5px; color: #6a6f80; } #sns-likes { color: #e0245e; font-weight: 700; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-family: var(--pix); }
.stat { padding: 10px 12px 12px; background: rgba(5, 6, 13, .85); border: 3px solid #fff; border-radius: 9px; display: flex; flex-direction: column; gap: 6px; }
.stat span, .stat small { font-size: 13px; opacity: .85; } .stat small { color: var(--gold); opacity: 1; } .stat b { font-weight: 400; font-size: clamp(24px, 7vmin, 34px); line-height: 1; font-variant-numeric: tabular-nums; }
.stat.big { grid-column: 1 / -1; border-color: var(--gold); } .stat.big b { font: 400 clamp(34px, 11vmin, 58px)/1 var(--disp); color: var(--gold); letter-spacing: .01em; }
#res-bulbs { display: flex; gap: 3px; } #res-bulbs i { flex: 1; height: 8px; border-radius: 4px; background: #2b3045; } #res-bulbs i.on { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.res-note { margin: 0; font-size: 13px; line-height: 1.5; color: #d5daf0; min-height: 0; } .res-note:empty { display: none; }
.res-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; padding: 4px 0 6px; }
.rank-form { display: flex; flex-direction: column; gap: 8px; padding: 12px; background: rgba(5, 6, 13, .7); border-radius: 10px; font-family: var(--pix); } .rank-form label { font-size: 14px; }
.rank-row { display: flex; gap: 10px; align-items: center; } .rank-row input { flex: 1; min-width: 0; padding: 10px 12px; font: 400 16px var(--pix); color: #fff; background: #05060d; border: 3px solid #fff; border-radius: 8px; user-select: text; -webkit-user-select: text; }
#share-box { display: flex; flex-direction: column; gap: 10px; padding: 12px; background: rgba(5, 6, 13, .7); border-radius: 10px; } #share-img { width: 100%; height: auto; border-radius: 8px; background: #060a14; aspect-ratio: 1200/630; }
.ranking { padding: 12px; background: rgba(5, 6, 13, .7); border-radius: 10px; font-family: var(--pix); } .ranking h3, dialog h2 { margin: 0 0 8px; font: 400 18px var(--pix); letter-spacing: .1em; }
ol#rank-list, ol#rank-list2 { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; font-size: 15px; }
ol#rank-list li, ol#rank-list2 li { display: grid; grid-template-columns: 2.4em 1fr auto 2.6em; gap: 8px; padding: 5px 6px; border-radius: 5px; align-items: baseline; }
ol#rank-list li.me, ol#rank-list2 li.me { background: rgba(255, 207, 74, .22); outline: 2px solid var(--gold); } li .rk-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } li .rk-score { font-variant-numeric: tabular-nums; } li .rk-grade { text-align: right; opacity: .8; }
.res-foot { text-align: center; margin: 6px 0 0; } .res-foot a { color: #e8ecff; font: 400 15px var(--pix); }

/* ---- 過剰発電エンド ---- */
#ending { position: absolute; inset: 0; z-index: 26; pointer-events: none; }
#sat-label { position: absolute; top: calc(60px + var(--sat)); left: 14px; padding: 4px 12px 6px; font: 400 clamp(14px, 3.6vmin, 20px) var(--pix); letter-spacing: .12em; background: rgba(0, 0, 0, .7); border-left: 5px solid #49f2a0; color: #49f2a0; }
#news { position: absolute; left: 0; right: 0; top: 16%; display: flex; flex-direction: column; align-items: stretch; background: rgba(255, 255, 255, .96); color: #10121a; border-top: 6px solid #d8121f; border-bottom: 6px solid #d8121f; animation: newsin .18s steps(3) both; }
@keyframes newsin { from { scale: 1 .1; opacity: 0; } }
.news-tag { align-self: flex-start; margin: 10px 0 0 14px; padding: 3px 14px 5px; font: 400 clamp(14px, 3.8vmin, 20px) var(--disp); letter-spacing: .1em; color: #fff; background: #d8121f; animation: blink .5s steps(2) 4; }
#news-text { margin: 6px 14px 14px; font: 900 clamp(20px, 6vmin, 40px)/1.35 system-ui, "Hiragino Sans", "Yu Gothic UI", sans-serif; letter-spacing: .02em; }
#gameover { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: #000; pointer-events: auto; text-align: center; padding: 20px; }
.go-title { margin: 0; font: 400 clamp(44px, 14vmin, 110px)/1 var(--pix); letter-spacing: .1em; color: #e8243a; } .go-sub { margin: 0; font: 400 clamp(18px, 5vmin, 26px) var(--pix); } .go-note { margin: 0 0 18px; font: 400 13px var(--pix); opacity: .7; }

/* ---- ダイアログ・ロード ---- */
dialog { max-width: min(92vw, 520px); max-height: 86vh; overflow: auto; color: #fff; background: #05060d; border: 4px solid #fff; border-radius: 10px; padding: 18px 18px 16px; font: 700 14px/1.7 var(--pop); user-select: text; -webkit-user-select: text; touch-action: pan-y; }
dialog::backdrop { background: rgba(0, 0, 0, .7); } dialog a { color: var(--gold); } dialog form { text-align: center; margin-top: 12px; } dialog p { margin: 0 0 10px; }
#loading { position: absolute; inset: 0; z-index: 50; display: grid; place-items: center; background: var(--ink); transition: opacity .5s; font-family: var(--pix); }
#loading.done { opacity: 0; pointer-events: none; }
.load-box { width: min(80vw, 360px); text-align: center; } .load-bar { height: 16px; border: 3px solid #fff; border-radius: 6px; padding: 2px; } .load-bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .2s; }
.load-box.err p { color: #ffb0a0; }
.noscript { position: absolute; inset: auto 0 20% 0; text-align: center; z-index: 60; }

/* ---- 縦長（スマホ）：リングは下中央、ウィンドウは下 ---- */
@media (max-aspect-ratio: 4/5) {
  #pad { right: auto; left: 50%; translate: -50% 0; width: min(62vw, 34vh, 300px); bottom: calc(max(3vh, 14px) + var(--sab)); }
  .title-lead .sp { display: inline; }
  .nv-logo { --u: clamp(7px, 3vw, 18px); }
  #choice { right: 3vw; }
  .rpg-win { font-size: clamp(14px, 4vw, 20px); padding: 14px 14px 18px; letter-spacing: .02em; }
}
@media (max-height: 460px) { .rpg-win { padding: 10px 16px 14px; font-size: 16px; } #msg { min-height: 4.6em; } #hud { top: calc(44px + var(--sat)); gap: 4px; } .title-lead { display: none; } .nv-logo { --u: clamp(8px, 3.2vh, 16px); } #pad { width: min(52vh, 240px); } }
@media (prefers-reduced-motion: reduce) { .title-actions .primary, .pad-ring, .pad-ring > * { animation: none; } }
