@font-face {
  font-family: 'Scoreboard';
  src: url('/media/scoreboard.woff2') format('woff2');
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #f6f1e5;
  --cream: #fffaf0;
  --ink: #19383a;
  --muted: #506763;
  --rule: #c9cbb8;
  --teal: #186c70;
  --orange: #c74429;
  --gold: #ffcd72;
  font-family: 'Scoreboard', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-width: 300px;
  min-height: 100vh;
  background-image: radial-gradient(#6a674425 .65px, transparent .79px);
  background-size: 5px 5px;
}
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, [tabindex="0"]:focus-visible { outline: 3px solid #b34025; outline-offset: 3px; }
button:disabled { cursor: default; }
button, a, input { touch-action: manipulation; }
h1, h2, h3, p { margin: 0; }
.shell {
  width: min(1240px, calc(100% - 72px));
  margin: 0 auto;
  padding: 0 0 max(30px, env(safe-area-inset-bottom));
}
.mast {
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand, .mast-actions, .scoreboard { display: flex; align-items: center; }
.brand {
  background: none;
  border: none;
  padding: 4px 0;
  font-size: 16px;
  font-weight: 850;
  gap: 10px;
  white-space: nowrap;
}
.brand-ball {
  display: block;
  width: 31px;
  height: 31px;
  background: url('/media/ball.webp') center / contain no-repeat;
  filter: drop-shadow(0 1px 1px #34404544);
}
.mast-actions { gap: 9px; }
.square, .scoreboard {
  min-width: 42px;
  min-height: 43px;
  border: 1px solid #bdc2ac;
  border-radius: 9px;
  background: #fff9ed;
}
.square { display: inline-grid; place-items: center; padding: 0; font-size: 23px; font-weight: 850; }
.sound-button { position: relative; font-family: sans-serif; }
.sound-button[aria-pressed="true"]::after {
  content: ''; position: absolute; width: 21px; height: 2px;
  background: var(--orange); transform: rotate(-44deg);
}
.scoreboard { gap: 6px; padding: 0 12px; color: #34554f; }
.score-label { font-size: 12px; font-weight: 720; }
.scoreboard strong { font-size: 21px; color: var(--ink); font-weight: 900; line-height: 1; }
.score-total, .scoreboard strong { font-variant-numeric: tabular-nums; }
.score-total { font-size: 13px; font-weight: 740; align-self: center; }
.cover {
  position: relative;
  isolation: isolate;
  min-height: clamp(490px, 47vw, 580px);
  overflow: hidden;
  display: flex;
  align-items: center;
  border: 2px solid #8d9e88;
  border-radius: 24px;
  background:
    radial-gradient(ellipse at 15% 7%, #fffdf2 13%, transparent 72%),
    linear-gradient(111deg, #f9eed1 23%, #e6ebcd 78%);
  box-shadow: 0 5px 0 #c5c9af, 0 20px 42px -30px #475b4880;
}
.cover::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(#53593d34 .55px, transparent .77px);
  background-size: 4px 4px;
  opacity: .36;
}
.cover-art {
  position: absolute;
  z-index: -1;
  inset: 0 0 0 auto;
  width: 73%;
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent 0%, #000 19%);
}
.cover-art img { width: 100%; height: 100%; object-fit: cover; object-position: 64% center; display: block; }
.cover-copy {
  position: relative;
  z-index: 1;
  width: 52%;
  padding: 42px 0 46px clamp(37px, 5.25vw, 78px);
}
.cover-label {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 20px;
  font-size: 13px;
  font-weight: 800;
  color: #35615e;
  letter-spacing: .05em;
}
.cover-label span {
  width: 18px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--teal);
  box-shadow: inset 0 0 0 2px #e9ebce;
  background: var(--teal);
  transform: rotate(-20deg);
}
.cover-copy h1 {
  font-size: clamp(62px, 7.27vw, 112px);
  font-weight: 900;
  font-style: normal;
  line-height: .995;
  letter-spacing: -.077em;
  color: #173c3d;
  white-space: nowrap;
  transform: skew(-5deg);
  transform-origin: bottom left;
}
.cover-copy h1 span { display: block; }
.cover-copy h1 span + span {
  margin-top: .095em;
  color: #c74429;
  text-shadow: 2px 2px #fff0c9, 4px 4px #d79766;
}
.cover-description {
  margin-top: 26px;
  font-size: clamp(14px, 1.44vw, 19px);
  font-weight: 660;
  line-height: 1.5;
  color: #36544b;
}
.cover-actions { display: grid; justify-items: start; gap: 13px; margin-top: 28px; }
.button {
  min-height: 43px;
  border: 1px solid transparent;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  font-size: 14px;
  font-weight: 790;
  letter-spacing: .015em;
  white-space: nowrap;
  transition: background-color .15s, transform .15s;
}
.button:active { transform: translateY(2px); }
.primary { background: var(--orange); border-color: #ab3e2b; box-shadow: 0 3px 0 #8f3426; color: #fff9ed; }
.primary:hover { background: #ae3925; }
.paper { background: #fff9e9; border-color: #b8c0a9; }
.paper:hover, .square:hover, .scoreboard:hover { background: #efe9ce; }
.start-button { padding: 0 17px 0 22px; min-width: 205px; min-height: 58px; justify-content: space-between; font-size: 19px; border-radius: 12px; }
.start-button span { font-family: sans-serif; font-size: 25px; line-height: 1; }
.side-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.side-actions .button { min-height: 40px; }

.chapters { margin-top: 21px; display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.chapter-card {
  --chapter: #e3eee0;
  min-height: 94px;
  position: relative;
  display: grid;
  grid-template-columns: minmax(64px,33%) 1fr;
  align-items: stretch;
  padding: 0;
  text-align: left;
  overflow: hidden;
  border: 1px solid #b1bda9;
  border-radius: 12px;
  background: var(--chapter);
}
.chapter-card:hover { border-color: #386866; }
.chapter-card:nth-child(2) { --chapter: #f5e7cd; }
.chapter-card:nth-child(3) { --chapter: #e7edcf; }
.chapter-card:nth-child(4) { --chapter: #ebe6f2; }
.chapter-card img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: 55% center; }
.chapter-info { display: grid; align-content: center; gap: 4px; padding: 8px 11px; }
.chapter-info strong { font-size: clamp(13px, 1.33vw, 17px); font-weight: 880; white-space: nowrap; }
.chapter-info small { color: #4d655a; font-weight: 720; font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chapter-meter { display: block; height: 3px; margin-top: 3px; border-radius: 3px; background: #234d4430; overflow: hidden; max-width: 83px; }
.chapter-meter span { display: block; height: 100%; width: var(--fill); background: #367779; }

.page { border-top: 1px solid var(--rule); padding: clamp(27px, 5.7vw, 68px) 0 0; }
.page-head { display: grid; justify-items: start; gap: 10px; margin-bottom: 25px; }
.page-head h1 { font-size: clamp(35px, 5vw, 62px); font-weight: 900; letter-spacing: -.052em; line-height: 1.1; }
.page-head p { font-size: 15px; color: #46625a; line-height: 1.6; }
.back { min-height: 39px; border: 0; background: none; padding: 0 7px 0 0; font-weight: 800; color: #376765; }
.back span { display: inline-block; margin-right: 4px; font: 25px/1 sans-serif; vertical-align: -.07em; }
.back:hover { color: #a73726; }
.chapter-tabs { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 15px; }
.tab {
  min-height: 42px;
  background: #fff9ec;
  border: 1px solid #b6beaa;
  border-radius: 9px;
  padding: 0 13px;
  font-size: 14px;
  font-weight: 780;
}
.tab[aria-pressed="true"] { background: #23666a; color: #fff9e4; border-color: #23666a; }
.level-list {
  display: flex;
  gap: 13px;
  overflow: auto hidden;
  scroll-snap-type: x mandatory;
  padding: 5px 4px 14px;
  scrollbar-color: #81968d transparent;
  overscroll-behavior-inline: contain;
}
.level-card {
  flex: 0 0 clamp(167px, 21vw, 244px);
  display: grid;
  overflow: hidden;
  background: #fff9eb;
  border-radius: 14px;
  border: 1px solid #aab8a7;
  scroll-snap-align: start;
  text-align: start;
  padding: 0;
  box-shadow: 0 3px 0 #cad0bc;
}
.level-card:enabled:hover { border-color: #2d6c68; background: #f1f3df; }
.level-card:disabled .level-picture img { filter: saturate(.62) brightness(.84); }
.level-picture { position: relative; aspect-ratio: 1.5; overflow: hidden; background: #c4d6c3; }
.level-picture img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-number {
  position: absolute;
  left: 9px;
  top: 9px;
  border-radius: 7px;
  border: 1px solid #54736a85;
  padding: 3px 7px;
  background: #fff8e8;
  color: #163d40;
  font-size: 13px;
  font-weight: 870;
  font-variant-numeric: tabular-nums;
}
.card-info { display: grid; padding: 12px 12px 14px; gap: 6px; }
.card-info strong { font-size: 18px; font-weight: 870; }
.card-info small { font-size: 12px; color: #475f56; font-weight: 710; }
.list-footer { display: flex; justify-content: end; gap: 7px; margin-top: 8px; }

.collection-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; }
.collect-card {
  position: relative;
  background: #fff9ea;
  border: 1px solid #b4bfab;
  border-radius: 14px;
  padding: clamp(12px, 1.6vw, 19px);
  display: grid;
  gap: 7px;
  align-content: start;
}
.collect-card.is-locked .collect-image { filter: grayscale(.85); opacity: .57; }
.collect-image {
  aspect-ratio: 1.65;
  border-radius: 9px;
  background: radial-gradient(ellipse at 50% 50%, #f4f3d7, #dfebd8);
  display: grid;
  place-items: center;
  overflow: hidden;
  margin-bottom: 5px;
}
.collect-image img { width: min(55%, 104px); height: auto; filter: drop-shadow(1px 7px 4px #163e4234); }
.collect-card h2 { font-size: 18px; font-weight: 880; }
.collect-card p { font-size: 12px; color: #496157; line-height: 1.5; }
.collect-card .button { justify-self: start; margin-top: 4px; min-height: 35px; font-size: 12px; padding-inline: 10px; }
.collect-card .button[aria-pressed="true"] { color: #fff9eb; background: #2c6863; border-color: #2c6863; }
.empty-bonus { margin-top: 15px; color: var(--muted); font-weight: 700; }

.shell.is-playing { width: min(1240px, calc(100% - 42px)); padding-bottom: 8px; }
.is-playing .mast { height: 59px; }
.play .game-frame { margin-inline: auto; width: min(100%, calc((100vh - 174px) * 1.7778)); width: min(100%, calc((100svh - 174px) * 1.7778)); min-width: min(100%, 630px); }
.game-head { min-height: 69px; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-bottom: 8px; }
.level-heading, .game-actions { display: flex; align-items: center; gap: 10px; }
.level-heading { min-width: 0; }
.game-back {
  width: 40px;
  min-width: 40px;
  height: 45px;
  padding: 0 1px 3px 0;
  font: 31px/1 sans-serif;
  border: 1px solid #b8c0aa;
  border-radius: 9px;
  background: #fff8ea;
}
.level-labels p { color: #41675e; font-size: 12px; font-weight: 740; letter-spacing: .045em; }
.level-labels h1 { font-size: clamp(21px, 2.8vw, 36px); line-height: 1.18; font-weight: 900; letter-spacing: -.03em; }
.title-switch { padding: 0; border: 0; background: none; font: inherit; }
.title-switch:hover { text-decoration: underline dotted #b74f36; text-underline-offset: 6px; }
.game-actions { gap: 6px; }
.game-actions .button { min-height: 41px; padding-inline: 11px; }
.game-actions .button > span:not(.hint-mark) { font: 20px/1 sans-serif; }
.game-status { white-space: nowrap; font-size: 12px; color: #77532d; font-weight: 800; }
.hint-mark { display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: #f1d184; color: #654d2d; font: 800 12px/1 sans-serif; }
.stage-shell { border: 1px solid #8b9c8c; border-radius: 15px; overflow: hidden; box-shadow: 0 4px 0 #b9c4ae; background: #f9f2df; }
.stage {
  aspect-ratio: 16 / 9;
  position: relative;
  overflow: hidden;
  background: #b9d6ca center center / cover no-repeat;
  outline-offset: -4px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.stage[data-scene="practice"] { background-image: url('/media/practice.webp'); }
.stage[data-scene="gym"] { background-image: url('/media/gym.webp'); }
.stage[data-scene="outdoor"] { background-image: url('/media/outdoor.webp'); }
.stage[data-scene="stars"] { background-image: url('/media/stars.webp'); }
.stage > canvas { display: block; width: 100%; height: 100%; position: absolute; inset: 0; }
.stage-toast, .loading {
  position: absolute;
  z-index: 1;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(12px, 1.35vw, 16px);
  font-weight: 790;
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid #afbd9a;
  background: #fff8df;
  color: #203e37;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}
.stage-toast { top: 17px; box-shadow: 0 2px 0 #40574045; }
.loading { top: 46%; }
.loading:has(button) { pointer-events: auto; white-space: normal; min-width: 180px; }
.loading button { margin-top: 10px; }
.controls {
  min-height: 41px;
  padding: 5px 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: #3d625c;
  font-size: 12px;
  font-weight: 710;
}
.controls kbd { display: inline-grid; place-items: center; font: 750 11px/1 'Scoreboard', sans-serif; color: #1e5250; border: 1px solid #aebdae; border-bottom-width: 2px; background: #fffcef; border-radius: 4px; min-width: 20px; min-height: 19px; margin-right: 3px; }
.controls .space { padding-inline: 4px; margin-left: 8px; }
.legend-divider { vertical-align: middle; display: inline-block; width: 1px; height: 12px; background: #a5b8aa; margin: 0 8px; }
.touch-legend { display: none; }
#frame-index { white-space: nowrap; font-variant-numeric: tabular-nums; }

.dialog {
  width: min(425px, calc(100% - 38px));
  max-height: calc(100% - 35px);
  overflow: auto;
  border: 2px solid #8a9c88;
  border-radius: 18px;
  background: #fff9e9;
  color: var(--ink);
  padding: 28px;
  box-shadow: 0 7px 0 #789183, 0 24px 65px #122f3b70;
}
.dialog::backdrop { background: #102f3eb5; backdrop-filter: blur(4px); }
.dialog h2 { font-size: clamp(27px, 6vw, 35px); font-weight: 900; letter-spacing: -.05em; }
.close { position: absolute; top: 10px; right: 11px; width: 38px; height: 38px; display: grid; place-items: center; font: 26px/1 sans-serif; border-radius: 50%; border: none; background: transparent; }
.close:hover { background: #eee5ca; }
.settings-list { display: grid; margin: 17px 0 22px; }
.settings-list label { display: flex; justify-content: space-between; align-items: center; min-height: 56px; border-top: 1px solid #d8decd; font-weight: 790; cursor: pointer; }
.settings-list input { appearance: none; border: 1px solid #909b8f; width: 44px; height: 26px; margin: 0 0 0 15px; border-radius: 25px; background: #d4d8c7; cursor: pointer; position: relative; }
.settings-list input::before { content: ''; width: 18px; height: 18px; position: absolute; left: 3px; top: 3px; border-radius: 50%; background: #fffbee; box-shadow: 0 1px 1px #0004; }
.settings-list input:checked { background: #2d7470; border-color: #2d7470; }
.settings-list input:checked::before { left: 21px; }
.dialog-actions { display: flex; gap: 8px; justify-content: end; }
.dialog-wide { width: 100%; }
.clue-text { margin: 14px 0 22px; min-height: 48px; line-height: 1.7; font-weight: 660; }
.victory { text-align: center; }
.victory .dialog-actions { justify-content: center; margin-top: 20px; }
.victory p { margin-top: 9px; color: #4b665b; font-size: 14px; line-height: 1.65; font-weight: 710; }
.victory-art { position: relative; width: 160px; height: 101px; margin: 0 auto 9px; }
.victory-art img { transform: rotate(-12deg); animation: victory-hop .58s cubic-bezier(.22,.54,.42,1) both; }
.victory-art span { position: absolute; color: #b34d2e; font-size: 24px; }
.victory-art span:nth-child(2) { left: 10px; top: 13px; }
.victory-art span:nth-child(3) { right: 10px; top: 38px; color: #2e7974; }
.victory-art span:nth-child(4) { right: 28px; top: 2px; font-size: 15px; }
@keyframes victory-hop { from { transform: translateY(21px) rotate(-66deg) scale(.6); } 65% { transform: translateY(-8px) rotate(4deg); } to { transform: rotate(-12deg); } }

@media (pointer: coarse) {
  .touch-legend { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0 4px; }
  .touch-legend b:not(:first-child) { margin-left: 8px; }
  .keyboard-legend { display: none; }
}
@media (max-width: 920px) {
  .shell { width: calc(100% - 39px); }
  .chapters { gap: 8px; }
  .chapter-info { padding-inline: 8px; }
  .collection-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 700px) {
  .shell, .shell.is-playing { width: calc(100% - 24px); }
  .mast { height: 60px; }
  .brand { font-size: 13px; gap: 6px; }
  .brand-ball { width: 28px; height: 28px; }
  .scoreboard { padding: 0 7px; gap: 3px; }
  .scoreboard strong { font-size: 17px; }
  .score-label { font-size: 10px; }
  .score-total { font-size: 11px; }
  .square, .scoreboard { min-height: 37px; min-width: 36px; }
  .mast-actions { gap: 5px; }
  .cover { min-height: 0; align-items: start; border-radius: 19px; }
  .cover-art { width: 100%; height: auto; inset: var(--art-top, 151px) 0 auto 0; aspect-ratio: 1.28; mask-image: linear-gradient(180deg, transparent 0%, #000 14%, #000 87%, transparent 100%); }
  .cover-art img { object-fit: cover; object-position: center; }
  .cover-copy { width: 100%; padding: 23px 20px 21px; }
  .cover-copy h1 { font-size: clamp(34px, 9.6vw, 66px); letter-spacing: -.069em; transform: skew(-5deg); }
  .cover-copy h1 span { display: inline-block; }
  .cover-copy h1 span + span { margin-top: 0; }
  .cover-label { margin-bottom: 9px; font-size: 11px; }
  .cover-description { margin-top: 13px; font-size: clamp(12px, 3.5vw, 16px); }
  .cover { --art-top: max(106px, calc(65px + 11.5vw)); }
  .cover-actions { gap: 8px; margin-top: clamp(206px, 60vw, 385px); width: 100%; }
  .start-button { width: 100%; min-height: 48px; font-size: 17px; }
  .side-actions { display: grid; grid-template-columns: 1fr 1.35fr 1fr; width: 100%; gap: 5px; }
  .side-actions .button { padding-inline: 6px; min-height: 37px; font-size: 12px; }
  .chapters { margin-top: 13px; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
  .chapter-card { min-height: 68px; grid-template-columns: minmax(44px,33%) 1fr; }
  .chapter-info { gap: 2px; }
  .chapter-meter { margin-top: 2px; }
  .page { padding-top: 19px; }
  .page-head { margin-bottom: 18px; }
  .page-head p { font-size: 13px; }
  .tab { min-height: 39px; padding-inline: 8px; font-size: 12px; }
  .level-list { margin-inline: -4px; }
  .collection-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .is-playing .mast { height: 49px; }
  .game-head { min-height: 65px; }
  .game-back { height: 41px; min-width: 32px; width: 32px; font-size: 26px; }
  .level-heading, .game-actions { gap: 5px; }
  .level-labels p { font-size: 10px; }
  .level-labels h1 { font-size: clamp(18px, 4.6vw, 25px); }
  .game-actions .button { gap: 3px; font-size: 12px; padding-inline: 6px; min-height: 39px; }
  .game-status { position: absolute; z-index: 2; right: 6px; top: 6px; border-radius: 7px; background: #fff8e6; padding: 4px 7px; pointer-events: none; font-size: 10px; }
  .game-frame { position: relative; }
  .play .game-frame { width: 100%; min-width: 0; }
  .stage-shell { border-radius: 12px; }
  .controls { padding-inline: 7px; font-size: 10px; }
  .stage-toast { top: 11px; }
}
@media (max-width: 700px) and (orientation: portrait) {
  .stage { aspect-ratio: auto; height: clamp(340px, calc(100vh - 205px), 640px); height: clamp(340px, calc(100svh - 205px), 640px); }
  .game-status { top: auto; bottom: 48px; }
}
@media (max-height: 530px) and (orientation: landscape) {
  .shell.is-playing { width: calc(100% - 18px); }
  .is-playing .mast { height: 38px; }
  .is-playing .game-head { min-height: 49px; padding-bottom: 4px; }
  .is-playing .game-head h1 { font-size: 20px; }
  .play .game-frame { width: min(100%, calc((100svh - 118px) * 1.7778)); min-width: 0; }
  .controls { min-height: 28px; }
  .game-status { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
