/* 音鳴る方へ style.css — 構造とクラス名は docs/design.md を参照 */

:root {
  --c-ink: #3b2f2f;
  --c-ink-sub: #7a6a5e;
  --c-paper: #fffdf7;
  --c-line: #eadcc0;
  --c-red: #e8413b;
  --c-red-deep: #b8302c;
  --c-gold: #ffc83d;
  --c-gold-deep: #d99a00;
  --c-green: #3fa66a;
  --c-green-deep: #256e45;
  --c-sky: #4f9be0;
  --c-sky-deep: #2f6fb8;
  --c-night: #1b2960;
  --c-night-mid: #2c3f94;
  --c-night-deep: #0b1438;
  --c-snow: #f4f9ff;
  --c-snow-shade: #bcd3ee;

  /* 8音（Sprites.NOTES と同じ値） */
  --n-do: #ff5d5d;  --n-do-d: #c33a3a;
  --n-re: #ff9a3c;  --n-re-d: #c96a17;
  --n-mi: #ffd23f;  --n-mi-d: #c99a0a;
  --n-fa: #5fcf6a;  --n-fa-d: #2f9440;
  --n-so: #3fc4e8;  --n-so-d: #1a8db0;
  --n-la: #5b84ee;  --n-la-d: #3256b8;
  --n-si: #a070f0;  --n-si-d: #6f42bf;
  --n-do2: #ff74c4; --n-do2-d: #c9408f;

  --font-base: "Hiragino Maru Gothic ProN", "Hiragino Maru Gothic Pro", "BIZ UDPGothic",
    "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --font-num: "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN", "SF Pro Rounded",
    ui-rounded, system-ui, sans-serif;

  --radius-m: 18px;
  --radius-l: 28px;
  --btn-depth: 6px;
  --play-w: min(100vw, 480px);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --dur-fast: 0.15s;
  --dur-mid: 0.35s;
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-base);
  color: var(--c-ink);
  background: var(--c-night-deep);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
  line-height: 1.5;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
.num { font-family: var(--font-num); font-weight: 900; font-variant-numeric: tabular-nums; }

.app {
  position: relative;
  width: var(--play-w);
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: linear-gradient(180deg, var(--c-night-deep), var(--c-night-mid) 60%, #5a5fb0);
}
@media (min-width: 520px) {
  .app { border-left: 4px solid var(--c-ink); border-right: 4px solid var(--c-ink); }
}

/* ---------- 画面切替 ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(16px + var(--safe-left));
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(12px);
  transition: opacity var(--dur-mid) ease, transform var(--dur-mid) ease, visibility 0s linear var(--dur-mid);
  overflow-y: auto;
}
.screen.is-active {
  opacity: 1; visibility: visible; pointer-events: auto; transform: none;
  transition: opacity var(--dur-mid) ease, transform var(--dur-mid) ease, visibility 0s;
}
.screen__bg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.screen > :not(.screen__bg) { position: relative; z-index: 1; }

/* ---------- ボタン（押すと沈む） ---------- */
.btn {
  --btn-bg: var(--c-red);
  --btn-edge: var(--c-red-deep);
  --btn-fg: #fff;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 12px 28px;
  border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--btn-bg); color: var(--btn-fg);
  font-size: 20px; font-weight: 800; letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 var(--btn-depth) 0 var(--btn-edge), 0 var(--btn-depth) 0 3px var(--c-ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter var(--dur-fast);
}
.btn::after {
  content: ""; position: absolute; top: 5px; left: 18%; right: 18%; height: 6px;
  border-radius: 999px; background: rgba(255, 255, 255, 0.35); pointer-events: none;
}
.btn:hover { filter: brightness(1.05); }
.btn:active, .btn.is-pressed {
  transform: translateY(var(--btn-depth));
  box-shadow: 0 0 0 var(--btn-edge), 0 0 0 3px var(--c-ink);
}
.btn:disabled { filter: grayscale(0.8) opacity(0.6); cursor: not-allowed; transform: none; }
.btn--block { display: flex; width: 100%; }
.btn--green { --btn-bg: var(--c-green); --btn-edge: var(--c-green-deep); }
.btn--sky { --btn-bg: var(--c-sky); --btn-edge: var(--c-sky-deep); }
.btn--gold { --btn-bg: var(--c-gold); --btn-edge: var(--c-gold-deep); --btn-fg: var(--c-ink); }
.btn--ghost { --btn-bg: var(--c-paper); --btn-edge: var(--c-line); --btn-fg: var(--c-ink); }
.btn--small { min-height: 40px; padding: 6px 16px; font-size: 15px; --btn-depth: 4px; }
.btn__sub { display: block; font-size: 12px; font-weight: 700; opacity: 0.9; }
.btn__icon { font-size: 1.1em; line-height: 1; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; padding: 0; flex: none;
  border: 3px solid var(--c-ink); border-radius: 50%;
  background: var(--c-paper);
  font-size: 20px; font-weight: 900; line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--c-ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.icon-btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--c-ink); }
/* ミュート: ♪ に斜線 */
.icon-btn--mute::before { content: "♪"; }
.icon-btn--mute.is-muted { background: #d9d3c8; }
.icon-btn--mute.is-muted::after {
  content: ""; position: absolute; width: 26px; height: 3px; border-radius: 2px;
  background: var(--c-red); transform: rotate(-45deg);
}
.icon-btn--mute { position: relative; }
.btn:focus-visible, .icon-btn:focus-visible, .key:focus-visible, .song-card:focus-visible, .tool:focus-visible {
  outline: 4px solid var(--c-gold); outline-offset: 3px;
}

/* ---------- タイトル ---------- */
.screen--title { align-items: center; justify-content: center; gap: 14px; text-align: center; }
.title__corner { position: absolute !important; top: calc(12px + var(--safe-top)); right: calc(12px + var(--safe-right)); }
.logo { margin: 0; font-weight: 900; line-height: 1.05; }
.logo__sub {
  display: inline-block; padding: 2px 14px;
  border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--c-paper);
  font-size: clamp(14px, 3.8vmin, 18px);
  transform: rotate(-3deg);
}
.logo__main { display: flex; justify-content: center; gap: 2px; margin-top: 10px; font-size: clamp(44px, 13vmin, 70px); }
/* 1 文字ずつ音の色。--i で順番に跳ねる（ドレミの階段） */
.logo__char {
  display: inline-block;
  color: var(--c, var(--c-paper));
  -webkit-text-stroke: 3px var(--c-ink);
  paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--c-ink);
  transform: translateY(calc(var(--i, 0) * -5px));
  animation: hop 2.4s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 0.12s);
}
.logo__char:nth-child(1) { --c: var(--n-do); --i: 0; }
.logo__char:nth-child(2) { --c: var(--n-mi); --i: 1; }
.logo__char:nth-child(3) { --c: var(--n-so); --i: 2; }
.logo__char:nth-child(4) { --c: var(--n-la); --i: 3; }
.logo__char:nth-child(5) { --c: var(--n-do2); --i: 4; }
@keyframes hop {
  0%, 55%, 100% { translate: 0 0; }
  65% { translate: 0 3px; }
  78% { translate: 0 -12px; }
}
.title__scene { width: min(76vw, 300px); height: auto; aspect-ratio: 4 / 3; border: 3px solid var(--c-ink); border-radius: var(--radius-l); box-shadow: 0 6px 0 var(--c-ink); background: var(--c-night); }
.title__lead { margin: 0; color: var(--c-paper); font-size: 15px; font-weight: 800; text-shadow: 0 2px 0 var(--c-ink); }
.title__actions { display: flex; flex-direction: column; gap: 12px; width: min(80vw, 320px); }

/* ---------- 曲えらび ---------- */
.screen--select { gap: 14px; }
.select__head { display: flex; align-items: center; gap: 10px; }
.select__title {
  flex: 1; margin: 0; text-align: center;
  color: var(--c-paper); font-size: 24px; font-weight: 900;
  -webkit-text-stroke: 2px var(--c-ink); paint-order: stroke fill; text-shadow: 0 3px 0 var(--c-ink);
}
.select__head::after { content: ""; width: 44px; flex: none; }
.song-list { display: flex; flex-direction: column; gap: 14px; margin: 0; padding: 4px 0 8px; }
.song-card {
  --c: var(--n-mi); --d: var(--n-mi-d);
  display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 12px;
  width: 100%; min-height: 84px; padding: 10px 14px 10px 10px;
  border: 3px solid var(--c-ink); border-radius: var(--radius-l);
  background: var(--c-paper);
  box-shadow: 0 6px 0 var(--c-ink);
  text-align: left; cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.song-card:nth-child(2) { --c: var(--n-so); --d: var(--n-so-d); }
.song-card:nth-child(3) { --c: var(--n-si); --d: var(--n-si-d); }
.song-card:active { transform: translateY(6px); box-shadow: 0 0 0 var(--c-ink); }
.song-card__no {
  display: grid; place-items: center;
  width: 56px; height: 56px;
  border: 3px solid var(--c-ink); border-radius: 16px;
  background: var(--c); box-shadow: inset 0 -6px 0 var(--d);
  color: #fff; font-size: 28px;
  -webkit-text-stroke: 2px var(--c-ink); paint-order: stroke fill;
}
.song-card__body { display: flex; flex-direction: column; min-width: 0; }
.song-card__title { font-size: 19px; font-weight: 900; line-height: 1.25; }
.song-card__meta { color: var(--c-ink-sub); font-size: 12px; font-weight: 700; }
.song-card__stars { font-size: 20px; white-space: nowrap; }
.song-card.is-locked { background: #e4e0ea; cursor: not-allowed; }
.song-card.is-locked .song-card__no { background: #b8b3c4; box-shadow: inset 0 -6px 0 #8f8a9c; }
.song-card.is-locked:active { transform: none; box-shadow: 0 6px 0 var(--c-ink); }
.song-card.is-cleared .song-card__title::after {
  content: "クリア"; margin-left: 6px; padding: 0 6px; vertical-align: 2px;
  border: 2px solid var(--c-ink); border-radius: 8px; background: var(--c-gold);
  font-size: 11px;
}
.star { color: #d6cfc2; -webkit-text-stroke: 1.5px var(--c-ink); paint-order: stroke fill; }
.star.is-on { color: var(--c-gold); }

/* ---------- モーダル（ルール） ---------- */
.modal {
  position: absolute; inset: 0; z-index: 20;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(11, 20, 56, 0.66);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity var(--dur-mid) ease, visibility 0s linear var(--dur-mid);
}
.modal.is-open { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity var(--dur-mid) ease, visibility 0s; }
.card {
  width: min(100%, 360px);
  max-height: 100%; overflow-y: auto;
  padding: 20px 18px 22px;
  border: 3px solid var(--c-ink); border-radius: var(--radius-l);
  background: var(--c-paper);
  box-shadow: 0 8px 0 var(--c-ink);
  text-align: center;
}
.modal.is-open .card { animation: pop-in var(--dur-mid) var(--ease-pop) both; }
@keyframes pop-in { from { transform: scale(0.85); opacity: 0; } to { transform: none; opacity: 1; } }
.card__title { margin: 0 0 12px; font-size: 22px; font-weight: 900; }
.card__actions { display: flex; flex-direction: column; gap: 12px; }

.rules { display: grid; gap: 10px; margin: 0 0 16px; padding: 0; list-style: none; text-align: left; }
.rules__item {
  display: grid; grid-template-columns: 56px 1fr; align-items: center; gap: 12px;
  padding: 8px 10px;
  border: 3px solid var(--c-ink); border-radius: var(--radius-m);
  background: #fff;
}
.rules__pic { width: 56px; height: 56px; border: 2px solid var(--c-ink); border-radius: 12px; background: #dfe8fb; }
.rules__step { display: grid; place-items: center; width: 56px; height: 56px; border: 2px solid var(--c-ink); border-radius: 12px; background: var(--c-gold); font-size: 26px; }
.rules__text { margin: 0; font-size: 14px; font-weight: 700; }
.rules__text b { color: var(--c-red); }

/* ---------- プレイ ---------- */
.screen--play { padding: 0; overflow: hidden; gap: 0; }
.play__top {
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + var(--safe-top)) calc(10px + var(--safe-right)) 6px calc(10px + var(--safe-left));
}
.play__title {
  flex: 1; min-width: 0; margin: 0;
  padding: 4px 14px;
  border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--c-paper); box-shadow: 0 3px 0 var(--c-ink);
  font-size: 16px; font-weight: 900; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* ためした回数・空きマス */
.play__stats { display: flex; justify-content: center; gap: 8px; padding: 0 10px 6px; }
.stat {
  display: inline-flex; align-items: baseline; gap: 4px;
  padding: 1px 12px;
  border: 3px solid var(--c-ink); border-radius: 999px;
  background: rgba(255, 253, 247, 0.92);
  font-size: 12px; font-weight: 800;
}
.stat .num { font-size: 18px; color: var(--c-red); }
.stat--empty .num { color: var(--c-sky-deep); }
.stat.is-tick { animation: tick 0.25s var(--ease-pop); }
@keyframes tick { from { transform: scale(1.2); } to { transform: none; } }

.play__board { position: relative; flex: 1; min-height: 0; margin: 0 10px; border: 3px solid var(--c-ink); border-radius: var(--radius-m); overflow: hidden; box-shadow: 0 4px 0 var(--c-ink); background: var(--c-night); }
.play__canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.play__hint {
  position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 2;
  margin: 0; padding: 4px 10px;
  border: 2px dashed var(--c-ink); border-radius: 12px;
  background: rgba(255, 246, 216, 0.95);
  font-size: 12px; font-weight: 800; text-align: center;
  pointer-events: none;
}

.play__bottom {
  display: flex; flex-direction: column; gap: 10px;
  padding: 10px calc(10px + var(--safe-right)) calc(12px + var(--safe-bottom)) calc(10px + var(--safe-left));
}
/* お手本・ヒント・消す（小）＋ スタート（大） */
.tools { display: grid; grid-template-columns: repeat(3, 1fr) 1.5fr; gap: 8px; align-items: stretch; }
.tool {
  --t-bg: var(--c-paper); --t-edge: var(--c-line);
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  min-height: 52px; padding: 4px 2px;
  border: 3px solid var(--c-ink); border-radius: 16px;
  background: var(--t-bg);
  box-shadow: 0 4px 0 var(--t-edge), 0 4px 0 3px var(--c-ink);
  font-size: 13px; font-weight: 900; line-height: 1.15;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.tool:active { transform: translateY(4px); box-shadow: 0 0 0 var(--t-edge), 0 0 0 3px var(--c-ink); }
.tool:disabled { filter: grayscale(0.8) opacity(0.55); cursor: not-allowed; transform: none; }
.tool__icon { font-size: 20px; line-height: 1; }
.tool--demo { --t-bg: #fff3c4; --t-edge: var(--c-gold-deep); }
.tool--demo.is-playing { --t-bg: var(--c-gold); animation: beat 0.5s ease-in-out infinite alternate; }
@keyframes beat { to { transform: scale(1.05); } }
.tool--hint { --t-bg: #e3f3ff; --t-edge: var(--c-sky-deep); }
.tool__badge {
  position: absolute; top: -8px; right: -6px;
  min-width: 22px; height: 22px; padding: 0 5px;
  border: 2px solid var(--c-ink); border-radius: 999px;
  background: var(--c-red); color: #fff;
  font-size: 12px; line-height: 18px;
}
.tool__badge:empty { display: none; }
.tool--start {
  --t-bg: var(--c-green); --t-edge: var(--c-green-deep);
  color: #fff; font-size: 18px;
  text-shadow: 0 2px 0 var(--c-green-deep);
}
.tool--start .tool__icon { font-size: 22px; }

/* ---------- 鍵盤パレット（8 音） ----------
   1 列 8 鍵（木琴のように低い音ほど背が高い）。幅 440px 未満は 4×2 に折り返す */
.keys { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; align-items: end; }
.key {
  --c: var(--n-do); --d: var(--n-do-d); --h: 90px;
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  min-width: 0; height: var(--h); padding: 0 0 8px;
  border: 3px solid var(--c-ink); border-radius: 14px;
  background: var(--c);
  box-shadow: inset 0 -7px 0 var(--d), 0 5px 0 var(--c-ink);
  color: #fff; cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.06s ease, filter var(--dur-fast);
  touch-action: manipulation;
}
.key::before {
  content: ""; position: absolute; top: 5px; left: 20%; right: 20%; height: 5px;
  border-radius: 999px; background: rgba(255, 255, 255, 0.45);
}
.key__bell {
  position: absolute; top: 12px; left: 50%;
  width: var(--bell, 18px); height: var(--bell, 18px); margin-left: calc(var(--bell, 18px) / -2);
  border: 2.5px solid var(--c-ink); border-radius: 50% 50% 18% 18%;
  background: rgba(255, 255, 255, 0.7);
}
.key__label {
  font-size: 22px; font-weight: 900; line-height: 1;
  -webkit-text-stroke: 3px var(--c-ink); paint-order: stroke fill;
}
.key__sub { margin-top: 2px; font-family: var(--font-num); font-size: 10px; font-weight: 900; color: var(--c-ink); opacity: 0.65; }
.key:active, .key.is-down {
  transform: translateY(5px);
  box-shadow: inset 0 -3px 0 var(--d), 0 0 0 var(--c-ink);
}
.key.is-ring { animation: ring 0.35s ease-out; }
@keyframes ring {
  0% { filter: brightness(1.45); }
  100% { filter: none; }
}
/* 空きマスを選んでいる間は「ここから選んでね」で少し揺れる */
.key.is-target { animation: nudge 1.6s ease-in-out infinite; animation-delay: calc(var(--k, 0) * 0.06s); }
.key.is-target.is-ring { animation: ring 0.35s ease-out; }
@keyframes nudge { 0%, 80%, 100% { translate: 0 0; } 88% { translate: 0 -4px; } }
.key:disabled { filter: grayscale(0.7) opacity(0.6); cursor: not-allowed; }
.key[data-note="do"]  { --c: var(--n-do);  --d: var(--n-do-d);  --h: 96px; --bell: 22px; --k: 0; }
.key[data-note="re"]  { --c: var(--n-re);  --d: var(--n-re-d);  --h: 93px; --bell: 20px; --k: 1; }
.key[data-note="mi"]  { --c: var(--n-mi);  --d: var(--n-mi-d);  --h: 90px; --bell: 18px; --k: 2; }
.key[data-note="fa"]  { --c: var(--n-fa);  --d: var(--n-fa-d);  --h: 87px; --bell: 16px; --k: 3; }
.key[data-note="so"]  { --c: var(--n-so);  --d: var(--n-so-d);  --h: 84px; --bell: 14px; --k: 4; }
.key[data-note="la"]  { --c: var(--n-la);  --d: var(--n-la-d);  --h: 81px; --bell: 12px; --k: 5; }
.key[data-note="si"]  { --c: var(--n-si);  --d: var(--n-si-d);  --h: 78px; --bell: 11px; --k: 6; }
.key[data-note="do2"] { --c: var(--n-do2); --d: var(--n-do2-d); --h: 76px; --bell: 10px; --k: 7; }
/* 高いドは金の内枠＋きらり */
.key[data-note="do2"] { box-shadow: inset 0 0 0 3px var(--c-gold), inset 0 -7px 0 var(--d), 0 5px 0 var(--c-ink); }
.key[data-note="do2"]::after { content: "✦"; position: absolute; top: 2px; right: 4px; color: var(--c-gold); font-size: 12px; -webkit-text-stroke: 1px var(--c-ink); }
.key[data-note="do2"]:active { box-shadow: inset 0 0 0 3px var(--c-gold), inset 0 -3px 0 var(--d), 0 0 0 var(--c-ink); }
.key[data-note="fa"] .key__label { font-size: 17px; }
@media (max-width: 439px) {
  .keys { grid-template-columns: repeat(4, 1fr); gap: 8px 6px; }
  .key { --h: 60px !important; flex-direction: row; justify-content: center; gap: 4px; padding: 0 0 4px; }
  .key__bell { position: static; flex: none; margin: 0; width: calc(var(--bell) * 0.8); height: calc(var(--bell) * 0.8); }
  .key__sub { display: none; }
  .key__label { font-size: 22px; }
  .key[data-note="fa"] .key__label { font-size: 19px; }
}

/* ---------- 判定（ちがうマス ◯個） ---------- */
.judge-banner {
  position: absolute; left: 50%; top: 14%; z-index: 5;
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 22px;
  border: 3px solid var(--c-ink); border-radius: var(--radius-m);
  background: var(--c-paper); box-shadow: 0 6px 0 var(--c-ink);
  white-space: nowrap; text-align: center;
  transform: translateX(-50%);
  pointer-events: none; opacity: 0;
}
.judge-banner__main { font-size: 20px; font-weight: 900; }
.judge-banner__main .num { margin: 0 2px; color: var(--c-red); font-size: 30px; }
.judge-banner__sub { font-size: 12px; font-weight: 800; color: var(--c-ink-sub); }
.judge-banner.is-show { opacity: 1; animation: drop-in 0.5s var(--ease-pop) both; }
@keyframes drop-in { from { opacity: 0; transform: translateX(-50%) translateY(-24px) scale(0.8); } to { opacity: 1; transform: translateX(-50%); } }

/* ---------- クリア演出（盤面の上に重ねる） ---------- */
.clear-banner {
  position: absolute; left: 50%; top: 30%; z-index: 6;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 26px;
  border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--c-red); color: #fff;
  box-shadow: 0 6px 0 var(--c-ink);
  font-size: 30px; font-weight: 900; white-space: nowrap;
  text-shadow: 0 3px 0 var(--c-red-deep);
  transform: translateX(-50%);
  pointer-events: none; opacity: 0;
}
.clear-banner::before, .clear-banner::after {
  content: ""; position: absolute; top: 12px; z-index: -1;
  width: 30px; height: 36px;
  border: 3px solid var(--c-ink); background: var(--c-red-deep);
}
.clear-banner::before { left: -20px; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 35% 50%); border-right: 0; }
.clear-banner::after { right: -20px; clip-path: polygon(0 0, 100% 0, 65% 50%, 100% 100%, 0 100%); border-left: 0; }
.clear-banner.is-show { animation: banner 2.6s var(--ease-pop) both; }
@keyframes banner {
  0% { opacity: 0; transform: translateX(-50%) translateY(30px) scale(0.6) rotate(-6deg); }
  14% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.08) rotate(2deg); }
  22% { transform: translateX(-50%) scale(1) rotate(0); }
  85% { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-30px) scale(0.9); }
}

/* ---------- 結果 ---------- */
.screen--result { align-items: center; justify-content: center; gap: 14px; text-align: center; background: rgba(11, 20, 56, 0.6); }
.result__card { width: min(100%, 360px); padding: 18px 16px 20px; }
.result__label { margin: 0; font-size: 14px; font-weight: 900; color: var(--c-ink-sub); }
.result__title { margin: 2px 0 4px; font-size: 24px; font-weight: 900; }
.result__stars { display: flex; justify-content: center; gap: 6px; margin: 4px 0 10px; font-size: 52px; line-height: 1; }
.result__stars .star { -webkit-text-stroke: 3px var(--c-ink); animation: star-pop 0.5s var(--ease-pop) both; }
.result__stars .star:nth-child(2) { animation-delay: 0.25s; font-size: 1.2em; translate: 0 -6px; }
.result__stars .star:nth-child(3) { animation-delay: 0.5s; }
@keyframes star-pop { from { transform: scale(0) rotate(-40deg); } to { transform: none; } }
.result__rows { display: grid; gap: 6px; margin: 0 0 12px; padding: 8px 12px; border: 3px solid var(--c-ink); border-radius: var(--radius-m); background: #eef4ff; text-align: left; }
.result__row { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; font-weight: 800; }
.result__row .num { font-size: 20px; color: var(--c-red); }
.result__note { margin: 0 0 12px; font-size: 12px; font-weight: 700; color: var(--c-ink-sub); }
.result__new {
  display: inline-block; margin: 0 0 10px; padding: 0 10px;
  border: 2px solid var(--c-ink); border-radius: 8px;
  background: var(--c-gold); font-size: 13px; font-weight: 900;
  animation: wiggle 0.9s ease-in-out infinite;
}
@keyframes wiggle { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg) scale(1.1); } }
.result__all { margin: 0 0 12px; padding: 8px; border: 3px dashed var(--c-ink); border-radius: var(--radius-m); background: #fff6d8; font-size: 14px; font-weight: 900; }
.result__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.result__actions .btn--block { grid-column: 1 / -1; }

.toast {
  position: absolute; left: 50%; bottom: calc(180px + var(--safe-bottom)); z-index: 30;
  padding: 6px 16px; border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--c-paper); font-size: 14px; font-weight: 800; white-space: nowrap;
  transform: translateX(-50%); animation: pop-in var(--dur-mid) var(--ease-pop) both;
}

/* ---------- 横向き警告 ---------- */
.rotate {
  position: fixed; inset: 0; z-index: 50;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: var(--c-night); color: var(--c-paper);
  font-size: 20px; font-weight: 900; text-align: center;
}
.rotate__phone {
  width: 44px; height: 72px;
  border: 4px solid var(--c-paper); border-radius: 10px;
  animation: turn 1.8s ease-in-out infinite;
}
@keyframes turn { 0%, 30% { transform: rotate(-90deg); } 60%, 100% { transform: rotate(0); } }
@media (orientation: landscape) and (max-height: 520px) and (pointer: coarse) {
  .rotate { display: flex; }
}
.rotate.is-show { display: flex; }

/* ---------- 低い画面（iPhone SE 等）：鍵盤とボタンを詰める ---------- */
@media (max-height: 640px) {
  .tool { min-height: 44px; }
  .tool__icon { font-size: 16px; }
  .key { --h: 54px !important; flex-direction: row; justify-content: center; gap: 4px; padding: 0 0 4px; }
  .key__bell { position: static; flex: none; margin: 0; width: calc(var(--bell) * 0.7); height: calc(var(--bell) * 0.7); }
  .key__sub { display: none; }
  .play__bottom { gap: 8px; padding-top: 8px; }
}

/* ---------- 動きを減らす ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .logo__char, .rotate__phone, .result__new, .key.is-target, .tool--demo.is-playing { animation: none !important; }
  .clear-banner.is-show { animation: banner-fade 2.6s linear both !important; animation-duration: 2.6s !important; }
}
@keyframes banner-fade { 0%, 100% { opacity: 0; } 8%, 85% { opacity: 1; } }
