:root {
  color-scheme: light;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  color: #342a1c;
  background: #f8f4e8;
  font-synthesis: none;
  --ink: #342a1c;
  --muted: #766752;
  --line: #e7dcc6;
  --paper: #fffaf0;
  --green: #497a3a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  background-image: radial-gradient(#d6c4a656 .65px, transparent .65px);
  background-size: 10px 10px;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 3px solid #257357; outline-offset: 4px; }
button:disabled { cursor: default; }
[hidden], .symbols { display: none !important; }
svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.shell { width: min(1180px, calc(100% - 64px)); margin: 0 auto; padding-bottom: 36px; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 94px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 45px;
  height: 45px;
  color: #523919;
  background: #f6cd70;
  border: 1px solid #d8a443;
  border-radius: 14px;
  box-shadow: 0 2px 0 #dbad52;
}
.brand-mark svg { width: 27px; height: 27px; }
.brand-name { font-size: 17px; font-weight: 800; letter-spacing: .04em; }
.brand-name small {
  display: block;
  margin-top: 3px;
  font: 750 9px/1.2 "Trebuchet MS", sans-serif;
  letter-spacing: .19em;
  color: var(--muted);
}
.sound-toggle, .secondary, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #ded1b9;
  border-radius: 12px;
  background: var(--paper);
  font-size: 13px;
  font-weight: 700;
  padding: 10px 14px;
}
.sound-toggle svg { width: 18px; height: 18px; color: #5b6842; }
.sound-toggle:hover, .secondary:hover, .icon-button:hover { background: #f2e9d6; }

.stage {
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 2.1;
  min-height: 470px;
  overflow: hidden;
  background: #cae5c0;
  border: 2px solid #c7b588;
  border-radius: 27px;
  box-shadow: 0 6px 0 #e3d5b8, 0 14px 35px #6f4b2810;
}
.home, #track, .hud, .overlay { position: absolute; inset: 0; }
.home {
  display: flex;
  align-items: center;
  background:
    linear-gradient(90deg, #fbf3d9 0%, #fbf3d9f7 19%, #fbf3d9ba 32%, #fbf3d92b 47%, transparent 58%),
    url("assets/meadow.jpg") right center / cover no-repeat,
    linear-gradient(#c7e5d6, #a7c86b);
}
.home-content { position: relative; padding: 36px 0 30px clamp(32px, 5.4vw, 72px); }
.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  color: #6b7446;
  font: 800 14px/1.4 "Trebuchet MS", sans-serif;
  letter-spacing: .24em;
}
.wordmark::before { content: ""; width: 23px; height: 2px; background: #8c9857; }
h1 {
  margin: 0;
  font-size: clamp(62px, 7vw, 105px);
  font-weight: 950;
  line-height: 1.13;
  letter-spacing: -.06em;
  text-shadow: 0 3px 0 #fff8e0;
  white-space: nowrap;
}
h1 span { color: #9c5324; }
.intro { margin: 18px 0 26px; color: #5e543c; font-size: 16px; line-height: 1.8; font-weight: 650; }
.start-row { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; }
.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  padding: 10px 24px;
  color: #fffbea;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .05em;
  background: var(--green);
  border: 1px solid #315a2a;
  border-radius: 14px;
  box-shadow: 0 4px 0 #315a2a, inset 0 1px 0 #ffffff30;
  transition: background .15s, transform .15s;
}
#start { min-width: 176px; }
.primary:hover { background: #3c6b31; transform: translateY(-1px); }
.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #315a2a; }
.start-key { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0 0 14px; font-size: 12px; color: #655640; }
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 23px;
  padding: 3px 6px;
  background: #fcf6e9;
  border: 1px solid #e2d6bf;
  border-bottom-width: 2px;
  border-radius: 5px;
  color: #64543e;
  font: 700 11px/1.1 Consolas, monospace;
  white-space: nowrap;
}
.records { display: flex; gap: 17px; margin-top: 28px; padding-top: 15px; border-top: 1px solid #a38d5b50; }
.records div { display: flex; align-items: center; gap: 6px; color: #67583e; font-size: 12px; }
.records svg { width: 18px; height: 18px; color: #9d6d21; }
.records strong { margin-left: 3px; font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }

.instructions { margin-top: 27px; }
.instruction-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.instruction-heading h2 { margin: 0; font-size: 15px; letter-spacing: .08em; }
.guide-toggle {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 0;
  padding: 5px 0 5px 10px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.guide-toggle svg { width: 16px; height: 16px; }
.guide-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.controls { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.control {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 73px;
  padding: 11px 12px;
  overflow: hidden;
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: 0 2px 0 #eae0cc;
  user-select: none;
  touch-action: none;
}
.control:hover, .control:active { border-color: #bca981; }
.control-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 10px;
  background: #e3edcf;
  color: #4e7039;
}
.slide .control-icon { background: #f8e6ce; color: #91532d; }
.dash .control-icon { background: #faedbd; color: #8d6117; }
.rest .control-icon { background: #e6e9dd; color: #5c6748; }
.control-copy { display: grid; gap: 4px; white-space: nowrap; }
.control-copy strong { font-size: 13px; }
.control-copy > span { color: var(--muted); font-size: 11px; }
.keys { display: flex; gap: 3px; margin-left: auto; }
.cooldown { position: absolute; inset: auto 0 0; height: 3px; background: #c1933b; transform-origin: left; }
.item-guide { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 14px 0 0; }
.item-guide div { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.item-guide dt { font-size: 13px; font-weight: 800; }
.item-guide dd { margin: 5px 0 0; font-size: 12px; color: var(--muted); }

#track { width: 100%; height: 100%; }
.hud { padding: 19px; display: flex; align-items: flex-start; gap: 8px; pointer-events: none; }
.run-stats, .scene, .effects span {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #a78c5a66;
  border-radius: 13px;
  background: #fff9e8f0;
}
.run-stats { padding: 9px 13px; }
.hud-stat { display: grid; gap: 2px; min-width: 53px; }
.hud-stat span { font-size: 10px; color: var(--muted); }
.hud-stat strong { font-size: 19px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hud-coins { display: flex; align-items: center; gap: 4px; min-width: 0; color: #8b5b13; }
.hud-coins svg, .scene svg { width: 17px; height: 17px; }
.scene { margin-left: auto; gap: 5px; padding: 9px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.icon-button { pointer-events: auto; width: 38px; height: 38px; padding: 0; }
.icon-button svg { width: 18px; height: 18px; }
.effects { position: absolute; top: 84px; left: 19px; display: flex; gap: 6px; }
.effects span { padding: 4px 8px; font-size: 11px; font-weight: 700; }
.overlay { display: grid; place-items: center; padding: 12px; background: #241d2269; }
.dialog {
  width: min(360px, 100%);
  padding: 22px 26px;
  text-align: center;
  background: var(--paper);
  border: 2px solid #d9c393;
  border-radius: 22px;
  box-shadow: 0 5px 0 #846741, 0 14px 38px #271b2735;
}
.dialog-icon { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: #8d5b19; background: #f9e6b3; }
.dialog h2 { margin: 8px 0 14px; font-size: 27px; }
.dialog .primary { width: 100%; min-height: 45px; font-size: 16px; }
.secondary-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 13px; }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 12px; }
.result-grid > div { display: grid; gap: 4px; padding: 7px; border-radius: 8px; background: #f4edda; }
.result-grid span { color: var(--muted); font-size: 11px; }
.result-grid strong { font-size: 19px; font-variant-numeric: tabular-nums; }
.result-grid .longest { grid-column: span 2; display: flex; justify-content: center; align-items: center; gap: 8px; padding: 4px; }
.longest strong { font-size: 14px; }
.dialog-home { width: 100%; margin-top: 10px; }

@media (max-width: 1060px) {
  .controls .keys { flex-wrap: wrap; justify-content: flex-end; }
  .control { padding-inline: 9px; gap: 7px; }
}
@media (max-width: 860px) {
  .controls, .item-guide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage { min-height: 425px; }
}
@media (max-width: 700px) {
  .stage:has(.home:not([hidden])) { min-height: 500px; }
  .home {
    align-items: flex-start;
    background:
      linear-gradient(#fbf3d9 2%, #fbf3d9ea 26%, #fbf3d900 62%),
      url("assets/meadow.jpg") right bottom / auto min(77%, 76vw - 22px) no-repeat,
      #fbf3d9;
  }
  .home-content { width: 100%; padding: 23px 16px 0; text-align: center; }
  .wordmark, .start-row, .records { justify-content: center; }
  .wordmark { margin-bottom: 4px; font-size: 11px; }
  .wordmark::before { width: 14px; }
  h1 { font-size: clamp(51px, 13vw, 68px); }
  .intro { margin: 8px 0 13px; font-size: 13px; line-height: 1.45; }
  .intro br { display: none; }
  .primary { min-height: 43px; padding: 8px 16px; font-size: 16px; }
  .records { width: max-content; max-width: 100%; margin: 13px auto 0; padding: 5px 9px; gap: 11px; border: 0; background: #fff9e8db; border-radius: 8px; }
  .records div { font-size: 10px; }
  .records svg { width: 15px; height: 15px; }
  .records strong { font-size: 13px; }
}
@media (max-width: 580px) {
  .shell { width: calc(100% - 24px); padding-bottom: 20px; }
  .topbar { min-height: 67px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 11px; }
  .brand-mark svg { width: 23px; height: 23px; }
  .sound-toggle { padding: 7px 9px; font-size: 12px; }
  .stage { min-height: 335px; border-radius: 19px; aspect-ratio: 1.3; }
  .instructions { margin-top: 18px; }
  .instruction-heading { margin-bottom: 8px; }
  .controls, .item-guide { gap: 7px; }
  .control { min-height: 55px; padding: 6px 8px; }
  .control-icon { width: 31px; height: 31px; border-radius: 7px; }
  .control-icon svg { width: 18px; height: 18px; }
  .control-copy { gap: 2px; }
  .control-copy > span { font-size: 10px; }
  .control .keys { display: none; }
  .hud { padding: 9px; gap: 4px; }
  .run-stats { gap: 7px; padding: 5px 7px; border-radius: 9px; }
  .hud-stat { min-width: 36px; }
  .hud-stat strong { font-size: 15px; }
  .hud-coins { min-width: 0; }
  .scene { padding: 6px; border-radius: 9px; font-size: 10px; }
  .scene svg { width: 12px; height: 12px; }
  .icon-button { width: 29px; height: 29px; border-radius: 9px; }
  .effects { top: 55px; left: 9px; }
  .dialog { padding: 12px 17px; width: min(290px, 100%); }
  .dialog-icon { width: 31px; height: 31px; }
  .dialog-icon svg { width: 17px; height: 17px; }
  .dialog h2 { margin: 5px 0 8px; font-size: 22px; }
  .result-grid { margin-bottom: 7px; gap: 5px; }
  .result-grid > div { padding: 4px; }
  .dialog .primary { min-height: 37px; }
  .dialog-home { margin-top: 8px; padding-block: 6px; }
}
@media (pointer: coarse) {
  .start-key, .control .keys { display: none; }
}
@media (pointer: coarse) and (orientation: landscape) and (max-height: 520px) {
  .shell { width: calc(100% - 24px); padding-bottom: 12px; }
  .topbar { min-height: 54px; }
  .stage:has(.home[hidden]) { height: calc(100dvh - 149px); min-height: 225px; }
  .overlay { overflow: auto; align-items: safe center; }
  .instructions { margin-top: 13px; }
  .instruction-heading { margin-bottom: 4px; }
  .controls { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
  .control { min-height: 47px; padding-block: 5px; }
  .control-icon { width: 32px; height: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
