/* 脳内BPM — 見た目 */
:root {
  --bg: #07070b;
  --ink: #f4f4f0;
  --dim: rgba(244, 244, 240, .58);
  --faint: rgba(244, 244, 240, .14);
  --acc: #c6ff3d;
  --hot: #ff3d8b;
  --cy: #3df0ff;
  --panel: rgba(14, 14, 20, .72);
  --r: 18px;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --disp: 'Dela Gothic One', 'Zen Kaku Gothic New', sans-serif;
  --body: 'Zen Kaku Gothic New', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--body); font-size: 16px; line-height: 1.75;
  min-height: 100svh; overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
.mono { font-family: var(--mono); }
.small { font-size: 12px; }
strong { color: var(--acc); font-weight: 700; }

#bg { position: fixed; inset: 0; z-index: 0; }
.grain {
  position: fixed; inset: -50%; z-index: 1; pointer-events: none; opacity: .06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1s steps(6) infinite;
}
@keyframes grain { 0%{transform:translate(0,0)} 25%{transform:translate(-3%,2%)} 50%{transform:translate(2%,-4%)} 75%{transform:translate(-1%,3%)} 100%{transform:translate(0,0)} }

/* ───── 画面切りかえのワイプ（5本の帯が時間差で落ちる） ───── */
#wipe { position: fixed; inset: 0; z-index: 50; pointer-events: none; display: flex; }
#wipe span { flex: 1; background: var(--acc); transform: scaleY(0); transform-origin: top; }
#wipe.in span { animation: wipeIn .34s cubic-bezier(.7,0,.3,1) forwards; }
#wipe.out span { transform: scaleY(1); transform-origin: bottom; animation: wipeOut .42s cubic-bezier(.7,0,.3,1) forwards; }
#wipe span:nth-child(2) { animation-delay: .035s !important; background: var(--hot); }
#wipe span:nth-child(3) { animation-delay: .07s !important; background: var(--ink); }
#wipe span:nth-child(4) { animation-delay: .105s !important; background: var(--cy); }
#wipe span:nth-child(5) { animation-delay: .14s !important; }
@keyframes wipeIn { to { transform: scaleY(1); } }
@keyframes wipeOut { to { transform: scaleY(0); } }

/* ───── ヘッダー ───── */
.top {
  position: relative; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: linear-gradient(var(--bg) 40%, transparent);
}
.logo { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-family: var(--disp); font-size: 18px; white-space: nowrap; }
.logo svg { width: 38px; height: 16px; color: var(--acc); }
.tracks { display: flex; gap: 4px; list-style: none; margin: 0 0 0 auto; padding: 0; }
.tracks li { display: flex; align-items: center; gap: 4px; font-size: 11px; padding: 3px 7px; border-radius: 99px; border: 1px solid var(--faint); color: var(--dim); transition: .3s; }
.tracks li b { font-family: var(--mono); }
.tracks li span { display: none; }
.tracks li.on { border-color: var(--acc); color: var(--bg); background: var(--acc); }
.tracks li.on span { display: inline; }
.tracks li.done { color: var(--acc); border-color: rgba(198,255,61,.4); }
body[data-screen="intro"] .tracks, body[data-screen="result"] .tracks, body[data-screen="analyze"] .tracks, body[data-screen="share"] .tracks { visibility: hidden; }
.rec { display: none; align-items: center; gap: 5px; font-family: var(--mono); font-size: 11px; color: var(--hot); }
.rec i { width: 8px; height: 8px; border-radius: 50%; background: var(--hot); animation: blink 1s infinite; }
body[data-screen="tap"] .rec, body[data-screen="keep"] .rec, body[data-screen="clock"] .rec { display: inline-flex; }
@keyframes blink { 50% { opacity: .2; } }

/* ───── 画面の共通 ───── */
main { position: relative; z-index: 2; max-width: 560px; margin: 0 auto; padding: 8px 16px 40px; }
.screen { display: none; }
.screen.active { display: block; animation: rise .6s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { opacity: 0; transform: translateY(18px); filter: blur(6px); } }
.eyebrow { font-size: 12px; letter-spacing: .22em; color: var(--acc); margin: 18px 0 6px; }
.title { font-family: var(--disp); font-weight: 400; font-size: clamp(34px, 9vw, 48px); line-height: 1.15; margin: 0 0 10px; }
.lead { font-size: 16px; margin: 0 0 8px; }
.hint, .note { color: var(--dim); font-size: 13px; margin: 0 0 8px; }
.note.small { font-size: 11px; }
.pc-only { display: none; }
@media (hover: hover) and (pointer: fine) { .pc-only { display: inline; } }

/* ───── はじめの画面 ───── */
.hero { margin: 6px 0 18px; font-weight: 400; }
.hero-q { display: block; font-family: var(--disp); font-size: clamp(26px, 7.4vw, 40px); line-height: 1.2; }
.hero-num { display: flex; align-items: baseline; gap: 10px; font-family: var(--mono); font-weight: 800; line-height: .95; margin: 4px 0; }
.hero-num span { font-size: clamp(110px, 34vw, 190px); letter-spacing: -.06em; color: var(--acc); text-shadow: 0 0 40px rgba(198,255,61,.45); font-variant-numeric: tabular-nums; }
.hero-num small { font-size: clamp(20px, 5vw, 28px); color: var(--ink); letter-spacing: .1em; }
.setlist { list-style: none; padding: 0; margin: 18px 0 22px; border-top: 1px solid var(--faint); }
.setlist li { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--faint); font-weight: 700; }
.setlist b { color: var(--acc); font-size: 13px; }
.setlist span { color: var(--dim); font-size: 12px; font-weight: 400; }
.friend-banner { margin: 14px 0 0; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--hot); background: rgba(255,61,139,.1); font-size: 14px; }
.friend-banner b { font-family: var(--mono); font-size: 22px; color: var(--hot); }
.counter { margin-top: 18px; font-size: 12px; color: var(--dim); }

.btn-main {
  position: relative; display: flex; justify-content: space-between; align-items: center; width: 100%;
  padding: 20px 22px; border: 0; border-radius: 999px; margin: 0 0 14px;
  background: var(--acc); color: #07070b; font-family: var(--disp); font-size: 22px;
  box-shadow: 0 0 0 0 rgba(198,255,61,.6), 0 10px 40px rgba(198,255,61,.25);
  animation: breathe 2s infinite; transition: transform .15s;
}
.btn-main i { font-style: normal; font-size: 13px; opacity: .7; }
.btn-main:active { transform: scale(.97); }
@keyframes breathe { 0% { box-shadow: 0 0 0 0 rgba(198,255,61,.55), 0 10px 40px rgba(198,255,61,.25); } 70% { box-shadow: 0 0 0 18px rgba(198,255,61,0), 0 10px 40px rgba(198,255,61,.25); } 100% { box-shadow: 0 0 0 0 rgba(198,255,61,0), 0 10px 40px rgba(198,255,61,.25); } }
.btn-sub { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 18px; border-radius: 999px; border: 1px solid var(--faint); background: var(--panel); font-weight: 700; font-size: 15px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: .2s; text-decoration: none; color: var(--ink); }
.btn-sub:hover { border-color: var(--acc); }
.btn-sub[disabled] { opacity: .45; cursor: default; }

/* ───── タップする円 ───── */
.pad {
  position: relative; display: grid; place-items: center; align-content: center;
  width: min(78vw, 340px); aspect-ratio: 1; margin: 22px auto 12px; border-radius: 50%;
  border: 1px solid var(--faint); background: radial-gradient(circle at 50% 40%, rgba(198,255,61,.10), rgba(10,10,14,.85) 65%);
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
  transition: transform .08s, box-shadow .2s;
}
.pad.hit { transform: scale(.955); box-shadow: 0 0 0 2px var(--acc), 0 0 80px rgba(198,255,61,.35); }
.pad-bpm { font-size: clamp(56px, 17vw, 84px); font-weight: 800; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.pad-label { font-size: 12px; color: var(--dim); letter-spacing: .14em; margin-top: 8px; }
.pad-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); pointer-events: none; }
.pad-ring circle { fill: none; stroke: var(--acc); stroke-width: 1.6; stroke-dasharray: 100; stroke-dashoffset: 100; transition: stroke-dashoffset .2s; stroke-linecap: round; }
.status { text-align: center; color: var(--dim); min-height: 28px; margin: 0; }
.status b { color: var(--ink); font-size: 20px; }
.beats { display: flex; justify-content: center; gap: 14px; margin: 18px 0 0; }
.beats i { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--faint); transition: background .05s, transform .1s; }
.beats i.on { background: var(--acc); border-color: var(--acc); transform: scale(1.4); box-shadow: 0 0 18px var(--acc); }
.beats.solo i { border-style: dashed; }

.pad-clock { background: radial-gradient(circle at 50% 40%, rgba(61,240,255,.10), rgba(10,10,14,.85) 65%); }
body.dark .pad-clock { background: #000; border-color: rgba(255,255,255,.05); }
body.dark .pad-clock .pad-bpm { opacity: 0; }
body.dark main .title, body.dark main .lead, body.dark main .eyebrow, body.dark .top { opacity: .08; transition: opacity 1.2s; }

/* ───── 質問 ───── */
.qbar { height: 3px; background: var(--faint); border-radius: 3px; overflow: hidden; margin: 8px 0 18px; }
.qbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--acc), var(--cy)); transition: width .4s; }
.qbox { min-height: 360px; }
.qbox.swap { animation: qswap .35s cubic-bezier(.2,.8,.2,1); }
@keyframes qswap { from { opacity: 0; transform: translateX(30px); } }
.qnum { color: var(--acc); font-size: 13px; margin: 0; }
.qtext { font-family: var(--disp); font-size: clamp(22px, 6.2vw, 30px); line-height: 1.45; margin: 6px 0 22px; min-height: 2.9em; }
.answers { display: grid; gap: 8px; }
.answers button {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px 16px; border-radius: 14px; border: 1px solid var(--faint); background: var(--panel);
  font-weight: 700; transition: .15s; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.answers button i { flex: none; width: calc(10px + var(--lv) * 7px); height: 10px; border-radius: 9px; background: linear-gradient(90deg, var(--cy), var(--acc)); opacity: calc(.3 + var(--lv) * .17); }
.answers button:hover { border-color: var(--acc); }
.answers button.pick { background: var(--acc); color: var(--bg); border-color: var(--acc); }
.back { display: block; margin: 16px auto 0; background: none; border: 0; color: var(--dim); font-size: 13px; }
.back[hidden] { display: none; }

/* ───── 解析中 ───── */
.analyze { min-height: 70svh; display: flex; flex-direction: column; justify-content: center; }
.wave { width: 100%; height: 120px; }
.wave path { fill: none; stroke: var(--acc); stroke-width: 1.6; filter: drop-shadow(0 0 6px var(--acc)); }
.ana-steps { list-style: none; padding: 0; margin: 18px 0; font-size: 13px; }
.ana-steps li { color: rgba(244,244,240,.25); padding: 3px 0; transition: .3s; }
.ana-steps li.now { color: var(--ink); }
.ana-steps li.now::before { content: '▶ '; color: var(--acc); }
.ana-steps li.ok { color: var(--dim); }
.ana-steps li.ok::after { content: '  OK'; color: var(--acc); }
.ana-pct { font-size: 64px; font-weight: 800; margin: 0; color: var(--acc); font-variant-numeric: tabular-nums; }

/* ───── 結果 ───── */
.res-hero { position: relative; padding-top: 14px; }
.res-hero .eyebrow { color: var(--gc); }
.res-num { display: flex; align-items: baseline; gap: 8px; font-family: var(--mono); font-weight: 800; line-height: .9; margin: 0; }
.res-num span { font-size: clamp(120px, 40vw, 220px); letter-spacing: -.07em; color: var(--gc); text-shadow: 0 0 50px color-mix(in srgb, var(--gc) 50%, transparent); font-variant-numeric: tabular-nums; }
.res-num small { font-size: 26px; letter-spacing: .1em; }
.res-num.land span { animation: land .6s cubic-bezier(.2,1.6,.4,1); }
@keyframes land { 0% { transform: scale(1.25); filter: blur(4px); } 100% { transform: none; filter: none; } }
.res-type { font-family: var(--disp); font-weight: 400; margin: 10px 0 4px; line-height: 1.2; }
.res-type .mod { display: block; font-size: clamp(18px, 5vw, 24px); color: var(--dim); }
.res-type .gen { display: block; font-size: clamp(38px, 11vw, 60px); }
.res-type .gen em { font-style: normal; color: var(--gc); }
.res-en { font-family: var(--mono); font-size: 12px; letter-spacing: .3em; color: var(--dim); margin: 0 0 14px; }
.res-catch { font-size: 19px; font-weight: 900; margin: 0 0 18px; padding-left: 12px; border-left: 3px solid var(--gc); }
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .7s, transform .7s cubic-bezier(.2,.8,.2,1); }
.reveal.in { opacity: 1; transform: none; }

.card { position: relative; border: 1px solid var(--faint); border-radius: var(--r); background: var(--panel); padding: 18px 16px; margin: 0 0 14px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.card h3 { font-size: 13px; font-family: var(--mono); letter-spacing: .16em; color: var(--gc, var(--acc)); margin: 0 0 12px; font-weight: 700; }

.player { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.play {
  width: 64px; height: 64px; border-radius: 50%; border: 0; background: var(--gc); color: var(--bg);
  display: grid; place-items: center; box-shadow: 0 0 30px color-mix(in srgb, var(--gc) 40%, transparent);
}
.play svg { width: 26px; height: 26px; }
.player p { margin: 0; font-size: 14px; color: var(--dim); }
.player p b { color: var(--ink); font-size: 16px; display: block; }
#viz { grid-column: 1 / -1; width: 100%; height: 130px; display: block; }
.steps16 { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(16, 1fr); gap: 3px; }
.steps16 i { height: 6px; border-radius: 2px; background: var(--faint); }
.steps16 i:nth-child(4n+1) { background: rgba(244,244,240,.28); }
.steps16 i.on { background: var(--gc); box-shadow: 0 0 10px var(--gc); }

.meters { display: grid; gap: 14px; }
.meter-top { display: flex; justify-content: space-between; font-weight: 700; font-size: 14px; }
.meter-top span:last-child { font-family: var(--mono); color: var(--gc); }
.meter-bar { height: 10px; border-radius: 10px; background: var(--faint); overflow: hidden; margin-top: 6px; }
.meter-bar i { display: block; height: 100%; width: 0; border-radius: 10px; background: linear-gradient(90deg, color-mix(in srgb, var(--gc) 40%, transparent), var(--gc)); transition: width 1.2s cubic-bezier(.2,.8,.2,1); }
.meter-note { font-size: 12px; color: var(--dim); margin-top: 4px; }

.raw { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.raw div { border: 1px solid var(--faint); border-radius: 12px; padding: 10px 12px; }
.raw small { display: block; font-size: 11px; color: var(--dim); }
.raw b { font-family: var(--mono); font-size: 22px; }
.raw em { font-style: normal; font-size: 12px; color: var(--dim); margin-left: 4px; }

.desc p { margin: 0 0 10px; }
.desc .good { font-size: 13px; color: var(--dim); margin: 0; }
.desc .good b { color: var(--ink); }

.dist svg { width: 100%; height: auto; display: block; overflow: visible; }
.dist .rank { font-size: 15px; margin: 8px 0 0; }
.dist .rank b { font-family: var(--mono); font-size: 26px; color: var(--gc); }
.dist .tiny { font-size: 11px; color: var(--dim); margin: 6px 0 0; }

.compat .vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; text-align: center; gap: 6px; }
.compat .vs b { font-family: var(--mono); font-size: 40px; display: block; line-height: 1; }
.compat .vs small { color: var(--dim); font-size: 12px; }
.compat .vs .x { font-family: var(--disp); color: var(--dim); }
.compat .verdict { font-family: var(--disp); font-size: 24px; margin: 14px 0 4px; color: var(--gc); }
.compat .score { font-family: var(--mono); }

.share { display: grid; gap: 8px; }
.share .btn-x { background: #fff; color: #000; border: 0; font-weight: 900; padding: 16px; font-size: 16px; }
.share-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.share-preview { width: 100%; border-radius: 12px; border: 1px solid var(--faint); display: block; margin-top: 6px; }

.ofuse { text-align: center; border-color: rgba(255,61,139,.45); background: linear-gradient(160deg, rgba(255,61,139,.14), var(--panel)); }
.ofuse p { margin: 0 0 12px; font-size: 14px; }
.ofuse .btn-sub { border-color: var(--hot); width: 100%; }
.ad-slot { min-height: 100px; margin: 0 0 14px; display: grid; place-items: center; border: 1px dashed var(--faint); border-radius: 12px; color: var(--dim); font-family: var(--mono); font-size: 11px; }
.history ul { list-style: none; padding: 0; margin: 0; }
.history li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--faint); font-size: 13px; }
.history li b { font-family: var(--mono); }
.retry { display: flex; gap: 8px; }
.retry .btn-sub { flex: 1; }

/* ───── フッター・その他 ───── */
.foot { position: relative; z-index: 2; text-align: center; color: var(--dim); font-size: 12px; padding: 24px 16px calc(28px + env(safe-area-inset-bottom)); }
.foot p { margin: 4px 0; }
.linkish { background: none; border: 0; color: var(--dim); text-decoration: underline; font-size: 12px; }
dialog { max-width: min(520px, calc(100vw - 32px)); border: 1px solid var(--faint); border-radius: var(--r); background: #101016; color: var(--ink); padding: 22px 20px; line-height: 1.8; font-size: 14px; }
dialog::backdrop { background: rgba(0,0,0,.7); backdrop-filter: blur(4px); }
dialog h3 { font-family: var(--disp); font-weight: 400; margin: 0 0 8px; font-size: 22px; }
dialog h4 { margin: 16px 0 4px; color: var(--acc); }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px); opacity: 0; z-index: 60; background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 99px; font-weight: 700; font-size: 14px; transition: .3s; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ───── ニックネーム・入力欄 ───── */
.namefield { display: block; margin: 0 0 14px; }
.namefield span { display: flex; align-items: baseline; gap: 8px; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.namefield i { font-style: normal; font-weight: 400; font-size: 12px; color: var(--dim); }
.namefield i.over { color: var(--hot); font-weight: 700; }
.namefield input, .namefield textarea {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--faint);
  background: rgba(14,14,20,.85); color: var(--ink); font: inherit; font-size: 16px; line-height: 1.6;
  transition: border-color .2s, box-shadow .2s; resize: vertical;
}
.namefield input:focus, .namefield textarea:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px rgba(198,255,61,.18); }
.namefield input::placeholder { color: rgba(244,244,240,.32); }

/* ───── 上位% ───── */
.ranks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 14px; }
.ranks div { border: 1px solid var(--faint); border-radius: 14px; padding: 12px 8px; text-align: center; background: rgba(0,0,0,.25); }
.ranks small { display: block; font-size: 11px; color: var(--dim); line-height: 1.4; min-height: 2.8em; }
.ranks b { display: block; font-family: var(--mono); font-size: 30px; line-height: 1.1; color: var(--gc); }
.ranks b em { font-style: normal; font-size: 14px; margin-left: 1px; }
.ranks span { font-size: 11px; color: var(--dim); }
.ranks .best { border-color: var(--gc); box-shadow: inset 0 0 24px color-mix(in srgb, var(--gc) 18%, transparent); }
.res-who { font-weight: 700; font-size: 15px; margin: 0 0 -4px; color: var(--ink); }

/* ───── シェア画面 ───── */
.post { border: 1px solid var(--faint); border-radius: 18px; background: rgba(10,10,14,.9); padding: 14px; margin: 14px 0 18px; }
.post-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.post-av { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--gc, var(--acc)); color: var(--bg); font-weight: 900; }
.post-head b { display: block; font-size: 15px; line-height: 1.3; }
.post-head small { font-size: 11px; color: var(--dim); }
.post-text { white-space: pre-wrap; word-break: break-word; font-size: 15px; margin: 0 0 10px; }
.post-text a { color: #4aa3ff; }
.post-card { border: 1px solid var(--faint); border-radius: 14px; overflow: hidden; }
.post-card img { display: block; width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; background: #111; }
.post-card-meta { padding: 8px 12px; }
.post-card-meta small { display: block; color: var(--dim); font-size: 12px; }
.post-card-meta b { font-size: 14px; }
#resetText { margin: -4px 0 18px; padding: 8px 14px; font-size: 13px; }
.share-actions { display: grid; gap: 10px; }
.btn-x { background: #f4f4f0; color: #000; box-shadow: 0 10px 40px rgba(255,255,255,.12); animation: none; }
.share-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.share-row .btn-sub[hidden] { display: none; }
.share-big { width: 100%; }
