:root {
  color-scheme: light;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  color: #362a32;
  background: #fff6e8;
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  display: grid;
  min-height: 100svh;
  margin: 0;
  place-items: center;
  background: radial-gradient(ellipse at 48% 12%, #fffdf6, #ffeedb 85%);
}
button { color: inherit; cursor: pointer; font: inherit; }
button:focus-visible { outline: 3px solid #864c65; outline-offset: 3px; }
.game {
  display: flex;
  flex-direction: column;
  gap: 9px;
  height: min(100svh, 950px);
  min-height: 475px;
  width: min(100%, 550px);
  padding: max(8px, env(safe-area-inset-top)) 12px max(8px, env(safe-area-inset-bottom));
}
.top { display: flex; justify-content: space-between; align-items: center; min-height: 42px; padding-inline: 3px 1px; }
.title { display: flex; gap: 10px; align-items: center; }
h1 { margin: 0; font-size: clamp(25px, 6.7vw, 36px); font-weight: 950; line-height: 1.1; letter-spacing: .07em; }
.title-icon {
  width: 24px;
  height: 14px;
  border: 2px solid #5c3c35;
  border-radius: 4px;
  background: #fbc768;
  box-shadow: 1px 2px #8a4f41;
  transform: rotate(-17deg) skew(-12deg);
}
.sound {
  display: flex;
  gap: 5px;
  align-items: center;
  min-height: 39px;
  padding: 0 10px;
  border: 1px solid #c99070;
  border-radius: 13px;
  background: #fffcf5;
  font-size: 13px;
  font-weight: 750;
}
.sound span:first-child { color: #85506d; font-size: 17px; font-weight: 900; }
.sound[aria-pressed=false] { background: #f3eee8; border-color: #a9a1a4; }
.hud {
  display: grid;
  grid-template-columns: 1fr 1fr .96fr;
  align-items: center;
  gap: 6px;
  min-height: 63px;
  padding: 7px 12px 8px;
  border: 1.5px solid #dbac92;
  border-radius: 15px;
  background: #fffdfa;
}
.hud > div { min-width: 0; }
.hud > div + div { padding-left: 9px; border-left: 1px solid #eed9c8; }
.hud span { display: block; color: #6d534d; font-size: clamp(12px, 3.25vw, 14px); font-weight: 650; white-space: nowrap; }
.amount strong { display: block; font-size: clamp(16px, 4.5vw, 23px); font-variant-numeric: tabular-nums; line-height: 1.18; white-space: nowrap; }
.amount strong.compact { font-size: clamp(12px, 3.5vw, 18px); }
#bag { color: #983f45; }
.progress {
  width: 100%;
  height: 10px;
  margin-top: 8px;
  border-radius: 12px;
  border: 1px solid #d5ad97;
  background: #f7e9df;
  overflow: hidden;
}
.progress i { display: block; height: 100%; background: #df815e; transform: scaleX(0); border-radius: inherit; transform-origin: left; }
.stage {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
  isolation: isolate;
  background: #fff5ee;
  border: 2px solid #ce987b;
  border-radius: 23px;
  box-shadow: 0 5px #e6b997, 0 9px 20px #b6734720;
}
canvas { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; }
.lane-names {
  position: absolute;
  inset: 13px 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  justify-items: center;
  pointer-events: none;
}
.lane-names span {
  padding: 4px 11px;
  border: 1px solid #daa087;
  border-radius: 40px;
  background: #fff0e2;
  color: #7a4437;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .06em;
}
.lane-names span + span { background: #ffeff3; border-color: #d69cb6; color: #82445c; }
.challenge-readout {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 8px;
  border: 1px solid #cd9178;
  border-radius: 10px;
  background: #fff9ec;
  color: #68413b;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}
.challenge-readout.met { border-color: #a1ad76; background: #f4f6df; color: #4c613c; }
.stage-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  justify-items: center;
  align-items: start;
  padding: clamp(48px, 10svh, 90px) 13px 0;
  background: linear-gradient(#fff9ef42, #fff9ef00 80%);
  pointer-events: none;
}
.sheet {
  width: min(100%, 310px);
  padding: 18px 16px 15px;
  background: #fffcf4f5;
  border: 2px solid #a26c63;
  border-radius: 23px;
  box-shadow: 0 5px #ecbfaa, 0 9px 20px #a97b6929;
  text-align: center;
  pointer-events: auto;
}
h2 { margin: 0; font-size: clamp(28px, 8.3vw, 41px); line-height: 1.07; letter-spacing: .03em; font-weight: 950; }
.sheet > p { margin: 10px 0 13px; font-size: 15px; line-height: 1.48; color: #695250; }
.action {
  width: 100%;
  min-height: 46px;
  border: 2px solid #995347;
  border-radius: 13px;
  background: #ffc47e;
  box-shadow: 0 3px #b96649;
  color: #442f2e;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .11em;
}
.action:enabled:hover { background: #ffda9e; }
.action:enabled:active { transform: translateY(2px); box-shadow: 0 1px #b96649; }
.action:disabled { opacity: .62; cursor: wait; }
.difficulty-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 0 10px;
  padding: 3px;
  border: 1px solid #e5baa0;
  border-radius: 11px;
  background: #f7ebdf;
}
.difficulty-picker label { position: relative; cursor: pointer; }
.difficulty-picker label span {
  display: grid;
  min-height: 33px;
  place-items: center;
  border-radius: 7px;
  color: #695250;
  font-size: 14px;
  font-weight: 780;
}
.difficulty-picker input:checked + span { background: #7f3f51; color: #fff8ef; }
.difficulty-picker input:focus-visible + span { outline: 2px solid #864c65; outline-offset: 2px; }
.song-picker { border: 0; margin: 0 0 13px; padding: 0; }
.song-options { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.song-choice { position: relative; min-width: 0; cursor: pointer; }
.song-choice:first-child:nth-last-child(odd) { grid-column: 1 / -1; }
.song-choice > .song-tile {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
  padding: 5px 7px;
  border: 1px solid #cca18a;
  border-radius: 9px;
  background: #fff8ee;
  font-weight: 780;
  font-size: 14px;
}
.song-tile .song-length { color: #735447; font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
#song-label { overflow: hidden; text-overflow: ellipsis; }
.song-choice input:checked + .song-tile { border-color: #9a503d; background: #ffd8a6; box-shadow: inset 0 0 0 1px #ac583e; }
.song-choice input:focus-visible + .song-tile { outline: 3px solid #864c65; outline-offset: 2px; }
.result-actions { display: grid; grid-template-columns: .86fr 1.14fr; gap: 7px; }
.second-action {
  width: 100%;
  border: 1px solid #a97869;
  border-radius: 13px;
  background: #fff2e4;
  color: #62423b;
  font-size: 15px;
  font-weight: 800;
}
.second-action:enabled:hover { background: #ffe0ca; }
.sheet .success-tag { margin: 0 0 7px; color: #945053; font-size: 13px; font-weight: 850; letter-spacing: .1em; }
#results h2 { font-size: clamp(24px, 6.7vw, 34px); }
#results.failure { border-color: #9e5360; box-shadow: 0 5px #f2b7c0, 0 9px 20px #a97b6929; }
#results.failure .success-tag { color: #8d3248; }
.income { margin: 4px 0; color: #983f45; font-size: clamp(28px, 8vw, 40px); font-weight: 950; font-variant-numeric: tabular-nums; }
.result-details { display: grid; grid-template-columns: 1fr 1fr; margin: 7px 0 12px; font-size: 13px; color: #6d534d; }
.result-details span,.result-details strong { display: block; }
.result-details strong { color: #362a32; font-size: 17px; }
.controls { display: flex; justify-content: space-between; min-height: 27px; align-items: center; padding-inline: 4px; color: #6d534d; font-size: 13px; font-weight: 650; }
.controls > div { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.controls kbd { min-width: 17px; height: 18px; display: inline-grid; place-items: center; border-radius: 4px; border: 1px solid #b38d80; background: #fffaf4; font: 11px system-ui; }
.controls .left-dot,.controls .right-dot { width: 8px; height: 8px; display: inline-block; border-radius: 50%; background: #db815e; }
.controls .right-dot { background: #c87ba3; }
.touch-hint { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@media (pointer: coarse) {
  .controls kbd { display: none; }
  .touch-hint { display: inline; }
}
@media (max-height: 680px) {
  .stage-overlay { padding-top: 45px; }
  .sheet { padding: 10px 13px; border-radius: 17px; }
  .sheet > p { margin: 6px 0 9px; font-size: 14px; }
  #welcome h2 { font-size: clamp(22px, 6.5vw, 30px); }
  .song-choice > .song-tile { min-height: 43px; font-size: 13px; }
  .song-options { max-height: 145px; overflow: auto; padding: 2px; scrollbar-width: thin; }
  .song-picker { margin-bottom: 9px; }
  #results .success-tag { font-size: 12px; margin-bottom: 4px; }
  #results .income { font-size: 26px; line-height: 1.15; margin: 1px 0; }
  #results .result-details { margin: 4px 0 7px; line-height: 1.2; }
  #results .result-details strong { font-size: 15px; }
  .action { min-height: 39px; }
}
@media (max-width: 350px) {
  .game { padding-inline: 8px; }
  .hud { padding-inline: 8px; }
  .song-variant > .song-tile {
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    white-space: nowrap;
  }
}
@media (max-height: 525px) {
  .stage-overlay { padding-top: 37px; }
  #welcome { padding-block: 7px 6px; }
  #welcome h2 { font-size: 20px; }
  #welcome > p { margin-block: 4px 6px; font-size: 13px; }
  .difficulty-picker { margin-bottom: 6px; padding: 2px; }
  .difficulty-picker label span { min-height: 26px; }
  .song-options { row-gap: 4px; max-height: 116px; }
  .song-choice > .song-tile { min-height: 34px; padding-block: 2px; }
  .song-picker { margin-bottom: 7px; }
  #start { min-height: 34px; }
}
