:root {
  color-scheme: light;
  --ink: #244d43;
  --muted: #496d61;
  --paper: #fffdf6;
  --mint: #d3eee4;
  --orange: #f88455;
  --line: #dce8de;
  --shadow: 0 24px 80px #204b3b20;
  font-family: "Hiragino Sans GB", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100dvh;
  background: #e8eee7;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
button,
input {
  font: inherit;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
  border: 0;
  color: inherit;
  background: none;
  touch-action: manipulation;
}
button:disabled {
  opacity: 0.38;
  cursor: default;
}
button:focus-visible,
a:focus-visible,
canvas:focus-visible {
  outline: 3px solid #147e73;
  outline-offset: 3px;
}
button:hover:not(:disabled) {
  filter: brightness(0.96);
}
button:active:not(:disabled) {
  transform: translateY(1px);
}
[hidden] {
  display: none !important;
}
svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.stage {
  position: relative;
  width: min(100vw, 460px);
  height: min(900px, calc(100dvh - 72px));
  overflow: hidden;
  border-radius: 24px;
  background: var(--mint);
  box-shadow: var(--shadow);
  isolation: isolate;
}
canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none !important;
}
.topbar {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 12px;
  gap: 8px;
  pointer-events: none;
}
.topbar > * {
  pointer-events: auto;
}
.wordmark {
  font-size: 21px;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.wordmark span {
  color: #c8502c;
}
.tools {
  display: flex;
  align-items: center;
  gap: 4px;
}
.tools button {
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 7px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  background: #fffdf67a;
}
.tools svg {
  width: 18px;
  height: 18px;
}
.tools .sound {
  padding: 8px;
}
.hud {
  position: absolute;
  top: 83px;
  left: 26px;
  right: 26px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}
.height {
  display: flex;
  align-items: baseline;
  gap: 5px;
}
.height strong {
  font-size: 46px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.height span {
  font-size: 13px;
}
.record {
  padding-top: 8px;
  font-size: 12px;
}
.record strong {
  font-size: 15px;
}
.intro {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.intro-copy {
  position: absolute;
  top: 16%;
  left: 8%;
}
h1 {
  font-size: clamp(36px, 10vw, 48px);
  line-height: 1.24;
  letter-spacing: -0.035em;
  margin: 0 0 19px;
  font-weight: 900;
}
h1 span {
  color: #c8512d;
}
.intro-copy p {
  font-size: 13px;
  line-height: 1.85;
  margin: 0;
  color: var(--muted);
}
.intro-actions {
  position: absolute;
  bottom: 12%;
  left: 8%;
  right: 8%;
  text-align: center;
  pointer-events: auto;
}
.primary {
  height: 54px;
  width: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border-radius: 16px;
  background: var(--ink);
  color: #fffdf6;
  font-size: 17px;
  font-weight: 700;
  box-shadow: 0 7px 16px #244d4318;
  transition:
    filter 0.15s,
    transform 0.15s;
}
.intro-best {
  font-size: 12px;
  color: var(--muted);
  margin: 14px 0 0;
}
.intro-best strong {
  color: var(--ink);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
footer {
  position: absolute;
  z-index: 5;
  bottom: 12px;
  left: 22px;
  right: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink);
  min-height: 44px;
  pointer-events: none;
}
footer > * {
  pointer-events: auto;
}
.text-button {
  min-height: 44px;
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 600;
}
.text-button svg {
  width: 16px;
  height: 16px;
}
footer .text-button {
  display: flex;
  align-items: center;
  gap: 6px;
}
.desktop-note {
  font-size: 11px;
  letter-spacing: 0.02em;
  color: #52665a;
  margin: 16px 0 0;
}
.desktop-note span {
  padding: 0 8px;
}
.tutorial {
  position: absolute;
  bottom: 15%;
  left: 7%;
  right: 7%;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  color: #244d43;
  text-align: center;
  font-size: 12px;
  line-height: 1.8;
}
.tutorial span {
  background: #fffdf6ed;
  padding: 13px 17px;
  border-radius: 14px;
  box-shadow: 0 6px 20px #214c3710;
}
.tutorial strong {
  font-size: 14px;
}
.milestone {
  position: absolute;
  top: 22%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  pointer-events: none;
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 0.25s,
    transform 0.25s;
}
.milestone.show {
  opacity: 1;
  transform: translateY(0);
}
.warning {
  position: absolute;
  bottom: 10%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 12px;
  color: #962f21;
  font-weight: 700;
  pointer-events: none;
  background: #fff7e9e8;
  padding: 8px;
}
.overlay {
  position: absolute;
  z-index: 4;
  inset: 0;
  background: #e5f0e5e8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 28px 56px;
}
.result {
  width: 100%;
  max-width: 310px;
  text-align: center;
}
.result-art {
  width: 80px;
  height: 80px;
  margin: 0 auto 8px;
}
.result-art svg {
  width: 80px;
  height: 80px;
  stroke: none;
}
h2 {
  font-size: 24px;
  line-height: 1.4;
  letter-spacing: -0.03em;
  margin: 0;
  font-weight: 800;
}
.result > p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}
.result-score {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 8px;
  margin-top: 22px;
}
.result-score strong {
  font-size: 76px;
  font-weight: 900;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.result-score span {
  font-size: 17px;
}
.result .result-best {
  font-size: 12px;
  margin: 5px 0 20px;
}
.result .primary {
  margin-top: 12px;
}
.result .rank-check {
  font-size: 11px;
  min-height: 20px;
  margin: 4px 0;
}
.result > .text-button {
  display: block;
  margin: 4px auto 0;
}
.result .error {
  color: #a33527;
}
dialog {
  border: 0;
  color: var(--ink);
  background: var(--paper);
  border-radius: 24px;
  width: min(420px, calc(100vw - 28px));
  padding: 24px;
  box-shadow: 0 24px 90px #163f3540;
  max-height: calc(100dvh - 36px);
  overflow: hidden;
}
dialog::backdrop {
  background: #173f3a83;
}
.board[open] {
  display: flex;
  flex-direction: column;
  height: min(760px, calc(100dvh - 36px));
  gap: 0;
}
.board-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}
.board-top p {
  font-size: 12px;
  color: var(--muted);
  margin: 5px 0 0;
}
.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #edf2e9;
}
.totals {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin: 22px 0 8px;
  flex-shrink: 0;
}
.totals dt {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}
.totals dd {
  margin: 6px 0 0;
  font-size: 21px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.stats-period {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 12px;
  flex-shrink: 0;
}
#nameForm {
  padding: 13px 0 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
#nameForm > p {
  font-size: 12px;
  line-height: 1.6;
  margin: 0 0 12px;
}
#nameForm label {
  font-size: 11px;
  display: block;
  margin-bottom: 6px;
}
.name-input {
  display: flex;
  gap: 8px;
}
.name-input input {
  width: 0;
  flex: 1;
  min-width: 0;
  height: 44px;
  border: 1px solid #afc5b6;
  border-radius: 11px;
  padding: 0 12px;
  background: white;
  color: var(--ink);
  font-size: 16px;
}
.name-input .primary {
  width: 76px;
  height: 44px;
  font-size: 14px;
  padding: 0 12px;
  border-radius: 11px;
}
.board-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.board-status p {
  font-size: 11px;
  line-height: 1.5;
  margin: 8px 0;
}
.error {
  color: #a33527 !important;
}
.rank-scroll {
  overflow: auto;
  overscroll-behavior: contain;
  flex: 1;
  min-height: 60px;
  border-radius: 12px;
  scroll-padding: 40px 0 10px;
  scrollbar-width: thin;
}
table {
  width: 100%;
  border-spacing: 0;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}
th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #edf2e9;
  font-size: 10px;
  padding: 12px 10px;
  font-weight: 500;
}
td {
  padding: 14px 10px;
  border-bottom: 1px solid #e9eee6;
  font-variant-numeric: tabular-nums;
}
th:last-child,
td:last-child {
  text-align: right;
  white-space: nowrap;
}
td:nth-child(2) {
  overflow-wrap: anywhere;
  max-width: 160px;
}
td:first-child {
  font-weight: 800;
  width: 42px;
}
.rank-self {
  background: #e1f2e8;
}
.self-tag {
  display: inline-block;
  font-size: 9px;
  margin-left: 5px;
  background: var(--ink);
  color: #fff;
  padding: 2px 4px;
  border-radius: 4px;
}
.empty-board {
  text-align: center;
  padding: 35px 0;
  font-size: 13px;
  line-height: 1.9;
  color: var(--muted);
}
.board-foot {
  font-size: 10px;
  margin: 14px 0 0;
  color: var(--muted);
  flex-shrink: 0;
}
.help-dialog {
  overflow: auto;
}
.help-dialog > p {
  font-size: 13px;
  line-height: 1.9;
  color: var(--muted);
  margin: 22px 0;
}
.help-items {
  list-style: none;
  margin: 22px 0;
  padding: 0;
}
.help-items li {
  margin: 15px 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
}
.help-items span {
  color: var(--muted);
}
.help-dialog .help-note {
  font-size: 11px;
}
.help-dialog .board-top h2 {
  font-size: 21px;
}
.help-dialog .primary {
  margin-top: 24px;
}
@media (max-width: 600px) {
  body {
    background: var(--mint);
  }
  .stage {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
  .topbar {
    padding-top: calc(env(safe-area-inset-top) + 14px);
  }
  .hud {
    top: calc(env(safe-area-inset-top) + 78px);
  }
  footer {
    bottom: calc(env(safe-area-inset-bottom) + 5px);
  }
  .desktop-note {
    display: none;
  }
  .intro-actions {
    bottom: calc(12% + env(safe-area-inset-bottom));
  }
}
@media (max-width: 350px) {
  .topbar {
    padding-left: 15px;
    padding-right: 12px;
  }
  .wordmark {
    font-size: 19px;
  }
  .tools {
    gap: 2px;
  }
  .tools button {
    padding: 4px 5px;
  }
  .tools svg {
    width: 16px;
  }
  .intro-copy {
    top: 17%;
  }
  h1 {
    font-size: 36px;
  }
  .intro-copy p {
    font-size: 12px;
  }
  .board {
    padding: 18px;
  }
  .totals {
    gap: 4px;
  }
  .totals dt {
    font-size: 9px;
  }
  .totals dd {
    font-size: 18px;
  }
  .result-art {
    width: 64px;
    height: 64px;
  }
  .result-art svg {
    width: 64px;
    height: 64px;
  }
  .result-score strong {
    font-size: 60px;
  }
}
@media (max-height: 650px) {
  .intro-copy {
    top: 15%;
  }
  h1 {
    font-size: 34px;
    margin-bottom: 10px;
  }
  .intro-copy p {
    font-size: 11px;
  }
  .intro-actions {
    bottom: 11%;
  }
  .intro-best {
    margin-top: 7px;
  }
  .primary {
    height: 48px;
  }
  .result-art {
    display: none;
  }
  .result-score {
    margin-top: 8px;
  }
  .result .result-best {
    margin-bottom: 8px;
  }
  .result h2 {
    font-size: 22px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
