:root {
  --bg0: #07040d;
  --purple: #7b3fe4;
  --violet: #b48bff;
  --orange: #ff7b1c;
  --gold: #ffcf4a;
  --ink: #f4ecff;
  --dim: #a596c4;
  --miss: #ff3d6a;
  --panel: rgba(22, 12, 40, .82);
  --line: rgba(180, 139, 255, .28);
  --left: #c39bff;
  --right: #ff9a4a;
  --neon: #5ff4ff;
  --key: 58px;
  --gap: 6px;
  --u: calc(var(--key) + var(--gap));
  --round: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
  --logo: "Dela Gothic One", "M PLUS Rounded 1c", "Yu Gothic UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--round);
  color: var(--ink);
  background: radial-gradient(ellipse at 78% 10%, #4a2373 0%, #1e0f35 38%, var(--bg0) 78%) fixed, var(--bg0);
  overflow-x: hidden;
  user-select: none;
}
kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 .4em;
  margin: 0 .1em;
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .06);
  font: 700 .85em var(--round);
  text-align: center;
  color: var(--ink);
}
button { font-family: inherit; }

/* ===== 背景シーン ===== */
#scene { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bg-image {
  position: absolute; inset: 0;
  background: url("assets/bg.png") center / cover no-repeat;
}
/* 背景画像があるときは、画像に描かれている月・墓地と重なる内蔵イラストを隠す */
body.has-bg .moon, body.has-bg .stars, body.has-bg .gy-art { display: none; }
body.has-bg .graveyard { height: 200px; }
.stars i {
  position: absolute; width: 2px; height: 2px; border-radius: 50%;
  background: #fff; opacity: .2;
  animation: twinkle 3s ease-in-out infinite;
}
@keyframes twinkle { 50% { opacity: .9; transform: scale(1.6); } }

.moon {
  position: absolute; top: 5vh; right: 8vw;
  width: 150px; height: 150px; border-radius: 50%;
  background: radial-gradient(circle at 38% 36%, #fffbe6 0%, #ffe9a8 45%, #f5c065 100%);
  box-shadow: 0 0 60px 18px rgba(255, 214, 120, .35), 0 0 180px 70px rgba(255, 150, 60, .14);
}
.moon::before, .moon::after {
  content: ""; position: absolute; border-radius: 50%; background: rgba(214, 160, 70, .35);
}
.moon::before { width: 28px; height: 28px; top: 40px; left: 74px; }
.moon::after { width: 16px; height: 16px; top: 92px; left: 44px; box-shadow: 52px -6px 0 4px rgba(214, 160, 70, .25); }

.bat { position: absolute; width: 56px; height: 28px; fill: #0a0510; animation: batfly 22s linear infinite; }
.bat use { transform-box: fill-box; transform-origin: center; animation: flap .28s ease-in-out infinite alternate; }
.bat.b1 { top: 14vh; animation-delay: -3s; }
.bat.b2 { top: 24vh; width: 36px; animation-duration: 28s; animation-delay: -15s; }
.bat.b3 { top: 8vh; width: 44px; animation-duration: 19s; animation-delay: -9s; animation-direction: reverse; }
.bat.b4 { top: 32vh; width: 30px; animation-duration: 34s; animation-delay: -22s; }
@keyframes batfly {
  0% { transform: translate(-10vw, 0); }
  25% { transform: translate(22vw, -5vh); }
  50% { transform: translate(52vw, 3vh); }
  75% { transform: translate(82vw, -3vh); }
  100% { transform: translate(112vw, 1vh); }
}
@keyframes flap { to { transform: scaleY(.35); } }

/* 背景の魔女 */
.bg-witch {
  position: absolute; top: 18vh; left: 0; width: 96px;
  transform: translate(-12vw, 0);
  animation: witchpass 30s linear 2s infinite backwards;
}
@keyframes witchpass {
  0% { transform: translate(-12vw, 0) rotate(-4deg); }
  8.75% { transform: translate(19vw, -3vh) rotate(2deg); }
  17.5% { transform: translate(50vw, 1vh) rotate(-3deg); }
  26.25% { transform: translate(81vw, -2vh) rotate(2deg); }
  35%, 100% { transform: translate(112vw, 0) rotate(-4deg); }
}

.graveyard { position: absolute; left: 0; bottom: 0; width: 100%; height: 300px; }
.graveyard .pk { filter: drop-shadow(0 0 10px rgba(255, 140, 30, .55)); }
.pk-face { animation: candle 2.4s ease-in-out infinite; }
@keyframes candle { 0%, 100% { opacity: 1; } 40% { opacity: .75; } 60% { opacity: .95; } 80% { opacity: .7; } }
.mist {
  position: absolute; left: -20%; right: -20%; bottom: 0; height: 160px;
  background: radial-gradient(ellipse at 30% 100%, rgba(180, 150, 230, .16), transparent 60%),
              radial-gradient(ellipse at 75% 100%, rgba(180, 150, 230, .12), transparent 60%);
  animation: drift 16s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translateX(8%); } }

/* ===== 画面共通 ===== */
main { position: relative; z-index: 1; min-height: 100vh; display: flex; padding: 24px 16px 40px; }
.screen { display: none; width: min(1080px, 100%); margin: auto; }
.screen.active { display: block; animation: fadein .35s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } }

/* ===== タイトル ===== */
.title-wrap { text-align: center; position: relative; }
.title-ghost {
  position: absolute; top: -10px; right: max(0px, calc(50% - 400px)); width: 150px;
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 0 18px rgba(200, 180, 255, .55));
}
.title-logo {
  margin: 40px 0 32px;
  font: 400 clamp(44px, 8vw, 88px)/1.05 var(--logo);
  background: linear-gradient(180deg, #ffe08a 0%, #ff9a2a 55%, #e2560c 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 #3b1466) drop-shadow(0 0 24px rgba(255, 140, 40, .45));
}
.title-logo span { display: block; font-size: .7em; letter-spacing: .2em; }

.start-btn {
  padding: 14px 44px; border-radius: 999px; cursor: pointer;
  font: 400 26px var(--logo); color: #2a1206;
  background: linear-gradient(180deg, #ffd27a, #ff7b1c);
  border: 0;
  box-shadow: 0 6px 0 #8a2a00, 0 0 36px rgba(255, 123, 28, .55);
  animation: pulse 1.6s ease-in-out infinite;
}
.start-btn kbd { color: #2a1206; border-color: rgba(42, 18, 6, .4); font-size: .55em; vertical-align: middle; }
.start-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #8a2a00; }
.title-best { min-height: 1.4em; margin: 18px 0 0; color: var(--gold); font-weight: 800; }

.title-foot { margin-top: 20px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.chip-btn {
  padding: 8px 16px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  font-size: 14px; cursor: pointer;
}
.chip-btn b { color: var(--gold); }
.howto { color: var(--dim); font-size: 13px; margin-top: 14px; }
.tut-open-btn {
  margin-top: 18px; padding: 9px 24px; border-radius: 999px; cursor: pointer;
  background: rgba(8, 28, 44, .6); border: 2px solid var(--neon); color: #dffcff;
  font: 800 17px var(--round);
  text-shadow: 0 0 8px rgba(95, 244, 255, .8);
  box-shadow: 0 0 10px rgba(95, 244, 255, .5), inset 0 0 10px rgba(95, 244, 255, .2);
  transition: box-shadow .15s;
}
.tut-open-btn:hover { box-shadow: 0 0 20px rgba(95, 244, 255, .8), inset 0 0 14px rgba(95, 244, 255, .35); }
.tut-open-btn kbd { color: inherit; border-color: rgba(95, 244, 255, .5); text-shadow: none; }

/* ===== 練習画面 ===== */
.play-head {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 24px;
  padding: 10px 18px; margin-bottom: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
}
.ph-stage { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.ph-progress { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--dim); }
.bar { width: 140px; height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--purple), var(--orange)); transition: width .25s; }
.ph-stats { display: flex; gap: 20px; margin: 0; }
.ph-stats div { text-align: center; }
.ph-stats dt { font-size: 11px; color: var(--dim); }
.ph-stats dd { margin: 0; font: 400 22px var(--logo); color: var(--gold); min-width: 64px; }
.ph-stats small { font: 700 11px var(--round); color: var(--dim); margin-left: 2px; }

.stage-area { display: grid; grid-template-columns: 170px 1fr 190px; gap: 16px; align-items: stretch; }

.ghost-wrap { position: relative; display: flex; align-items: flex-end; justify-content: center; }
.ghost { width: 120px; height: 144px; position: relative; animation: float 3s ease-in-out infinite; }
.ghost-svg { width: 100%; height: 100%; filter: drop-shadow(0 0 16px rgba(200, 180, 255, .6)); }
.g-body { fill: #f4efff; }
.ghost-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: none; }
.ghost.use-img { width: 165px; height: 165px; }
.ghost.use-img .ghost-svg { display: none; }
.ghost-img { filter: drop-shadow(0 0 14px rgba(200, 180, 255, .5)); }
.ghost.use-img .gi-normal { display: block; }
.ghost.use-img.happy .gi-normal, .ghost.use-img.scared .gi-normal { display: none; }
.ghost.use-img.happy .gi-happy, .ghost.use-img.scared .gi-scared { display: block; }
.eyes-happy, .eyes-scared, .m-happy, .m-scared { display: none; }
.ghost.happy .eyes-normal, .ghost.happy .m-normal, .ghost.scared .eyes-normal, .ghost.scared .m-normal { display: none; }
.ghost.happy .eyes-happy, .ghost.happy .m-happy { display: inline; }
.ghost.scared .eyes-scared, .ghost.scared .m-scared { display: inline; }
.ghost.happy { animation: hop .35s ease; }
.ghost.scared { animation: shiver .45s linear; }
@keyframes float { 50% { transform: translateY(-10px); } }
@keyframes hop { 40% { transform: translateY(-22px) rotate(-6deg); } }
@keyframes shiver { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.bubble {
  position: absolute; top: 0; left: 50%; transform: translate(-50%, -6px) scale(.8);
  max-width: 170px; padding: 6px 12px;
  background: #fff; color: #2a1640; border-radius: 14px;
  font-size: 13px; font-weight: 800; white-space: nowrap;
  opacity: 0; transition: opacity .15s, transform .15s; z-index: 2;
}
.bubble::after {
  content: ""; position: absolute; bottom: -7px; left: 50%; margin-left: -7px;
  border: 7px solid transparent; border-top-color: #fff; border-bottom: 0;
}
.bubble.show { opacity: 1; transform: translate(-50%, -6px) scale(1); }

.prompt-box {
  min-height: 190px; padding: 18px 24px;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px;
  background: var(--panel); border: 2px solid var(--line); border-radius: 18px;
  box-shadow: inset 0 0 40px rgba(123, 63, 228, .25);
}
.prompt-box.shake { animation: shake .3s linear; border-color: var(--miss); }
@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }
.prompt-display { font-size: 22px; font-weight: 700; color: var(--violet); min-height: 1.4em; }
.prompt-kana { font-size: 40px; font-weight: 800; letter-spacing: .04em; line-height: 1.5; text-align: center; }
.prompt-kana .ch { display: inline-block; position: relative; color: rgba(244, 236, 255, .55); transition: color .1s; }
.prompt-kana .ch.done { color: var(--gold); text-shadow: 0 0 12px rgba(255, 207, 74, .5); }
.prompt-kana .ch.current {
  color: #fff; transform: scale(1.12);
  text-shadow: 0 0 16px rgba(180, 139, 255, .9);
}
.prompt-kana .ch.current::after {
  content: ""; position: absolute; left: 10%; right: 10%; bottom: -2px; height: 4px; border-radius: 4px;
  background: var(--orange); animation: blink 1s steps(2) infinite;
}
.prompt-kana .ch.missed { color: var(--miss); text-shadow: none; }
.prompt-kana .ch.done.missed { color: #ff8aa6; }
@keyframes blink { 50% { opacity: .2; } }

.next-box {
  padding: 12px; text-align: center;
  background: var(--panel); border: 2px solid var(--orange); border-radius: 18px;
  box-shadow: 0 0 24px rgba(255, 123, 28, .25);
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
}
.next-label { font-size: 12px; color: var(--dim); font-weight: 700; }
.next-char { font-size: 76px; font-weight: 800; line-height: 1.1; }
.next-char.sh-left { color: var(--left); }
.next-char.sh-right { color: var(--right); }
.next-hint { font-size: 15px; font-weight: 800; }
.next-hint .t-left { color: var(--left); }
.next-hint .t-right { color: var(--right); }
.next-hint .k { display: inline-block; padding: 0 8px; border-radius: 6px; background: rgba(255, 255, 255, .12); }
.next-after { font-size: 12px; color: var(--dim); min-height: 1.3em; }

/* キーボード */
.kb-wrap { margin-top: 16px; padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; }
.kb-wrap.hide .keyboard { display: none; }
.keyboard { width: calc(var(--u) * 10.75); margin: 0 auto; display: grid; gap: var(--gap); }
.kb-row { display: flex; gap: var(--gap); }
.kb-row.row1 { margin-left: calc(var(--u) * .25); }
.kb-row.row2 { margin-left: calc(var(--u) * .75); }
.kb-row.thumbs { margin-top: 2px; }
.key {
  position: relative; width: var(--key); height: 60px; flex: none;
  border-radius: 10px;
  background: linear-gradient(180deg, #2c1c44, #1c112e);
  border: 1px solid #4a3470; border-bottom-width: 3px;
  transition: transform .06s, background .1s;
}
.key.homing::before {
  content: ""; position: absolute; bottom: 7px; left: 50%; width: 14px; height: 2px; margin-left: -7px; background: var(--dim); border-radius: 2px;
}
.key .kn { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-size: 22px; font-weight: 800; }
.key .kl { position: absolute; top: 3px; left: 6px; font-size: 13px; font-weight: 800; color: var(--left); }
.key .kr { position: absolute; top: 3px; right: 6px; font-size: 13px; font-weight: 800; color: var(--right); }
.key .kc { position: absolute; bottom: 2px; right: 5px; font-size: 9px; color: rgba(165, 150, 196, .6); }
.key.target {
  border-color: var(--gold);
  background: linear-gradient(180deg, #4b2d70, #2c1a47);
  box-shadow: 0 0 0 2px rgba(255, 207, 74, .5), 0 0 20px rgba(255, 207, 74, .45);
}
.key .hit { color: var(--gold) !important; text-shadow: 0 0 10px rgba(255, 207, 74, .9); transform: scale(1.3); }
.key.pressed { transform: translateY(2px); background: #4b2d70; }
.key.wrong { animation: keywrong .35s; }
@keyframes keywrong { from { background: var(--miss); } }
.key.thumb {
  width: calc(var(--u) * 2.4); display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800;
}
.key.thumb.tl { margin-left: calc(var(--u) * 2.75); color: var(--left); border-color: rgba(195, 155, 255, .6); }
.key.thumb.tr { margin-left: calc(var(--u) * .35); color: var(--right); border-color: rgba(255, 154, 74, .6); }
.key.thumb.target { animation: pulse .8s ease-in-out infinite; }
.key.thumb.tl.target { border-color: var(--left); box-shadow: 0 0 22px rgba(195, 155, 255, .7); }
.key.thumb.tr.target { border-color: var(--right); box-shadow: 0 0 22px rgba(255, 154, 74, .7); }
.key.thumb.down { transform: translateY(2px); background: #4b2d70; }
@keyframes pulse { 50% { filter: brightness(1.5); } }

.kb-legend { margin: 10px 0 0; display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; font-size: 12px; color: var(--dim); }
.kb-legend span::before { content: "●"; margin-right: 4px; }
.lg-l::before { color: var(--left); }
.lg-n::before { color: var(--ink); }
.lg-r::before { color: var(--right); }
.kb-legend .lg-k::before { content: none; }

/* ===== 結果画面 ===== */
.result-card {
  width: min(720px, 100%); margin: 0 auto; padding: 28px 32px;
  background: var(--panel); border: 2px solid var(--line); border-radius: 22px;
  box-shadow: 0 0 60px rgba(123, 63, 228, .35);
}
.res-top { display: flex; align-items: center; gap: 28px; justify-content: center; flex-wrap: wrap; }
.res-rank {
  width: 140px; height: 140px; border-radius: 50%;
  display: grid; place-items: center;
  font: 400 86px/1 var(--logo); color: #fff;
  background: radial-gradient(circle at 40% 35%, #ffb35a, #e2560c 70%, #8a2a00);
  box-shadow: 0 0 40px rgba(255, 123, 28, .6), inset 0 -10px 20px rgba(0, 0, 0, .3);
  animation: rankin .7s cubic-bezier(.2, 1.6, .4, 1);
}
.res-rank.r-S { background: radial-gradient(circle at 40% 35%, #fff1a8, #ffcf4a 55%, #c77a00); color: #3b1466; box-shadow: 0 0 70px rgba(255, 207, 74, .8); }
.res-rank.r-D, .res-rank.r-C { background: radial-gradient(circle at 40% 35%, #b48bff, #5a2aa8 70%, #2a0f55); box-shadow: 0 0 40px rgba(123, 63, 228, .6); }
@keyframes rankin { from { transform: scale(0) rotate(-30deg); } }
.res-rank-wrap { position: relative; }
.res-ghost {
  position: absolute; right: -58px; bottom: -22px; width: 100px;
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 0 12px rgba(200, 180, 255, .5));
}
.res-label { margin: 0; font-size: 12px; color: var(--dim); }
.res-title { margin: 2px 0 6px; font: 400 36px var(--logo); color: var(--gold); }
.res-comment { margin: 0; }
.res-best { margin: 6px 0 0; color: var(--orange); font-weight: 800; }
.res-stats { margin: 24px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.res-stats div { padding: 10px; text-align: center; background: rgba(255, 255, 255, .05); border-radius: 12px; }
.res-stats dt { font-size: 12px; color: var(--dim); }
.res-stats dd { margin: 2px 0 0; font: 400 26px var(--logo); }
.res-sub { margin: 8px 0 0; display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; font-size: 13px; }
.res-sub div { display: flex; gap: 6px; align-items: baseline; }
.res-sub dt { color: var(--dim); }
.res-sub dd { margin: 0; font-weight: 800; }
.res-badges { margin-top: 18px; text-align: center; }
.res-badges h3 { margin: 0 0 8px; font-size: 13px; color: var(--dim); }
.res-badges ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.badge {
  position: relative; width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; font-size: 22px; cursor: default;
  background: radial-gradient(circle at 40% 35%, #5a3a86, #2a1640 75%);
  border: 2px solid var(--gold); box-shadow: 0 0 14px rgba(255, 207, 74, .35);
}
.badge.locked { border-color: var(--line); box-shadow: none; background: rgba(255, 255, 255, .04); }
.badge.locked .bd-icon { filter: grayscale(1) brightness(.6); opacity: .45; }
.badge.new { animation: badgein .7s cubic-bezier(.2, 1.6, .4, 1); }
.badge.new::after {
  content: "NEW"; position: absolute; top: -8px; right: -10px;
  padding: 1px 5px; border-radius: 6px; background: var(--orange); color: #fff;
  font: 800 9px/1.4 var(--round);
}
@keyframes badgein { from { transform: scale(0) rotate(-40deg); } }
.bd-tip {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 220px; padding: 8px 12px; border-radius: 10px; z-index: 5;
  background: #1a0d2e; border: 1px solid var(--line); box-shadow: 0 4px 18px rgba(0, 0, 0, .5);
  font-size: 12px; line-height: 1.5; color: var(--dim); text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.bd-tip b { display: block; font-size: 14px; color: var(--gold); }
.badge.locked .bd-tip b { color: var(--ink); }
.bd-tip i { display: block; font-style: normal; font-size: 11px; color: var(--violet); }
.badge:hover .bd-tip { opacity: 1; }
.res-share { margin-top: 10px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.res-share button {
  padding: 7px 14px; border-radius: 10px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: var(--dim); font-size: 13px; font-weight: 700;
}
.res-share button:hover { border-color: var(--violet); color: var(--ink); }
.res-btns { margin-top: 22px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.res-btns button {
  padding: 10px 18px; border-radius: 12px; cursor: pointer;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line); color: var(--ink); font-size: 15px; font-weight: 700;
}
.res-btns button:hover { border-color: var(--orange); }
.res-btns button:disabled { opacity: .35; cursor: default; }

/* ===== エフェクト ===== */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 10; overflow: hidden; }
.particle {
  position: fixed; transform: translate(-50%, -50%);
  animation: burst .75s ease-out forwards;
  text-shadow: 0 0 8px currentColor;
}
@keyframes burst {
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--rot)) scale(.2); opacity: 0; }
}
.pop {
  position: fixed; transform: translate(-50%, -100%);
  font-weight: 800; font-size: 20px; white-space: nowrap;
  animation: popup .8s ease-out forwards;
}
.pop.miss { color: var(--miss); text-shadow: 0 0 10px rgba(255, 61, 106, .7); }
.pop.clear { font: 400 34px var(--logo); color: var(--gold); text-shadow: 0 0 18px rgba(255, 140, 40, .8), 0 3px 0 #3b1466; }
@keyframes popup {
  0% { transform: translate(-50%, -60%) scale(.6); opacity: 0; }
  20% { transform: translate(-50%, -100%) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -190%) scale(1); opacity: 0; }
}
.combo-banner {
  position: fixed; left: 50%; top: 30%; transform: translate(-50%, -50%);
  font: 400 64px var(--logo); color: var(--gold); white-space: nowrap;
  text-shadow: 0 0 30px rgba(255, 140, 40, .9), 0 5px 0 #3b1466;
  animation: banner 1.2s ease-out forwards;
}
.combo-banner small { display: block; font-size: 22px; text-align: center; color: var(--violet); }
@keyframes banner {
  0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; }
  20% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -70%) scale(1); opacity: 0; }
}
.flash { position: fixed; inset: 0; pointer-events: none; z-index: 9; opacity: 0; }
.flash.on { animation: missflash .35s ease-out; }
@keyframes missflash {
  from { opacity: 1; background: radial-gradient(ellipse at center, transparent 50%, rgba(255, 30, 80, .45)); }
  to { opacity: 0; background: radial-gradient(ellipse at center, transparent 50%, rgba(255, 30, 80, .45)); }
}
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  padding: 10px 18px; border-radius: 12px;
  background: #2a1640; border: 1px solid var(--orange); color: var(--ink); font-weight: 700;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* ===== 黒猫ダッシュ ===== */
.cat-run {
  position: fixed; inset: 0; z-index: 8;
  display: flex; flex-direction: column; justify-content: center; gap: 10px;
  padding: 16px;
  background: radial-gradient(ellipse at 50% 60%, rgba(30, 15, 53, .55), rgba(7, 4, 13, .88) 75%);
  backdrop-filter: blur(3px);
  cursor: pointer; touch-action: manipulation;
  animation: catin .35s ease-out;
}
@keyframes catin { from { opacity: 0; transform: scale(1.04); } }
body.cat-active main { filter: blur(2px) brightness(.6); }
.cr-head {
  width: min(1080px, 100%); margin: 0 auto;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px;
}
.cr-title {
  font: 400 clamp(22px, 4vw, 34px) var(--logo);
  background: linear-gradient(180deg, #ffe08a 0%, #ff9a2a 55%, #e2560c 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #3b1466);
}
.cr-song { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.cr-song i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--purple), var(--orange)); }
.cr-score { font: 400 30px var(--logo); color: var(--gold); min-width: 90px; text-align: right; }
.cr-score small { font: 700 14px var(--round); color: var(--dim); margin-left: 3px; }
.cr-canvas { display: block; width: 100%; height: min(56vh, 420px); }
.cr-hint { margin: 0; text-align: center; color: var(--dim); font-size: 14px; }
.cr-msg {
  position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%) scale(.6);
  font: 400 clamp(36px, 7vw, 64px) var(--logo); color: var(--gold); white-space: nowrap; text-align: center;
  text-shadow: 0 0 30px rgba(255, 140, 40, .9), 0 5px 0 #3b1466;
  opacity: 0; pointer-events: none;
}
.cr-msg small { display: block; font: 800 20px var(--round); color: var(--violet); text-shadow: none; margin-top: 4px; }
.cr-msg.show { animation: crmsg .35s cubic-bezier(.2, 1.6, .4, 1) forwards; }
.cr-msg.crash { color: var(--miss); text-shadow: 0 0 30px rgba(255, 61, 106, .8), 0 5px 0 #3b1466; }
@keyframes crmsg { to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

/* ===== チュートリアル ===== */
.tut-shade { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 6; pointer-events: none; }
.tut-dim { fill: rgba(6, 3, 14, .62); }
.tut-ring {
  position: fixed; z-index: 7; pointer-events: none;
  border: 2px solid var(--neon); border-radius: 12px;
  box-shadow: 0 0 6px var(--neon), 0 0 18px rgba(95, 244, 255, .75), 0 0 38px rgba(95, 244, 255, .35), inset 0 0 12px rgba(95, 244, 255, .45);
  animation: neon 1.8s ease-in-out infinite;
}
@keyframes neon {
  50% { box-shadow: 0 0 4px var(--neon), 0 0 10px rgba(95, 244, 255, .5), 0 0 20px rgba(95, 244, 255, .2), inset 0 0 6px rgba(95, 244, 255, .3); }
}
/* 説明だけのステップは、水色の枠で囲むだけ（ちかちかさせない） */
body.tut-explain .tut-ring { animation: none; }
body.tut-explain .prompt-kana .ch.current::after { animation: none; }
.tut-card {
  position: fixed; left: 0; top: 0; z-index: 12;
  width: min(500px, calc(100vw - 24px)); padding: 12px 18px 12px;
  background: rgba(14, 10, 32, .96); border: 2px solid var(--neon); border-radius: 16px;
  box-shadow: 0 0 18px rgba(95, 244, 255, .4), 0 10px 40px rgba(0, 0, 0, .6);
  transition: transform .25s ease;
}
.tut-card.in .tut-body { animation: tutin .3s ease; }
@keyframes tutin { from { opacity: 0; transform: translateY(6px); } }
.tut-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tut-chapters { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.tut-chapters button {
  min-width: 24px; padding: 2px 7px; border-radius: 99px; cursor: pointer;
  background: transparent; border: 1px solid rgba(95, 244, 255, .3); color: var(--dim);
  font: 700 11px var(--round);
}
.tut-chapters .done button { color: #9feeff; border-color: rgba(95, 244, 255, .55); }
.tut-chapters .cur button { background: var(--neon); border-color: var(--neon); color: #062028; font-weight: 800; }
.tut-count { font-size: 11px; color: var(--dim); white-space: nowrap; }
.tut-title { margin: 8px 0 6px; font: 400 22px var(--logo); color: #dffcff; text-shadow: 0 0 10px rgba(95, 244, 255, .6); }
.tut-text { font-size: 15px; line-height: 1.7; }
.tut-text b { color: var(--gold); }
.tut-text small { color: var(--dim); font-size: 12px; }
.tut-text ul { margin: 2px 0; padding-left: 1.2em; }
.tut-text kbd { font-size: .8em; }
.c-l { color: var(--left); font-weight: 800; }
.c-r { color: var(--right); font-weight: 800; }
.tut-text b.c-n { color: #fff; }
.tut-key-demo { display: flex; align-items: center; gap: 18px; margin: 4px 0 8px; }
.tut-key-demo .key { width: 84px; height: 86px; }
.tut-key-demo .key .kn { font-size: 32px; bottom: 14px; }
.tut-key-demo .key .kl, .tut-key-demo .key .kr { font-size: 18px; top: 5px; }
.tut-key-demo .key .kl { left: 9px; }
.tut-key-demo .key .kr { right: 9px; }
.tut-key-demo .key .kc { font-size: 11px; }
.tut-key-demo ul { list-style: none; margin: 0; padding: 0; }
.tut-key-demo b { display: inline-block; width: 1.3em; font-size: 18px; }
.tut-status { margin: 6px 0 0; min-height: 1.4em; font-size: 14px; font-weight: 800; }
.tut-status:empty { display: none; }
.tut-status.wait { color: var(--neon); animation: tutwait 1.4s ease-in-out infinite; }
.tut-status.ok { color: var(--gold); }
@keyframes tutwait { 50% { opacity: .45; } }
.tut-btns { margin-top: 10px; display: flex; gap: 8px; justify-content: flex-end; }
.tut-btns button {
  padding: 6px 14px; border-radius: 10px; cursor: pointer;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line); color: var(--ink);
  font-size: 13px; font-weight: 700;
}
.tut-btns button:disabled { opacity: .3; cursor: default; }
#tut-exit { margin-right: auto; color: var(--dim); }
#tut-next { border-color: var(--neon); color: #dffcff; }
/* 進めるときは、打つキーと同じように枠のまわりを光らせて点滅させる */
#tut-next.ready { border: 2px solid var(--neon); animation: nextglow 1s ease-in-out infinite; }
@keyframes nextglow {
  0%, 100% { box-shadow: 0 0 0 2px rgba(95, 244, 255, .5), 0 0 18px rgba(95, 244, 255, .7); }
  50% { box-shadow: 0 0 0 0 rgba(95, 244, 255, 0), 0 0 4px rgba(95, 244, 255, .2); }
}

/* 画面が狭いとき */
@media (max-width: 900px) {
  :root { --key: 44px; --gap: 4px; }
  .stage-area { grid-template-columns: 1fr; }
  .ghost-wrap { display: none; }
  .play-head { grid-template-columns: 1fr; gap: 8px; }
  .key .kn { font-size: 17px; }
  .key .kl, .key .kr { font-size: 10px; }
  .kb-wrap { overflow-x: auto; }
}
