:root {
  color-scheme: dark;
  --night-950: #080c1b;
  --night-900: #0d1328;
  --night-850: #111a35;
  --night-800: #172343;
  --ink: #f5f7ff;
  --muted: #aab6d1;
  --line: rgba(185, 211, 255, 0.16);
  --glass: rgba(20, 31, 61, 0.72);
  --glass-soft: rgba(225, 239, 255, 0.08);
  --moon: #f6d98e;
  --cyan: #86e9ff;
  --violet: #b9adff;
  --teal: #7ee8c7;
  --rose: #ffa5ce;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", sans-serif;
  background: var(--night-950);
  color: var(--ink);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  min-height: 100%;
  background: var(--night-950);
  touch-action: pan-y;
}

body {
  min-width: 320px;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  touch-action: pan-y;
  background:
    radial-gradient(circle at 10% -5%, rgba(108, 171, 255, 0.18), transparent 35%),
    radial-gradient(circle at 92% 18%, rgba(168, 125, 255, 0.12), transparent 32%),
    linear-gradient(165deg, #111a35 0%, #090e20 48%, #080b17 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  content: "";
  pointer-events: none;
  opacity: 0.65;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.72) 0 1px, transparent 1.4px),
    radial-gradient(circle, rgba(134, 233, 255, 0.55) 0 1px, transparent 1.4px);
  background-position: 18px 24px, 67px 82px;
  background-size: 98px 114px, 143px 157px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

button,
canvas {
  font: inherit;
}

button {
  color: inherit;
}

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

[hidden] {
  display: none !important;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  filter: blur(70px);
  pointer-events: none;
}

.ambient-one {
  top: 22%;
  left: -220px;
  background: rgba(69, 188, 226, 0.12);
}

.ambient-two {
  right: -230px;
  bottom: 8%;
  background: rgba(152, 116, 238, 0.12);
}

.app-shell {
  width: min(100%, 520px);
  margin: 0 auto;
  padding:
    calc(20px + env(safe-area-inset-top))
    16px
    calc(28px + env(safe-area-inset-bottom));
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 2px 0 18px;
}

.topbar > div:first-child {
  min-width: 0;
}

.topbar-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
}

.topbar-actions .icon-button {
  flex: 0 0 49px;
  width: 49px;
  min-height: 50px;
  padding: 7px 4px 5px;
  border-radius: 17px;
}

.eyebrow,
.stage-kicker,
.modal-kicker,
.app-footer,
.story-header > span {
  margin: 0;
  color: #89cad8;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.21em;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 5px 0 0;
  white-space: nowrap;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(1.35rem, 5.8vw, 1.75rem);
  font-weight: 500;
  letter-spacing: 0.035em;
}

.icon-button {
  display: grid;
  flex: 0 0 58px;
  min-height: 58px;
  place-items: center;
  gap: 1px;
  padding: 8px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: rgba(233, 243, 255, 0.07);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08);
}

.icon-button:active {
  transform: scale(0.96);
}

.book-icon {
  position: relative;
  display: block;
  width: 23px;
  height: 20px;
  border: 2px solid #b8d6e0;
  border-radius: 4px 4px 6px 6px;
}

.book-icon::after {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 50%;
  width: 2px;
  content: "";
  background: #b8d6e0;
  transform: translateX(-1px);
}

.icon-button-label {
  color: var(--muted);
  font-size: 0.62rem;
}

.sound-button {
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 100ms ease;
}

.sound-button:not(.muted) {
  border-color: rgba(134, 233, 255, 0.28);
  background: rgba(103, 206, 236, 0.1);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), 0 0 18px rgba(105, 219, 243, 0.08);
}

.sound-glyph {
  display: grid;
  width: 23px;
  height: 20px;
  place-items: center;
  color: #bceef7;
  font-family: Georgia, serif;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 0 11px rgba(134, 233, 255, 0.42);
}

.sound-button.muted .sound-glyph,
.sound-button.muted .icon-button-label {
  color: #7f8da7;
  text-shadow: none;
}

.guide-card,
.stage-card {
  border: 1px solid var(--line);
  background: linear-gradient(155deg, rgba(30, 44, 81, 0.8), rgba(14, 22, 46, 0.82));
  box-shadow: var(--shadow), inset 0 1px rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.guide-card {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 13px;
  padding: 12px;
  border-radius: 23px;
}

.guide-avatar {
  position: relative;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(157, 211, 235, 0.34);
  border-radius: 19px;
  background:
    radial-gradient(circle at 50% 45%, rgba(135, 230, 255, 0.24), transparent 38%),
    linear-gradient(145deg, #243963, #151c39);
  box-shadow: inset 0 0 22px rgba(126, 225, 255, 0.12);
}

.wolf-ear {
  position: absolute;
  top: 7px;
  width: 16px;
  height: 19px;
  border: 1px solid rgba(192, 224, 245, 0.32);
  background: #273b61;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.wolf-ear-left {
  left: 10px;
  transform: rotate(-12deg);
}

.wolf-ear-right {
  right: 10px;
  transform: rotate(12deg);
}

.moon-mark {
  position: relative;
  z-index: 1;
  margin-top: 7px;
  color: #d9eeff;
  font-family: Georgia, serif;
  font-size: 2rem;
  text-shadow: 0 0 15px rgba(134, 233, 255, 0.8);
}

.guide-copy {
  min-width: 0;
}

.speaker {
  display: inline-block;
  margin-bottom: 4px;
  color: #8fd7e8;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.guide-copy p {
  margin: 0;
  color: #d9e1f2;
  font-size: 0.83rem;
  font-weight: 600;
  line-height: 1.55;
}

.stage-card {
  position: relative;
  padding: 18px 14px 16px;
  overflow: hidden;
  border-radius: 28px;
}

.stage-card::before {
  position: absolute;
  top: -80px;
  right: -80px;
  width: 180px;
  height: 180px;
  border: 1px solid rgba(235, 224, 180, 0.09);
  border-radius: 50%;
  content: "";
  box-shadow: inset 0 0 50px rgba(246, 217, 142, 0.05);
  pointer-events: none;
}

.stage-heading {
  position: relative;
  display: grid;
  grid-template-columns: 48px 1fr 44px;
  gap: 11px;
  align-items: center;
  margin: 0 2px 14px;
}

.stage-number {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(246, 217, 142, 0.33);
  border-radius: 17px;
  color: #fff0c4;
  background: linear-gradient(145deg, rgba(198, 151, 69, 0.36), rgba(76, 57, 95, 0.38));
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  font-weight: 800;
}

.stage-heading h2 {
  margin: 3px 0 0;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(1.16rem, 5vw, 1.42rem);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.reset-button,
.close-button {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
}

.reset-button {
  width: 42px;
  height: 42px;
  color: #c9d5e8;
  font-size: 1.35rem;
}

.mode-switch {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  margin: 0 2px 12px;
  padding: 4px;
  border: 1px solid rgba(181, 211, 246, 0.12);
  border-radius: 17px;
  background: rgba(5, 11, 27, 0.35);
}

.mode-button {
  display: grid;
  min-height: 48px;
  place-content: center;
  gap: 2px;
  padding: 6px 4px;
  border: 1px solid transparent;
  border-radius: 13px;
  color: #8795af;
  background: transparent;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease, transform 100ms ease;
}

.mode-button span {
  font-size: 0.5rem;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.mode-button strong {
  font-size: 0.71rem;
}

.mode-button.active {
  border-color: rgba(133, 229, 248, 0.28);
  color: #ddf8ff;
  background: linear-gradient(145deg, rgba(91, 196, 226, 0.16), rgba(165, 137, 237, 0.11));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.07), 0 0 18px rgba(91, 196, 226, 0.08);
}

.mode-button:active {
  transform: scale(0.975);
}

.status-grid {
  display: grid;
  grid-template-columns: 92px 1fr;
  grid-auto-rows: 78px;
  gap: 10px;
  margin-bottom: 12px;
}

.status-block {
  height: 78px;
  min-height: 78px;
  padding: 11px 13px;
  border: 1px solid rgba(191, 215, 255, 0.12);
  border-radius: 18px;
  background: rgba(5, 11, 27, 0.34);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.04);
}

.status-label {
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.moves-block {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.moves-block .status-label {
  white-space: nowrap;
  writing-mode: vertical-rl;
  text-orientation: upright;
  line-height: 1;
  letter-spacing: 0.08em;
}

.moves-block strong {
  width: 2ch;
  justify-self: end;
  text-align: center;
  color: #f6e8bd;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.8rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.moves-block.wide strong {
  width: 3.5ch;
  font-size: 1.35rem;
}

.moves-block.low strong {
  color: #ffb2c9;
  animation: lowPulse 1.1s ease-in-out infinite;
}

.restore-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.restore-heading strong {
  color: #b8edf7;
  font-size: 0.88rem;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(220, 234, 255, 0.1);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.38);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #66cce6, #9bbcfb 43%, #beaaff 70%, #f6d98e);
  box-shadow: 0 0 16px rgba(126, 225, 255, 0.45);
  transition: width 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.restore-chamber {
  position: relative;
  height: 170px;
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid rgba(155, 214, 236, 0.17);
  border-radius: 23px;
  background:
    radial-gradient(circle at 50% 62%, rgba(112, 215, 245, 0.15), transparent 28%),
    linear-gradient(180deg, rgba(11, 24, 51, 0.8), rgba(6, 13, 31, 0.88));
  box-shadow: inset 0 0 45px rgba(109, 190, 237, 0.05);
}

.restore-chamber::after {
  position: absolute;
  right: 18%;
  bottom: 22px;
  left: 18%;
  height: 16px;
  border-radius: 50%;
  content: "";
  background: rgba(90, 201, 238, 0.15);
  filter: blur(9px);
}

.chamber-stars {
  position: absolute;
  top: 12px;
  right: 16px;
  color: rgba(246, 217, 142, 0.58);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
}

.restore-chamber canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 137px;
  touch-action: none;
  cursor: grab;
}

.restore-chamber canvas:active {
  cursor: grabbing;
}

.chamber-caption {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 13px 10px;
  border-top: 1px solid rgba(180, 216, 240, 0.1);
  color: #d7e6f0;
  background: rgba(9, 17, 37, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.chamber-caption span {
  font-size: 0.72rem;
  font-weight: 800;
}

.chamber-caption small {
  color: #8494b1;
  font-size: 0.61rem;
}

.play-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 0 3px 10px;
}

.play-heading h3 {
  margin: 2px 0 0;
  font-size: 1.04rem;
  font-weight: 800;
}

.chain-readout {
  min-width: 72px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: #bdc9de;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.68rem;
  font-weight: 800;
  text-align: center;
  transition: 160ms ease;
}

.chain-readout.active {
  color: #0b1830;
  background: #c3eff7;
  box-shadow: 0 0 19px rgba(134, 233, 255, 0.35);
  transform: scale(1.05);
}

.board-shell {
  position: relative;
  width: 100%;
  padding: 9px;
  border: 1px solid rgba(188, 218, 255, 0.17);
  border-radius: 25px;
  background:
    radial-gradient(circle at 48% 40%, rgba(102, 192, 230, 0.12), transparent 50%),
    rgba(5, 11, 27, 0.56);
  box-shadow: inset 0 0 30px rgba(84, 161, 213, 0.05), 0 13px 30px rgba(0, 0, 0, 0.18);
  touch-action: none;
}

.board {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: clamp(4px, 1.4vw, 7px);
  width: 100%;
  aspect-ratio: 1;
  padding: 4px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.board.disabled {
  pointer-events: none;
  opacity: 0.68;
}

.gem {
  --gem-rgb: 134, 233, 255;
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: visible;
  border: 1px solid rgba(var(--gem-rgb), 0.64);
  border-radius: 28% 42% 31% 38%;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.56), transparent 23%),
    linear-gradient(320deg, rgba(255, 255, 255, 0.18), transparent 42%),
    radial-gradient(circle at 53% 60%, rgba(var(--gem-rgb), 0.5), rgba(var(--gem-rgb), 0.17) 63%, rgba(var(--gem-rgb), 0.05));
  box-shadow:
    inset 2px 2px 4px rgba(255, 255, 255, 0.2),
    inset -3px -3px 7px rgba(0, 0, 0, 0.2),
    0 3px 8px rgba(var(--gem-rgb), 0.15);
  transform: rotate(var(--tilt, 0deg)) scale(0.92);
  transition: transform 120ms ease, filter 120ms ease, opacity 170ms ease;
  touch-action: none;
}

.gem::before {
  position: absolute;
  inset: 10% 14% 52% 18%;
  border-radius: 50%;
  content: "";
  background: rgba(255, 255, 255, 0.48);
  filter: blur(1px);
  transform: rotate(-18deg);
}

.gem::after {
  position: absolute;
  right: 11%;
  bottom: 12%;
  width: 34%;
  height: 22%;
  border-right: 1px solid rgba(255, 255, 255, 0.35);
  border-bottom: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 0 0 50% 0;
  content: "";
  transform: skew(-10deg);
}

.gem.shape-b {
  --tilt: 5deg;
  border-radius: 44% 27% 40% 30%;
}

.gem.shape-c {
  --tilt: -4deg;
  border-radius: 31% 38% 25% 46%;
}

.gem.color-0 { --gem-rgb: 95, 186, 255; }
.gem.color-1 { --gem-rgb: 185, 173, 255; }
.gem.color-2 { --gem-rgb: 83, 229, 158; }
.gem.color-3 { --gem-rgb: 255, 214, 119; }
.gem.color-4 { --gem-rgb: 255, 158, 205; }

.gem.selected {
  z-index: 3;
  filter: brightness(1.25) saturate(1.1);
  box-shadow:
    inset 2px 2px 5px rgba(255, 255, 255, 0.36),
    0 0 0 3px rgba(var(--gem-rgb), 0.25),
    0 0 20px rgba(var(--gem-rgb), 0.75);
  transform: rotate(var(--tilt, 0deg)) scale(0.92);
}

.gem.tail {
  outline: 2px solid rgba(var(--gem-rgb), 0.35);
  outline-offset: 2px;
  animation: tailGlow 620ms ease-in-out infinite alternate;
}

.gem.clearing {
  pointer-events: none;
  opacity: 0;
  filter: brightness(1.8);
  transform: rotate(var(--tilt, 0deg)) scale(1.55);
}

.cascade-play {
  width: 100%;
}

.cascade-next {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  width: min(100%, 300px);
  min-height: 42px;
  margin: 0 auto 8px;
  padding: 5px 10px;
  border: 1px solid rgba(184, 217, 250, 0.12);
  border-radius: 15px;
  color: #88cbd9;
  background: rgba(5, 11, 27, 0.4);
  font-size: 0.55rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.cascade-next small {
  justify-self: end;
  color: #8998b2;
  font-size: 0.52rem;
  letter-spacing: 0.08em;
}

.next-pair {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 52px;
}

.cascade-shell {
  position: relative;
  width: min(100%, 300px);
  margin: 0 auto;
  padding: 8px;
  overflow: hidden;
  border: 1px solid rgba(180, 220, 255, 0.2);
  border-radius: 23px;
  background:
    radial-gradient(circle at 50% 72%, rgba(77, 196, 228, 0.13), transparent 45%),
    linear-gradient(180deg, rgba(5, 12, 29, 0.85), rgba(8, 16, 38, 0.95));
  box-shadow: inset 0 0 34px rgba(92, 176, 225, 0.07), 0 14px 34px rgba(0, 0, 0, 0.2);
  touch-action: none;
  transition: box-shadow 180ms ease, border-color 180ms ease;
}

.cascade-shell.resolving {
  border-color: rgba(134, 233, 255, 0.36);
  box-shadow: inset 0 0 40px rgba(92, 213, 237, 0.11), 0 0 26px rgba(103, 201, 231, 0.08);
}

.cascade-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(10, minmax(0, 1fr));
  gap: 3px;
  width: 100%;
  aspect-ratio: 3 / 5;
  padding: 4px;
  border-radius: 17px;
  background:
    linear-gradient(rgba(177, 219, 249, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(177, 219, 249, 0.035) 1px, transparent 1px),
    rgba(2, 7, 19, 0.52);
  background-size: calc(100% / 6) calc(100% / 10);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.cascade-board.disabled {
  pointer-events: none;
}

.cascade-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
}

.cascade-piece {
  --piece-rgb: 95, 186, 255;
  position: absolute;
  inset: 4%;
  display: block;
  overflow: hidden;
  border: 1px solid rgba(var(--piece-rgb), 0.72);
  border-radius: 44% 38% 46% 36%;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.65), transparent 25%),
    radial-gradient(circle at 52% 61%, rgba(var(--piece-rgb), 0.62), rgba(var(--piece-rgb), 0.2) 62%, rgba(var(--piece-rgb), 0.06));
  box-shadow:
    inset 2px 2px 4px rgba(255, 255, 255, 0.22),
    inset -3px -3px 7px rgba(0, 0, 0, 0.22),
    0 0 9px rgba(var(--piece-rgb), 0.2);
  transition: opacity 140ms ease, filter 140ms ease, transform 140ms ease;
}

.cascade-piece::before {
  position: absolute;
  inset: 9% 17% 55% 19%;
  border-radius: 50%;
  content: "";
  background: rgba(255, 255, 255, 0.55);
  filter: blur(0.7px);
  transform: rotate(-18deg);
}

.cascade-piece.color-0 { --piece-rgb: 95, 186, 255; }
.cascade-piece.color-1 { --piece-rgb: 185, 173, 255; }
.cascade-piece.color-2 { --piece-rgb: 83, 229, 158; }
.cascade-piece.color-3 { --piece-rgb: 255, 214, 119; }
.cascade-piece.color-4 { --piece-rgb: 255, 158, 205; }

.cascade-piece.falling {
  z-index: 3;
  filter: brightness(1.2) saturate(1.08);
  box-shadow:
    inset 2px 2px 5px rgba(255, 255, 255, 0.32),
    0 0 0 2px rgba(var(--piece-rgb), 0.18),
    0 0 14px rgba(var(--piece-rgb), 0.54);
  animation: cascadeStep 150ms ease-out;
}

.cascade-piece.settled {
  z-index: 2;
  transform: scale(0.94);
}

.cascade-piece.settled.split-falling {
  z-index: 5;
  animation: cascadeSplitDrop 92ms cubic-bezier(0.22, 0.78, 0.32, 1) both;
}

.cascade-piece.landing {
  z-index: 1;
  border-style: dashed;
  opacity: 0.2;
  filter: saturate(0.7);
  box-shadow: none;
}

.cascade-piece.clearing {
  z-index: 4;
  animation: cascadeClear 260ms ease-in-out infinite alternate;
}

.cascade-piece.next {
  position: relative;
  inset: auto;
  width: 24px;
  height: 24px;
}

.cascade-chain-flash {
  position: absolute;
  top: 48%;
  left: 50%;
  z-index: 8;
  min-width: 126px;
  padding: 10px 15px;
  border: 1px solid rgba(194, 240, 250, 0.5);
  border-radius: 99px;
  color: #08162d;
  background: linear-gradient(100deg, #8feaff, #c4b9ff 58%, #f6d98e);
  box-shadow: 0 0 34px rgba(131, 226, 250, 0.42);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-align: center;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.cascade-chain-flash.show {
  animation: chainFlash 720ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.cascade-controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  width: min(100%, 300px);
  margin: 9px auto 0;
}

.cascade-controls button {
  min-height: 52px;
  padding: 0;
  border: 1px solid rgba(183, 218, 252, 0.18);
  border-radius: 16px;
  color: #d8eafb;
  background: linear-gradient(160deg, rgba(42, 63, 108, 0.74), rgba(15, 25, 52, 0.88));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.07), 0 5px 13px rgba(0, 0, 0, 0.16);
  font-size: 1.25rem;
  font-weight: 800;
  touch-action: manipulation;
}

.cascade-controls button:active {
  color: #07152c;
  background: #bceef7;
  transform: scale(0.95);
}

.orbit-play {
  width: 100%;
}

.orbit-toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  width: min(100%, 360px);
  min-height: 42px;
  margin: 0 auto 8px;
  padding: 6px 11px;
  border: 1px solid rgba(184, 217, 250, 0.13);
  border-radius: 15px;
  color: #87cbd9;
  background: rgba(5, 11, 27, 0.42);
  font-size: 0.54rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.orbit-toolbar strong {
  min-width: 68px;
  color: #dff8ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.73rem;
  letter-spacing: 0.04em;
  text-align: center;
  transition: color 120ms ease, text-shadow 120ms ease;
}

.orbit-toolbar strong.danger {
  color: #ffd0dc;
  text-shadow: 0 0 12px rgba(255, 135, 173, 0.52);
  animation: lowPulse 520ms ease-in-out infinite alternate;
}

.orbit-toolbar small {
  justify-self: end;
  color: #8998b2;
  font-size: 0.47rem;
  letter-spacing: 0.07em;
  text-align: right;
}

.orbit-shell {
  position: relative;
  width: min(100%, 360px);
  margin: 0 auto;
  padding: 8px;
  overflow: hidden;
  border: 1px solid rgba(180, 220, 255, 0.2);
  border-radius: 23px;
  background:
    radial-gradient(circle at 50% 46%, rgba(111, 139, 241, 0.12), transparent 56%),
    linear-gradient(160deg, rgba(6, 14, 35, 0.9), rgba(9, 17, 42, 0.97));
  box-shadow: inset 0 0 34px rgba(92, 176, 225, 0.07), 0 14px 34px rgba(0, 0, 0, 0.2);
  touch-action: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.orbit-shell::before {
  position: absolute;
  inset: 8px;
  z-index: 0;
  border-radius: 17px;
  content: "";
  pointer-events: none;
  background:
    linear-gradient(rgba(177, 219, 249, 0.032) 1px, transparent 1px),
    linear-gradient(90deg, rgba(177, 219, 249, 0.032) 1px, transparent 1px);
  background-size: calc(100% / 6) calc(100% / 5);
}

.orbit-shell.dragging {
  border-color: rgba(165, 173, 255, 0.42);
  box-shadow: inset 0 0 42px rgba(126, 159, 244, 0.13), 0 0 28px rgba(111, 175, 238, 0.1);
}

.orbit-shell.resolving {
  border-color: rgba(134, 233, 255, 0.38);
  box-shadow: inset 0 0 46px rgba(92, 213, 237, 0.12), 0 0 30px rgba(103, 201, 231, 0.1);
}

.orbit-board {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: clamp(4px, 1.3vw, 6px);
  width: 100%;
  aspect-ratio: 6 / 5;
  padding: 4px;
  border-radius: 17px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.orbit-board.disabled {
  pointer-events: none;
  opacity: 0.72;
}

.orbit-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
}

.orbit-cell.diagonal-pop::after {
  position: absolute;
  inset: 9%;
  z-index: 5;
  border: 2px solid rgba(194, 241, 255, 0.82);
  border-radius: 42%;
  content: "";
  pointer-events: none;
  box-shadow: 0 0 13px rgba(133, 220, 255, 0.42);
  animation: orbitDiagonalRipple 105ms ease-out both;
}

.orbit-piece,
.orbit-drag-ghost {
  --piece-rgb: 95, 186, 255;
  overflow: hidden;
  border: 1px solid rgba(var(--piece-rgb), 0.72);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.65), transparent 24%),
    linear-gradient(325deg, rgba(255, 255, 255, 0.14), transparent 45%),
    radial-gradient(circle at 52% 61%, rgba(var(--piece-rgb), 0.64), rgba(var(--piece-rgb), 0.21) 62%, rgba(var(--piece-rgb), 0.06));
  box-shadow:
    inset 2px 2px 4px rgba(255, 255, 255, 0.24),
    inset -3px -3px 7px rgba(0, 0, 0, 0.22),
    0 0 10px rgba(var(--piece-rgb), 0.22);
}

.orbit-piece {
  position: absolute;
  inset: 3%;
  width: 94%;
  height: 94%;
  padding: 0;
  touch-action: none;
}

.orbit-piece::before,
.orbit-drag-ghost::before {
  position: absolute;
  inset: 10% 18% 56% 18%;
  border-radius: 50%;
  content: "";
  background: rgba(255, 255, 255, 0.56);
  filter: blur(0.7px);
  transform: rotate(-18deg);
}

.orbit-piece.color-0,
.orbit-drag-ghost.color-0 { --piece-rgb: 95, 186, 255; }
.orbit-piece.color-1,
.orbit-drag-ghost.color-1 { --piece-rgb: 185, 173, 255; }
.orbit-piece.color-2,
.orbit-drag-ghost.color-2 { --piece-rgb: 83, 229, 158; }
.orbit-piece.color-3,
.orbit-drag-ghost.color-3 { --piece-rgb: 255, 214, 119; }
.orbit-piece.color-4,
.orbit-drag-ghost.color-4 { --piece-rgb: 255, 158, 205; }

.orbit-piece.shape-0,
.orbit-drag-ghost.shape-0 {
  border-radius: 50%;
}

.orbit-piece.shape-1,
.orbit-drag-ghost.shape-1 {
  clip-path: polygon(50% 2%, 96% 50%, 50% 98%, 4% 50%);
}

.orbit-piece.shape-2,
.orbit-drag-ghost.shape-2 {
  clip-path: polygon(24% 5%, 76% 5%, 98% 50%, 76% 95%, 24% 95%, 2% 50%);
}

.orbit-piece.shape-3,
.orbit-drag-ghost.shape-3 {
  border-radius: 23%;
}

.orbit-piece.shape-4,
.orbit-drag-ghost.shape-4 {
  clip-path: polygon(50% 2%, 90% 23%, 84% 78%, 50% 98%, 16% 78%, 10% 23%);
}

.orbit-piece.held-slot {
  opacity: 0.2;
  filter: saturate(0.55);
}

.orbit-piece.shifting {
  z-index: 3;
  animation: orbitShift 115ms cubic-bezier(0.2, 0.78, 0.28, 1);
}

.orbit-piece.diagonal-popping {
  z-index: 3;
  animation: orbitDiagonalGlow 105ms ease-out both;
}

.orbit-piece.clearing {
  z-index: 4;
  pointer-events: none;
  animation: orbitClear 360ms ease-in-out both;
}

.orbit-piece.dropping {
  z-index: 3;
  animation: orbitDrop 215ms cubic-bezier(0.2, 0.8, 0.26, 1);
}

.orbit-drag-ghost {
  position: absolute;
  z-index: 12;
  pointer-events: none;
  filter: brightness(1.28) saturate(1.08);
  transform: translate(-50%, -66%) scale(1.08);
  box-shadow:
    inset 2px 2px 5px rgba(255, 255, 255, 0.34),
    0 0 0 3px rgba(var(--piece-rgb), 0.2),
    0 0 24px rgba(var(--piece-rgb), 0.66);
}

.orbit-combo-flash {
  position: absolute;
  top: 48%;
  left: 50%;
  z-index: 14;
  min-width: 132px;
  padding: 10px 15px;
  border: 1px solid rgba(194, 240, 250, 0.52);
  border-radius: 99px;
  color: #08162d;
  background: linear-gradient(100deg, #8feaff, #c4b9ff 58%, #f6d98e);
  box-shadow: 0 0 36px rgba(131, 226, 250, 0.45);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88rem;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-align: center;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.orbit-combo-flash.show {
  animation: chainFlash 430ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.stack-play {
  width: 100%;
}

.stack-play,
.stack-play * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

.stack-toolbar {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 72px;
  align-items: end;
  gap: 7px;
  width: min(100%, 330px);
  min-height: 72px;
  margin: 0 auto 7px;
}

.stack-preview-card {
  display: grid;
  min-height: 64px;
  place-items: center;
  align-content: center;
  gap: 3px;
  padding: 5px 4px;
  border: 1px solid rgba(184, 217, 250, 0.13);
  border-radius: 15px;
  color: #88cbd9;
  background: rgba(5, 11, 27, 0.42);
  font-size: 0.48rem;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.stack-mini-grid {
  display: grid;
  grid-template-columns: repeat(4, 10px);
  grid-template-rows: repeat(3, 10px);
  gap: 1px;
  width: 43px;
  height: 32px;
  place-content: center;
}

.stack-mini-grid.empty::after {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  place-self: center;
  color: rgba(166, 186, 215, 0.38);
  content: "—";
  font-size: 0.78rem;
}

.stack-mini-cell {
  position: relative;
  width: 10px;
  height: 10px;
}

.stack-clerk {
  display: grid;
  min-width: 0;
  place-items: center;
  align-self: stretch;
  align-content: end;
}

.stack-clerk small {
  display: block;
  width: 100%;
  min-height: 15px;
  margin-top: 1px;
  overflow: hidden;
  color: #a9bdd2;
  font-size: 0.52rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stack-owl {
  --owl-look: 0px;
  position: relative;
  width: 58px;
  height: 52px;
  border: 1px solid rgba(174, 215, 239, 0.3);
  border-radius: 45% 45% 38% 38%;
  background:
    radial-gradient(circle at 50% 36%, rgba(209, 242, 252, 0.22), transparent 38%),
    linear-gradient(150deg, #314a69, #1b2845 62%, #121c35);
  box-shadow: inset 0 0 14px rgba(126, 225, 255, 0.1), 0 5px 13px rgba(0, 0, 0, 0.22);
  transform-origin: 50% 86%;
  transition: transform 110ms ease, filter 140ms ease;
}

.stack-owl-ear {
  position: absolute;
  top: -7px;
  z-index: -1;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(174, 215, 239, 0.25);
  background: #2d4362;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.stack-owl-ear.ear-left {
  left: 4px;
  transform: rotate(-17deg);
}

.stack-owl-ear.ear-right {
  right: 4px;
  transform: rotate(17deg);
}

.stack-owl-wing {
  position: absolute;
  top: 25px;
  z-index: -1;
  width: 15px;
  height: 24px;
  border: 1px solid rgba(148, 198, 226, 0.22);
  border-radius: 70% 30% 70% 30%;
  background: #223654;
  transform-origin: 50% 15%;
}

.stack-owl-wing.wing-left {
  left: -6px;
  transform: rotate(19deg);
}

.stack-owl-wing.wing-right {
  right: -6px;
  transform: scaleX(-1) rotate(19deg);
}

.stack-owl-face {
  position: absolute;
  top: 8px;
  left: 50%;
  display: flex;
  gap: 2px;
  transform: translateX(-50%);
}

.stack-owl-eye {
  position: relative;
  display: block;
  width: 21px;
  height: 22px;
  overflow: hidden;
  border: 2px solid rgba(213, 235, 244, 0.52);
  border-radius: 50%;
  background: #d9edf1;
  box-shadow: inset 0 -4px 6px rgba(94, 119, 139, 0.2), 0 0 8px rgba(131, 222, 245, 0.12);
  animation: stackOwlBlink 5.8s ease-in-out infinite;
}

.stack-owl-eye b {
  position: absolute;
  top: 7px;
  left: 50%;
  width: 6px;
  height: 8px;
  margin-left: -3px;
  border-radius: 50%;
  background: #0b1325;
  box-shadow: 0 0 0 2px rgba(92, 202, 228, 0.16);
  transform: translateX(var(--owl-look));
  transition: transform 80ms linear;
}

.stack-owl-beak {
  position: absolute;
  top: 18px;
  left: 50%;
  z-index: 3;
  width: 8px;
  height: 8px;
  background: #f2cd75;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  transform: translateX(-50%);
}

.stack-owl-tag {
  position: absolute;
  right: 19px;
  bottom: 4px;
  display: grid;
  width: 19px;
  height: 13px;
  place-items: center;
  border: 1px solid rgba(245, 221, 155, 0.5);
  border-radius: 4px;
  color: #ffedb7;
  background: rgba(72, 52, 63, 0.58);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.42rem;
  font-style: normal;
  font-weight: 900;
}

.stack-owl.tilt {
  transform: rotate(8deg);
}

.stack-owl.hold {
  animation: stackOwlHold 420ms ease-out both;
}

.stack-owl.stamp {
  animation: stackOwlStamp 320ms ease-out both;
}

.stack-owl.cheer,
.stack-owl.bravo {
  filter: brightness(1.16);
  animation: stackOwlCheer 510ms ease-in-out infinite alternate;
}

.stack-owl.cheer .wing-left,
.stack-owl.bravo .wing-left {
  animation: stackWingLeft 260ms ease-in-out infinite alternate;
}

.stack-owl.cheer .wing-right,
.stack-owl.bravo .wing-right {
  animation: stackWingRight 260ms ease-in-out infinite alternate;
}

.stack-owl.bravo {
  box-shadow: inset 0 0 18px rgba(246, 217, 142, 0.18), 0 0 22px rgba(134, 233, 255, 0.34);
}

.stack-owl.worry {
  filter: saturate(0.62) brightness(0.85);
  transform: translateY(3px) rotate(-3deg);
}

.stack-owl.worry .stack-owl-eye {
  height: 17px;
  margin-top: 4px;
}

.stack-meta {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 6px;
  width: min(100%, 300px);
  min-height: 34px;
  margin: 0 auto 7px;
  padding: 5px 9px;
  border: 1px solid rgba(184, 217, 250, 0.12);
  border-radius: 13px;
  color: #8998b2;
  background: rgba(5, 11, 27, 0.4);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.48rem;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.stack-meta strong {
  color: #dff8ff;
  font-size: 0.61rem;
  text-align: center;
}

.stack-meta small {
  justify-self: end;
  font-size: 0.47rem;
}

.stack-shell {
  position: relative;
  width: min(100%, 300px);
  margin: 0 auto;
  padding: 7px;
  overflow: hidden;
  border: 1px solid rgba(180, 220, 255, 0.2);
  border-radius: 22px;
  background:
    linear-gradient(90deg, transparent 49.5%, rgba(246, 217, 142, 0.035) 50%, transparent 50.5%),
    radial-gradient(circle at 50% 78%, rgba(77, 196, 228, 0.13), transparent 48%),
    linear-gradient(180deg, rgba(5, 12, 29, 0.9), rgba(8, 16, 38, 0.98));
  box-shadow: inset 0 0 36px rgba(92, 176, 225, 0.07), 0 14px 34px rgba(0, 0, 0, 0.2);
  scroll-margin-top: 8px;
  touch-action: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.stack-shell.resolving {
  border-color: rgba(134, 233, 255, 0.4);
  box-shadow: inset 0 0 48px rgba(92, 213, 237, 0.14), 0 0 30px rgba(103, 201, 231, 0.11);
}

.stack-shell.failed {
  border-color: rgba(255, 142, 177, 0.24);
  box-shadow: inset 0 0 34px rgba(141, 69, 104, 0.1), 0 14px 34px rgba(0, 0, 0, 0.2);
}

.stack-shell.landing {
  animation: stackShellLand 150ms ease-out;
}

.stack-board {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  grid-template-rows: repeat(16, minmax(0, 1fr));
  gap: 2px;
  width: 100%;
  aspect-ratio: 5 / 8;
  padding: 4px;
  border-radius: 16px;
  background:
    linear-gradient(rgba(177, 219, 249, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(177, 219, 249, 0.04) 1px, transparent 1px),
    rgba(2, 7, 19, 0.58);
  background-size: calc(100% / 10) calc(100% / 16);
  contain: layout paint style;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.stack-board.disabled {
  pointer-events: none;
}

.stack-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  pointer-events: none;
}

.stack-crate {
  --crate-rgb: 95, 207, 255;
  position: absolute;
  inset: 2%;
  display: block;
  overflow: hidden;
  border: 1px solid rgba(var(--crate-rgb), 0.74);
  border-radius: 17%;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.6), transparent 22%),
    linear-gradient(315deg, rgba(255, 255, 255, 0.11), transparent 52%),
    rgba(var(--crate-rgb), 0.44);
  box-shadow:
    inset 2px 2px 4px rgba(255, 255, 255, 0.2),
    inset -3px -3px 6px rgba(0, 0, 0, 0.22),
    0 0 7px rgba(var(--crate-rgb), 0.2);
}

.stack-crate::before {
  position: absolute;
  inset: 18%;
  border: 1px solid rgba(227, 247, 255, 0.24);
  border-radius: 12%;
  content: "";
  box-shadow: inset 0 0 5px rgba(4, 11, 28, 0.18);
}

.stack-crate::after {
  position: absolute;
  top: 45%;
  left: 12%;
  width: 76%;
  height: 2px;
  content: "";
  background: rgba(225, 246, 255, 0.2);
  box-shadow: 0 -6px rgba(225, 246, 255, 0.08), 0 6px rgba(2, 8, 24, 0.12);
}

.stack-crate.type-i { --crate-rgb: 78, 217, 255; }
.stack-crate.type-o { --crate-rgb: 255, 211, 100; }
.stack-crate.type-t { --crate-rgb: 189, 145, 255; }
.stack-crate.type-s { --crate-rgb: 67, 224, 137; }
.stack-crate.type-z { --crate-rgb: 255, 105, 150; }
.stack-crate.type-j { --crate-rgb: 86, 132, 255; }
.stack-crate.type-l { --crate-rgb: 255, 162, 77; }

.stack-crate.active {
  z-index: 4;
  filter: brightness(1.16) saturate(1.08);
  box-shadow:
    inset 2px 2px 4px rgba(255, 255, 255, 0.28),
    0 0 0 2px rgba(var(--crate-rgb), 0.16),
    0 0 11px rgba(var(--crate-rgb), 0.46);
  animation: stackActiveStep 82ms ease-out;
}

.stack-crate.settled {
  z-index: 2;
  transform: scale(0.96);
}

.stack-crate.just-landed {
  animation: stackCrateLand 150ms cubic-bezier(0.2, 0.82, 0.3, 1);
}

.stack-crate.ghost {
  z-index: 1;
  border-style: dashed;
  opacity: 0.3;
  background: rgba(var(--crate-rgb), 0.14);
  box-shadow: inset 0 0 7px rgba(var(--crate-rgb), 0.16);
}

.stack-crate.ghost::before,
.stack-crate.ghost::after {
  opacity: 0.35;
}

.stack-cell.clearing .stack-crate {
  z-index: 7;
  animation: stackLineClear 330ms ease-in-out var(--clear-delay) both;
}

.stack-crate.mini {
  inset: 0;
  border-width: 1px;
  border-radius: 2px;
  box-shadow: inset 1px 1px 2px rgba(255, 255, 255, 0.24), 0 0 4px rgba(var(--crate-rgb), 0.24);
}

.stack-crate.mini::before,
.stack-crate.mini::after {
  display: none;
}

.stack-line-flash {
  position: absolute;
  top: 48%;
  left: 50%;
  z-index: 14;
  min-width: 142px;
  padding: 10px 14px;
  border: 1px solid rgba(194, 240, 250, 0.52);
  border-radius: 99px;
  color: #08162d;
  background: linear-gradient(100deg, #8feaff, #c4b9ff 58%, #f6d98e);
  box-shadow: 0 0 38px rgba(131, 226, 250, 0.46);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-align: center;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.stack-line-flash.show {
  animation: chainFlash 700ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.stack-controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  width: min(100%, 330px);
  margin: 9px auto 0;
}

.stack-controls button {
  min-width: 0;
  min-height: 50px;
  padding: 0;
  border: 1px solid rgba(183, 218, 252, 0.18);
  border-radius: 15px;
  color: #d8eafb;
  background: linear-gradient(160deg, rgba(42, 63, 108, 0.74), rgba(15, 25, 52, 0.88));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.07), 0 5px 13px rgba(0, 0, 0, 0.16);
  font-size: 1.16rem;
  font-weight: 800;
  touch-action: manipulation;
}

.stack-controls .stack-hold-button {
  color: #b9dce8;
  font-size: 0.54rem;
  letter-spacing: 0.07em;
}

.stack-controls button:disabled {
  color: #67758d;
  filter: saturate(0.5);
  opacity: 0.55;
}

.stack-controls button:not(:disabled):active {
  color: #07152c;
  background: #bceef7;
  transform: scale(0.94);
}

.rhythm-play {
  width: 100%;
}

.rhythm-play,
.rhythm-play * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

.rhythm-toolbar {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) 78px;
  align-items: end;
  gap: 7px;
  width: min(100%, 336px);
  min-height: 104px;
  margin: 0 auto 7px;
}

.rhythm-stat-card {
  display: grid;
  min-height: 62px;
  place-items: center;
  align-content: center;
  gap: 5px;
  padding: 6px 4px;
  overflow: hidden;
  border: 1px solid rgba(184, 217, 250, 0.13);
  border-radius: 15px;
  color: #88cbd9;
  background: rgba(5, 11, 27, 0.42);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.rhythm-stat-card span {
  font-size: 0.46rem;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.rhythm-stat-card strong {
  max-width: 100%;
  overflow: hidden;
  color: #e8f8ff;
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  text-overflow: clip;
}

.rhythm-performer {
  display: grid;
  min-width: 0;
  place-items: center;
  align-self: stretch;
  align-content: end;
}

.rhythm-performer small {
  display: block;
  width: 100%;
  min-height: 15px;
  margin-top: 2px;
  overflow: hidden;
  color: #a9bdd2;
  font-size: 0.51rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rhythm-deer {
  position: relative;
  width: 70px;
  height: 84px;
  transform-origin: 50% 91%;
  will-change: transform;
}

.deer-antler {
  position: absolute;
  top: 0;
  z-index: 0;
  width: 23px;
  height: 33px;
  border-top: 3px solid #b8d6df;
  border-left: 3px solid #b8d6df;
  border-radius: 70% 0 0;
  filter: drop-shadow(0 0 5px rgba(134, 233, 255, 0.22));
}

.deer-antler b,
.deer-antler em {
  position: absolute;
  display: block;
  width: 13px;
  height: 16px;
  border-top: 3px solid #b8d6df;
  border-left: 3px solid #b8d6df;
  border-radius: 80% 0 0;
  content: "";
}

.deer-antler b {
  top: 3px;
  left: 4px;
  transform: rotate(28deg);
}

.deer-antler em {
  top: 14px;
  left: -5px;
  transform: rotate(-17deg);
}

.deer-antler.antler-left {
  left: 8px;
  transform: rotate(-10deg);
}

.deer-antler.antler-right {
  right: 8px;
  transform: scaleX(-1) rotate(-10deg);
}

.deer-ear {
  position: absolute;
  top: 27px;
  z-index: 1;
  width: 21px;
  height: 14px;
  border: 1px solid rgba(190, 224, 235, 0.32);
  background: linear-gradient(145deg, #496681, #253a59);
  clip-path: polygon(0 42%, 100% 0, 76% 100%);
}

.deer-ear.ear-left {
  left: 0;
  transform: rotate(8deg);
}

.deer-ear.ear-right {
  right: 0;
  transform: scaleX(-1) rotate(8deg);
}

.deer-head {
  position: absolute;
  top: 24px;
  left: 50%;
  z-index: 2;
  width: 51px;
  height: 44px;
  border: 1px solid rgba(174, 215, 239, 0.34);
  border-radius: 48% 48% 46% 46%;
  background:
    radial-gradient(circle at 50% 35%, rgba(213, 243, 248, 0.19), transparent 36%),
    linear-gradient(150deg, #405d7b, #243852 68%, #182a44);
  box-shadow: inset 0 0 13px rgba(126, 225, 255, 0.1), 0 4px 11px rgba(0, 0, 0, 0.2);
  transform: translateX(-50%);
}

.deer-eye {
  position: absolute;
  top: 10px;
  display: block;
  width: 13px;
  height: 15px;
  overflow: hidden;
  border: 1px solid rgba(218, 239, 245, 0.5);
  border-radius: 50%;
  background: #dceef1;
  animation: rhythmDeerBlink 6.2s ease-in-out infinite;
}

.deer-eye.eye-left { left: 9px; }
.deer-eye.eye-right { right: 9px; }

.deer-eye b {
  position: absolute;
  top: 5px;
  left: 50%;
  width: 5px;
  height: 7px;
  margin-left: -2.5px;
  border-radius: 50%;
  background: #0a1428;
  box-shadow: 0 0 0 1px rgba(92, 202, 228, 0.18);
  transition: transform 70ms linear;
}

.deer-muzzle {
  position: absolute;
  bottom: 4px;
  left: 50%;
  width: 25px;
  height: 14px;
  border-radius: 48% 48% 52% 52%;
  background: rgba(201, 221, 220, 0.74);
  transform: translateX(-50%);
}

.deer-nose {
  position: absolute;
  bottom: 11px;
  left: 50%;
  z-index: 2;
  width: 8px;
  height: 6px;
  border-radius: 50% 50% 55% 55%;
  background: #101729;
  transform: translateX(-50%);
}

.deer-body {
  position: absolute;
  bottom: 2px;
  left: 50%;
  z-index: 1;
  width: 36px;
  height: 27px;
  border: 1px solid rgba(161, 207, 230, 0.25);
  border-radius: 48% 48% 36% 36%;
  background: linear-gradient(155deg, #304c69, #182a44);
  transform: translateX(-50%);
}

.deer-leg {
  position: absolute;
  bottom: -5px;
  width: 7px;
  height: 13px;
  border-radius: 0 0 4px 4px;
  background: #213750;
  transform-origin: 50% 0;
}

.deer-leg.leg-left { left: 7px; }
.deer-leg.leg-right { right: 7px; }

.deer-tag {
  position: absolute;
  top: 5px;
  left: 50%;
  display: grid;
  width: 18px;
  height: 12px;
  place-items: center;
  border: 1px solid rgba(245, 221, 155, 0.48);
  border-radius: 4px;
  color: #ffedb7;
  background: rgba(72, 52, 63, 0.58);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.39rem;
  font-style: normal;
  font-weight: 900;
  transform: translateX(-50%);
}

.rhythm-deer.step-left { animation: deerStepLeft 170ms cubic-bezier(0.2, 0.8, 0.3, 1); }
.rhythm-deer.step-right { animation: deerStepRight 170ms cubic-bezier(0.2, 0.8, 0.3, 1); }
.rhythm-deer.step-down { animation: deerStepDown 170ms cubic-bezier(0.2, 0.8, 0.3, 1); }
.rhythm-deer.step-up { animation: deerStepUp 170ms cubic-bezier(0.2, 0.8, 0.3, 1); }

.rhythm-deer.step-left .deer-eye b { transform: translateX(-2px); }
.rhythm-deer.step-right .deer-eye b { transform: translateX(2px); }
.rhythm-deer.step-up .deer-eye b { transform: translateY(-1px); }
.rhythm-deer.step-down .deer-eye b { transform: translateY(1px); }

.rhythm-deer.perfect-step {
  filter: brightness(1.16) drop-shadow(0 0 7px rgba(134, 233, 255, 0.32));
}

.rhythm-meta {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 6px;
  width: min(100%, 316px);
  min-height: 34px;
  margin: 0 auto 7px;
  padding: 5px 9px;
  border: 1px solid rgba(184, 217, 250, 0.12);
  border-radius: 13px;
  color: #8998b2;
  background: rgba(5, 11, 27, 0.4);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.48rem;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.rhythm-meta strong {
  color: #dff8ff;
  font-size: 0.58rem;
  font-variant-numeric: tabular-nums;
}

.rhythm-meta small {
  justify-self: end;
  font-size: 0.46rem;
}

.rhythm-shell {
  position: relative;
  width: min(100%, 330px);
  margin: 0 auto;
  padding: 7px;
  overflow: hidden;
  border: 1px solid rgba(180, 220, 255, 0.2);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 20%, rgba(126, 232, 199, 0.1), transparent 36%),
    linear-gradient(180deg, rgba(5, 12, 29, 0.92), rgba(8, 16, 38, 0.99));
  box-shadow: inset 0 0 36px rgba(92, 176, 225, 0.07), 0 14px 34px rgba(0, 0, 0, 0.2);
  scroll-margin-top: 8px;
  touch-action: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.rhythm-shell.playing {
  border-color: rgba(134, 233, 255, 0.4);
  box-shadow: inset 0 0 48px rgba(92, 213, 237, 0.11), 0 0 28px rgba(103, 201, 231, 0.1);
}

.rhythm-lanes {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: 100%;
  aspect-ratio: 4 / 5.15;
  overflow: hidden;
  border-radius: 16px;
  background:
    linear-gradient(rgba(177, 219, 249, 0.035) 1px, transparent 1px),
    rgba(2, 7, 19, 0.64);
  background-size: 100% 10%;
  contain: layout paint style;
  touch-action: none;
}

.rhythm-lane {
  position: relative;
  overflow: hidden;
  border-right: 1px solid rgba(181, 218, 250, 0.07);
  background: linear-gradient(180deg, rgba(var(--lane-rgb), 0.05), transparent 42%, rgba(var(--lane-rgb), 0.025));
}

.rhythm-lane::after {
  position: absolute;
  inset: 0;
  content: "";
  opacity: var(--lane-input, 0);
  background: linear-gradient(180deg, transparent 15%, rgba(var(--lane-rgb), 0.04) 52%, rgba(var(--lane-rgb), 0.25));
  box-shadow: inset 0 -42px 45px rgba(var(--lane-rgb), 0.13);
  pointer-events: none;
  transition: opacity var(--lane-input-speed, 95ms) ease-out;
}

.rhythm-lane.lane-3 {
  border-right: 0;
}

.rhythm-play .lane-0 { --lane-rgb: 74, 215, 255; }
.rhythm-play .lane-1 { --lane-rgb: 180, 145, 255; }
.rhythm-play .lane-2 { --lane-rgb: 255, 213, 105; }
.rhythm-play .lane-3 { --lane-rgb: 255, 125, 177; }

.rhythm-lanes.input-lane-0 .rhythm-lane.lane-0,
.rhythm-lanes.input-lane-1 .rhythm-lane.lane-1,
.rhythm-lanes.input-lane-2 .rhythm-lane.lane-2,
.rhythm-lanes.input-lane-3 .rhythm-lane.lane-3 {
  --lane-input: 1;
  --lane-input-speed: 0ms;
}

.rhythm-receptors {
  position: absolute;
  top: 80.5%;
  right: 0;
  left: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  height: 44px;
  padding: 0 5px;
  pointer-events: none;
}

.rhythm-receptors::after {
  position: absolute;
  right: 4px;
  bottom: -5px;
  left: 4px;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(189, 239, 250, 0.55), transparent);
  box-shadow: 0 0 9px rgba(134, 233, 255, 0.34);
}

.rhythm-receptors i {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  place-self: center;
  border: 2px solid rgba(var(--lane-rgb), 0.38);
  border-radius: 14px;
  color: rgba(var(--lane-rgb), 0.52);
  background: rgba(var(--lane-rgb), 0.06);
  box-shadow: inset 0 0 13px rgba(var(--lane-rgb), 0.08), 0 0 10px rgba(var(--lane-rgb), 0.08);
  font-size: 1.3rem;
  font-style: normal;
  font-weight: 900;
  transition: transform 55ms ease, color 55ms ease, background 55ms ease, box-shadow 55ms ease;
}

.rhythm-lanes.input-lane-0 .rhythm-receptors .lane-0,
.rhythm-lanes.input-lane-1 .rhythm-receptors .lane-1,
.rhythm-lanes.input-lane-2 .rhythm-receptors .lane-2,
.rhythm-lanes.input-lane-3 .rhythm-receptors .lane-3 {
  color: #07152c;
  background: rgb(var(--lane-rgb));
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.32), 0 0 24px rgba(var(--lane-rgb), 0.62);
  transform: scale(0.93);
  transition-duration: 0ms;
}

.rhythm-note-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  pointer-events: none;
}

.rhythm-note {
  position: absolute;
  top: 0;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 2px solid rgba(var(--lane-rgb), 0.84);
  border-radius: 14px;
  color: #f5fbff;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.38), transparent 28%),
    rgba(var(--lane-rgb), 0.46);
  box-shadow:
    inset 0 0 12px rgba(255, 255, 255, 0.15),
    0 0 0 3px rgba(var(--lane-rgb), 0.09),
    0 0 15px rgba(var(--lane-rgb), 0.38);
  font-size: 1.32rem;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
  will-change: transform;
}

.rhythm-note.lane-0 { left: 12.5%; }
.rhythm-note.lane-1 { left: 37.5%; }
.rhythm-note.lane-2 { left: 62.5%; }
.rhythm-note.lane-3 { left: 87.5%; }

.rhythm-note.double-note {
  border-color: rgba(255, 244, 196, 0.86);
  box-shadow:
    inset 0 0 13px rgba(255, 255, 255, 0.2),
    0 0 0 3px rgba(246, 217, 142, 0.18),
    0 0 19px rgba(var(--lane-rgb), 0.5);
}

.rhythm-judgment {
  position: absolute;
  top: 43%;
  left: 50%;
  z-index: 12;
  min-width: 118px;
  padding: 8px 13px;
  border: 1px solid rgba(213, 241, 250, 0.4);
  border-radius: 99px;
  color: #07152c;
  background: #c8eff8;
  box-shadow: 0 0 27px rgba(134, 233, 255, 0.34);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  font-weight: 1000;
  letter-spacing: 0.1em;
  text-align: center;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: rhythmJudge 230ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.rhythm-judgment.perfect { background: linear-gradient(100deg, #8feaff, #efffff 58%, #f6d98e); }
.rhythm-judgment.great { background: linear-gradient(100deg, #9dbdff, #d6caff); }
.rhythm-judgment.good { background: linear-gradient(100deg, #8fd9bf, #d4f4da); }
.rhythm-judgment.miss { color: #e7c9d4; background: rgba(67, 30, 53, 0.9); }

.rhythm-judgment.countdown {
  min-width: 62px;
  padding: 10px;
  border-color: rgba(246, 217, 142, 0.48);
  color: #fff0bd;
  background: rgba(15, 28, 54, 0.88);
  font-size: 1.35rem;
}

.rhythm-judgment.countdown.rush {
  min-width: 126px;
  color: #07152c;
  background: linear-gradient(100deg, #8feaff, #c4b9ff 58%, #f6d98e);
  font-size: 0.88rem;
}

.rhythm-start-panel {
  position: absolute;
  inset: 7px;
  z-index: 16;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 9px;
  padding: 18px;
  border-radius: 16px;
  background:
    radial-gradient(circle at 50% 36%, rgba(126, 232, 199, 0.14), transparent 34%),
    rgba(5, 12, 29, 0.89);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  text-align: center;
}

.rhythm-track-name {
  margin: 0 0 2px;
  color: #91dfea;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.rhythm-start-panel > strong {
  color: #e8f2ff;
  font-size: 0.83rem;
}

.rhythm-start-panel > small {
  color: #8291ad;
  font-size: 0.61rem;
}

.rhythm-start-panel button {
  min-width: 152px;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid rgba(183, 231, 244, 0.46);
  border-radius: 99px;
  color: #07152c;
  background: linear-gradient(105deg, #91e9fa, #c5baff 62%, #f6d98e);
  box-shadow: 0 0 24px rgba(134, 233, 255, 0.2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  font-weight: 1000;
  letter-spacing: 0.14em;
  touch-action: manipulation;
}

.rhythm-start-panel button:disabled {
  color: #718099;
  background: rgba(99, 116, 148, 0.12);
  box-shadow: none;
}

.rhythm-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  width: min(100%, 336px);
  margin: 9px auto 0;
}

.rhythm-controls button {
  min-width: 0;
  min-height: 58px;
  padding: 0;
  border: 1px solid rgba(var(--lane-rgb), 0.38);
  border-radius: 16px;
  color: rgba(var(--lane-rgb), 0.88);
  background: linear-gradient(160deg, rgba(var(--lane-rgb), 0.16), rgba(9, 18, 40, 0.91));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08), 0 5px 13px rgba(0, 0, 0, 0.16);
  font-size: 1.45rem;
  font-weight: 900;
  touch-action: none;
  transition: transform 65ms ease, color 65ms ease, background 65ms ease, box-shadow 65ms ease;
}

.rhythm-controls button:disabled {
  color: rgba(var(--lane-rgb), 0.3);
  filter: saturate(0.55);
  opacity: 0.6;
}

.rhythm-controls.enabled button.pressed,
.rhythm-controls.enabled button:active {
  color: #07152c;
  background: rgb(var(--lane-rgb));
  box-shadow: 0 0 22px rgba(var(--lane-rgb), 0.45);
  transform: translateY(2px) scale(0.94);
}

.rhythm-volume,
.rhythm-calibration {
  display: grid;
  grid-template-columns: 1fr 34px 72px 34px;
  align-items: center;
  gap: 5px;
  width: min(100%, 316px);
  margin: 8px auto 0;
  color: #8494af;
  font-size: 0.57rem;
  font-weight: 800;
}

.rhythm-calibration {
  margin-top: 5px;
}

.rhythm-volume button,
.rhythm-calibration button {
  display: grid;
  width: 34px;
  height: 30px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(181, 216, 248, 0.15);
  border-radius: 10px;
  color: #cbe8f2;
  background: rgba(31, 49, 86, 0.62);
  font-size: 0.9rem;
  touch-action: manipulation;
}

.rhythm-volume button:disabled,
.rhythm-calibration button:disabled {
  opacity: 0.35;
}

.rhythm-volume strong,
.rhythm-calibration strong {
  color: #b8cde0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.57rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.trace-layer,
.spark-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.trace-layer polyline {
  fill: none;
  stroke: rgba(var(--trace-rgb, 134, 233, 255), 0.77);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 6px rgba(var(--trace-rgb, 134, 233, 255), 0.92));
}

.spark {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(var(--spark-rgb), 0.95);
  box-shadow: 0 0 10px rgba(var(--spark-rgb), 0.9);
  animation: sparkFly 620ms ease-out forwards;
}

.gesture-note {
  margin: 11px 4px 2px;
  color: #9ca9c0;
  font-size: 0.69rem;
  line-height: 1.5;
  text-align: center;
}

.gesture-note span {
  color: #8edce9;
}

.stage-actions {
  margin-top: 12px;
}

.primary-button,
.secondary-button,
.ghost-button {
  width: 100%;
  min-height: 50px;
  border-radius: 17px;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.primary-button {
  border: 1px solid rgba(154, 232, 245, 0.42);
  color: #0b1630;
  background: linear-gradient(135deg, #bdeff7, #bcb4ff 66%, #f3da9e);
  box-shadow: 0 11px 24px rgba(92, 163, 219, 0.2);
}

.secondary-button {
  border: 1px solid rgba(139, 220, 238, 0.28);
  color: #d9f6fb;
  background: rgba(104, 203, 228, 0.1);
}

.ghost-button {
  margin-top: 8px;
  border: 1px solid var(--line);
  color: #b9c6dc;
  background: rgba(255, 255, 255, 0.04);
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.collection-item:active {
  transform: scale(0.985);
}

.app-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 7px 14px;
  padding: 17px 5px 0;
  color: #67738b;
  font-size: 0.56rem;
  letter-spacing: 0.12em;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: calc(22px + env(safe-area-inset-bottom));
  left: 18px;
  z-index: 80;
  width: fit-content;
  max-width: calc(100% - 36px);
  margin: auto;
  padding: 11px 16px;
  border: 1px solid rgba(165, 226, 241, 0.25);
  border-radius: 99px;
  color: #eafcff;
  background: rgba(10, 20, 43, 0.92);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.36), 0 0 20px rgba(108, 209, 236, 0.12);
  font-size: 0.76rem;
  font-weight: 800;
  text-align: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: toastIn 220ms ease-out;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  align-items: end;
  padding: 14px max(14px, env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 18, 0.78);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(100%, 500px);
  max-height: calc(100svh - 28px - env(safe-area-inset-bottom));
  margin: 0 auto;
  padding: 23px 20px 20px;
  overflow: auto;
  border: 1px solid rgba(187, 218, 255, 0.22);
  border-radius: 30px;
  background:
    radial-gradient(circle at 50% 8%, rgba(131, 223, 245, 0.12), transparent 31%),
    linear-gradient(165deg, #182747, #0d152d 62%, #0a1023);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.58), inset 0 1px rgba(255, 255, 255, 0.08);
  animation: modalRise 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.result-card {
  text-align: center;
}

.result-canvas-wrap {
  position: relative;
  height: min(42svh, 300px);
  min-height: 230px;
  margin: 5px 0 -3px;
}

.result-canvas-wrap canvas {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

.result-glow {
  position: absolute;
  right: 23%;
  bottom: 16%;
  left: 23%;
  height: 33px;
  border-radius: 50%;
  background: rgba(108, 221, 245, 0.25);
  filter: blur(15px);
}

.congratulations {
  margin: 0 0 7px;
  color: var(--moon);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.25em;
}

.result-card h2,
.compact-modal h2,
.collection-card h2 {
  margin: 4px 0 10px;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: 1.55rem;
  font-weight: 500;
  letter-spacing: 0.06em;
}

.result-copy,
.compact-modal > p:not(.modal-kicker),
.collection-intro {
  color: #b9c5d8;
  font-size: 0.8rem;
  line-height: 1.7;
}

.result-copy {
  margin: 0 auto 6px;
  max-width: 330px;
}

.rhythm-result-breakdown {
  display: grid;
  gap: 4px;
  width: min(100%, 360px);
  margin: 10px auto 2px;
  padding: 10px 12px;
  border: 1px solid rgba(134, 233, 255, 0.25);
  border-radius: 15px;
  background: linear-gradient(145deg, rgba(134, 233, 255, 0.08), rgba(185, 173, 255, 0.07));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.06);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  animation: rhythmResultStamp 360ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.rhythm-result-breakdown strong {
  color: #c9f5ff;
  font-size: 0.9rem;
  font-weight: 1000;
  letter-spacing: 0.18em;
}

.rhythm-result-breakdown > span {
  color: #c4d4e8;
  font-size: 0.63rem;
  font-weight: 850;
  line-height: 1.45;
}

.rhythm-result-breakdown > span:last-child {
  color: #f3e4b3;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
}

.rhythm-result-breakdown.full-combo {
  border-color: rgba(246, 217, 142, 0.5);
  background:
    radial-gradient(circle at 50% 0%, rgba(246, 217, 142, 0.18), transparent 58%),
    linear-gradient(145deg, rgba(134, 233, 255, 0.1), rgba(185, 173, 255, 0.09));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), 0 0 22px rgba(246, 217, 142, 0.1);
}

.rhythm-result-breakdown.full-combo strong {
  color: #ffe7a2;
  text-shadow: 0 0 14px rgba(246, 217, 142, 0.42);
}

.best-record {
  min-height: 1.3em;
  margin: 5px 0 16px;
  color: #e8dcae;
  font-size: 0.7rem;
  font-weight: 800;
}

.rhythm-timing-log {
  width: min(100%, 360px);
  margin: -7px auto 14px;
  padding: 8px;
  border: 1px solid rgba(183, 216, 248, 0.16);
  border-radius: 14px;
  background: rgba(4, 10, 24, 0.58);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: left;
}

.rhythm-timing-log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 3px 7px;
  color: #82cddb;
  font-size: 0.54rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.rhythm-timing-log-head strong {
  color: #aab9cf;
  font-size: 0.53rem;
  letter-spacing: 0;
}

.rhythm-timing-log-list {
  display: grid;
  gap: 3px;
  max-height: 116px;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.rhythm-timing-entry {
  display: grid;
  grid-template-columns: 52px 23px 44px minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 3px 6px;
  border-radius: 8px;
  color: #aebdd2;
  background: rgba(126, 157, 199, 0.055);
  font-size: 0.52rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rhythm-timing-time {
  color: #8798b2;
}

.rhythm-timing-lane {
  color: #d9f7ff;
  font-size: 0.7rem;
  text-align: center;
}

.rhythm-timing-entry.great .rhythm-timing-judgment {
  color: #c9bdff;
}

.rhythm-timing-entry.good .rhythm-timing-judgment {
  color: #9be5ca;
}

.rhythm-timing-entry.miss .rhythm-timing-judgment {
  color: #f0b3c9;
}

.rhythm-timing-delta {
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
}

.rhythm-timing-delta.early {
  color: #8feaff;
}

.rhythm-timing-delta.late {
  color: #f3d995;
}

.rhythm-timing-delta.no-input {
  color: #e9a9c0;
}

.rhythm-timing-all-perfect {
  margin: 0;
  padding: 9px 6px;
  border-radius: 8px;
  color: #ffe7a2;
  background: rgba(246, 217, 142, 0.07);
  font-size: 0.59rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-align: center;
}

.compact-modal {
  align-self: center;
  text-align: center;
}

.fail-moon {
  margin: 12px 0 3px;
  color: #8fb9d0;
  font-family: Georgia, serif;
  font-size: 3.8rem;
  text-shadow: 0 0 28px rgba(103, 198, 229, 0.28);
}

.compact-modal .primary-button {
  margin-top: 12px;
}

.collection-card {
  align-self: center;
}

.close-button {
  position: absolute;
  top: 17px;
  right: 17px;
  width: 38px;
  height: 38px;
  color: #b8c4d8;
  font-size: 1.4rem;
}

.collection-intro {
  margin: 0 0 17px;
}

.collection-item {
  display: grid;
  grid-template-columns: 40px 54px 1fr 28px;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 88px;
  padding: 12px;
  border: 1px dashed rgba(190, 207, 233, 0.16);
  border-radius: 21px;
  color: #929db1;
  background: rgba(255, 255, 255, 0.025);
  text-align: left;
}

.collection-item.unlocked {
  border-style: solid;
  border-color: rgba(151, 225, 241, 0.25);
  color: var(--ink);
  background:
    linear-gradient(115deg, rgba(103, 212, 236, 0.11), rgba(183, 166, 255, 0.1) 60%, rgba(244, 216, 145, 0.09));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.05);
}

.collection-index {
  align-self: start;
  color: #8190a8;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  font-weight: 800;
}

.collection-thumb {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 1px solid rgba(169, 217, 238, 0.16);
  border-radius: 17px;
  background: rgba(133, 218, 241, 0.07);
  font-family: Georgia, serif;
  font-size: 1.8rem;
}

.unlocked .collection-thumb {
  color: #d7f7ff;
  text-shadow: 0 0 15px rgba(124, 226, 247, 0.65);
}

.collection-copy {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.collection-copy strong {
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: 0.96rem;
  font-weight: 600;
}

.collection-copy small {
  color: #8997ad;
  font-size: 0.66rem;
}

.collection-state {
  color: #8290a4;
  font-size: 1.4rem;
}

.unlocked .collection-state {
  color: var(--moon);
}

.locked-slots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.locked-slots div {
  min-height: 83px;
  padding: 13px;
  border: 1px dashed rgba(190, 207, 233, 0.12);
  border-radius: 18px;
  color: #657187;
  background: rgba(255, 255, 255, 0.016);
}

.locked-slots span {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.66rem;
}

.locked-slots p {
  margin: 12px 0 0;
  font-size: 0.68rem;
}

.story-view {
  position: fixed;
  inset: 0;
  z-index: 110;
  overflow-y: auto;
  color: #273044;
  background:
    linear-gradient(rgba(79, 117, 159, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79, 117, 159, 0.055) 1px, transparent 1px),
    #f4f2ea;
  background-size: 28px 28px;
  overscroll-behavior: contain;
}

.story-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: calc(13px + env(safe-area-inset-top)) 18px 13px;
  border-bottom: 1px solid rgba(63, 85, 111, 0.12);
  background: rgba(244, 242, 234, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.back-button {
  padding: 8px 11px;
  border: 1px solid rgba(56, 84, 112, 0.18);
  border-radius: 99px;
  color: #3e5870;
  background: rgba(255, 255, 255, 0.5);
  font-size: 0.7rem;
  font-weight: 800;
}

.story-header > span {
  color: #668c99;
  font-size: 0.58rem;
  text-align: right;
}

.story-paper {
  width: min(100%, 650px);
  margin: 0 auto;
  padding: 39px 25px calc(65px + env(safe-area-inset-bottom));
}

.story-item {
  margin: 0 0 10px;
  color: #53818b;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
}

.story-paper h2 {
  margin: 0;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(1.75rem, 8vw, 2.65rem);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-align: center;
}

.story-divider {
  display: flex;
  align-items: center;
  gap: 15px;
  margin: 27px auto 31px;
  color: #b59a52;
}

.story-divider::before,
.story-divider::after {
  flex: 1;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(74, 102, 126, 0.28));
}

.story-divider::after {
  background: linear-gradient(90deg, rgba(74, 102, 126, 0.28), transparent);
}

.story-paper > p:not(.story-item, .story-end) {
  margin: 0 0 1.65em;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(0.98rem, 4.2vw, 1.08rem);
  line-height: 2.05;
  letter-spacing: 0.035em;
}

.story-paper > p:not(.story-item, .story-end):first-of-type::first-letter {
  float: left;
  margin: 0.03em 0.1em -0.02em 0;
  color: #735b69;
  font-size: 3.2em;
  line-height: 0.9;
}

.story-paper blockquote {
  margin: 2.2em 0;
  padding: 18px 20px;
  border-left: 3px solid #6d9eac;
  color: #26394d;
  background: rgba(96, 151, 169, 0.08);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: 1.04rem;
  font-weight: 600;
  line-height: 1.8;
}

.story-end {
  margin: 42px 0 0;
  color: #72818d;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-align: center;
}

body.modal-open {
  overflow: hidden;
}

@keyframes tailGlow {
  from { outline-color: rgba(var(--gem-rgb), 0.28); }
  to { outline-color: rgba(var(--gem-rgb), 0.82); }
}

@keyframes cascadeStep {
  from { transform: translateY(-18%) scale(0.94); }
  to { transform: translateY(0) scale(1); }
}

@keyframes cascadeSplitDrop {
  from { transform: translateY(-112%) scale(0.94); }
  to { transform: translateY(0) scale(0.94); }
}

@keyframes cascadeClear {
  from {
    filter: brightness(1.15);
    transform: scale(0.9) rotate(-2deg);
  }
  to {
    filter: brightness(1.9) saturate(1.25);
    transform: scale(1.12) rotate(2deg);
  }
}

@keyframes orbitShift {
  from { filter: brightness(1.45); transform: scale(0.8); }
  to { filter: brightness(1); transform: scale(1); }
}

@keyframes orbitDiagonalGlow {
  0% { filter: brightness(1.85) saturate(1.28); }
  58% { filter: brightness(1.42) saturate(1.14); }
  100% { filter: brightness(1) saturate(1); }
}

@keyframes orbitDiagonalRipple {
  0% { opacity: 0.95; transform: scale(0.42); }
  62% { opacity: 0.5; transform: scale(0.9); }
  100% { opacity: 0; transform: scale(1.08); }
}

@keyframes orbitClear {
  from {
    filter: brightness(1.18);
    opacity: 0.9;
    transform: scale(0.88) rotate(-2deg);
  }
  to {
    filter: brightness(1.95) saturate(1.25);
    opacity: 0.42;
    transform: scale(1.14) rotate(2deg);
  }
}

@keyframes orbitDrop {
  from { opacity: 0.25; transform: translateY(-58%) scale(0.88); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes chainFlash {
  0% { opacity: 0; transform: translate(-50%, -42%) scale(0.72); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(1); }
}

@keyframes stackActiveStep {
  from { opacity: 0.8; transform: translateY(-2px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes stackCrateLand {
  0% { transform: translateY(-5px) scale(0.92, 1.08); }
  65% { transform: translateY(1px) scale(1.03, 0.91); }
  100% { transform: translateY(0) scale(0.96); }
}

@keyframes stackLineClear {
  0% { opacity: 1; filter: brightness(1); transform: scale(0.96); }
  48% { opacity: 1; filter: brightness(2.1) saturate(0.65); transform: scale(1.16, 0.78); }
  100% { opacity: 0; filter: brightness(2.5); transform: scale(0.04, 0.62); }
}

@keyframes stackShellLand {
  0% { transform: translateY(0); }
  48% { transform: translateY(2px); }
  100% { transform: translateY(0); }
}

@keyframes stackOwlBlink {
  0%, 45%, 49%, 100% { transform: scaleY(1); }
  47% { transform: scaleY(0.08); }
}

@keyframes stackOwlHold {
  0% { transform: translateX(0) rotate(0); }
  38% { transform: translateX(-5px) rotate(-8deg); }
  72% { transform: translateX(3px) rotate(5deg); }
  100% { transform: translateX(0) rotate(0); }
}

@keyframes stackOwlStamp {
  0% { transform: translateY(0) scale(1); }
  44% { transform: translateY(3px) scale(1.04, 0.9); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes stackOwlCheer {
  from { transform: translateY(1px) rotate(-2deg); }
  to { transform: translateY(-3px) rotate(2deg); }
}

@keyframes stackWingLeft {
  from { transform: rotate(19deg); }
  to { transform: rotate(68deg); }
}

@keyframes stackWingRight {
  from { transform: scaleX(-1) rotate(19deg); }
  to { transform: scaleX(-1) rotate(68deg); }
}

@keyframes lowPulse {
  50% { opacity: 0.55; }
}

@keyframes rhythmDeerBlink {
  0%, 45%, 48%, 100% { transform: scaleY(1); }
  46.5% { transform: scaleY(0.08); }
}

@keyframes deerStepLeft {
  0%, 100% { transform: translateX(0) rotate(0); }
  45% { transform: translateX(-8px) rotate(-7deg); }
}

@keyframes deerStepRight {
  0%, 100% { transform: translateX(0) rotate(0); }
  45% { transform: translateX(8px) rotate(7deg); }
}

@keyframes deerStepDown {
  0%, 100% { transform: translateY(0) scaleY(1); }
  45% { transform: translateY(5px) scaleY(0.92); }
}

@keyframes deerStepUp {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(-8px); }
}

@keyframes rhythmJudge {
  from { opacity: 0; transform: translate(-50%, -42%) scale(0.82); }
  55% { opacity: 1; transform: translate(-50%, -52%) scale(1.08); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes rhythmResultStamp {
  from { opacity: 0; transform: translateY(7px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes sparkFly {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0);
  }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes modalRise {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (min-width: 560px) {
  .modal {
    align-items: center;
  }

  .app-shell {
    padding-top: 30px;
  }

  .stage-card {
    padding: 21px 19px 18px;
  }
}

@media (max-width: 370px) {
  .app-shell {
    padding-right: 11px;
    padding-left: 11px;
  }

  .stage-card {
    padding-right: 10px;
    padding-left: 10px;
  }

  .guide-copy p {
    font-size: 0.77rem;
  }

  h1 {
    font-size: 1.3rem;
    letter-spacing: 0.02em;
  }

  .topbar-actions {
    gap: 4px;
  }

  .topbar-actions .icon-button {
    flex-basis: 46px;
    width: 46px;
    min-height: 48px;
    border-radius: 16px;
  }

  .status-grid {
    grid-template-columns: 85px 1fr;
  }

  .board-shell {
    padding: 7px;
  }

  .mode-button {
    min-height: 46px;
    padding-right: 4px;
    padding-left: 4px;
  }

  .mode-button span {
    font-size: 0.44rem;
    letter-spacing: 0.04em;
  }

  .mode-button strong {
    font-size: 0.64rem;
  }

  .stack-toolbar {
    grid-template-columns: 67px minmax(0, 1fr) 67px;
    gap: 5px;
  }

  .stack-controls {
    gap: 4px;
  }

  .orbit-toolbar small {
    max-width: 70px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
