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

@font-face {
  font-family: 'Bravura';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/bravura.woff2') format('woff2');
}

:root {
  --app-sky-bg: linear-gradient(
    180deg,
    #a8e4ff 0%,
    #a0e2fc 10%,
    #97dff9 22%,
    #8edbf7 34%,
    #85d7f5 46%,
    #7dd3f3 58%,
    #74cef0 70%,
    #6cc9ed 82%,
    #64c4ea 92%,
    #5ebfe7 100%
  );
  --app-sky-fallback: #7dd3f3;
  --custom-bottom-inset: clamp(8px, 2vmin, 16px);
  --game-bottom-inset: clamp(12px, 2.5vmin, 20px);
  --font-2xs: clamp(7px, 2.2vmin, 9px);
  --font-xs: clamp(8px, 2.5vmin, 11px);
  --font-sm: clamp(10px, 3vmin, 13px);
  --font-md: clamp(12px, 3.5vmin, 16px);
  --font-lg: clamp(14px, 4vmin, 19px);
  --font-xl: clamp(16px, 4.5vmin, 22px);
  --font-display: clamp(26px, 7.5vmin, 50px);
}

html {
  overflow-x: hidden;
  font-size: var(--font-sm);
}

body {
  min-height: 100dvh;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: inherit;
  background: var(--app-sky-fallback);
  background-image: var(--app-sky-bg);
  color: #1a1a2e;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
  margin: 0;
  padding: 0;
}

/* Shared full-screen frame padding (cover + game) */
.cover-content,
.game-container {
  --screen-pad-top: max(10px, env(safe-area-inset-top));
  --screen-pad-right: max(20px, env(safe-area-inset-right));
  --screen-pad-bottom: max(12px, env(safe-area-inset-bottom));
  --screen-pad-left: max(20px, env(safe-area-inset-left));
}

/* Cover screen */
.cover-screen {
  position: fixed;
  inset: 0;
  min-height: 100dvh;
  min-width: 100dvw;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 20;
  background: #3498db;
  animation: cover-fade-in 0.5s ease-out;
}

.cover-screen--hub-map .cover-content {
  z-index: 2;
}

.cover-map-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  background: #3498db;
}

.cover-map-bg__stage {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  transform-origin: center center;
}

.cover-map-bg__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.cover-map-bg__canvas--fish,
.cover-map-bg__canvas--animals,
.cover-map-bg__canvas--bridge {
  pointer-events: none;
}

.cover-map-bg__shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(8, 28, 48, 0.42) 0%, rgba(8, 28, 48, 0.08) 22%, transparent 42%),
    linear-gradient(0deg, rgba(8, 28, 48, 0.5) 0%, rgba(8, 28, 48, 0.12) 24%, transparent 46%);
}

.cover-screen--hub-map .cover-title {
  color: #fff6e8;
  text-shadow:
    4px 4px 0 #1a4a6a,
    2px 2px 0 #0d2a40,
    0 0 20px rgba(0, 0, 0, 0.35);
  text-align: left;
}

.cover-screen--hub-map .cover-subtitle {
  text-align: left;
}

.cover-screen--hub-map .cover-subtitle,
.cover-screen--hub-map .cover-hint {
  color: #e8f4ff;
  text-shadow: 2px 2px 0 rgba(13, 42, 64, 0.85);
}

.cover-title-cluster {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 1.2vmin, 14px);
  width: min(100%, 820px);
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.cover-title-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(4px, 1vmin, 10px);
  text-align: left;
  flex: 0 1 auto;
  min-width: 0;
  padding-bottom: 0;
}

.cover-mascot {
  position: relative;
  width: clamp(52px, 11vmin, 84px);
  height: clamp(46px, 10vmin, 76px);
  flex: 0 0 auto;
  transform-origin: bottom center;
  filter: drop-shadow(3px 4px 0 rgba(13, 42, 64, 0.34));
  align-self: flex-end;
  margin-bottom: calc(clamp(14px, 4vmin, 26px) + clamp(4px, 1vmin, 10px));
}

.cover-mascot__shadow {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 58%;
  height: clamp(6px, 1.4vmin, 10px);
  transform: translateX(-50%);
  background: rgba(13, 42, 64, 0.3);
  border-radius: 50%;
  pointer-events: none;
}

.cover-mascot.character--slime .slime-sprite {
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 122%;
  height: auto;
  transform: translateX(-50%);
}

.cover-screen--map-fallback {
  background: linear-gradient(180deg, #5dade2 0%, #3498db 55%, #2874a6 100%);
}

.cover-screen[hidden],
.bridge-cover-screen[hidden],
.app-shell[hidden] {
  display: none !important;
}

.bridge-cover-screen {
  z-index: 15;
}

.cover-title--bridge {
  font-size: clamp(22px, 7vmin, 44px);
}

.cover-footer--bridge {
  flex-direction: column;
  gap: clamp(10px, 2.5vmin, 16px);
}

.cover-back-button {
  font-family: inherit;
  font-size: clamp(8px, 2.2vmin, 11px);
  color: #e8f8ff;
  background: rgba(36, 59, 85, 0.72);
  border: 2px solid #1a2a3a;
  box-shadow: 3px 3px 0 rgba(13, 26, 38, 0.35);
  padding: clamp(8px, 2vmin, 12px) clamp(14px, 4vmin, 22px);
  min-height: 40px;
  cursor: pointer;
  touch-action: manipulation;
}

.cover-back-button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 rgba(13, 26, 38, 0.35);
}

.cover-hero-character--sprite {
  width: auto;
  height: auto;
  min-width: clamp(40px, 11vw, 56px);
  min-height: clamp(40px, 11vw, 56px);
}

.cover-hero-character--sprite::before,
.cover-hero-character--sprite::after {
  display: none !important;
}

.bridge-cover-sprite {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  pointer-events: none;
  filter: drop-shadow(3px 3px 0 rgba(26, 74, 106, 0.25));
}

/* App shell + top navigation (landscape-first) */
.app-shell {
  position: fixed;
  inset: 0;
  min-height: 100dvh;
  min-width: 100dvw;
  display: flex;
  flex-direction: column;
  z-index: 10;
  background: transparent;
  --app-top-nav-height: calc(46px + max(4px, env(safe-area-inset-top)));
  --control-rail-width: clamp(148px, 24vw, 220px);
}

.app-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

.play-panel,
.custom-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.play-panel[hidden],
.custom-panel[hidden] {
  display: none !important;
}

.app-top-nav {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-height: var(--app-top-nav-height);
  background: #243b55;
  border-bottom: 3px solid #1a2a3a;
  box-shadow: 0 3px 0 rgba(13, 26, 38, 0.25);
  padding:
    max(4px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    6px
    max(10px, env(safe-area-inset-left));
  gap: 8px;
  z-index: 60;
}

.app-top-nav[hidden] {
  display: none !important;
}

.app-top-nav__item {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: clamp(8px, 2.2vh, 11px);
  color: #9eb4c8;
  background: rgba(42, 74, 106, 0.45);
  border: 2px solid #1a2a3a;
  border-radius: 0;
  box-shadow: 2px 2px 0 rgba(13, 26, 38, 0.35);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.12s, color 0.12s, transform 0.08s;
}

.app-top-nav__item:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 rgba(13, 26, 38, 0.35);
}

.app-top-nav__item--active {
  background: #4a8ab8;
  color: #fff;
  box-shadow:
    2px 2px 0 rgba(13, 26, 38, 0.35),
    inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.app-top-nav__icon {
  font-size: clamp(12px, 3.3vh, 17px);
  line-height: 1;
}

.app-top-nav__label {
  line-height: 1.3;
  white-space: nowrap;
}

.game-screen[hidden] {
  display: none !important;
}

.game-screen {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.game-back-button {
  position: static;
  flex-shrink: 0;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(10px, 3.3vw, 12px);
  line-height: 1.6;
  color: #e8f8ff;
  background: rgba(42, 74, 106, 0.92);
  border: 3px solid #1a2a3a;
  box-shadow: 3px 3px 0 rgba(13, 26, 38, 0.45);
  padding: 6px 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.12s ease;
}

.game-back-button:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 rgba(13, 26, 38, 0.45);
}

.game-back-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.screen-fade-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}

.screen-fade-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

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

.game-bg-sky {
  position: absolute;
  inset: 0;
  background: transparent;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.game-bg-ground {
  display: none;
}

.game-cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.82);
  border-radius: 2px;
  opacity: 0.85;
  box-shadow:
    8px 0 0 rgba(255, 255, 255, 0.82),
    16px 0 0 rgba(255, 255, 255, 0.78),
    4px -6px 0 rgba(255, 255, 255, 0.68),
    12px -6px 0 rgba(255, 255, 255, 0.64);
  animation: cover-cloud-drift 18s ease-in-out infinite;
  pointer-events: none;
}

.game-cloud--1 {
  width: clamp(20px, 6vw, 28px);
  height: clamp(11px, 3vw, 14px);
  top: 8%;
  left: 8%;
}

.game-cloud--2 {
  width: clamp(16px, 5vw, 24px);
  height: clamp(9px, 2.5vw, 12px);
  top: 14%;
  right: 10%;
  animation-delay: -6s;
  animation-duration: 22s;
}

.game-cloud--3 {
  width: clamp(12px, 4vw, 20px);
  height: clamp(7px, 2vw, 10px);
  top: 5%;
  left: 42%;
  animation-delay: -11s;
  animation-duration: 24s;
  opacity: 0.65;
}

.game-deco--hills-far {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 18%;
  background: linear-gradient(180deg, transparent 0%, rgba(90, 168, 120, 0.22) 55%, rgba(72, 148, 100, 0.28) 100%);
  clip-path: polygon(
    0% 100%, 0% 72%, 8% 58%, 16% 68%, 24% 52%, 34% 64%, 44% 48%,
    54% 60%, 64% 46%, 74% 58%, 84% 44%, 92% 56%, 100% 42%, 100% 100%
  );
  opacity: 0.55;
  pointer-events: none;
}

@keyframes cover-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.cover-bg-sky {
  position: absolute;
  inset: 0;
  background: transparent;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.cover-bg-ground {
  display: none;
}

.cover-content {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: min(100%, 720px);
  height: 100%;
  min-height: 0;
  margin: 0 auto;
  padding:
    clamp(12px, 3vmin, 28px)
    var(--screen-pad-right)
    clamp(28px, 7vmin, 56px)
    var(--screen-pad-left);
  gap: clamp(16px, 4vmin, 32px);
  box-sizing: border-box;
}

.cover-cloud {
  position: absolute;
  z-index: 2;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 2px;
  box-shadow:
    10px 0 0 rgba(255, 255, 255, 0.9),
    20px 0 0 rgba(255, 255, 255, 0.85),
    5px -8px 0 rgba(255, 255, 255, 0.75),
    15px -8px 0 rgba(255, 255, 255, 0.7);
  animation: cover-cloud-drift 14s ease-in-out infinite;
}

/* Sun top-left + title top-center stay clear; fill gap above bridge */
.cover-cloud--1 {
  width: clamp(22px, 7vw, 32px);
  height: clamp(12px, 3.5vw, 16px);
  bottom: 32%;
  left: 7%;
  top: auto;
}

.cover-cloud--2 {
  width: clamp(20px, 6vw, 30px);
  height: clamp(11px, 3.2vw, 15px);
  top: 27%;
  left: 38%;
  right: auto;
  animation-delay: -5s;
  animation-duration: 17s;
  opacity: 0.82;
}

.cover-cloud--3 {
  width: clamp(14px, 4.5vw, 24px);
  height: clamp(8px, 2.5vw, 12px);
  top: 15%;
  right: 6%;
  left: auto;
  animation-delay: -9s;
  animation-duration: 20s;
  opacity: 0.75;
}

.cover-cloud--4 {
  width: clamp(18px, 5.5vw, 26px);
  height: clamp(10px, 3vw, 14px);
  top: 35%;
  left: 52%;
  animation-delay: -3s;
  animation-duration: 16s;
  opacity: 0.78;
}

.cover-cloud--5 {
  width: clamp(12px, 4vw, 22px);
  height: clamp(7px, 2.2vw, 11px);
  bottom: 36%;
  right: 8%;
  top: auto;
  animation-delay: -12s;
  animation-duration: 19s;
  opacity: 0.7;
}

.cover-cloud--6 {
  width: clamp(16px, 5vw, 26px);
  height: clamp(9px, 2.8vw, 13px);
  bottom: 26%;
  left: 6%;
  right: auto;
  animation-delay: -7s;
  animation-duration: 21s;
  opacity: 0.65;
}

/* Cover sky decorations */
.cover-deco {
  position: absolute;
  pointer-events: none;
}

.cover-deco--scanlines {
  inset: 0;
  background: repeating-linear-gradient(
    180deg,
    transparent 0,
    transparent 3px,
    rgba(255, 255, 255, 0.03) 3px,
    rgba(255, 255, 255, 0.03) 4px
  );
  opacity: 0.5;
}

.cover-deco--sun {
  z-index: 4;
  top: clamp(20px, 6vmin, 52px);
  left: clamp(14px, 5vw, 40px);
  width: clamp(28px, 8vmin, 48px);
  height: clamp(28px, 8vmin, 48px);
  background: #ffe566;
  border: 3px solid #f5c842;
  box-shadow:
    0 0 0 4px rgba(255, 229, 102, 0.35),
    6px 6px 0 rgba(245, 200, 66, 0.25);
  border-radius: 2px;
  animation: cover-sun-pulse 4s ease-in-out infinite;
}

.cover-deco--sun::before,
.cover-deco--sun::after {
  content: '';
  position: absolute;
  background: #ffe566;
  border-radius: 1px;
}

.cover-deco--sun::before {
  width: 3px;
  height: clamp(10px, 3vmin, 16px);
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  box-shadow:
    0 calc(100% + 24px) 0 #ffe566,
    calc(-50% - 6px) calc(50% + 6px) 0 #ffe566,
    calc(50% + 6px) calc(50% + 6px) 0 #ffe566;
}

.cover-deco--sun::after {
  width: clamp(10px, 3vmin, 16px);
  height: 3px;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  box-shadow:
    calc(100% + 24px) 0 0 #ffe566,
    calc(50% + 6px) calc(-50% - 6px) 0 #ffe566,
    calc(50% + 6px) calc(50% + 6px) 0 #ffe566;
}

@keyframes cover-sun-pulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.04); filter: brightness(1.08); }
}

.cover-star {
  position: absolute;
  width: 3px;
  height: 3px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 1px 1px 0 rgba(255, 255, 255, 0.4);
  animation: cover-star-twinkle 2.8s ease-in-out infinite;
}

.cover-star--1 { top: 12%; right: 28%; animation-delay: 0s; }
.cover-star--2 { top: 10%; left: 12%; animation-delay: -0.9s; }
.cover-star--3 { top: 22%; right: 8%; animation-delay: -1.6s; }
.cover-star--4 { top: 18%; left: 82%; animation-delay: -2.2s; }
.cover-star--5 { top: 26%; left: 18%; animation-delay: -1.1s; width: 2px; height: 2px; }

@keyframes cover-star-twinkle {
  0%, 100% { opacity: 0.35; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.3); }
}

.cover-deco--hills {
  left: 0;
  right: 0;
  pointer-events: none;
}

.cover-deco--hills-far {
  bottom: 14%;
  height: 22%;
  background: linear-gradient(180deg, transparent 0%, rgba(100, 180, 130, 0.45) 50%, rgba(82, 158, 112, 0.55) 100%);
  clip-path: polygon(
    0% 100%, 0% 65%, 6% 50%, 14% 62%, 22% 44%, 30% 58%, 38% 40%,
    48% 54%, 58% 38%, 68% 52%, 78% 36%, 88% 50%, 96% 42%, 100% 55%, 100% 100%
  );
  opacity: 0.7;
}

.cover-deco--hills-near {
  bottom: 0;
  height: 18%;
  background: linear-gradient(180deg, transparent 0%, rgba(58, 130, 82, 0.55) 40%, rgba(42, 108, 68, 0.72) 100%);
  clip-path: polygon(
    0% 100%, 0% 55%, 10% 38%, 20% 52%, 32% 32%, 44% 48%, 56% 28%,
    68% 44%, 80% 30%, 90% 46%, 100% 34%, 100% 100%
  );
  opacity: 0.85;
}

.cover-deco--ground {
  bottom: 0;
  left: 0;
  right: 0;
  height: clamp(6px, 1.8vmin, 12px);
  background: repeating-linear-gradient(
    90deg,
    #3d9a5c 0,
    #3d9a5c 4px,
    #46a866 4px,
    #46a866 8px,
    #358f52 8px,
    #358f52 12px
  );
  border-top: 2px solid #2a7040;
  opacity: 0.9;
}

.cover-deco-glyph {
  position: absolute;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(14px, 4vmin, 22px);
  color: rgba(255, 255, 255, 0.35);
  text-shadow: 2px 2px 0 rgba(42, 106, 74, 0.4);
  animation: cover-glyph-float 5s ease-in-out infinite;
  pointer-events: none;
}

.cover-deco-glyph--1 { top: 42%; left: 6%; animation-delay: -1s; }
.cover-deco-glyph--2 { top: 52%; right: 7%; animation-delay: -2.5s; font-size: clamp(12px, 3.5vmin, 18px); }
.cover-deco-glyph--3 { bottom: 18%; right: 14%; animation-delay: -0.5s; opacity: 0.5; }

@keyframes cover-glyph-float {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-8px) rotate(4deg); }
}

@keyframes cover-cloud-drift {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(14px); }
}

.cover-header {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  gap: clamp(8px, 2vmin, 16px);
  position: relative;
  z-index: 2;
}

.cover-title {
  font-size: clamp(40px, 12.5vmin, 88px);
  color: #fff;
  text-shadow:
    5px 5px 0 #2a6a8a,
    3px 3px 0 #1a4a6a,
    -1px -1px 0 #2a6a8a,
    0 0 24px rgba(168, 228, 255, 0.45);
  line-height: 1.35;
  letter-spacing: 0.02em;
}

.cover-subtitle {
  margin-top: 0;
  font-size: clamp(14px, 4vmin, 26px);
  color: #e8f8ff;
  text-shadow: 2px 2px 0 #2a6a8a;
  letter-spacing: 0.06em;
}

.cover-hero-main {
  grid-area: hero;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  position: relative;
  padding: clamp(16px, 5vmin, 48px) 0 clamp(8px, 2vmin, 20px);
  margin-top: clamp(4px, 1.5vmin, 12px);
}

.cover-hero-note {
  position: absolute;
  opacity: 0.92;
  font-size: clamp(18px, 5.5vmin, 26px);
  color: #fff;
  text-shadow: 2px 2px 0 rgba(26, 74, 106, 0.45);
  filter: drop-shadow(2px 2px 0 rgba(26, 74, 106, 0.35));
  animation: cover-note-float 3.5s ease-in-out infinite;
  pointer-events: none;
}

.cover-hero-note--a {
  top: 8%;
  right: 12%;
  animation-delay: -0.8s;
}

.cover-hero-note--b {
  top: 22%;
  left: 10%;
  animation-delay: -2s;
}

.cover-hero-note .cover-hero-icon {
  width: clamp(28px, 9vw, 36px);
  height: clamp(28px, 9vw, 36px);
}

.cover-hero-note .cover-hero-icon .pixel-icon {
  width: clamp(22px, 7vw, 28px);
  height: clamp(22px, 7vw, 28px);
  max-width: clamp(22px, 7vw, 28px);
  max-height: clamp(22px, 7vw, 28px);
}

@keyframes cover-note-float {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-6px) rotate(4deg); }
}

.cover-hero-bridge-scene {
  position: relative;
  width: min(92%, 560px);
  height: clamp(72px, 28vmin, 140px);
  flex-shrink: 0;
}

.cover-hero-bridge {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(3px, 1vw, 6px);
  height: clamp(28px, 7vw, 36px);
}

.cover-bridge-cell {
  display: block;
  height: 100%;
  border: 2px solid rgba(0, 0, 0, 0.18);
  box-shadow:
    inset 0 -4px 0 rgba(0, 0, 0, 0.1),
    2px 2px 0 rgba(0, 0, 0, 0.08);
}

.cover-bridge-cell--0 { background: #ab47bc; }
.cover-bridge-cell--1 { background: #4285f4; }
.cover-bridge-cell--2 { background: #66bb6a; }
.cover-bridge-cell--3 { background: #ffa726; }

.cover-hero-character {
  position: absolute;
  left: 0;
  bottom: clamp(28px, 7vw, 36px);
  width: clamp(52px, 14vw, 72px);
  height: clamp(58px, 16vw, 78px);
  transform-origin: bottom center;
  animation: cover-hero-bob 2.4s ease-in-out infinite;
  filter: drop-shadow(3px 3px 0 rgba(26, 74, 106, 0.25));
}

.cover-hero-character.character--default {
  --person-unit: clamp(4px, 1.1vw, 6px);
}

@keyframes cover-hero-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* Pixel person on bridge cover */
.cover-hero-character.character--default {
  --person-border: max(1px, calc(var(--person-unit) * 1));
}

.cover-hero-character.character--default::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 40%;
  height: 28%;
  transform: translateX(-50%);
  background: #ffccbc;
  border: var(--person-border) solid #d4956a;
  box-shadow:
    calc(var(--person-unit) * 0.9) calc(var(--person-unit) * 1.1) 0 0 #4e342e,
    calc(var(--person-unit) * 2.4) calc(var(--person-unit) * 1.1) 0 0 #4e342e;
  box-sizing: border-box;
}

.cover-hero-character.character--default::after {
  content: '';
  position: absolute;
  top: 26%;
  left: 50%;
  width: 48%;
  height: 30%;
  transform: translateX(-50%);
  background: #e53935;
  border: var(--person-border) solid #b71c1c;
  box-sizing: border-box;
  box-shadow:
    calc(var(--person-unit) * -1.15) 100% 0 calc(var(--person-unit) * -0.15) #1565c0,
    calc(var(--person-unit) * 1.15) 100% 0 calc(var(--person-unit) * -0.15) #1565c0;
}

.cover-hero-character.character--slime .slime-sprite {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 118%;
  height: auto;
  transform: translateX(-50%);
  overflow: visible;
  pointer-events: none;
}

.cover-footer {
  flex-shrink: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding-bottom: clamp(8px, 2.5vmin, 20px);
}

.cover-hint {
  text-align: center;
  font-size: clamp(8px, 2.4vmin, 12px);
  line-height: 1.7;
  color: #1a4a6a;
  text-shadow: none;
  width: min(100%, 520px);
  margin: 0;
}

.cover-start-button {
  font-family: inherit;
  font-size: clamp(14px, 4.1vmin, 22px);
  color: #fff;
  background: #43a047;
  border: 4px solid #1b5e20;
  box-shadow: 6px 6px 0 #0d3d12;
  padding: clamp(12px, 2.8vmin, 18px) clamp(24px, 6vmin, 40px);
  width: auto;
  min-width: clamp(180px, 44vw, 300px);
  max-width: min(100%, 360px);
  min-height: clamp(48px, 11vmin, 68px);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s, box-shadow 0.08s, filter 0.12s;
  letter-spacing: 0.04em;
}

.cover-start-button:hover:not(:disabled) {
  filter: brightness(1.06);
}

.cover-start-button:active:not(:disabled) {
  transform: translate(4px, 4px);
  box-shadow: 2px 2px 0 #0d3d12;
}

.game-container {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  min-height: 0;
  padding:
    max(6px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(var(--game-bottom-inset), env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  box-sizing: border-box;
  overflow: hidden;
}

.game-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr var(--control-rail-width);
  gap: clamp(10px, 2vw, 18px);
  align-items: stretch;
}

.game-stage {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: stretch;
}

.game-controls {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: clamp(6px, 1.4vmin, 12px);
  padding:
    clamp(8px, 1.8vmin, 12px)
    clamp(8px, 1.8vmin, 12px)
    clamp(10px, 2vmin, 14px);
  background: rgba(42, 74, 106, 0.58);
  border: 3px solid #1a2a3a;
  box-shadow: 3px 3px 0 rgba(13, 26, 38, 0.35);
  box-sizing: border-box;
  overflow: hidden;
}

.game-controls .game-controls-footer {
  width: 100%;
  margin-top: auto;
  margin-bottom: 2px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(4px, 1vmin, 6px);
}

.game-controls-footer .game-back-button {
  width: 100%;
  margin-top: 0;
  margin-bottom: 0;
}

.game-pref-dock {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  gap: clamp(6px, 1.5vmin, 10px);
  flex-shrink: 0;
  width: 100%;
  margin-top: clamp(4px, 1vmin, 8px);
  padding: 0;
}

.game-pref-open-btn {
  width: clamp(48px, 14vmin, 72px);
  height: clamp(48px, 14vmin, 72px);
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px;
  font-family: inherit;
  font-size: clamp(6px, 1.8vmin, 9px);
  line-height: 1.3;
  color: #fff;
  background: #5d7a9a;
  border: 3px solid #2a4a6a;
  box-shadow: 4px 4px 0 #1a3a5a;
  cursor: pointer;
  touch-action: manipulation;
  flex-shrink: 0;
  box-sizing: border-box;
}

.game-pref-open-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #1a3a5a;
}

.game-pref-open-btn__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(20px, 6vmin, 28px);
  height: clamp(20px, 6vmin, 28px);
}

.game-pref-open-btn__icon .tap-sound-icon,
.game-pref-open-btn__icon .character-icon {
  width: 100%;
  height: 100%;
}

.game-pref-open-btn__label {
  text-shadow: 1px 1px 0 #1a3a5a;
}

.tap-sound-picker {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: clamp(6px, 1.5vmin, 12px);
  background: rgba(26, 74, 106, 0.92);
  box-sizing: border-box;
}

.tap-sound-picker[hidden] {
  display: none !important;
}

.tap-sound-picker__panel {
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: clamp(8px, 2vmin, 16px);
  background: rgba(42, 74, 106, 0.95);
  border: 3px solid #1a2a3a;
  box-shadow: 6px 6px 0 rgba(13, 26, 38, 0.4);
  box-sizing: border-box;
}

.tap-sound-picker__title {
  font-size: clamp(10px, 2.8vmin, 14px);
  color: #fff;
  text-align: center;
  text-shadow: 2px 2px 0 #2a6a8a;
  margin-bottom: clamp(6px, 1.4vmin, 10px);
  line-height: 1.5;
  flex-shrink: 0;
}

.tap-sound-picker__list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: clamp(6px, 1.5vmin, 10px);
  container-type: size;
  align-items: center;
  justify-items: center;
}

.tap-sound-picker__option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(3px, 0.8vmin, 6px);
  aspect-ratio: 1;
  width: min(31cqw, 47cqh);
  height: auto;
  max-width: 100%;
  max-height: 100%;
  padding: clamp(4px, 1vmin, 8px);
  font-family: inherit;
  font-size: clamp(6px, 1.8vmin, 10px);
  line-height: 1.3;
  color: #e8f8ff;
  text-align: center;
  background: rgba(125, 211, 243, 0.1);
  border: 3px solid #2a4a6a;
  box-shadow: 3px 3px 0 rgba(13, 26, 38, 0.3);
  cursor: pointer;
  touch-action: manipulation;
  box-sizing: border-box;
}

.tap-sound-picker__option:active {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 rgba(13, 26, 38, 0.3);
}

.tap-sound-picker__option.is-selected {
  border-color: #ffe566;
  background: rgba(255, 229, 102, 0.18);
  color: #fff;
}

.tap-sound-picker__option-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(20px, 5.5vmin, 36px);
  height: clamp(20px, 5.5vmin, 36px);
  flex-shrink: 0;
}

.tap-sound-picker__option-icon .tap-sound-icon {
  width: 100%;
  height: 100%;
}

.tap-sound-picker__actions {
  display: flex;
  gap: clamp(8px, 1.8vmin, 12px);
  margin-top: clamp(6px, 1.4vmin, 10px);
  flex-shrink: 0;
}

.tap-sound-picker__cancel,
.tap-sound-picker__confirm {
  flex: 1;
  min-height: clamp(32px, 8vmin, 44px);
  font-size: clamp(8px, 2.2vmin, 11px);
}

.tap-sound-picker__confirm {
  background: #43a047;
  border-color: #1b5e20;
  box-shadow: 3px 3px 0 #0d3d12;
}

.tap-sound-picker__confirm:active:not(:disabled) {
  box-shadow: 1px 1px 0 #0d3d12;
}

.character-picker {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: clamp(6px, 1.5vmin, 12px);
  background: rgba(26, 74, 106, 0.92);
  box-sizing: border-box;
}

.character-picker[hidden] {
  display: none !important;
}

.character-picker__panel {
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: clamp(8px, 2vmin, 16px);
  background: rgba(42, 74, 106, 0.95);
  border: 3px solid #1a2a3a;
  box-shadow: 6px 6px 0 rgba(13, 26, 38, 0.4);
  box-sizing: border-box;
}

.character-picker__title {
  font-size: clamp(10px, 2.8vmin, 14px);
  color: #fff;
  text-align: center;
  text-shadow: 2px 2px 0 #2a6a8a;
  margin-bottom: clamp(6px, 1.4vmin, 10px);
  line-height: 1.5;
  flex-shrink: 0;
}

.character-picker__list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(clamp(48px, 11vmin, 68px), auto);
  gap: clamp(5px, 1.2vmin, 8px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  align-items: center;
  justify-items: center;
}

.character-picker__option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(2px, 0.6vmin, 4px);
  width: 100%;
  max-width: clamp(52px, 14vmin, 76px);
  min-height: clamp(48px, 11vmin, 68px);
  padding: clamp(3px, 0.8vmin, 6px);
  font-family: inherit;
  font-size: clamp(6px, 1.8vmin, 10px);
  line-height: 1.3;
  color: #e8f8ff;
  text-align: center;
  background: rgba(125, 211, 243, 0.1);
  border: 3px solid #2a4a6a;
  box-shadow: 3px 3px 0 rgba(13, 26, 38, 0.3);
  cursor: pointer;
  touch-action: manipulation;
  box-sizing: border-box;
}

.character-picker__option:active {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 rgba(13, 26, 38, 0.3);
}

.character-picker__option.is-selected {
  border-color: #ffe566;
  background: rgba(255, 229, 102, 0.18);
  color: #fff;
}

.character-picker__option-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(36px, 9vmin, 52px);
  height: clamp(26px, 6.5vmin, 38px);
  flex-shrink: 0;
}

.character-picker__option-icon .character-icon {
  width: 100%;
  height: 100%;
  display: block;
}

.character-picker__actions {
  display: flex;
  gap: clamp(8px, 1.8vmin, 12px);
  margin-top: clamp(6px, 1.4vmin, 10px);
  flex-shrink: 0;
}

.character-picker__cancel,
.character-picker__confirm {
  flex: 1;
  min-height: clamp(32px, 8vmin, 44px);
  font-size: clamp(8px, 2.2vmin, 11px);
}

.character-picker__confirm {
  background: #43a047;
  border-color: #1b5e20;
  box-shadow: 3px 3px 0 #0d3d12;
}

.character-picker__confirm:active:not(:disabled) {
  box-shadow: 1px 1px 0 #0d3d12;
}

.game-settings-picker {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: clamp(6px, 1.5vmin, 12px);
  background: rgba(26, 74, 106, 0.92);
  box-sizing: border-box;
}

.game-settings-picker[hidden] {
  display: none !important;
}

.game-settings-picker__panel {
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: clamp(10px, 2.5vmin, 18px);
  padding: clamp(12px, 3vmin, 24px);
  background: rgba(42, 74, 106, 0.95);
  border: 3px solid #1a2a3a;
  box-shadow: 6px 6px 0 rgba(13, 26, 38, 0.4);
  box-sizing: border-box;
}

.game-settings-picker__title {
  font-size: clamp(10px, 2.8vmin, 14px);
  color: #fff;
  text-align: center;
  text-shadow: 2px 2px 0 #2a6a8a;
  line-height: 1.5;
  flex-shrink: 0;
  margin: 0;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: clamp(8px, 2vmin, 14px);
  width: 100%;
  padding: clamp(10px, 2.5vmin, 16px);
  background: rgba(125, 211, 243, 0.08);
  border: 3px solid #2a4a6a;
  box-shadow: 3px 3px 0 rgba(13, 26, 38, 0.3);
  box-sizing: border-box;
}

.volume-control__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: clamp(22px, 6vmin, 32px);
  height: clamp(22px, 6vmin, 32px);
}

.volume-control__icon .volume-icon {
  width: 100%;
  height: 100%;
}

.volume-control__slider {
  flex: 1;
  min-width: 0;
  height: clamp(10px, 2.5vmin, 14px);
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  background: #1a2a3a;
  border: 2px solid #2a4a6a;
  border-radius: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.volume-control__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: clamp(14px, 4vmin, 20px);
  height: clamp(18px, 5vmin, 26px);
  background: #ffe566;
  border: 2px solid #c9a000;
  box-shadow: 2px 2px 0 rgba(13, 26, 38, 0.4);
  cursor: pointer;
}

.volume-control__slider::-moz-range-thumb {
  width: clamp(14px, 4vmin, 20px);
  height: clamp(18px, 5vmin, 26px);
  background: #ffe566;
  border: 2px solid #c9a000;
  box-shadow: 2px 2px 0 rgba(13, 26, 38, 0.4);
  border-radius: 0;
  cursor: pointer;
}

.volume-control__slider::-moz-range-track {
  height: clamp(10px, 2.5vmin, 14px);
  background: #1a2a3a;
  border: 2px solid #2a4a6a;
}

.volume-control__value {
  margin: 0;
  text-align: center;
  font-size: clamp(8px, 2.2vmin, 11px);
  color: #e8f8ff;
  text-shadow: 1px 1px 0 #1a3a5a;
}

.game-settings-picker__actions {
  display: flex;
  flex-shrink: 0;
}

.game-settings-picker__confirm {
  flex: 1;
  min-height: clamp(32px, 8vmin, 44px);
  font-size: clamp(8px, 2.2vmin, 11px);
  background: #43a047;
  border-color: #1b5e20;
  box-shadow: 3px 3px 0 #0d3d12;
}

.game-settings-picker__confirm:active:not(:disabled) {
  box-shadow: 1px 1px 0 #0d3d12;
}

.game-playfield {
  --game-scale: 1.5;
  --bridge-cell-size: calc(28px * var(--game-scale, 1));
  --bridge-width: 100%;
  --bridge-intro-pad: calc(28px * var(--game-scale, 1));
  --bridge-origin-x: var(--bridge-intro-pad);
  --playfield-inset-x: 4px;
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: clamp(8px, 1.8vmin, 16px);
  min-height: 0;
  padding: clamp(2px, 0.8vmin, 8px) 0 clamp(8px, 1.8vmin, 14px);
}

/* In-game rhythm HUD — centered above rhythm bar */
.game-rhythm-header {
  flex-shrink: 0;
  text-align: center;
  width: 100%;
  padding: 0 0 clamp(2px, 0.6vmin, 6px);
}

.game-level-tag {
  font-size: clamp(12px, 3.6vmin, 22px);
  color: #fff;
  text-shadow: 2px 2px 0 #2a6a8a;
  letter-spacing: 0.04em;
  line-height: 1.6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-level-meta {
  margin-top: 4px;
  font-size: clamp(8px, 2.5vmin, 14px);
  color: #e8f8ff;
  text-shadow: 1px 1px 0 #2a6a8a;
  opacity: 0.85;
}

/* Rhythm bar — minimal HUD strip (no outer panel) */
.rhythm-zone {
  flex: 0 0 auto;
  min-height: 0;
  width: 100%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: clamp(2px, 0.6vmin, 6px);
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0 var(--playfield-inset-x, 8px);
  box-sizing: border-box;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.zone-label {
  display: none;
}

/* Playfield tap feedback — between rhythm bar and bridge */
.playfield-feedback {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: clamp(48px, 12vmin, 120px);
  padding: clamp(6px, 1.5vmin, 14px) var(--playfield-inset-x, 8px);
  pointer-events: none;
  box-sizing: border-box;
}

.playfield-feedback__bubble {
  margin: 0;
  max-width: min(94%, 440px);
  padding: clamp(12px, 2.8vmin, 18px) clamp(16px, 3.6vmin, 24px);
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(11px, 3.4vmin, 20px);
  line-height: 1.7;
  text-align: center;
  color: #5a4030;
  background: rgba(255, 246, 232, 0.96);
  border: 3px solid #c9a06c;
  border-radius: 18px;
  box-shadow: 4px 4px 0 rgba(42, 74, 106, 0.28);
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.45);
}

.playfield-feedback__bubble.is-pop {
  animation: playfield-feedback-pop 0.32s ease-out;
}

.playfield-feedback__bubble.success {
  color: #2e7d32;
  border-color: #81c784;
  background: rgba(232, 245, 233, 0.97);
}

.playfield-feedback__bubble.encourage {
  color: #33691e;
  border-color: #aed581;
  background: rgba(241, 248, 233, 0.97);
}

.playfield-feedback__bubble.near {
  color: #e65100;
  border-color: #ffcc80;
  background: rgba(255, 248, 225, 0.97);
}

.playfield-feedback__bubble.error {
  color: #c62828;
  border-color: #ef9a9a;
  background: rgba(255, 235, 238, 0.97);
}

@keyframes playfield-feedback-pop {
  0% {
    transform: scale(0.86);
    opacity: 0;
  }
  70% {
    transform: scale(1.04);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.rhythm-bar-meta {
  display: none;
}

.rhythm-bar {
  position: relative;
  width: 100%;
  background: rgba(42, 74, 106, 0.88);
  border: 3px solid #1a2a3a;
  box-shadow: 3px 3px 0 rgba(13, 26, 38, 0.35);
  --rhythm-icon-top-pad: calc(8px * var(--game-scale, 1));
  --rhythm-notation-bottom: 0px;
  height: auto;
  min-height: 48px;
  aspect-ratio: 400 / 44;
  --rhythm-icon-vp-w: clamp(24px, 6vmin, 40px);
  --rhythm-icon-vp-h: clamp(24px, 6vmin, 40px);
  --rhythm-icon-anchor-bottom: 0px;
}

.beat-grid {
  display: grid;
  grid-template-columns: repeat(var(--beat-columns, 16), 1fr);
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.beat-cell {
  border-right: 1px solid rgba(168, 216, 240, 0.1);
}

.beat-cell--beat-end {
  border-right: 1px solid rgba(168, 216, 240, 0.38);
}

.beat-cell--sub:nth-child(4n + 1) {
  background: rgba(255, 255, 255, 0.035);
}

.beat-cell:last-child {
  border-right: none;
}

.rhythm-segments {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.rhythm-notation-host {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.rhythm-notation {
  position: absolute;
  inset: 0;
}

.rhythm-notation-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  height: auto;
  box-sizing: border-box;
  overflow: visible;
}

.rhythm-notation-bar .notation-svg {
  width: 100%;
  display: block;
  overflow: visible;
}

.rhythm-notation-bar .notation-svg--bar {
  height: auto;
  max-height: none;
}

.rhythm-notation--tiny {
  position: relative;
  inset: auto;
  display: flex;
  align-items: flex-end;
  height: 22px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.rhythm-notation--tiny .rhythm-notation-bar {
  position: relative;
  inset: auto;
  top: auto;
  bottom: auto;
  height: 22px;
  width: 100%;
}

.rhythm-grid-debug {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  overflow: hidden;
}

.rhythm-grid-debug__cell {
  position: absolute;
  top: 0;
  bottom: 0;
  box-sizing: border-box;
  border-left: 1px solid rgba(255, 80, 80, 0.55);
  border-right: 1px solid rgba(255, 80, 80, 0.2);
}

.rhythm-grid-debug__center {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0;
  border-left: 1px dashed rgba(255, 200, 80, 0.7);
}

.rhythm-grid-debug__index {
  position: absolute;
  bottom: 0;
  left: 2px;
  font-size: 11px;
  line-height: 1;
  color: rgba(255, 120, 120, 0.95);
  font-family: monospace;
}

.rhythm-grid-debug__token {
  position: absolute;
  top: 0;
  height: 12px;
  box-sizing: border-box;
  border: 1px solid rgba(80, 220, 255, 0.9);
  background: rgba(80, 220, 255, 0.12);
  font-size: 10px;
  line-height: 12px;
  color: rgba(180, 240, 255, 0.95);
  font-family: monospace;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
}

.notation-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
  --notation-fill: #f0f0f0;
  --notation-stem: #f0f0f0;
  --notation-beam: #f0f0f0;
}

.notation-smufl {
  fill: var(--notation-fill);
  stroke: none;
}

.notation-notehead {
  fill: var(--notation-fill);
}

.notation-notehead--hollow {
  fill: none;
  stroke: var(--notation-fill);
  stroke-width: 1.2;
}

.notation-stem {
  stroke: var(--notation-stem);
  stroke-width: 1.4;
  fill: none;
}

.notation-beam,
.notation-rest {
  fill: var(--notation-stem);
  stroke: none;
}

.notation-beam {
  fill: var(--notation-beam);
}

.notation-dot {
  fill: var(--notation-fill);
}

.notation-seg.active {
  filter: drop-shadow(0 0 3px rgba(168, 216, 240, 0.85));
}

.notation-seg.notation-seg--rest-active.active {
  filter: drop-shadow(0 0 3px rgba(176, 190, 197, 0.85));
}

.rhythm-segment {
  position: absolute;
  top: 0;
  height: 100%;
  box-sizing: border-box;
  padding: 0;
  min-width: 0;
  overflow: visible;
  transition: background 0.12s, box-shadow 0.12s;
}

.rhythm-segment--note {
  background: rgba(74, 122, 154, 0.12);
}

.rhythm-segment--rest {
  background: rgba(58, 90, 122, 0.16);
}

.rhythm-symbol {
  display: flex;
  align-items: center;
  justify-content: center;
  --icon-fill: #f0f0f0;
  transition: filter 0.12s, transform 0.1s;
}

.rhythm-symbol--bar {
  position: absolute;
  bottom: var(--rhythm-icon-anchor-bottom, 8px);
  width: clamp(28px, 5vh, 44px);
  height: clamp(28px, 5vh, 44px);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  transform: none;
  margin: 0;
}

.rhythm-symbol--bar .pixel-icon {
  width: clamp(22px, 4vh, 36px);
  height: clamp(22px, 4vh, 36px);
  max-width: clamp(22px, 4vh, 36px);
  max-height: clamp(22px, 4vh, 36px);
  flex: 0 0 auto;
  display: block;
  margin: 0;
}

.rhythm-symbol--tiny {
  position: static;
  width: 14px;
  height: 18px;
}

.pixel-icon {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.pixel-icon .pixel-block {
  fill: var(--icon-fill);
}

/* Piskel sprite swap:
.rhythm-symbol.use-sprite .pixel-icon--svg { display: none; }
.rhythm-symbol.use-sprite .pixel-icon--sprite { display: block; }
.pixel-icon--sprite { display: none; width: 100%; height: 100%; }
*/

.rhythm-segment--note.active {
  background: rgba(168, 216, 240, 0.28);
  box-shadow: inset 0 0 8px rgba(200, 230, 255, 0.45);
  z-index: 2;
}

.rhythm-segment--rest.active {
  background: rgba(144, 164, 174, 0.35);
  box-shadow: inset 0 0 8px rgba(176, 190, 197, 0.4);
  z-index: 2;
}

.rhythm-segment.hit {
  background: rgba(76, 175, 80, 0.55);
  box-shadow: inset 0 0 8px rgba(129, 199, 132, 0.65), 0 0 6px rgba(76, 175, 80, 0.35);
  z-index: 2;
}

.rhythm-segment.miss {
  background: rgba(198, 40, 40, 0.42);
  box-shadow: inset 0 0 8px rgba(229, 115, 115, 0.55);
  z-index: 2;
}

@keyframes symbol-hit {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Bridge zone */
.bridge-zone {
  width: 100%;
  flex: 0 0 auto;
  min-height: calc(var(--bridge-cell-size, 28px) * 2.3);
  margin-top: auto;
  margin-bottom: clamp(4px, 1vmin, 8px);
  padding: 0 var(--playfield-inset-x, 4px);
  box-sizing: border-box;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  overflow: visible;
}

.bridge-scene {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: calc(var(--bridge-cell-size, 28px) * 2.3);
  min-height: calc(var(--bridge-cell-size, 28px) * 2.3);
  overflow: visible;
}

.bridge {
  position: absolute;
  left: var(--bridge-origin-x);
  bottom: 0;
  display: block;
  width: var(--bridge-width);
  max-width: 100%;
  height: var(--bridge-cell-size);
  z-index: 1;
}

.bridge-beat-zones {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 0;
  pointer-events: none;
}

.bridge-beat-zone.beat-part-0 {
  background: rgba(66, 133, 244, 0.14);
}

.bridge-beat-zone.beat-part-1 {
  background: rgba(102, 187, 106, 0.14);
}

.bridge-beat-zone.beat-part-2 {
  background: rgba(255, 167, 38, 0.16);
}

.bridge-beat-zone.beat-part-3 {
  background: rgba(171, 71, 188, 0.14);
}

.bridge-cells {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.bridge-cell {
  position: absolute;
  top: 0;
  min-width: 3px;
  display: block;
  box-sizing: border-box;
  transition: box-shadow 0.2s, opacity 0.2s;
}

.bridge-cell--note.beat-part-0 {
  background: #5c6bc0;
  border: 2px solid #3949ab;
  box-shadow:
    2px 2px 0 #1a237e,
    inset 0 -3px 0 #3f51b5;
}

.bridge-cell--note.beat-part-1 {
  background: #66bb6a;
  border: 2px solid #2e7d32;
  box-shadow:
    2px 2px 0 #1b5e20,
    inset 0 -3px 0 #43a047;
}

.bridge-cell--note.beat-part-2 {
  background: #ffa726;
  border: 2px solid #e65100;
  box-shadow:
    2px 2px 0 #bf360c,
    inset 0 -3px 0 #fb8c00;
}

.bridge-cell--note.beat-part-3 {
  background: #ab47bc;
  border: 2px solid #6a1b9a;
  box-shadow:
    2px 2px 0 #4a148c,
    inset 0 -3px 0 #8e24aa;
}

.bridge-cell--rest {
  background: transparent;
  border: none;
  box-shadow: none;
}

.bridge-ghost {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.85;
  box-sizing: border-box;
}

.bridge-cell--rest.beat-part-0 .bridge-ghost {
  background: repeating-linear-gradient(
    90deg,
    rgba(92, 107, 192, 0.35) 0,
    rgba(92, 107, 192, 0.35) 4px,
    transparent 4px,
    transparent 8px
  );
  border: 2px dashed rgba(92, 107, 192, 0.75);
  box-shadow: inset 0 0 0 1px rgba(121, 134, 203, 0.4);
}

.bridge-cell--rest.beat-part-1 .bridge-ghost {
  background: repeating-linear-gradient(
    90deg,
    rgba(102, 187, 106, 0.35) 0,
    rgba(102, 187, 106, 0.35) 4px,
    transparent 4px,
    transparent 8px
  );
  border: 2px dashed rgba(67, 160, 71, 0.75);
  box-shadow: inset 0 0 0 1px rgba(129, 199, 132, 0.4);
}

.bridge-cell--rest.beat-part-2 .bridge-ghost {
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 167, 38, 0.35) 0,
    rgba(255, 167, 38, 0.35) 4px,
    transparent 4px,
    transparent 8px
  );
  border: 2px dashed rgba(251, 140, 0, 0.75);
  box-shadow: inset 0 0 0 1px rgba(255, 183, 77, 0.4);
}

.bridge-cell--rest.beat-part-3 .bridge-ghost {
  background: repeating-linear-gradient(
    90deg,
    rgba(171, 71, 188, 0.35) 0,
    rgba(171, 71, 188, 0.35) 4px,
    transparent 4px,
    transparent 8px
  );
  border: 2px dashed rgba(142, 36, 170, 0.75);
  box-shadow: inset 0 0 0 1px rgba(186, 104, 200, 0.4);
}

.bridge-cell--note.active-segment {
  z-index: 2;
  box-shadow:
    2px 2px 0 rgba(0, 0, 0, 0.25),
    0 0 10px #ffd54f,
    0 0 16px #ffe082,
    inset 0 0 0 2px #ffd54f;
}

.bridge-cell--note.hit {
  box-shadow:
    2px 2px 0 rgba(0, 0, 0, 0.25),
    0 0 8px #81c784,
    inset 0 0 0 2px #66bb6a;
}

.bridge-cell--note.miss {
  opacity: 0.45;
  filter: grayscale(0.35);
  box-shadow:
    2px 2px 0 rgba(0, 0, 0, 0.2),
    inset 0 0 0 2px rgba(198, 40, 40, 0.55);
}

.bridge-cell--note.lit {
  background: #ffd54f;
  border-color: #f9a825;
  box-shadow:
    2px 2px 0 #1a0f00,
    0 0 14px #ffe082,
    0 0 22px #ffca28;
  animation: plank-glow 0.35s ease;
}

.bridge-cell.active-segment.bridge-cell--rest .bridge-ghost {
  border-color: #ffd54f;
  box-shadow:
    0 0 8px #ffe082,
    inset 0 0 0 1px #ffd54f;
}

@keyframes plank-glow {
  0% { transform: scaleY(1); }
  50% { transform: scaleY(1.25); }
  100% { transform: scaleY(1); }
}

.character.character--sprite {
  width: auto;
  height: auto;
  min-width: calc(var(--bridge-cell-size, 22px) * 1.4);
  min-height: calc(var(--bridge-cell-size, 22px) * 1.6);
}

.character.character--sprite::before,
.character.character--sprite::after {
  display: none !important;
}

.bridge-character-sprite {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  pointer-events: none;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.35));
}

.character {
  position: absolute;
  left: 0;
  bottom: var(--bridge-cell-size);
  width: var(--bridge-cell-size, 22px);
  height: calc(var(--bridge-cell-size, 22px) * 1.29);
  z-index: 2;
  transform-origin: bottom center;
  will-change: left, transform;
  transition: none;
}

.character::before,
.character::after {
  content: '';
  position: absolute;
  box-sizing: border-box;
}

.character.character--default::before {
  --person-unit: calc(var(--bridge-cell-size, 22px) * 0.14);
  top: 0;
  left: 50%;
  width: 40%;
  height: 28%;
  transform: translateX(-50%);
  background: #ffccbc;
  border: max(1px, calc(var(--bridge-cell-size, 22px) * 0.06)) solid #d4956a;
  box-shadow:
    calc(var(--bridge-cell-size, 22px) * 0.12) calc(var(--bridge-cell-size, 22px) * 0.14) 0 0 #4e342e,
    calc(var(--bridge-cell-size, 22px) * 0.26) calc(var(--bridge-cell-size, 22px) * 0.14) 0 0 #4e342e;
}

.character.character--default::after {
  top: 26%;
  left: 50%;
  width: 48%;
  height: 30%;
  transform: translateX(-50%);
  background: #e53935;
  border: max(1px, calc(var(--bridge-cell-size, 22px) * 0.06)) solid #b71c1c;
  box-shadow:
    calc(var(--bridge-cell-size, 22px) * -0.16) calc(var(--bridge-cell-size, 22px) * 0.34) 0
      calc(var(--bridge-cell-size, 22px) * -0.02) #1565c0,
    calc(var(--bridge-cell-size, 22px) * 0.16) calc(var(--bridge-cell-size, 22px) * 0.34) 0
      calc(var(--bridge-cell-size, 22px) * -0.02) #1565c0;
}

.character.character--slime {
  transform-origin: bottom center;
}

.character.character--slime::before,
.character.character--slime::after {
  display: none;
}

.character.character--slime .slime-sprite {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 150%;
  height: auto;
  transform: translateX(-50%);
  overflow: visible;
  pointer-events: none;
}

.character.character--ball {
  transform-origin: 50% 50%;
}

.character.character--ball::before {
  top: 8%;
  left: 8%;
  width: 84%;
  height: 84%;
  border-radius: 50%;
  background: #ff9800;
  border: max(1px, calc(var(--bridge-cell-size, 22px) * 0.07)) solid #e65100;
  box-shadow: max(1px, calc(var(--bridge-cell-size, 22px) * 0.07))
    max(1px, calc(var(--bridge-cell-size, 22px) * 0.07)) 0 #bf360c;
}

.character.character--ball::after {
  display: none;
}

.character.character--star::before {
  top: 6%;
  left: 6%;
  width: 88%;
  height: 88%;
  background: #ffeb3b;
  border: max(1px, calc(var(--bridge-cell-size, 22px) * 0.07)) solid #f9a825;
  clip-path: polygon(
    50% 0%,
    61% 35%,
    98% 35%,
    68% 57%,
    79% 91%,
    50% 70%,
    21% 91%,
    32% 57%,
    2% 35%,
    39% 35%
  );
  box-shadow: none;
}

.character.character--star::after {
  display: none;
}

.character.character--pencil::before {
  top: 0;
  left: 30%;
  width: 40%;
  height: 72%;
  background: #ffc107;
  border: max(1px, calc(var(--bridge-cell-size, 22px) * 0.07)) solid #ff8f00;
  box-shadow: max(1px, calc(var(--bridge-cell-size, 22px) * 0.07))
    max(1px, calc(var(--bridge-cell-size, 22px) * 0.07)) 0 #e65100;
}

.character.character--pencil::after {
  bottom: 0;
  left: 30%;
  width: 40%;
  height: 22%;
  background: #ff7043;
  border: max(1px, calc(var(--bridge-cell-size, 22px) * 0.07)) solid #d84315;
  clip-path: polygon(50% 100%, 0% 0%, 100% 0%);
  box-shadow: none;
}

.character.character--exclaim::before {
  content: '!';
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Courier New', Courier, monospace;
  font-weight: 900;
  font-size: calc(var(--bridge-cell-size, 22px) * 0.95);
  line-height: 1;
  color: #ff5722;
  text-shadow: max(1px, calc(var(--bridge-cell-size, 22px) * 0.07))
    max(1px, calc(var(--bridge-cell-size, 22px) * 0.07)) 0 #bf360c;
  background: transparent;
  border: none;
  box-shadow: none;
}

.character.character--exclaim::after {
  display: none;
}

.character.character--question::before {
  content: '?';
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Courier New', Courier, monospace;
  font-weight: 900;
  font-size: calc(var(--bridge-cell-size, 22px) * 0.88);
  line-height: 1;
  color: #9c27b0;
  text-shadow: max(1px, calc(var(--bridge-cell-size, 22px) * 0.07))
    max(1px, calc(var(--bridge-cell-size, 22px) * 0.07)) 0 #6a1b9a;
  background: transparent;
  border: none;
  box-shadow: none;
}

.character.character--question::after {
  display: none;
}

.character.quick-step {
  /* bounce handled via rAF position updates */
}

.character.long-step {
  /* glide handled via rAF position updates */
}

.character.motion-hold {
  filter: brightness(0.92);
}

.character.motion-anticipate {
  filter: brightness(0.95);
}

.character.motion-jump {
  filter: brightness(1.05);
}

.character.motion-land {
  animation: land-squash 0.12s ease;
}

@keyframes land-squash {
  0% { filter: brightness(1.05); }
  50% { filter: brightness(0.9); }
  100% { filter: brightness(1); }
}

/* Message */
.message {
  font-size: clamp(8px, 2.2vmin, 11px);
  text-align: center;
  min-height: 14px;
  line-height: 1.6;
  color: #fff;
  text-shadow: 2px 2px 0 #2a6a8a;
  padding: 0 2px;
  flex-shrink: 0;
}

.message.success {
  color: #c8f7c9;
  text-shadow: 2px 2px 0 #1b5e20;
}

.message.error {
  color: #ffcdd2;
  text-shadow: 2px 2px 0 #b71c1c;
}

.message.encourage {
  color: #e8f5e9;
  text-shadow: 2px 2px 0 #2e7d32;
}

.message.near {
  color: #fff9c4;
  text-shadow: 2px 2px 0 #f57f17;
}

.accuracy-display {
  font-size: clamp(11px, 3.0vmin, 17px);
  text-align: center;
  color: #fff;
  text-shadow: 2px 2px 0 #2a6a8a;
  min-height: clamp(16px, 4.5vmin, 26px);
  line-height: 1.5;
  padding: 0 2px;
  flex-shrink: 0;
}

.accuracy-display.is-layout-hidden {
  visibility: hidden;
}

/* Practice toggle */
.btn-practice-toggle {
  background: #5d7a9a;
  border-color: #2a4a6a;
  box-shadow: 3px 3px 0 #1a3a5a;
  padding: 6px 4px;
  font-size: clamp(8px, 2.8vw, 11px);
  line-height: 1.3;
  overflow: hidden;
}

.practice-toggle-label {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.practice-toggle-arrow {
  font-size: 10px;
  flex-shrink: 0;
  line-height: 1;
}

.btn-practice-toggle.is-open {
  background: #4a6a8a;
  box-shadow:
    3px 3px 0 #1a3a5a,
    inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.btn-practice-toggle:active:not(:disabled) {
  box-shadow: 1px 1px 0 #1a3a5a;
}

.play-panel--behind-levels {
  display: none !important;
}

/* Levels full page */
.levels-panel {
  position: absolute;
  inset: 0;
  top: 0;
  z-index: 50;
  overflow: hidden;
  isolation: isolate;
  background-color: var(--app-sky-fallback);
  background-image: var(--app-sky-bg);
}

.levels-panel[hidden] {
  display: none !important;
}

.levels-bg {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: transparent;
  pointer-events: none;
}

.levels-cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 2px;
  opacity: 0.88;
  box-shadow: 10px 0 0 rgba(255, 255, 255, 0.9);
  animation: cover-cloud-drift 18s ease-in-out infinite;
  pointer-events: none;
}

.levels-cloud--1 {
  width: clamp(20px, 5vmin, 32px);
  height: clamp(11px, 2.8vmin, 16px);
  top: 8%;
  left: 10%;
}

.levels-cloud--2 {
  width: clamp(16px, 4vmin, 26px);
  height: clamp(9px, 2.4vmin, 13px);
  top: 14%;
  right: 12%;
  animation-delay: -6s;
  animation-duration: 22s;
}

.levels-page {
  position: relative;
  z-index: 2;
  min-height: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.2vmin, 10px);
  padding:
    max(6px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  box-sizing: border-box;
  overflow: hidden;
}

.levels-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr var(--control-rail-width);
  gap: clamp(10px, 2vw, 18px);
  align-items: stretch;
  overflow: hidden;
}

.levels-stage {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2vmin, 16px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.levels-controls .practice-bpm-section.levels-bpm-panel {
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  gap: clamp(6px, 1.2vmin, 8px);
}

.levels-controls .practice-bpm-input {
  width: 100%;
  flex: none;
  box-sizing: border-box;
  padding: 6px 8px;
  font-size: clamp(12px, 3.6vw, 17px);
}

.levels-controls .practice-bpm-apply {
  width: 100%;
}

.levels-controls .levels-confirm-button {
  width: 100%;
  padding: clamp(8px, 2vmin, 12px) clamp(10px, 2.5vmin, 16px);
  font-size: clamp(10px, 3vw, 14px);
  background: #43a047;
  border: 4px solid #1b5e20;
  color: #fff;
  box-shadow: 4px 4px 0 rgba(13, 26, 38, 0.35);
}

.levels-controls .levels-confirm-button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 rgba(13, 26, 38, 0.35);
}

.levels-controls .practice-bpm-hint {
  margin: 0;
}

.levels-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Custom practice — landscape drag-and-drop editor */
.custom-practice-page {
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding:
    max(4px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(4px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
}

.custom-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(148px, 24vw, 260px);
  gap: clamp(8px, 1.5vmin, 12px);
  align-items: stretch;
  overflow: hidden;
}

.custom-editor-col {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: flex-start;
  overflow: hidden;
}

.custom-info-dock {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: clamp(4px, 1vmin, 8px);
  margin-bottom: var(--custom-bottom-inset);
  padding: clamp(6px, 1.2vmin, 10px) clamp(8px, 1.4vmin, 12px);
  background: rgba(42, 74, 106, 0.42);
  border: 2px solid rgba(26, 42, 58, 0.55);
  box-shadow: 2px 2px 0 rgba(13, 26, 38, 0.18);
}

.custom-info-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: clamp(5px, 1vmin, 8px);
}

.custom-info-cell {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(6px, 1.4vmin, 14px) clamp(8px, 1.6vmin, 14px);
  background: rgba(20, 36, 52, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.custom-info-cell__label {
  margin: 0 0 clamp(3px, 0.7vmin, 6px);
  font-size: clamp(8px, 1.8vmin, 10px);
  color: #9ec8e8;
  line-height: 1.3;
  letter-spacing: 0.02em;
}

.custom-info-cell__text {
  margin: 0;
  font-size: clamp(8px, 1.8vmin, 11px);
  color: rgba(255, 255, 255, 0.86);
  line-height: 1.4;
}

.custom-info-cell__text + .custom-info-cell__text {
  margin-top: clamp(2px, 0.5vmin, 4px);
}

.custom-info-cell__text--accent {
  color: #ffe082;
}

.custom-info-cell__text--live {
  color: #ffe082;
}

.custom-editor-top {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.custom-strip-zone {
  flex-shrink: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.custom-side-col {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.8vmin, 12px);
  justify-content: space-between;
  overflow: hidden;
}

.custom-page-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.custom-strip-zone {
  flex-shrink: 0;
}

.custom-palette {
  flex: 1;
  min-height: 0;
}

.custom-footer-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 0;
  flex-shrink: 0;
  margin-bottom: var(--custom-bottom-inset);
}

.custom-save-btn {
  width: 100%;
  background: #43a047;
  border: 3px solid #1b5e20;
  box-shadow: 3px 3px 0 #0d3d12;
  color: #fff;
  font-family: inherit;
  font-size: clamp(8px, 2.5vmin, 11px);
  padding: clamp(10px, 2.2vmin, 14px) clamp(12px, 2.8vmin, 16px);
  cursor: pointer;
  touch-action: manipulation;
}

.custom-save-btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #0d3d12;
}

.levels-page-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
}

.levels-page-title {
  font-size: clamp(14px, 4.4vw, 19px);
  color: #fff;
  text-shadow: 2px 2px 0 #2a6a8a;
  line-height: 1.5;
  font-weight: inherit;
}

.levels-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.levels-section__title {
  font-size: clamp(10px, 3.0vw, 12px);
  color: #e8f8ff;
  text-shadow: 1px 1px 0 #2a6a8a;
  line-height: 1.5;
  font-weight: inherit;
}

.levels-empty {
  font-size: clamp(8px, 2.8vw, 11px);
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.6;
  padding: 8px;
  background: rgba(42, 74, 106, 0.35);
  border: 3px dashed rgba(26, 42, 58, 0.5);
}

.custom-page-title {
  font-size: clamp(11px, 3.2vmin, 17px);
  color: #fff;
  text-shadow: 2px 2px 0 #2a6a8a;
  line-height: 1.35;
  font-weight: inherit;
}

.custom-page-hint {
  display: none;
}

.builder-label {
  font-size: clamp(8px, 2.8vw, 11px);
  color: #e8f8ff;
  line-height: 1.4;
}

.builder-name-input {
  width: 100%;
  font-family: inherit;
  font-size: clamp(11px, 3.4vw, 14px);
  color: #1a2a3a;
  background: #e8f4fc;
  border: 3px solid #1a2a3a;
  padding: 8px 10px;
  box-shadow: inset 2px 2px 0 rgba(26, 42, 58, 0.15);
}

.custom-rhythm-bar {
  --custom-strip-height: auto;
  position: relative;
  width: 100%;
  height: auto;
  min-height: 40px;
  aspect-ratio: 400 / 44;
  flex: none;
  background: rgba(42, 74, 106, 0.92);
  border: 3px solid #1a2a3a;
  box-shadow: 3px 3px 0 rgba(13, 26, 38, 0.4);
  overflow: hidden;
}

.custom-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  grid-template-rows: 1fr;
  z-index: 1;
}

.custom-grid-cell {
  border-right: 1px solid rgba(168, 216, 240, 0.12);
  transition: background 0.1s;
  cursor: copy;
  min-width: 0;
  min-height: 0;
}

.custom-grid-cell--beat-end {
  border-right: 1px solid rgba(168, 216, 240, 0.42);
}

.custom-grid-cell--beat-start {
  background: rgba(255, 255, 255, 0.04);
}

.custom-grid-cell--filled {
  background: rgba(255, 255, 255, 0.03);
}

.custom-grid-cell--drop-target {
  background: rgba(102, 187, 106, 0.35);
  box-shadow: inset 0 0 0 2px rgba(129, 199, 132, 0.8);
}

.custom-grid-cell--drop-invalid {
  background: rgba(229, 57, 53, 0.22);
  box-shadow: inset 0 0 0 2px rgba(229, 57, 53, 0.55);
}

.custom-notation-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.custom-beat-notation,
.custom-slot-notation {
  position: absolute;
  inset: 0;
  height: 100%;
}

.custom-notation-layer .rhythm-notation-bar {
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  height: auto;
}

.custom-slot-notation .notation-svg {
  --notation-fill: #f8fafc;
  --notation-stem: #f8fafc;
  --notation-beam: #f8fafc;
}

/* legacy class names */
.custom-beat-notation .custom-notation-beat,
.custom-beat-notation .custom-beat-notation-inner {
  position: absolute;
  top: 0;
  bottom: 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
}

.custom-beat-notation .custom-notation-beat--empty {
  opacity: 0;
  pointer-events: none;
}

.custom-beat-notation .custom-beat-notation-inner {
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
}

.custom-beat-notation .notation-svg {
  width: 100%;
  height: 100%;
  max-height: calc(var(--custom-strip-height, 56px) - 6px);
  display: block;
  overflow: visible;
  --notation-fill: #f8fafc;
  --notation-stem: #f8fafc;
  --notation-beam: #f8fafc;
}

.custom-notation-layer .rhythm-notation {
  position: absolute;
  inset: 0;
  height: 100%;
}

.custom-grid-meta {
  font-size: clamp(8px, 2.2vh, 11px);
  color: rgba(255, 255, 255, 0.9);
  text-align: left;
  line-height: 1.4;
  flex-shrink: 0;
}

.custom-palette {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  flex: 1;
  min-height: 0;
  align-content: start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.custom-palette-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: clamp(56px, 12vmin, 96px);
  padding: clamp(6px, 1.2vmin, 10px) 4px;
  background: rgba(42, 74, 106, 0.75);
  border: 3px solid #1a2a3a;
  box-shadow: 3px 3px 0 rgba(13, 26, 38, 0.4);
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition: transform 0.08s, box-shadow 0.08s;
}

.custom-palette-block:active {
  cursor: grabbing;
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 rgba(13, 26, 38, 0.4);
}

.custom-palette-icon-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: clamp(48px, 10vmin, 80px);
  height: clamp(44px, 9vmin, 72px);
  overflow: visible;
}

.token-icon {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: clamp(48px, 10vmin, 80px);
  height: clamp(44px, 9vmin, 72px);
}

.token-icon .notation-svg--token {
  width: clamp(48px, 10vmin, 80px);
  height: clamp(44px, 9vmin, 72px);
  display: block;
  overflow: visible;
  --notation-fill: #f8fafc;
  --notation-stem: #f8fafc;
  --notation-beam: #f8fafc;
}

.notation-flag {
  fill: var(--notation-fill);
  stroke: none;
}

.custom-palette-label {
  font-size: clamp(8px, 3.0vw, 11px);
  color: #e8f8ff;
  text-align: center;
  line-height: 1.45;
  padding: 0 2px;
}

.custom-drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 300;
  pointer-events: none;
  transform: translate(-9999px, -9999px);
}

.custom-drag-ghost-piece {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 76px;
  padding: 4px;
  background: rgba(74, 138, 184, 0.92);
  border: 2px solid #1a2a3a;
  box-shadow: 3px 3px 0 rgba(13, 26, 38, 0.45);
  opacity: 0.95;
}

.custom-drag-ghost-piece .token-icon {
  width: 72px;
  height: 68px;
}

.custom-drag-ghost-piece .notation-svg--token {
  width: 72px;
  height: 68px;
}

.custom-footer-actions .btn {
  flex: none;
  width: 100%;
  min-width: 0;
}

.custom-status {
  display: none;
}

/* Practice picker (levels list) */
.practice-bpm-section {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: rgba(42, 74, 106, 0.55);
  border: 3px solid #1a2a3a;
  box-shadow: 4px 4px 0 rgba(13, 26, 38, 0.35);
}

.practice-bpm-label {
  font-size: clamp(8px, 2.8vw, 11px);
  color: #e0e0e0;
  line-height: 1.4;
}

.practice-bpm-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.practice-bpm-input {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: clamp(14px, 4.4vw, 19px);
  color: #1a2a3a;
  background: #e8f4fc;
  border: 3px solid #1a2a3a;
  padding: 8px 10px;
  border-radius: 0;
  box-shadow: inset 2px 2px 0 rgba(26, 42, 58, 0.15);
  -moz-appearance: textfield;
}

.practice-bpm-input::-webkit-outer-spin-button,
.practice-bpm-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.practice-bpm-input:focus {
  outline: 2px solid #ffd54f;
  outline-offset: 1px;
}

.practice-bpm-apply {
  flex-shrink: 0;
  background: #43a047;
  font-size: clamp(8px, 2.8vw, 11px);
  padding: 8px 10px;
  border: 3px solid #1a2a3a;
  box-shadow: 3px 3px 0 #0d1a26;
  color: #fff;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.practice-bpm-apply:active {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 #0d1a26;
}

.practice-bpm-hint {
  font-size: clamp(7px, 2.2vw, 8px);
  color: rgba(224, 224, 224, 0.85);
  line-height: 1.5;
}

.practice-picker-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(6px, 1.5vmin, 10px);
  align-content: start;
}

.practice-modal-back {
  flex-shrink: 0;
  background: #546e7a;
  font-size: clamp(8px, 2.8vw, 11px);
  padding: 8px 10px;
  border: 3px solid #1a2a3a;
  box-shadow: 3px 3px 0 #0d1a26;
  color: #fff;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.practice-modal-back:active {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 #0d1a26;
}

.practice-card-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.practice-card__delete {
  align-self: flex-end;
  font-size: clamp(7px, 2.2vw, 8px) !important;
  padding: 6px 10px !important;
  background: #8a5a5a;
  border-color: #5a2a2a;
  box-shadow: 2px 2px 0 #3a1a1a;
}

.practice-item {
  width: 100%;
  font-family: inherit;
  text-align: left;
  border: 4px solid #1a2a3a;
  background: #3a6a8a;
  color: #fff;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.1s, transform 0.08s;
  box-shadow: 4px 4px 0 rgba(13, 26, 38, 0.4);
}

.practice-item:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 rgba(13, 26, 38, 0.4);
}

.practice-item.selected {
  background: #3a6a8a;
  color: #fff;
  border-color: #7dd3f3;
  box-shadow:
    4px 4px 0 rgba(13, 26, 38, 0.4),
    inset 0 0 0 3px rgba(125, 211, 243, 0.55);
}

.practice-item.selected .practice-item-meta {
  opacity: 0.92;
}

.practice-item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.practice-item-title {
  font-size: clamp(8px, 2.8vw, 11px);
  line-height: 1.5;
}

.practice-item-meta {
  font-size: clamp(7px, 2.2vw, 8px);
  opacity: 0.8;
  line-height: 1.4;
}

.practice-preview {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  width: 100%;
  min-height: clamp(28px, 5vmin, 40px);
  padding: 4px 0;
  opacity: 0.95;
  overflow-x: auto;
}

.practice-item-cta {
  font-size: clamp(8px, 2.8vw, 11px);
  color: #ffe082;
  text-align: right;
  line-height: 1.4;
}

.practice-item.selected .practice-preview .notation-svg {
  --notation-fill: #fff;
  --notation-stem: #fff;
  --notation-beam: #fff;
}

/* Controls — right rail */
.controls-panel {
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.4vmin, 12px);
  flex: 1;
  min-height: 0;
}

.controls {
  width: 100%;
  max-width: 100%;
  margin: 0;
  align-items: stretch;
  padding-bottom: 0;
  box-sizing: border-box;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tap-primary-row {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 0;
  flex-shrink: 0;
}

.secondary-controls-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(4px, 1vmin, 8px);
}

.secondary-controls-row .btn-levels {
  grid-column: 1 / -1;
}

.tap-button,
.btn-tap {
  width: 100%;
  max-width: 100%;
  min-height: clamp(40px, 10vmin, 68px);
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: horizontal-tb;
  aspect-ratio: auto;
  white-space: nowrap;
  font-size: clamp(14px, 4.1vmin, 22px);
  background: #e53935;
  border-color: #b71c1c;
  box-shadow: 4px 4px 0 #7f0000;
}

.secondary-button {
  min-height: clamp(32px, 7.5vmin, 42px);
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  white-space: normal;
  font-size: clamp(8px, 2.2vmin, 11px);
  line-height: 1.3;
  padding: clamp(4px, 1vmin, 8px) clamp(4px, 1vmin, 6px);
  gap: 4px;
  background: #5d7a9a;
  border-color: #2a4a6a;
  box-shadow: 3px 3px 0 #1a3a5a;
}

.secondary-button:active:not(:disabled) {
  box-shadow: 1px 1px 0 #1a3a5a;
}

.btn-levels {
  background: #6a7a9a;
  border-color: #3a4a6a;
  box-shadow: 3px 3px 0 #2a3a5a;
}

.btn-levels:active:not(:disabled) {
  box-shadow: 1px 1px 0 #2a3a5a;
}

.btn {
  font-family: inherit;
  font-size: clamp(12px, 3.9vw, 15px);
  border: 4px solid #1a2a3a;
  box-shadow: 4px 4px 0 #0d1a26;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s, box-shadow 0.08s, opacity 0.15s;
  color: #fff;
  border-radius: 0;
}

.btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #0d1a26;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-demo {
  background: #4e8f6a;
  border-color: #2a6a4a;
  box-shadow: 3px 3px 0 #1a4a32;
}

.btn-demo:active:not(:disabled) {
  box-shadow: 1px 1px 0 #1a4a32;
}

.btn-tap:active:not(:disabled) {
  box-shadow: 2px 2px 0 #7f0000;
}

.btn-retry {
  background: #6a7a9a;
  border-color: #3a4a6a;
  box-shadow: 3px 3px 0 #2a3a5a;
}

.btn-retry:not(:disabled) {
  background: #7a8a9a;
}

.btn-retry:active:not(:disabled) {
  box-shadow: 1px 1px 0 #2a3a5a;
}

.game-container.state-success .bridge-cell--note.lit {
  background: #ffeb3b;
}

.debug-panel {
  width: 100%;
  font-size: 10px;
  line-height: 1.8;
  background: rgba(0, 0, 0, 0.75);
  color: #0f0;
  padding: 8px 10px;
  border: 2px solid #0f0;
  font-family: 'Courier New', monospace;
}

.debug-panel .debug-title {
  color: #ff0;
  margin-bottom: 4px;
}

@media (max-width: 340px) {
  .rhythm-symbol {
    width: 22px;
    height: 28px;
  }

  .rhythm-symbol--tiny {
    width: 12px;
    height: 16px;
  }
}

/* All landscape: compact controls + scale game */
@media (orientation: landscape) {
  .game-playfield {
    --game-scale: clamp(1.35, 2vmin, 1.85);
  }

  .game-container {
    padding:
      max(4px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(var(--game-bottom-inset), env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }
}

/* Phone / short landscape (e.g. iPhone 844×390) */
@media (orientation: landscape) and (max-height: 520px) {
  .app-shell {
    --app-top-nav-height: calc(36px + max(2px, env(safe-area-inset-top)));
    --control-rail-width: clamp(132px, 20vw, 168px);
  }

  .app-top-nav {
    padding-bottom: 4px;
    gap: 6px;
  }

  .app-top-nav__item {
    min-height: 30px;
    padding: 4px 8px;
    font-size: clamp(7px, 1.9vmin, 10px);
  }

  .app-top-nav__icon {
    font-size: clamp(11px, 2.8vmin, 14px);
  }

  .cover-content {
    max-width: 100%;
    gap: clamp(12px, 3vmin, 20px);
    padding:
      max(8px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      clamp(20px, 5vmin, 36px)
      max(10px, env(safe-area-inset-left));
  }

  .cover-title-cluster {
    gap: clamp(3px, 1vmin, 10px);
  }

  .cover-mascot {
    width: clamp(44px, 10vmin, 68px);
    height: clamp(38px, 9vmin, 62px);
    margin-bottom: calc(clamp(12px, 3.2vmin, 18px) + clamp(3px, 0.8vmin, 8px));
  }

  .cover-title {
    font-size: clamp(32px, 10vmin, 64px);
  }

  .cover-subtitle {
    font-size: clamp(12px, 3.2vmin, 18px);
  }

  .cover-hint {
    font-size: clamp(7px, 2vmin, 10px);
  }

  .cover-start-button {
    min-width: clamp(150px, 38vw, 240px);
    min-height: clamp(40px, 9vmin, 52px);
    padding: 8px 20px;
  }

  .game-rhythm-header {
    padding-bottom: 2px;
  }

  .game-playfield {
    --game-scale: 1.3;
    gap: 4px;
  }

  .rhythm-bar {
    min-height: 40px;
  }

  .bridge-zone,
  .bridge-scene {
    min-height: calc(var(--bridge-cell-size, 28px) * 2.3);
    height: calc(var(--bridge-cell-size, 28px) * 2.3);
  }

  .game-controls {
    padding: 6px;
    gap: 4px;
  }

  .tap-button,
  .btn-tap {
    min-height: clamp(36px, 9vmin, 48px);
    font-size: clamp(12px, 3.6vmin, 18px);
  }

  .secondary-button {
    min-height: clamp(28px, 6.5vmin, 36px);
    font-size: clamp(7px, 1.9vmin, 10px);
    padding: 4px 3px;
  }

  .game-back-button {
    padding: 4px 6px;
    font-size: clamp(8px, 2.2vmin, 11px);
  }

  .custom-practice-page {
    gap: 4px;
    padding:
      max(4px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(4px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  .custom-body {
    grid-template-columns: minmax(0, 1fr) clamp(132px, 20vw, 168px);
    gap: 8px;
  }

  .custom-rhythm-bar {
    min-height: 36px;
  }

  .custom-palette-block {
    min-height: clamp(48px, 10vmin, 72px);
    gap: 2px;
  }

  .custom-palette-icon-wrap,
  .token-icon,
  .token-icon .notation-svg--token {
    width: clamp(40px, 8vmin, 56px);
    height: clamp(36px, 7.5vmin, 52px);
  }

  .custom-page-hint,
  .custom-grid-meta,
  .builder-label {
    font-size: clamp(7px, 1.9vmin, 10px);
  }

  .builder-name-input {
    padding: 6px 8px;
    font-size: clamp(10px, 2.5vmin, 12px);
  }

  .custom-info-dock {
    margin-top: 0;
  }

  .custom-info-grid {
    gap: 3px;
  }

  .custom-info-cell {
    padding: 3px 4px;
  }
}

/* Narrow portrait fallback — stack controls below stage */
@media (orientation: portrait) and (max-width: 600px) {
  .game-body {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  .game-controls {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .game-controls .controls-panel {
    flex: 1;
    min-width: 200px;
  }

  .game-controls .secondary-controls-row {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .game-controls .secondary-controls-row .btn {
    flex: 1;
    min-width: 80px;
  }

  .game-controls .game-controls-footer {
    width: 100%;
  }

  .game-controls .game-controls-footer .game-back-button {
    width: 100%;
  }

  .custom-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    overflow-y: auto;
    align-items: stretch;
  }

  .custom-info-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .custom-rhythm-bar {
    min-height: 40px;
  }

  .custom-palette {
    grid-template-columns: repeat(4, 1fr);
  }

  .levels-body {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  .levels-controls {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .levels-controls .levels-bpm-panel {
    flex: 1;
    min-width: 160px;
  }

  .levels-controls .practice-bpm-apply {
    width: auto;
  }

  .levels-controls .levels-confirm-button {
    width: auto;
    flex: 1;
    min-width: 100px;
  }

  .levels-controls .game-back-button {
    width: auto;
    margin-top: 0;
  }

  .practice-picker-list {
    grid-template-columns: 1fr;
  }
}

/* Mobile portrait — prompt landscape (iOS Safari uses aspect-ratio + JS class) */
.rotate-prompt {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(26, 74, 106, 0.94);
  box-sizing: border-box;
}

html.needs-landscape .rotate-prompt {
  display: flex;
}

@media (max-aspect-ratio: 1/1) and (max-width: 900px) {
  .rotate-prompt:not([hidden]) {
    display: flex;
  }
}

.rotate-prompt[hidden] {
  display: none !important;
}

@media (min-aspect-ratio: 13/10) and (min-width: 480px) {
  .rotate-prompt {
    display: none !important;
  }
}

.rotate-prompt__card {
  max-width: 320px;
  width: 100%;
  text-align: center;
  padding: clamp(20px, 5vmin, 32px);
  background: rgba(125, 211, 243, 0.15);
  border: 3px solid #e8f8ff;
  box-shadow: 6px 6px 0 rgba(13, 26, 38, 0.35);
}

.rotate-prompt__icon {
  font-size: clamp(36px, 12vmin, 56px);
  color: #ffe566;
  text-shadow: 3px 3px 0 #2a6a8a;
  margin-bottom: 12px;
  animation: rotate-prompt-spin 2.5s ease-in-out infinite;
}

@keyframes rotate-prompt-spin {
  0%, 100% { transform: rotate(-90deg); }
  50% { transform: rotate(0deg); }
}

.rotate-prompt__title {
  font-size: clamp(12px, 3.8vmin, 18px);
  color: #fff;
  text-shadow: 2px 2px 0 #2a6a8a;
  line-height: 1.6;
  margin-bottom: 8px;
}

.rotate-prompt__hint {
  font-size: clamp(8px, 2.6vmin, 12px);
  color: #e8f8ff;
  line-height: 1.7;
  margin-bottom: 4px;
}

.rotate-prompt__hint--sub {
  opacity: 0.85;
  margin-bottom: 12px;
}

.rotate-prompt__http {
  font-size: clamp(7px, 2.2vmin, 10px);
  color: #c8f7c9;
  line-height: 1.6;
  padding-top: 8px;
  border-top: 2px solid rgba(232, 248, 255, 0.25);
}
