:root {
  --night: #10232b;
  --surface: rgba(11, 26, 33, 0.9);
  --solid: #0d1f27;
  --panel: #182e34;
  --panel-2: #233d42;
  --line: rgba(193, 190, 161, 0.2);
  --line-2: rgba(218, 198, 155, 0.45);
  --brass: #d9b77a;
  --brass-2: #f5dfb6;
  --brass-dim: #6b4f26;
  --mist: #f3eddf;
  --soft: #bbc5be;
  --ink: #1a140f;
  --teal: #6fcfb0;
  --bad: #d9735c;
  --serif: Georgia, "Times New Roman", serif;
  --script: "Pinyon Script", var(--serif);
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --r: 16px;
  --r-s: 8px;
  --fill: rgba(255, 255, 255, 0.06);
  --fill-2: rgba(255, 255, 255, 0.11);
  --ring: inset 0 0 0 1px rgba(255, 255, 255, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  --lift: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 28px 60px -24px rgba(0, 0, 0, 0.7), 0 8px 20px -12px rgba(0, 0, 0, 0.5);
  --ease: 140ms ease;
  --left: var(--brass);
  --right: var(--mist);
  --pad: 20px;
  --pan-h: min(56vh, 540px);
  --edge: rgba(217, 183, 122, 0.35);
  --edge-2: rgba(217, 183, 122, 0.1);
  --aura: rgba(217, 183, 122, 0.14);
  --glass:
    radial-gradient(120% 140% at 0% 0%, var(--aura), transparent 55%),
    radial-gradient(90% 120% at 100% 100%, var(--aura), transparent 60%),
    linear-gradient(160deg, rgba(24, 46, 52, 0.82), rgba(11, 26, 33, 0.92));
  --glass-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 28px 60px -24px rgba(0, 0, 0, 0.7), 0 0 0 1px var(--edge-2);
  --violet: #b49cff;
  color-scheme: dark;
}

.tools, #dock, body.is-learn #learn, .mic, .caption, .game, .scene-notice:not(:empty) {
  background: var(--glass);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
}

.tools, .mic, .caption, .game { position: relative; isolation: isolate; }

.tools::before, .mic::before, .caption::before, .game::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, var(--edge), transparent 40%, transparent 60%, var(--edge));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: -1;
  transition: background 900ms ease;
}

#dock, body.is-learn #learn { background-attachment: local; }

* { box-sizing: border-box; }


html, body { margin: 0; }

body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0 var(--pad) calc(16px + env(safe-area-inset-bottom));
  background: var(--night);
  color: var(--mist);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body.is-learn { --pan-h: min(64vh, 620px); }

body.has-3d::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.45 0 0 0 0 0.4 0 0 0 0.07 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23g)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse 120% 95% at 50% 42%, transparent 55%, rgba(5, 10, 16, 0.55)),
    linear-gradient(180deg, rgba(7, 17, 26, 0.45), rgba(7, 17, 26, 0.05) 30%, rgba(7, 17, 26, 0.55));
}

button, a, input, select { font: inherit; color: inherit; }
button { touch-action: manipulation; }
button, select, .open, .back, .brand { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.wrap { width: 100%; flex: 1; min-height: 0; display: flex; flex-direction: column; }

.top {
  position: relative;
  z-index: 6;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
}

.brand {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1;
  color: var(--mist);
  text-decoration: none;
  text-shadow: 0 2px 14px var(--night);
}

.brand img { flex: 0 0 auto; width: 34px; height: 34px; }

.tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: end; gap: 6px; }
.ico { flex: 0 0 auto; width: 18px; height: 18px; opacity: 0.85; }
.top #listen, .top #explore-world, .top #tools-toggle { min-height: 40px; padding: 6px 14px 6px 11px; }
.top .scene-pick { max-width: 260px; gap: 8px; padding-inline-start: 11px; }
.top .scene-pick .ico { color: var(--mist); }
.top .scene-pick select { min-height: 40px; padding-inline-start: 0; }
.top-end { display: flex; align-items: center; gap: 14px; }
.top .lang-switch { min-height: 40px; }
.motion-controls { display: flex; align-items: center; gap: 8px; }

#listen, #tools-toggle, #explore-world, #motion-toggle, #motion-center, #simple-view,
.open, .back, .stepper, .loop, .range, .chip, .step-btn, .part-loop,
.mode-link, .practice-start, .practice-control, .play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  padding: 8px 14px;
  background: var(--fill);
  border: 0;
  border-radius: var(--r-s);
  box-shadow: var(--ring);
  color: var(--mist);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  white-space: normal;
  transition: background-color var(--ease), color var(--ease), box-shadow var(--ease), scale var(--ease);
}

#listen:active, #tools-toggle:active, #explore-world:active, .open:active, .back:active,
.stepper:active, .loop:active, .range:active, .chip:active, .step-btn:active, .part-loop:active,
.step-chip:active, .play:active, .row-play:active { scale: 0.96; }

#listen[aria-pressed="true"], #motion-toggle[aria-pressed="true"],
#tools-toggle[aria-expanded="true"], .loop[aria-pressed="true"], .chip[aria-pressed="true"],
.part-loop[aria-pressed="true"], .is-main, .practice-panel .is-main, .play,
.practice-mode[aria-pressed="true"] {
  background: linear-gradient(180deg, #e9cc94, #cfa96a);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 6px 16px -8px rgba(217, 183, 122, 0.7);
  color: var(--ink);
}

.tools { padding: 4px; border-radius: 14px; }
.top { gap: 12px; }

#listen[aria-pressed="true"] .ico { animation: pulse 1.2s ease-in-out infinite; }

@keyframes menu-in {
  from { opacity: 0; translate: 0 -6px; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.top #tools-toggle { display: none; }


.lang-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 6px 14px 6px 11px;
  margin-inline-start: 4px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(217, 183, 122, 0.16), rgba(217, 183, 122, 0.06));
  box-shadow: inset 0 0 0 1px var(--edge), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  color: var(--brass-2);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background-color var(--ease), color var(--ease), box-shadow var(--ease), scale var(--ease);
}
.lang-switch::before {
  content: "";
  position: absolute;
  inset-inline-start: -11px;
  top: 50%;
  width: 1px;
  height: 22px;
  translate: 0 -50%;
  background: var(--line-2);
  opacity: 0.6;
}
.lang-switch .ico { color: var(--brass); opacity: 1; }
.lang-switch[lang="fa"] { font-family: "Vazirmatn", var(--sans); font-size: 15px; letter-spacing: 0; }
.lang-switch:hover { color: var(--ink); background: linear-gradient(180deg, #e9cc94, #cfa96a); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 6px 16px -8px rgba(217, 183, 122, 0.7); }
.lang-switch:hover .ico { color: var(--ink); }
.lang-switch:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.lang-switch:active { scale: 0.96; }

.pick {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  background: var(--fill);
  border-radius: var(--r-s);
  box-shadow: var(--ring);
  transition: background-color var(--ease), box-shadow var(--ease);
}
.pick::after {
  content: "";
  position: absolute;
  top: 50%;
  inset-inline-end: 12px;
  width: 12px;
  height: 8px;
  margin-top: -4px;
  background: currentColor;
  color: var(--soft);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
  transition: color var(--ease), translate var(--ease);
}
.pick select {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 6px 12px;
  padding-inline-end: 34px;
  font-size: 13px;
  font-weight: 500;
  color: var(--mist);
  background: transparent;
  border: 0;
  border-radius: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-appearance: none;
  appearance: none;
}
.pick select:focus-visible { outline: 0; }
.pick:has(select:focus-visible) { outline: 2px solid var(--brass); outline-offset: 3px; }
.pick:has(select:focus-visible)::after, .pick:has(select:active)::after { color: var(--brass-2); translate: 0 1px; }
.pick select:disabled { opacity: 0.5; cursor: default; }
.pick option { background: var(--solid); color: var(--mist); }

.split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 12px 24px;
}

body.is-learn .split { grid-template-columns: minmax(360px, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
body.is-learn #dock { display: none; }
body.is-learn .pan-stick { grid-column: 2; grid-row: 1; align-self: center; }
body.is-learn #learn { grid-column: 1; grid-row: 1; }

#dock {
  grid-column: 1;
  grid-row: 1 / -1;
  min-height: 0;
  overflow: auto;
  padding: 0 16px 16px;
  border-radius: 22px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}

.pan-stick {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#learn {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  container-type: inline-size;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}

#pan {
  position: relative;
  align-self: stretch;
  flex: 0 0 auto;
  height: var(--pan-h);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pan-svg {
  display: block;
  width: auto;
  max-width: 100%;
  height: 100%;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  filter: drop-shadow(0 18px 16px rgba(0, 0, 0, 0.45));
}

body.has-3d .pan-svg { opacity: 0; pointer-events: none; filter: none; }

.pan-3d {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.world {
  position: fixed;
  inset: 0;
  z-index: -1;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.caption {
  margin: 0;
  min-height: 32px;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 500;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

#motion-status, .scene-notice {
  margin: 0;
  max-width: 48ch;
  text-align: center;
  color: var(--soft);
  font-size: 13px;
  text-shadow: 0 1px 8px var(--night);
}

#motion-status:empty { display: none; }

.mic {
  align-self: stretch;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 8px 10px 8px 12px;
  border-radius: 18px;
  font-size: 13px;
}

.mic[data-state="error"] { --edge: var(--bad); --edge-2: rgba(217, 115, 92, 0.35); --aura: rgba(217, 115, 92, 0.14); }
.mic[data-state="on"] { --edge: rgba(111, 207, 176, 0.55); --aura: rgba(111, 207, 176, 0.12); }
.mic[data-state="on"] .mic-dot { box-shadow: 0 0 0 3px rgba(111, 207, 176, 0.18), 0 0 12px rgba(111, 207, 176, 0.8); }
.mic-dot { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: var(--soft); }
.mic[data-state="asking"] .mic-dot { animation: pulse 1.2s ease-in-out infinite; }
.mic[data-state="on"] .mic-dot { background: var(--teal); box-shadow: 0 0 0 3px rgba(111, 207, 176, 0.18); }
.mic[data-state="on"][data-quiet="1"] .mic-dot { background: var(--brass); box-shadow: 0 0 0 3px rgba(230, 177, 90, 0.18); }
.mic[data-state="error"] .mic-dot { background: var(--bad); }
.mic-text { flex: 1 1 140px; min-width: 0; line-height: 1.3; }
.mic-meter { flex: 0 0 96px; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }

#mic-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--teal) 0%, var(--teal) 60%, var(--brass) 85%, var(--bad) 100%);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 60ms linear;
}

.mic[data-heard="hit"] .mic-meter { box-shadow: 0 0 0 2px var(--teal); }
.mic[data-heard="miss"] .mic-meter { box-shadow: 0 0 0 2px var(--bad); }
.mic-pick { flex: 0 1 260px; }

.game {
  align-self: stretch;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "medal read streak stats" "tier tier tier tier";
  align-items: center;
  gap: 10px 18px;
  padding: 14px 18px 12px;
  border-radius: 22px;
  --q-color: var(--brass);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  transition: box-shadow 900ms ease;
}

.game[data-tier="1"] { --edge: rgba(230, 177, 90, 0.55); --aura: rgba(230, 177, 90, 0.2); }
.game[data-tier="2"] { --edge: rgba(245, 223, 182, 0.65); --aura: rgba(230, 177, 90, 0.26); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1) inset, 0 28px 60px -24px rgba(0, 0, 0, 0.7), 0 0 36px -10px rgba(230, 177, 90, 0.5); }
.game[data-tier="3"] { --edge: rgba(111, 207, 176, 0.75); --aura: rgba(111, 207, 176, 0.22); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1) inset, 0 28px 60px -24px rgba(0, 0, 0, 0.7), 0 0 44px -8px rgba(111, 207, 176, 0.55); }
.game[data-tier="4"] { --edge: rgba(180, 156, 255, 0.85); --aura: rgba(180, 156, 255, 0.26); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 28px 60px -24px rgba(0, 0, 0, 0.7), 0 0 56px -6px rgba(180, 156, 255, 0.6); }
.game[data-tier="5"] { --edge: rgba(255, 245, 225, 0.95); --aura: rgba(190, 170, 255, 0.34); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.16) inset, 0 28px 60px -24px rgba(0, 0, 0, 0.7), 0 0 72px -4px rgba(190, 170, 255, 0.8), 0 0 120px -20px rgba(245, 223, 182, 0.6); }

.game-medallion {
  grid-area: medal;
  position: relative;
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #4e3b2e, #2a1d14 70%);
  box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.12), inset 0 -8px 16px rgba(0, 0, 0, 0.45);
  transition: transform 220ms cubic-bezier(0.2, 0.9, 0.2, 1.4), box-shadow 300ms ease;
}

.game-ring {
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: conic-gradient(from -90deg, var(--q-color) calc(var(--q) * 360deg), rgba(255, 255, 255, 0.07) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
  filter: drop-shadow(0 0 6px var(--q-color));
  transition: --q 300ms ease, filter 300ms ease;
}

.game-note {
  font-family: var(--persian);
  font-size: 34px;
  line-height: 1;
  color: var(--brass-2);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6), 0 0 18px rgba(245, 223, 182, 0.25);
  transition: color var(--ease), text-shadow 300ms ease;
}

.game[data-heard="hit"] .game-medallion { transform: scale(1.06); box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 0 28px -4px var(--q-color); }
.game[data-heard="hit"] .game-note { color: #fff6e6; text-shadow: 0 0 22px var(--q-color), 0 2px 10px rgba(0, 0, 0, 0.6); }
.game[data-heard="miss"] .game-medallion { animation: game-shake 360ms ease; box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.8), 0 0 24px -4px var(--bad); }
.game[data-heard="miss"] .game-note { color: var(--bad); }
.game[data-heard="dull"] .game-note { color: var(--soft); }

.game-read { grid-area: read; min-width: 0; display: grid; gap: 3px; }
.game-word { font-family: var(--serif); font-size: 22px; line-height: 1.1; color: var(--mist); letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game[data-heard="hit"] .game-word { color: #fff6e6; }
.game[data-heard="miss"] .game-word { color: var(--bad); }
.game-sub { color: var(--soft); font-size: 13px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.game-streak { grid-area: streak; display: grid; justify-items: center; gap: 0; padding: 0 6px; }
.game-streak strong {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 46px;
  line-height: 1;
  background: linear-gradient(180deg, #fff3d6 0%, var(--brass) 55%, #a9792f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}
.game[data-tier="3"] .game-streak strong { background-image: linear-gradient(180deg, #ecfff7 0%, var(--teal) 60%, #2f8f72 100%); }
.game[data-tier="4"] .game-streak strong, .game[data-tier="5"] .game-streak strong { background-image: linear-gradient(180deg, #fff 0%, #cdb9ff 50%, #7f5cff 100%); }
.game-label { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--soft); margin-top: 2px; }
.game-streak strong.is-bump { animation: game-bump 420ms cubic-bezier(0.2, 0.9, 0.2, 1.4); }

.game-stats { grid-area: stats; margin: 0; display: grid; gap: 4px 0; padding-left: 16px; border-left: 1px solid var(--line); }
.game-stats div { display: flex; justify-content: space-between; gap: 14px; align-items: baseline; }
.game-stats dt { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--soft); }
.game-stats dd { margin: 0; font-size: 15px; font-weight: 600; color: var(--mist); }
.game-stats dd.is-bump { animation: game-bump 360ms cubic-bezier(0.2, 0.9, 0.2, 1.4); }

.game-tier { grid-area: tier; display: flex; align-items: center; gap: 12px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--soft); }
.game-lanterns { display: flex; gap: 9px; }
.game-lanterns i {
  display: block;
  width: 9px;
  height: 9px;
  transform: rotate(45deg);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  transition: background 600ms ease, box-shadow 600ms ease;
}
.game[data-tier="0"] .game-lanterns i:nth-child(-n+1),
.game[data-tier="1"] .game-lanterns i:nth-child(-n+2),
.game[data-tier="2"] .game-lanterns i:nth-child(-n+3),
.game[data-tier="3"] .game-lanterns i:nth-child(-n+4),
.game[data-tier="4"] .game-lanterns i:nth-child(-n+5),
.game[data-tier="5"] .game-lanterns i:nth-child(-n+6) {
  background: linear-gradient(135deg, #fff3d6, var(--brass));
  box-shadow: 0 0 10px rgba(230, 177, 90, 0.8);
}
.game[data-tier="3"] .game-lanterns i:nth-child(4) { background: linear-gradient(135deg, #ecfff7, var(--teal)); box-shadow: 0 0 10px rgba(111, 207, 176, 0.9); }
.game[data-tier="4"] .game-lanterns i:nth-child(-n+5), .game[data-tier="5"] .game-lanterns i:nth-child(-n+6) { background: linear-gradient(135deg, #ffffff, #b49cff); box-shadow: 0 0 12px rgba(180, 156, 255, 0.95); }
.game-tier-name { font-family: var(--serif); font-size: 16px; color: var(--brass-2); letter-spacing: 0.02em; }
.game[data-tier="3"] .game-tier-name { color: var(--teal); }
.game[data-tier="4"] .game-tier-name, .game[data-tier="5"] .game-tier-name { color: #d7c9ff; }
.game-tier-next { margin-left: auto; font-size: 12px; white-space: nowrap; }

.game-pop {
  position: absolute;
  left: 50%;
  top: -10px;
  margin: 0;
  padding: 8px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fff3d6, var(--brass));
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.7), 0 0 24px rgba(245, 223, 182, 0.35);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 0);
}

.game[data-tier="4"] .game-pop, .game[data-tier="5"] .game-pop { background: linear-gradient(135deg, #ffffff, #b49cff); }
.game-pop.is-live { animation: game-pop 1800ms ease forwards; }

@keyframes game-pop {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(0.88); }
  15% { opacity: 1; transform: translate(-50%, -16px) scale(1.06); }
  75% { opacity: 1; transform: translate(-50%, -24px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -38px) scale(1); }
}

@keyframes game-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

@keyframes game-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-3px); }
}
}

.field { cursor: pointer; }
.field-face { stroke: #1a120e; stroke-width: 1; transition: stroke var(--ease), stroke-width var(--ease); }

.field-name {
  font-family: var(--script);
  font-weight: 400;
  fill: var(--right);
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.field.hand-left .field-name { fill: var(--left); }
.field.is-on .field-face { stroke: #fff6e4; stroke-width: 2; }
.field.is-on .field-name, .field.is-tap .field-name { fill: var(--ink); }
.field.is-place .field-face, .field.is-next .field-face { stroke: var(--brass); stroke-width: 2.5; }
.field.is-place .field-name { fill: var(--brass-2); }
.field-face[fill^="url"] + .field-name { fill: var(--ink); }
.field:focus-visible { outline: none; }
.field:focus-visible .field-face { stroke: #fff; stroke-width: 3; }
.pan-svg.is-tak .rim { stroke: var(--brass); stroke-opacity: 0.7; stroke-width: 3; }

body:not(.is-learn) #learn { display: none; }

.key {
  margin: 0 auto;
  max-width: 56ch;
  color: var(--soft);
  font-size: 13px;
  line-height: 1.6;
  text-shadow: 0 1px 8px var(--night);
}

.library-head {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0 -16px;
  padding: 16px 16px 10px;
  background: linear-gradient(180deg, rgba(13, 31, 39, 0.98), rgba(13, 31, 39, 0.9));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 1px 0 var(--edge-2);
  border-radius: 22px 22px 0 0;
}

#dock h2 { margin: 0; font-family: var(--serif); font-weight: 400; line-height: 1.2; }
#dock .library-head h2, #learn h1 {
  font-size: 28px;
  letter-spacing: 0.01em;
  margin-bottom: 0;
  background: linear-gradient(180deg, #fff3d6 0%, var(--brass) 70%, #b98a3c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.library-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.library-site-nav { display: flex; flex-wrap: wrap; gap: 2px 14px; }
.library-site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  color: var(--soft);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--ease);
}

.find {
  display: block;
  width: 100%;
  min-height: 40px;
  margin: 0 0 10px;
  padding: 8px 14px 8px 38px;
  font-size: 15px;
  background: rgba(0, 0, 0, 0.22);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Ccircle cx='6.8' cy='6.8' r='4.6' fill='none' stroke='%23a6b6b4' stroke-width='1.6'/%3E%3Cpath d='M10.4 10.4 14 14' stroke='%23a6b6b4' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 13px center;
  border: 0;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transition: box-shadow var(--ease);
}

.find:focus { box-shadow: inset 0 0 0 1.5px var(--brass); outline: none; }
.find::placeholder { color: #8fa09e; }
.find::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

.chips {
  display: flex;
  gap: 18px;
  margin: 0 -16px;
  padding: 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  box-shadow: inset 0 -1px 0 var(--line);
  mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
}
.chips::-webkit-scrollbar { display: none; }
.chip, .chip[aria-pressed="true"] {
  flex: 0 0 auto;
  min-width: 0;
  min-height: 36px;
  padding: 6px 0 8px;
  gap: 5px;
  border-radius: 0;
  background: none;
  box-shadow: inset 0 -2px 0 transparent;
  color: var(--soft);
  font-size: 13px;
  text-shadow: none;
  white-space: nowrap;
}
.chip[aria-pressed="true"] { color: var(--brass-2); box-shadow: inset 0 -2px 0 var(--brass); }
.chip-count { font-size: 11px; font-variant-numeric: tabular-nums; opacity: 0.6; }
.list-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px; margin-top: 4px; }
.list-options-toggle {
  position: relative;
  min-height: 36px;
  min-width: 0;
  padding: 6px 0;
  padding-inline-end: 18px;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--soft);
  font-size: 13px;
  transition: color var(--ease);
}
.list-options-toggle::after {
  content: "";
  position: absolute;
  top: 50%;
  inset-inline-end: 2px;
  width: 12px;
  height: 8px;
  margin-top: -4px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: rotate 200ms ease;
}
.list-options-toggle.is-set { color: var(--brass-2); }
.list-options-toggle[aria-expanded="true"]::after { rotate: 180deg; }
.list-options { display: grid; gap: 6px; padding: 4px 0 8px; animation: menu-in 160ms ease; }
.option-row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; }
.option-row-name { min-width: 3.6em; margin-inline-end: 6px; color: var(--soft); opacity: 0.6; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.option {
  min-height: 30px;
  min-width: 0;
  padding: 4px 10px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--soft);
  font-size: 13px;
  line-height: 1.2;
  transition: background-color var(--ease), color var(--ease);
}
.option[aria-pressed="true"] { background: rgba(217, 183, 122, 0.16); color: var(--brass-2); }
.result-count { margin: 0; margin-inline-start: auto; color: var(--soft); font-size: 12px; opacity: 0.7; font-variant-numeric: tabular-nums; }
.empty { color: var(--soft); margin: 16px 0; line-height: 1.8; }

#dock .kind {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 6px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brass);
}

#dock .kind::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-2), transparent); }
.kind-note { display: none; }

.row { margin: 0 -8px 4px; border-radius: var(--r-s); }
.row.is-current { background: rgba(217, 183, 122, 0.12); }
.row .open {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 16px;
  gap: 12px;
  width: 100%;
  padding: 10px 8px;
  text-align: left;
  background: transparent;
  box-shadow: none;
  white-space: normal;
}
.row-body { min-width: 0; }
.row h3 { margin: 0 0 4px; font: 400 19px/1.3 var(--serif); letter-spacing: 0.005em; overflow-wrap: anywhere; color: var(--brass-2); }
.row .meta { margin: 0; color: var(--soft); font-size: 13px; line-height: 1.45; }
.row-arrow { color: var(--brass); font-size: 24px; }
.library-welcome { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 12px; }
.library-welcome .practice-start { min-height: 36px; font-size: 13px; }
.library-welcome .practice-start { text-align: left; justify-content: start; white-space: normal; }
.library-welcome .practice-start:not(.is-main) { background: transparent; box-shadow: none; color: var(--soft); }
.tool-context { max-width: 22ch; font-size: 13px; line-height: 1.45; color: var(--soft); }
@media (min-width: 1001px) and (min-height: 521px) {
  .tool-context { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
button:disabled { cursor: default; opacity: 0.5; }
.slot:disabled, .bar-num:disabled { opacity: 1; }

.thumb {
  flex: 0 0 auto;
  display: block;
  border-radius: var(--r-s);
  outline: 1px solid rgba(255, 255, 255, 0.1);
  outline-offset: -1px;
  background: var(--panel);
  object-fit: cover;
}

.play { min-width: 76px; }
.play[data-state="playing"] { background: var(--mist); }

body.is-learn #learn {
  overflow: auto;
  padding: 0 16px 16px;
  border-radius: 22px;
}

.learn-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px 0 10px;
}

.learn-title { min-width: 0; }
#learn h1 { margin: 0; font-family: var(--serif); font-size: 28px; font-weight: 400; line-height: 1.2; overflow-wrap: anywhere; }
#learn h1:focus { outline: none; }
.piece-modes { display: inline-grid; gap: 4px; }
.share-link { color: var(--soft); font-weight: 500; }
.mode-link { min-width: 72px; min-height: 40px; color: var(--brass-2); font-weight: 600; }
.about { margin: 3px 0 0; color: var(--soft); font-size: 13px; line-height: 1.4; }
.rating { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; margin-top: 4px; margin-left: -6px; }
.stars { display: flex; }
.star {
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--r-s);
  font-size: 20px;
  line-height: 1;
  color: var(--brass-dim);
  background: transparent;
  box-shadow: none;
  transition: color var(--ease);
}
.star.is-on { color: var(--brass); }
.rating-text { color: var(--soft); font-size: 13px; }
.row-rating { color: var(--brass); white-space: nowrap; }
.row-added { white-space: nowrap; }
.row-new {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  vertical-align: 2px;
  font: 600 11px/1.5 var(--sans);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--brass);
}
.mirror-note { margin: 0 0 10px; color: var(--brass-2); font-size: 13px; max-width: 70ch; }

.back { padding: 6px 14px 6px 12px; color: var(--soft); }

.back::before {
  content: "";
  width: 7px;
  height: 7px;
  border-left: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  margin-right: 2px;
}

.deck {
  margin: 0 0 12px;
  padding: 0;
}

.transport { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.stepper { width: 44px; padding: 0; }

.stepper::before {
  content: "";
  width: 10px;
  height: 10px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  margin-left: 7px;
}

.stepper.is-next::before { transform: rotate(-135deg); margin-left: -7px; }
.range { color: var(--brass-2); box-shadow: inset 0 0 0 1px rgba(217, 183, 122, 0.45); }

.tempo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 220px;
  max-width: 340px;
  margin-left: auto;
  color: var(--soft);
  font-size: 13px;
}

.tempo-unit { font-size: 12px; }
.tempo #bpm { color: var(--mist); min-width: 3ch; text-align: right; font-variant-numeric: tabular-nums; }

input[type="range"] {
  flex: 1;
  min-width: 100px;
  height: 44px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--soft); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--soft); }

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  box-sizing: border-box;
  width: 20px;
  height: 20px;
  margin-top: -8px;
  border: 2px solid var(--night);
  border-radius: 50%;
  background: var(--brass);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

input[type="range"]::-moz-range-thumb {
  box-sizing: border-box;
  width: 20px;
  height: 20px;
  border: 2px solid var(--night);
  border-radius: 50%;
  background: var(--brass);
}

.step-btn:disabled { opacity: 0.35; cursor: default; }


.note.left { color: var(--left); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.note.right { color: var(--right); }

.sheet { display: flex; flex-direction: column; gap: 18px; }
.sheet.is-focus { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 10px 16px; }
.sheet.is-focus .part { flex: 1 0 100%; min-width: 0; }
.sheet.is-focus .part.is-folded { display: none; }
.part.is-folded .bars, .part.is-folded .part-done, .sheet.is-focus .part-loop { display: none; }
.part-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-bottom: 8px; }
.part-head h2 { margin: 0; font-family: var(--serif); font-size: 19px; font-weight: 400; line-height: 1.3; color: var(--brass-2); }
.part-bars, .part-done { font-size: 13px; color: var(--soft); }
.part-done { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; margin-left: auto; min-height: 44px; }
.part-done input { width: 16px; height: 16px; margin: 0; accent-color: var(--brass); }

.bars {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, calc(var(--cols) * 34px + 44px)), 1fr));
  gap: 8px;
}

.bar {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.045);
  box-shadow: var(--ring);
  overflow: hidden;
  scroll-margin: 10px;
  transition: box-shadow var(--ease);
}

.bar.in-range { box-shadow: inset 0 0 0 1.5px var(--brass); }

.bar-num {
  border: 0;
  border-right: 1px solid var(--line);
  padding: 0;
  background: rgba(255, 240, 220, 0.03);
  color: var(--soft);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  touch-action: none;
  transition: background-color var(--ease), color var(--ease);
}

.bar.in-range .bar-num { background: var(--brass); color: var(--ink); }
.slots { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); min-width: 0; }

.slot {
  position: relative;
  min-height: 52px;
  padding: 14px 0 4px;
  border: 0;
  border-left: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 20px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: background-color var(--ease), box-shadow var(--ease);
}

.slot[data-count] { border-left-color: var(--line); }

.slot[data-count]::before {
  content: attr(data-count);
  position: absolute;
  top: 3px;
  left: 4px;
  font-size: 12px;
  font-weight: 400;
  color: var(--soft);
}

.slot:not(.hit)::after { content: ""; width: 3px; height: 3px; border-radius: 50%; background: var(--line-2); }
.slot .note + .note::before { content: "+"; color: var(--soft); font-size: 12px; font-weight: 400; margin: 0 1px; }
.slot:has(.note + .note) { font-size: 14px; }
.slot:has(.note + .note) .note + .note::before { font-size: 10px; margin: 0; }
.slot.is-soft { font-size: 15px; }
.slot.is-soft:has(.note + .note) { font-size: 13px; }
.slot.is-soft .note { opacity: 0.75; }

.slot:focus-visible, .bar-num:focus-visible, .chip:focus-visible,
.step-chip:focus-visible, .back:focus-visible, .find:focus-visible { outline-offset: -2px; }

.slot.is-on:focus-visible, .bar.in-range .bar-num:focus-visible { outline-color: var(--ink); }
.slot.hit.is-next { box-shadow: inset 0 0 0 1.5px var(--brass); }
.slot.hit.is-place { background: #3f3a26; box-shadow: inset 0 0 0 1.5px var(--brass); }
.slot.hit.is-on { background: linear-gradient(180deg, #e9cc94, #cfa96a); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45); }
.slot.hit.is-on .note, .slot.hit.is-on .note + .note::before, .slot.hit.is-on::before { color: var(--ink); opacity: 1; }


.practice-panel { min-width: 0; margin: 0; }
.practice-actions, .phrase-navigation { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.practice-mode { flex: 1 1 80px; }
.phrase-navigation { justify-content: space-between; }
.phrase-navigation button { flex: 1 1 100px; }
#practice-position { display: block; color: var(--soft); font-size: 13px; font-weight: 500; }
#practice-target { margin: 8px 0 2px; font-size: 19px; font-weight: 600; overflow-wrap: anywhere; }
#practice-next, #practice-message, .practice-help { margin: 4px 0; font-size: 13px; line-height: 1.5; }
#practice-next, .practice-help { color: var(--soft); }
#practice-message { color: var(--brass-2); }
.practice-tempo { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; margin-top: 8px; }
.practice-tempo input { min-width: 100px; }
.practice-help summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--soft); }
.practice-help summary::before { content: "+"; margin-right: 8px; color: var(--brass); }
.practice-help[open] summary::before { content: "−"; }
.is-practicing .part-head { display: none; }
.is-practicing .sheet { margin: 10px 0; }
.is-practicing .slots { grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); }
.is-practicing .slot { min-height: 52px; }

.scene-loader {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 28px;
  background: var(--night);
  text-align: center;
  overflow: hidden;
  transition: opacity 0.6s ease, visibility 0.6s;
}
.scene-loader.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-glow {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 60vmax;
  height: 60vmax;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(201, 160, 86, 0.14) 0%, rgba(201, 160, 86, 0.04) 35%, transparent 65%);
  animation: loader-breathe 3.2s ease-in-out infinite alternate;
}
.scene-loader > img { position: relative; margin-bottom: 16px; animation: loader-float 3.2s ease-in-out infinite alternate; }
.loader-name { position: relative; font: 700 48px/1.1 var(--serif); letter-spacing: -0.035em; color: var(--mist); }
.scene-loader p { position: relative; margin: 18px 0 24px; max-width: 30ch; color: var(--soft); font-size: 13px; line-height: 1.6; }
.loading-track { position: relative; display: block; width: 220px; height: 3px; border-radius: 2px; background: #2a4248; overflow: hidden; }
.loading-bar {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brass), #f1d9a2);
  transform-origin: left center;
  transform: scaleX(var(--progress, 0));
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
:root[dir="rtl"] .loading-bar { transform-origin: right center; }
.loading-percent { position: relative; margin-top: 10px; font-size: 12px; font-variant-numeric: tabular-nums; letter-spacing: 0.08em; color: var(--brass); }
.scene-loader .slow-hint { margin: 20px 0 0; font-size: 12px; }
#simple-view { position: relative; margin-top: 20px; background: transparent; border-color: var(--line); color: var(--soft); }
@keyframes loader-breathe { from { opacity: 0.55; transform: translate(-50%, -50%) scale(0.9); } to { opacity: 1; transform: translate(-50%, -50%) scale(1.08); } }
@keyframes loader-float { from { transform: translateY(0); } to { transform: translateY(-6px); } }

@media (min-width: 1001px) and (max-height: 700px) {
  body.is-learn { --pan-h: min(52vh, 380px); }
}

@media (min-width: 1001px) and (min-height: 521px) and (max-height: 780px) {
  :root { --pad: 16px; --pan-h: min(52vh, 460px); }
  body { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .top { min-height: 56px; }
  .brand { font-size: 28px; }
  .brand img { width: 30px; height: 30px; }
  .split { gap: 12px 16px; }
  .library-head { position: static; padding: 10px 16px 6px; }
  #dock .library-head h2, #learn h1 { font-size: 24px; }
  .library-title { margin-bottom: 6px; }
  .library-site-nav a { min-height: 28px; }
  .library-welcome { padding-bottom: 8px; }
  .find { min-height: 36px; margin-bottom: 6px; padding-top: 6px; padding-bottom: 6px; }
  .chip, .chip[aria-pressed="true"] { min-height: 32px; padding: 4px 0 6px; }
  .list-tools { margin-top: 0; }
  .list-options-toggle { min-height: 32px; }
  #dock .kind { margin: 14px 0 4px; }
  .row .open { padding: 7px 8px; grid-template-columns: 42px minmax(0, 1fr) 16px; }
  .row .thumb { width: 42px; height: 42px; }
  .row h3 { font-size: 17px; margin-bottom: 2px; }
  .learn-head { padding: 10px 0 8px; }
  .deck { margin-bottom: 8px; }
  .sheet { gap: 12px; }
}

@media (min-width: 1001px) and (max-width: 1180px) {
  .split { grid-template-columns: minmax(340px, 11fr) minmax(0, 9fr); }
  body.is-learn .split { grid-template-columns: minmax(340px, 11fr) minmax(0, 9fr); }
  .tools { gap: 4px; }
  .top #listen .tool-text { display: none; }
  .top .scene-pick { max-width: 200px; }
}

@media (min-width: 1001px) {
  @container (max-width: 560px) {
    .learn-head { grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; }
    .learn-head .back { grid-column: 1; grid-row: 1; justify-self: start; }
    .learn-head .piece-modes { grid-column: 2; grid-row: 1; justify-self: end; }
    .learn-head .learn-title { grid-column: 1 / -1; grid-row: 2; }
    .legend { font-size: 12px; }
  }
}

@media (pointer: fine) {
  .motion-controls { display: none; }
}

@media (max-width: 1000px), (max-height: 520px) {
  :root { --pad: 14px; --pan-h: clamp(200px, 34vh, 300px); }
  body.is-learn { --pan-h: clamp(155px, 22vh, 200px); }
  body { height: auto; min-height: 100vh; min-height: 100dvh; overflow: auto; }
  .wrap { display: block; }
  .top { min-height: 56px; }
  .brand { font-size: 28px; }
  .brand img { width: 30px; height: 30px; }
  .top #tools-toggle { display: inline-flex; min-height: 44px; }
  .tools {
    display: none;
    position: absolute;
    top: calc(100% - 2px);
    right: 0;
    flex-direction: column;
    align-items: stretch;
    width: min(280px, calc(100vw - 2 * var(--pad)));
    max-height: calc(100dvh - 72px);
    overflow: auto;
    overscroll-behavior: contain;
    gap: 6px;
    padding: 8px;
    border-radius: 18px;
    transform-origin: top right;
  }
  body.tools-open .tools { display: flex; animation: menu-in 160ms ease; }
  .tools button, .top #listen, .top #explore-world { min-height: 44px; justify-content: start; }
  .top .scene-pick { max-width: none; }
  .top .scene-pick select { min-height: 44px; }
  .motion-controls { flex-direction: column; align-items: stretch; }
  .split { display: flex; flex-direction: column; gap: 12px; }
  .pan-stick {
    position: static;
    margin: 0 calc(-1 * var(--pad));
    padding: 6px var(--pad) 8px;
    gap: 6px;
    background: transparent;
  }
  .pan-stick, body.is-learn .pan-stick { align-self: stretch; }
  body:not(.is-learn) .caption { display: none; }
  .caption { min-height: 28px; padding: 4px 14px; font-size: 14px; background: transparent; }
  .game { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "medal read streak" "stats stats stats" "tier tier tier"; gap: 8px 12px; padding: 10px 14px; border-radius: 18px; }
  .game-medallion { width: 56px; height: 56px; }
  .game-note { font-size: 26px; }
  .game-word { font-size: 18px; }
  .game-streak strong { font-size: 36px; }
  .game-stats { grid-auto-flow: column; justify-content: space-between; padding-left: 0; border-left: 0; }
  .game-stats div { flex-direction: column; align-items: center; gap: 2px; }
  .game-tier { padding-top: 8px; }
  .game-tier-next { display: none; }
  body:not(.is-learn) #learn { display: none; }
  body.is-learn #dock { display: none; }
  #dock { overflow: visible; }
  .library-head { position: static; }
  .row .open { min-height: 44px; }
  body.is-learn #learn { overflow: visible; padding: 0 12px 16px; }
  .learn-head { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .piece-modes { display: grid; grid-column: 1 / -1; margin-bottom: 4px; }
  .learn-head .back { justify-self: start; margin-left: -6px; padding-left: 8px; background: transparent; box-shadow: none; }
  .tools .tool-context { max-width: none; padding: 0 6px 4px; }
  #learn h1 { font-size: 22px; }
  .stepper { width: 44px; min-height: 44px; }
  .tempo { flex: 1 1 100%; max-width: none; margin-left: 0; }
  .part-done { padding: 0 4px; }
  .part-bars { display: none; }
  .part-done input { width: 20px; height: 20px; }
}

@media (min-width: 600px) and (max-width: 1000px) and (min-height: 521px) {
  :root { --pad: 20px; --pan-h: clamp(220px, 36vh, 340px); }
  body.is-learn { --pan-h: min(25vh, 250px); }
}

@media (max-height: 520px) and (min-width: 600px) {
  body.is-learn { height: 100dvh; min-height: 0; overflow: hidden; --pan-h: min(62vh, 260px); }
  body.is-learn .wrap { display: flex; min-height: 0; }
  body.is-learn .split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, 32%); grid-template-rows: minmax(0, 1fr); gap: 12px; }
  body.is-learn .pan-stick { margin: 0; padding: 0; align-self: center; }
  body.is-learn #learn { overflow: auto; }
  .learn-head { grid-template-columns: auto minmax(0, 1fr) auto; }
  .piece-modes { display: inline-grid; grid-column: auto; margin-bottom: 0; }
  .about, .mirror-note { display: none; }
}

@media (hover: none) and (pointer: coarse) {
  .star { min-width: 40px; min-height: 44px; font-size: 22px; }
  .mode-link { min-height: 44px; }
  .pick select { font-size: 16px; }
}

@media (hover: hover) {
  #listen:hover, #tools-toggle:hover, #explore-world:hover, #simple-view:hover, .open:hover, .back:hover,
  .stepper:hover, .loop:hover, .range:hover, .chip:hover, .step-btn:hover, .part-loop:hover,
  .step-chip:hover, .pick:hover {
    background-color: var(--fill-2);
  }
  .pick:hover::after { color: var(--mist); }
  #listen[aria-pressed="true"]:hover, .loop[aria-pressed="true"]:hover,
  .chip[aria-pressed="true"]:hover, .part-loop[aria-pressed="true"]:hover, .step-btn.is-main:hover,
  .step-chip.is-current:hover {
    background: linear-gradient(180deg, #f3dcae, #d9b77a);
  }
  .step-btn:disabled:hover { background: var(--fill); }
  .row:hover { background: rgba(255, 240, 220, 0.04); }
  .stars:hover .star { color: var(--brass-2); }
  .stars .star:hover ~ .star { color: var(--brass-dim); }
  .row.is-current:hover { background: rgba(217, 183, 122, 0.16); }
  .row h3 a:hover { color: var(--brass-2); }
  .library-site-nav a:hover { color: var(--brass-2); }
  .chip:hover { background-color: transparent; color: var(--mist); }
  .list-options-toggle:hover { color: var(--mist); }
  .option:hover { background-color: rgba(255, 240, 220, 0.06); color: var(--mist); }
  .play:hover { filter: brightness(1.08); }
  .row-side .row-play:hover, .row-side .row-play:focus-visible { background: rgba(7, 20, 29, 0.65); border-color: var(--brass); }
  .back:hover { color: var(--mist); }
  .bar-num:hover { background: var(--brass); color: var(--ink); }
  .slot.hit:not(.is-on):not(.is-place):hover { background: rgba(255, 240, 220, 0.06); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

body.is-exploring { overflow: hidden; }
body.is-exploring .wrap { visibility: hidden; }
body.is-exploring .world { pointer-events: auto; z-index: 0; cursor: grab; touch-action: none; }
body.is-exploring .world:active { cursor: grabbing; }
.explore-hud { position: fixed; inset: 0; z-index: 8; padding: 36px; display: grid; grid-template-columns: minmax(0, 1fr) 310px; grid-template-rows: auto 1fr auto; gap: 24px; pointer-events: none; background: linear-gradient(#06172085, transparent 30%, transparent 65%, #06172095); color: #f3ead6; }
.explore-hud[hidden] { display: none; }
.explore-heading { grid-column: 1 / -1; display: flex; align-items: start; justify-content: space-between; gap: 24px; text-shadow: 0 2px 18px #041722; }
.explore-eyebrow { margin: 0 0 10px; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: #e3c38b; }
.explore-heading h1 { margin: 0; font: 650 clamp(28px, 3.5vw, 48px)/1.15 var(--sans); letter-spacing: -0.025em; }
#explore-description { margin: 12px 0 0; max-width: 42ch; font-size: 14px; line-height: 1.6; }
.explore-return, .explore-places button { pointer-events: auto; border: 1px solid #e3c38b66; color: #f3ead6; border-radius: 5px; background: #122b33e8; cursor: pointer; min-height: 44px; padding: 10px 16px; font: 500 13px var(--sans); }
.explore-return { flex: 0 0 auto; }
.explore-return span { margin-left: 16px; color: #e3c38b; }
.explore-music { pointer-events: auto; grid-column: 2; align-self: center; max-height: 100%; min-height: 0; overflow: auto; padding: 18px; border: 1px solid #e3c38b44; border-radius: 8px; background: #10252eea; box-shadow: 0 14px 45px #06141c55; scrollbar-width: thin; }
.explore-music-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.explore-music h2 { margin: 0; font: 650 20px var(--sans); }
.explore-count { font-size: 12px; color: #d0c4aa; white-space: nowrap; }
.explore-piece { display: flex; align-items: center; gap: 12px; padding: 10px 0; color: #f3ead6; text-decoration: none; border-top: 1px solid #e3c38b25; }
.explore-piece img { border-radius: 5px; object-fit: cover; flex: 0 0 auto; }
.explore-piece > span:not(.explore-piece-arrow) { min-width: 0; }
.explore-piece strong { display: block; font: 600 17px/1.3 var(--sans); }
.explore-piece small { display: block; font-size: 12px; margin-top: 5px; color: #c5c5b6; }
.explore-piece-arrow { margin-left: auto; color: #e3c38b; }
.explore-piece:hover strong { color: #e3c38b; }
.explore-places { grid-column: 1 / -1; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.explore-places button[aria-pressed="true"] { background: #cfad6d; color: #122b33; border-color: #f0dba9; box-shadow: 0 0 24px #cfad6d33; }
.explore-hud button:focus-visible, .explore-hud a:focus-visible { outline: 2px solid #f5d68d; outline-offset: 4px; }
@media (max-width: 650px) {
  body.is-learn:has(.deck) .about { display: none; }
  .explore-hud { padding: 20px 16px max(16px, env(safe-area-inset-bottom)); grid-template-columns: 1fr; grid-template-rows: auto 1fr auto auto; gap: 14px; }
  .explore-heading { gap: 10px; }
  .explore-heading h1 { font-size: 28px; }
  .explore-eyebrow { font-size: 12px; letter-spacing: 0.08em; }
  #explore-description { font-size: 13px; max-width: 27ch; }
  .explore-return { width: 80px; padding: 8px; font-size: 13px; }
  .explore-return span { display: none; }
  .explore-music { grid-column: 1; grid-row: 3; padding: 12px; max-height: 29vh; }
  .explore-music h2 { font-size: 18px; }
  .explore-pieces { display: flex; gap: 16px; overflow-x: auto; scroll-snap-type: x proximity; }
  .explore-piece { flex: 0 0 220px; scroll-snap-align: start; }
  .explore-piece strong { font-size: 17px; }
  .explore-places { grid-row: 4; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .explore-places button { padding: 8px 5px; font-size: 12px; }
}
@media (max-height: 540px) and (min-width: 651px) {
  .explore-hud { padding: 18px; gap: 10px; grid-template-rows: auto minmax(0, 1fr) auto; }
  .explore-heading h1 { font-size: 32px; }
  #explore-description { margin-top: 6px; font-size: 13px; }
  .explore-music { grid-row: 1 / 3; margin-top: 54px; align-self: stretch; }
}

:root[lang="fa"] {
  --serif: "Markazi Text", Georgia, "Times New Roman", serif;
  --sans: "Vazirmatn", system-ui, -apple-system, "Segoe UI", sans-serif;
}

:root[lang="fa"] body { font-size: 15.5px; line-height: 1.7; }
:root[lang="fa"] { --script: "Aref Ruqaa", var(--serif); }
:root[lang="fa"] .brand, :root[lang="fa"] .loader-name { font-family: "Aref Ruqaa", var(--serif); font-weight: 700; letter-spacing: 0; }
:root[lang="fa"] .brand { font-size: 30px; }
:root[lang="fa"] .field-name { font-weight: 700; }
:root[lang="fa"] h1, :root[lang="fa"] h2, :root[lang="fa"] h3, :root[lang="fa"] .row h3,
:root[lang="fa"] #learn h1, :root[lang="fa"] .part-head h2, :root[lang="fa"] .explore-heading h1,
:root[lang="fa"] .row-new, :root[lang="fa"] #dock .kind, :root[lang="fa"] .explore-eyebrow { letter-spacing: 0; }
:root[lang="fa"] #dock .kind, :root[lang="fa"] .row-new, :root[lang="fa"] .explore-eyebrow, :root[lang="fa"] .option-row-name { text-transform: none; font-size: 13px; }
:root[lang="fa"] .explore-heading h1 { font-family: var(--serif); font-weight: 600; }

[dir="rtl"] .tools { justify-content: start; }
[dir="rtl"] .top #listen, [dir="rtl"] .top #explore-world, [dir="rtl"] .top #tools-toggle { padding: 6px 11px 6px 14px; }
[dir="rtl"] .lang-switch { padding: 6px 11px 6px 14px; }
[dir="rtl"] .row .open, [dir="rtl"] .library-welcome .practice-start { text-align: right; }
[dir="rtl"] .rating { margin-left: 0; margin-right: -6px; }
[dir="rtl"] .row-new { margin-left: 0; margin-right: 4px; }
[dir="rtl"] .back { padding: 6px 12px 6px 14px; }
[dir="rtl"] .back::before { transform: rotate(-135deg); margin-right: 0; margin-left: 2px; }
[dir="rtl"] .tempo { margin-left: 0; margin-right: auto; }
[dir="rtl"] .tempo #bpm { text-align: left; }
[dir="rtl"] .part-done { margin-left: 0; margin-right: auto; }
[dir="rtl"] .practice-help summary::before { margin-right: 0; margin-left: 8px; }
[dir="rtl"] #dock .kind::after { background: linear-gradient(270deg, var(--line-2), transparent); }
[dir="rtl"] .explore-return span { margin-left: 0; margin-right: 16px; }
[dir="rtl"] .explore-piece-arrow { margin-left: 0; margin-right: auto; }
[dir="rtl"] .explore-piece-arrow, [dir="rtl"] .explore-return span, [dir="rtl"] .row-arrow { display: inline-block; transform: scaleX(-1); }
[dir="rtl"] .sheet, [dir="rtl"] #pan, [dir="rtl"] .mic-meter, [dir="rtl"] input[type="range"] { direction: ltr; }
[dir="rtl"] .tempo #bpm, [dir="rtl"] .chip-count, [dir="rtl"] .row-rating, [dir="rtl"] .explore-count { unicode-bidi: isolate; }
@media (max-width: 1000px), (max-height: 520px) {
  [dir="rtl"] .tools { right: auto; left: 0; transform-origin: top left; }
  [dir="rtl"] .learn-head .back { margin-left: 0; margin-right: -6px; padding-left: 14px; padding-right: 8px; }
  [dir="rtl"] .tempo { margin-right: 0; }
}
[dir="rtl"] .about, [dir="rtl"] #learn h1, [dir="rtl"] .row h3, [dir="rtl"] .explore-piece strong, [dir="rtl"] .part-head h2 { unicode-bidi: plaintext; }
[dir="rtl"] .game-stats { padding-left: 0; padding-right: 16px; border-left: 0; border-right: 1px solid var(--line); }
[dir="rtl"] .game-tier-next { margin-left: 0; margin-right: auto; }
@media (max-width: 1000px), (max-height: 520px) {
  [dir="rtl"] .game-stats { padding-right: 0; border-right: 0; }
}
