:root {
  --bg: #121614;
  --bg-raise: #1b221e;
  --line: #2c3832;
  --ink: #e7e1d4;
  --muted: #a39b8c;
  --brass: #d4844a;
  --brass-deep: #a85b2d;
  --paper: #f4efe4;
  --paper-ink: #221e19;
  --paper-soft: #6d6458;
  --danger: #d4684a;
  --ok: #7d9a72;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(212, 132, 74, 0.16), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
  padding: 28px 20px 64px;
}

button, input, select { font: inherit; color: inherit; }

button {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}

button:hover { border-color: var(--brass); }

button.primary {
  background: var(--brass);
  border-color: var(--brass);
  color: #1a120c;
  font-weight: 700;
}

button:disabled { opacity: 0.45; cursor: not-allowed; }

.app { max-width: 1080px; margin: 0 auto; }

header h1 {
  margin: 0 0 8px;
  font-size: 32px;
  letter-spacing: 0.04em;
  font-weight: 750;
}

header p { margin: 0; color: var(--muted); line-height: 1.6; }

.nav-line { margin: 0 0 8px; }

.home, .nav-line a, .pager a {
  color: var(--brass);
  text-decoration: none;
}

.home:hover, .nav-line a:hover, .pager a:hover { text-decoration: underline; }

.public-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-raise);
}

.public-bar[hidden] { display: none; }

.search-row {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.search-row input {
  flex: 1;
  min-width: 0;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.catalog {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.score-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-raise);
}

.score-card a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.score-card strong { font-size: 18px; }

.score-card span { color: var(--muted); font-size: 13px; }

.pager {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
}

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 22px;
  border: 1.5px dashed #415248;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 18px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.drop.hot {
  border-color: var(--brass);
  background: rgba(212, 132, 74, 0.08);
}

.drop strong { display: block; font-size: 18px; margin-bottom: 6px; }

.drop span { color: var(--muted); }

.drop input { display: none; }

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-top: 18px;
  align-items: end;
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  min-width: 120px;
}

label.field.grow { flex: 1; min-width: 180px; }

select, input[type="number"] {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 0;
}

.stepper { display: flex; gap: 6px; align-items: center; }

.stepper input { width: 72px; text-align: center; }

.stepper button { padding: 8px 10px; border-radius: 10px; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
  padding-bottom: 8px;
}

.status {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--muted);
}

.progress {
  height: 6px;
  background: #2a332e;
  border-radius: 99px;
  overflow: hidden;
  margin-top: 8px;
  display: none;
}

.progress.on { display: block; }

.progress i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brass-deep), var(--brass));
}

.layout { margin-top: 8px; }

.paper {
  border-radius: 18px;
  box-shadow: var(--shadow);
  background: var(--paper);
  color: var(--paper-ink);
  padding: 22px 22px 18px;
  min-height: 280px;
}

.paper h2 {
  margin: 0;
  font-family: "Palatino Linotype", "Songti SC", "SimSun", serif;
  font-size: 26px;
}

.meta {
  margin: 6px 0 14px;
  color: var(--paper-soft);
  font-size: 14px;
}

.score {
  font-family: "Songti SC", "SimSun", "Palatino Linotype", serif;
  color: #241c16;
}

.sheet-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
  margin-bottom: 18px;
  font-size: 13px;
  color: #4d453c;
}

.sheet-legend b { font-size: 14px; color: #241c16; }

.swatch { padding: 1px 6px; }

.swatch.red { background: #e10600; color: #fff; }
.swatch.white { background: #fff; color: #241c16; box-shadow: inset 0 0 0 1px #d9d3c7; }
.swatch.blue { background: #1d4f91; color: #fff; }

.board { display: flex; flex-direction: column; gap: 16px; }

.phrase-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 22px;
}

.run { display: flex; flex-direction: column; align-items: stretch; }

.digits, .letters {
  display: flex;
  justify-content: center;
}

.digits { gap: 2px; margin-bottom: 3px; font-size: 22px; line-height: 1.2; }

.digits span {
  min-width: 1.15em;
  text-align: center;
  position: relative;
  padding-top: 8px;
}

.sharp-dot {
  position: absolute;
  top: 0;
  left: 50%;
  width: 5px;
  height: 5px;
  margin-left: -2px;
  border-radius: 50%;
  background: #241c16;
}

.letters {
  font-family: "Segoe UI", "PingFang SC", sans-serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.35;
  padding: 0 4px;
}

.letters span { min-width: 1.15em; text-align: center; }
.letters .comma { font-size: 26px; line-height: 1; }

.marks {
  display: flex;
  justify-content: center;
  min-height: 16px;
  margin-top: 2px;
}

.marks span {
  min-width: 1.15em;
  text-align: center;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 11px;
  color: #8a8175;
  white-space: nowrap;
}

.hold-key { color: #a33b24 !important; font-weight: 700; }

.letters.red { background: #e10600; color: #fff; }
.letters.white { background: #fff; color: #241c16; box-shadow: inset 0 0 0 1px #e4ddd0; }
.letters.blue { background: #1d4f91; color: #fff; }

.digits .playing, .letters .playing { outline: 2px solid #d4844a; outline-offset: 1px; }

.bar {
  display: inline-flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 2px 10px;
  border-bottom: 1px solid transparent;
}

.beat, .group {
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  position: relative;
  padding: 0 2px 4px;
}

.group.ul1 { border-bottom: 2px solid var(--paper-ink); }
.group.ul2 { border-bottom: 5px double var(--paper-ink); }

.num, .hold, .rest {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1em;
  line-height: 1;
  font-weight: 700;
}

.mods {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
}

.mod {
  font-style: normal;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  color: #fff;
  border-radius: 4px;
  padding: 0 3px;
}

.mod-左 { background: #3d6b8c; }
.mod-右 { background: #a85b2d; }
.mod-中 { background: #5c4d86; }

.num small, .rest small {
  font-size: 0.48em;
  margin-right: 1px;
  color: var(--brass-deep);
  font-weight: 700;
}

.dots {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--paper-ink);
  display: block;
}

.dots.up { bottom: 100%; margin-bottom: 3px; }
.dots.down { top: 100%; margin-top: 3px; }

.hold { color: var(--paper-soft); padding-bottom: 2px; }

.barline {
  align-self: stretch;
  width: 2px;
  background: var(--paper-ink);
  margin: 4px 2px 8px;
}

.playing {
  background: rgba(212, 132, 74, 0.28);
  border-radius: 8px;
}

.legend {
  margin-top: 16px;
  color: var(--paper-soft);
  font-size: 13px;
  line-height: 1.7;
}

.toolbar {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.warn {
  color: #efc2a4;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.stats { color: var(--muted); font-size: 13px; line-height: 1.5; }

.play-modal[hidden] { display: none; }

.play-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(6, 8, 7, 0.78);
}

.play-dialog {
  width: min(760px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: #161c18;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 16px 16px 14px;
}

.play-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.play-head h2 {
  margin: 0;
  font-size: 20px;
}

#play-judge {
  margin: 2px 0 0;
  min-height: 32px;
  font-size: 26px;
  font-weight: 750;
  line-height: 1.2;
}

.judge-perfect { color: #9dcc8a; }
.judge-good { color: var(--brass); }
.judge-bad { color: #e07a62; }
.judge-wait { color: var(--muted); }

#play-stats {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.play-actions { display: flex; gap: 8px; }

.play-stage { overflow-x: auto; user-select: none; }

#play-canvas {
  display: block;
  width: 640px;
  height: 460px;
  border-radius: 12px 12px 0 0;
  background: #101410;
}

.play-keys {
  display: flex;
  width: 640px;
}

.play-key {
  flex: 0 0 80px;
  width: 80px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 750;
  font-size: 18px;
  border: 1px solid #2a3330;
  border-left-width: 0;
  border-radius: 0 0 0 0;
  background: #f4efe4;
  color: #241c16;
}

.play-key:first-child { border-left-width: 1px; }
.play-key:last-child { border-radius: 0 0 10px 0; }
.play-key:first-child { border-radius: 0 0 0 10px; }

.play-key.on {
  filter: brightness(1.28);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25);
}

.play-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

body.practice-open { overflow: hidden; }

@media (max-width: 860px) {
  header h1 { font-size: 26px; }
  .score { font-size: 24px; }
  .play-head { flex-wrap: wrap; }
}
