:root {
  --bg: #07070c;
  --bg-panel: rgba(14, 14, 22, 0.72);
  --glass: rgba(255, 255, 255, 0.045);
  --glass-strong: rgba(255, 255, 255, 0.07);
  --stroke: rgba(255, 255, 255, 0.1);
  --stroke-strong: rgba(255, 255, 255, 0.18);
  --text: #f5f2fb;
  --text-dim: #9a95ad;
  --pink: #ff5ca8;
  --purple: #c084fc;
  --cyan: #22d3ee;
  --gold: #ffd45a;
  --miss: #ff4d6d;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --radius: 22px;
  --font: "Manrope", "Segoe UI", system-ui, sans-serif;
  --display: "Syne", "Manrope", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
}

button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.ambient {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(124, 58, 237, 0.18), transparent 55%),
    radial-gradient(800px 500px at 100% 80%, rgba(34, 211, 238, 0.08), transparent 50%),
    #07070c;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  animation: drift 18s ease-in-out infinite;
}

.orb-a { width: 420px; height: 420px; left: -80px; top: 12%; background: #7c3aed; }
.orb-b { width: 360px; height: 360px; right: -60px; bottom: 8%; background: #0ea5b7; animation-delay: -6s; }
.orb-c { width: 260px; height: 260px; left: 40%; top: 48%; background: #db2777; opacity: 0.28; animation-delay: -11s; }

@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, -24px) scale(1.08); }
}

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding: calc(10px + var(--safe-t)) 12px calc(10px + var(--safe-b));
  gap: 8px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 4px 8px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.logo {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  box-shadow: 0 0 20px rgba(192, 132, 252, 0.15);
}

.logo-lg {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  margin: 0 auto 10px;
  background: rgba(10, 10, 16, 0.85);
  box-shadow: 0 0 28px rgba(192, 132, 252, 0.22);
}

.logo-lg svg {
  width: 36px;
  height: 36px;
}

.title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  line-height: 1;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--text);
  background: var(--glass);
  border: 1px solid var(--stroke);
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.icon-btn:hover {
  background: var(--glass-strong);
  border-color: var(--stroke-strong);
}

.icon-btn:active { transform: scale(0.94); }

.icon-btn .icon-off { display: none; }
.icon-btn.is-muted .icon-on { display: none; }
.icon-btn.is-muted .icon-off { display: block; }

.hud {
  flex-shrink: 0;
  padding: 10px 12px 8px;
  border-radius: 16px;
  background: var(--bg-panel);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.hud-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr 0.9fr;
  gap: 6px 10px;
  align-items: end;
}

.stat-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.stat-value {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat-score .stat-value {
  font-size: 1.35rem;
  background: linear-gradient(90deg, #fff, var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stat-score.is-pop .stat-value { animation: scorePop 0.28s ease; }

.stat-combo.is-pop .stat-value {
  animation: comboPop 0.32s ease;
  color: var(--pink);
  text-shadow: 0 0 16px rgba(255, 92, 168, 0.7);
}

.stat-best { color: var(--cyan); }

.meter-row {
  display: grid;
  grid-template-columns: auto 1fr auto 72px;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.lives {
  display: flex;
  gap: 5px;
  align-items: center;
  padding-right: 2px;
}

.life {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--stroke-strong);
  transition: background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.life.is-on {
  background: linear-gradient(180deg, #ffb4d8, var(--pink));
  border-color: transparent;
  box-shadow: 0 0 8px rgba(255, 92, 168, 0.7);
}

.life.is-lost {
  transform: scale(0.82);
  opacity: 0.45;
}

.lives.is-low .life.is-on {
  animation: lifePulse 0.7s ease infinite;
}

@keyframes lifePulse {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 92, 168, 0.55); }
  50% { box-shadow: 0 0 14px rgba(255, 92, 168, 1); transform: scale(1.12); }
}

.progress-track,
.fever-track {
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--purple), var(--pink), var(--cyan));
  box-shadow: 0 0 10px rgba(255, 92, 168, 0.45);
}

.fever-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffe08a, var(--gold), #ff9f1c);
}

.fever-track.is-ready {
  box-shadow: 0 0 12px rgba(255, 212, 90, 0.55);
}

.fever-track.is-hot .fever-fill {
  background: linear-gradient(90deg, #fff, var(--pink));
}

.fever-chip {
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #3a2200;
  background: linear-gradient(180deg, #fff6c2, var(--gold));
  box-shadow: 0 0 14px rgba(255, 212, 90, 0.45);
}

.fever-chip[hidden] { display: none !important; }

@keyframes scorePop {
  0% { transform: translateY(4px); filter: brightness(1.4); }
  100% { transform: none; filter: none; }
}

@keyframes comboPop {
  0% { transform: scale(1.35); }
  70% { transform: scale(0.96); }
  100% { transform: scale(1); }
}

.playfield {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(12, 12, 20, 0.9), rgba(8, 8, 14, 0.96));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.stage {
  position: relative;
  flex: 1;
  min-height: 140px;
  overflow: hidden;
}

.stage.is-punch { animation: punch 0.08s ease; }
.stage.is-fever { box-shadow: inset 0 0 40px rgba(255, 92, 168, 0.12); }

@keyframes punch {
  50% { transform: scale(1.008); }
}

.fx-canvas,
.impact-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.fx-canvas { width: 100%; height: 100%; z-index: 4; }

.impact-flash {
  z-index: 7;
  background: radial-gradient(circle at 50% 78%, rgba(255, 255, 255, 0.22), transparent 48%);
  opacity: 0;
}

.impact-flash.is-on { animation: flash 0.12s ease; }

@keyframes flash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

.lanes {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  z-index: 1;
}

.lane {
  position: relative;
  border-right: 1px solid rgba(255, 255, 255, 0.035);
}

.lane:last-child { border-right: 0; }

.lane.is-active {
  background: linear-gradient(180deg, transparent 10%, color-mix(in srgb, var(--lane-color) 18%, transparent) 100%);
}

.lane.is-hit {
  background: linear-gradient(180deg, transparent 20%, color-mix(in srgb, var(--lane-color) 32%, transparent) 100%);
}

.lane.is-miss {
  background: linear-gradient(180deg, transparent 30%, rgba(255, 77, 109, 0.16) 100%);
}

.note {
  position: absolute;
  left: 10%;
  right: 10%;
  height: 18px;
  top: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, var(--lane-color));
  box-shadow: 0 0 12px color-mix(in srgb, var(--lane-color) 70%, transparent);
  pointer-events: none;
  will-change: transform;
  z-index: 2;
}

.note.is-star {
  background: linear-gradient(180deg, #fffce8, var(--gold), #ff9f1c);
  box-shadow: 0 0 16px rgba(255, 212, 90, 0.9);
}

.note.is-hit { animation: noteHit 0.16s ease forwards; }
.note.is-missed { animation: noteMiss 0.22s ease forwards; }

@keyframes noteHit {
  100% { opacity: 0; transform: translate3d(0, var(--y, 0), 0) scale(1.45); }
}

@keyframes noteMiss {
  100% { opacity: 0; }
}

.hit-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18px;
  height: 10px;
  z-index: 3;
  pointer-events: none;
}

.hit-core {
  display: block;
  height: 3px;
  margin-top: 3px;
  border-radius: 99px;
  background: linear-gradient(90deg, transparent, var(--pink) 12%, #fff 50%, var(--cyan) 88%, transparent);
  box-shadow: 0 0 10px rgba(255, 92, 168, 0.7), 0 0 24px rgba(34, 211, 238, 0.4);
}

.judgement {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  z-index: 6;
  font-family: var(--display);
  font-size: clamp(1.4rem, 5vw, 2.1rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  pointer-events: none;
  opacity: 0;
  text-transform: uppercase;
}

.judgement.is-show {
  opacity: 1;
  animation: judgePop 0.55s ease forwards;
}

.judgement.perfect { color: var(--pink); text-shadow: 0 0 22px rgba(255, 92, 168, 0.85); }
.judgement.great { color: var(--purple); text-shadow: 0 0 22px rgba(192, 132, 252, 0.85); }
.judgement.good { color: var(--cyan); text-shadow: 0 0 22px rgba(34, 211, 238, 0.75); }
.judgement.miss { color: var(--miss); text-shadow: 0 0 18px rgba(255, 77, 109, 0.7); }

@keyframes judgePop {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.7); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  70% { opacity: 1; transform: translate(-50%, -58%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(0.96); }
}

.combo-float {
  position: absolute;
  left: 50%;
  top: 28%;
  transform: translateX(-50%);
  z-index: 5;
  font-family: var(--display);
  font-size: clamp(0.95rem, 3.4vw, 1.35rem);
  font-weight: 800;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.88);
  text-shadow: 0 0 18px rgba(192, 132, 252, 0.55);
  pointer-events: none;
  opacity: 0;
}

.combo-float.is-on { opacity: 1; }
.combo-float.is-pop { animation: comboFloatPop 0.28s ease; }

.intro-count {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  z-index: 8;
  font-family: var(--display);
  font-size: clamp(3.2rem, 16vw, 5.4rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 0 0 28px rgba(255, 92, 168, 0.85), 0 0 48px rgba(34, 211, 238, 0.4);
  pointer-events: none;
  opacity: 0;
}

.intro-count.is-on {
  opacity: 1;
  animation: introPop 0.55s ease;
}

.intro-count.is-go {
  color: var(--pink);
  letter-spacing: 0.14em;
}

@keyframes introPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.55); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes comboFloatPop {
  0% { transform: translateX(-50%) scale(1.22); }
  100% { transform: translateX(-50%) scale(1); }
}

.piano {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding: 8px 6px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.28));
  border-top: 1px solid var(--stroke);
  flex-shrink: 0;
}

.piano-key {
  position: relative;
  height: 92px;
  border-radius: 0 0 12px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-top: 0;
  background: linear-gradient(180deg, #f7f4ff 0%, #d9d4e8 78%, #c4bfd4 100%);
  color: #2a2438;
  box-shadow: inset 0 1px 0 #fff, 0 8px 0 #9c97ad, 0 12px 16px rgba(0, 0, 0, 0.35);
  transition: transform 0.06s ease, box-shadow 0.06s ease, filter 0.06s ease;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.piano-key:hover { filter: brightness(1.05); }

.piano-key.is-pressed,
.piano-key:active {
  transform: translateY(6px);
  box-shadow:
    inset 0 1px 0 #fff,
    0 2px 0 #9c97ad,
    0 0 22px color-mix(in srgb, var(--lane-color) 70%, transparent);
}

.piano-key.is-guide {
  box-shadow: inset 0 1px 0 #fff, 0 8px 0 #9c97ad, 0 0 16px color-mix(in srgb, var(--lane-color) 80%, transparent);
}

.piano-key::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, color-mix(in srgb, var(--lane-color) 55%, transparent), transparent 70%);
  opacity: 0;
  pointer-events: none;
}

.piano-key.is-pressed::before { opacity: 1; }

.key-note {
  display: block;
  margin-top: 14px;
  font-size: 0.95rem;
  font-weight: 800;
}

.key-bind {
  display: block;
  margin-top: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #5c566c;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 5, 10, 0.62);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.overlay[hidden] { display: none !important; }

.overlay.is-visible {
  display: grid;
  opacity: 1;
  pointer-events: auto;
}

.overlay-card {
  width: min(420px, 100%);
  padding: 32px 26px 26px;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(180deg, rgba(28, 24, 42, 0.92), rgba(12, 12, 20, 0.94));
  border: 1px solid var(--stroke-strong);
  box-shadow: var(--shadow), 0 0 80px rgba(124, 58, 237, 0.18);
}

.overlay-card-sm { padding: 28px 24px 22px; }

.overlay-card-pause {
  width: min(340px, 100%);
  padding: 36px 28px 28px;
}

.overlay-card-pause .overlay-title {
  margin-bottom: 28px;
}

.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ghost-btn {
  width: 100%;
  height: 50px;
  border-radius: 16px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text);
  background: var(--glass);
  border: 1px solid var(--stroke-strong);
  transition: background 0.16s ease, transform 0.16s ease;
}

.ghost-btn:hover { background: var(--glass-strong); }
.ghost-btn:active { transform: scale(0.97); }

.start-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 6px;
}

.overlay-kicker {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.28em;
  color: var(--cyan);
}

.overlay-title {
  margin: 0;
  font-family: var(--font);
  font-size: clamp(1.45rem, 5vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.overlay-copy {
  margin: 10px 12px 22px;
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.45;
}

.overlay-copy-touch,
.help-touch {
  display: none;
}

.key-legend {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin: 16px 0 14px;
}

.key-legend span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 800;
  background: var(--glass-strong);
  border: 1px solid var(--stroke-strong);
}

.key-gap { width: 10px; }

.song-pick {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 12px;
}

.song-btn {
  height: 44px;
  border-radius: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--text-dim);
  background: var(--glass);
  border: 1px solid var(--stroke);
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.song-btn:hover {
  color: var(--text);
  border-color: var(--stroke-strong);
}

.song-btn:active { transform: scale(0.97); }

.song-btn.is-active {
  color: #08222a;
  background: linear-gradient(180deg, #e7fbff, var(--cyan));
  border-color: transparent;
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.32);
}

.difficulty {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.diff-btn {
  height: 42px;
  border-radius: 12px;
  font-weight: 700;
  color: var(--text-dim);
  background: var(--glass);
  border: 1px solid var(--stroke);
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.diff-btn:hover {
  color: var(--text);
  border-color: var(--stroke-strong);
}

.diff-btn:active { transform: scale(0.97); }

.diff-btn.is-active {
  color: #1a1224;
  background: linear-gradient(180deg, #f4e9ff, var(--purple));
  border-color: transparent;
  box-shadow: 0 0 18px rgba(192, 132, 252, 0.35);
}

.play-btn {
  width: 100%;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 16px;
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #140c1c;
  background: linear-gradient(180deg, #ffe0f0, var(--pink) 40%, #d946a0);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15) inset, 0 10px 28px rgba(255, 92, 168, 0.38);
  transition: transform 0.16s ease, filter 0.16s ease;
}

.play-btn:hover { filter: brightness(1.06); }
.play-btn:active { transform: scale(0.97); }
.play-btn-sm { height: 48px; font-size: 1rem; }

.play-icon {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 7px 0 7px 12px;
  border-color: transparent transparent transparent #140c1c;
}

.text-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  color: var(--text-dim);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.text-btn:hover { color: var(--text); }

.new-best {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: var(--pink);
  text-shadow: 0 0 16px rgba(255, 92, 168, 0.8);
}

.rank-badge {
  display: inline-grid;
  place-items: center;
  min-width: 52px;
  height: 36px;
  margin: 0 auto 10px;
  padding: 0 12px;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0;
  color: #2a1a08;
  background: linear-gradient(180deg, #fff6c2, var(--gold));
}

.overlay.is-fail .rank-badge {
  color: #fff;
  background: linear-gradient(180deg, #fb7185, #be123c);
  box-shadow: 0 0 18px rgba(244, 63, 94, 0.35);
}

.results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  margin: 22px 0 8px;
  text-align: left;
}

.results div {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--stroke);
}

.results dt {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.results dd {
  margin: 4px 0 0;
  font-size: 1.2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.help-list {
  margin: 18px 0;
  padding: 0;
  list-style: none;
  color: var(--text-dim);
  text-align: left;
  line-height: 1.55;
}

.help-list li {
  position: relative;
  padding-left: 16px;
  margin-bottom: 8px;
}

.help-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
}

.help-grades {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}

.grade {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
}

.grade-perfect { color: var(--pink); }
.grade-great { color: var(--purple); }
.grade-good { color: var(--cyan); }
.grade-miss { color: var(--miss); }

@media (min-width: 880px) {
  body { display: grid; place-items: center; }

  .app {
    width: min(740px, calc(100vw - 48px));
    height: min(980px, calc(100dvh - 36px));
    padding: 16px 18px 18px;
    border-radius: 28px;
    background: rgba(8, 8, 14, 0.55);
    border: 1px solid var(--stroke);
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  .title { font-size: 1.2rem; letter-spacing: 0.22em; }
  .piano-key { height: 118px; }
  .note { height: 20px; }
}

@media (max-width: 720px) {
  .hud-grid { grid-template-columns: 1.35fr 1fr 0.9fr; }
  .stat-score { grid-column: 1; grid-row: 1; }
  .stat-combo { grid-column: 2; grid-row: 1; }
  .stat-time { grid-column: 3; grid-row: 1; }
  .hud-grid .stat:nth-child(2) { grid-column: 1; grid-row: 2; }
  .hud-grid .stat:nth-child(4) { grid-column: 2 / 4; grid-row: 2; }
}

@media (max-width: 480px) {
  .app {
    padding: calc(6px + var(--safe-t)) 8px calc(8px + var(--safe-b));
    gap: 6px;
  }

  .title { font-size: 0.92rem; letter-spacing: 0.12em; }
  .logo { width: 32px; height: 32px; }
  .icon-btn { width: 38px; height: 38px; }
  .hud { padding: 8px 10px 6px; }
  .stat-value { font-size: 0.98rem; }
  .stat-score .stat-value { font-size: 1.12rem; }
  .stat-label { font-size: 0.56rem; }
  .piano { gap: 3px; padding: 6px 4px; }
  .piano-key { height: 104px; border-radius: 0 0 9px 9px; }
  .key-note { margin-top: 18px; font-size: 1.05rem; }
  .overlay { padding: 20px 18px; }
  .overlay-card { padding: 28px 24px 22px; }
  .overlay-card-pause { padding: 32px 24px 24px; }
  .overlay-copy { margin: 10px 8px 24px; }
}

@media (max-width: 360px) {
  .hud-grid { gap: 4px 6px; }
  .piano-key { height: 92px; }
  .fever-chip { letter-spacing: 0.04em; padding: 0 8px; }
}

@media (max-height: 620px) {
  .piano-key { height: 70px; }
  .key-note { margin-top: 8px; }
}

html.is-touch .key-bind,
html.is-touch .key-legend,
html.is-touch .overlay-copy-desk,
html.is-touch .help-desk {
  display: none;
}

html.is-touch .overlay-copy-touch,
html.is-touch .help-touch {
  display: block;
}

html.is-touch .overlay-copy-touch {
  margin-bottom: 24px;
}

html.is-touch .piano-key {
  min-height: 100px;
}

html.is-touch .key-note {
  margin-top: 22px;
  font-size: 1.15rem;
}

@media (hover: none) and (pointer: coarse), (max-width: 700px) {
  html.is-touch .key-bind,
  .key-bind {
    display: none;
  }

  .key-legend,
  .overlay-copy-desk,
  .help-desk {
    display: none;
  }

  .overlay-copy-touch,
  .help-touch {
    display: block;
  }

  .piano-key {
    min-height: 96px;
  }

  .key-note {
    margin-top: 20px;
    font-size: 1.1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .orb,
  .judgement.is-show,
  .stat-score.is-pop .stat-value,
  .stat-combo.is-pop .stat-value,
  .combo-float.is-pop,
  .intro-count.is-on,
  .stage.is-punch,
  .impact-flash.is-on {
    animation: none !important;
  }

  .intro-count.is-on {
    opacity: 1;
    transform: translate(-50%, -50%);
  }

  .judgement.is-show {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}
