:root {
  color: #4e3b69;
  background: #f5effa;
  font-family: ui-rounded, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible { outline: 3px solid #8460b0; outline-offset: 3px; }
[hidden] { display: none !important; }
.shell { width: min(1440px, 100%); margin: auto; padding: 28px clamp(14px, 3.5vw, 48px) 26px; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 0 0 19px; border-bottom: 1px solid #dfd1e9; margin-bottom: 19px;
}
.brand { display: flex; align-items: center; gap: 13px; white-space: nowrap; }
.brand div { display: flex; align-items: baseline; gap: 16px; }
h1 { font-size: clamp(24px, 3vw, 34px); letter-spacing: .05em; margin: 0; }
.brand span, #mode-hint { color: #6f5d89; font-size: .9rem; }
fieldset {
  display: flex; gap: 2px; border: 1px solid #ddcce9; border-radius: 14px;
  background: #fff8f2; margin: 0; padding: 3px; min-width: 0;
}
legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
fieldset label { position: relative; }
fieldset input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
fieldset span { display: block; padding: 6px 12px; border-radius: 10px; font-size: .9rem; white-space: nowrap; }
fieldset small { font-size: .78em; font-weight: 650; }
fieldset input:checked + span { background: #e6d8fb; font-weight: 750; }
fieldset input:focus-visible + span { outline: 3px solid #8460b0; }
fieldset:disabled input, fieldset:disabled label { cursor: default; }
.game {
  position: relative; overflow: hidden; isolation: isolate;
  height: clamp(420px, 62vh, 610px); border: 2px solid #c4addb; border-radius: 23px;
  background: #e9e0f8;
}
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud { position: absolute; top: 18px; left: 18px; display: grid; gap: 8px; pointer-events: none; }
.score-card, .stage-card {
  display: grid; padding: 11px 13px; background: #fff8f1eb; border: 1px solid #bba0d3;
  border-radius: 15px; min-width: 156px;
}
.score-label, .stage-card strong { font-size: .85rem; font-weight: 750; }
.score-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.score-row strong { font-size: clamp(24px, 3.1vw, 34px); font-variant-numeric: tabular-nums; }
.score-row span, .stage-card span { font-size: .75rem; color: #67537e; }
.physical-height {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin-top: 5px; padding-top: 6px; border-top: 1px solid #dfd1e9; font-size: .75rem;
}
#sensor-status {
  margin: 0; padding: 4px 9px; border-radius: 9px; font-size: .78rem;
  color: #6f5d89; background: #eee4f8;
}
#sensor-status[data-ready="true"] { color: #36574b; background: #e4f1e8; }
.leaderboard {
  position: absolute; top: 17px; right: 20px; width: min(198px, 37%);
  color: #4e3b69; --board-line: #68467f40; --board-highlight: #fff8eea6;
}
.game[data-night="true"] .leaderboard { color: #fff2fa; --board-line: #f4dcf56e; --board-highlight: #40345ca6; }
.board-head { display: flex; align-items: center; gap: 6px; padding-bottom: 5px; border-bottom: 1px solid var(--board-line); }
.board-head h2 { margin: 0; font-size: 1rem; }
.board-head span { margin-left: auto; font-size: .73rem; }
.records { display: grid; gap: 2px; list-style: none; margin: 4px 0; padding: 0; }
.records li { display: grid; grid-template-columns: 18px minmax(0, 1fr) 29px max-content; gap: 6px; align-items: center; line-height: 1.35; padding: 3px 5px; border-radius: 6px; font-size: .83rem; }
.records li.mine { background: var(--board-highlight); }
.records .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.records .mode { font-size: .73rem; }
.records strong { font-variant-numeric: tabular-nums; }
#empty-board, .own-record { font-size: .75rem; margin: 8px 0 0; }
.veil { position: absolute; inset: 0; display: grid; place-items: center; background: rgb(67 46 98 / 15%); padding: 14px; z-index: 2; }
.dialog {
  width: min(334px, 100%); padding: 22px 23px 19px; border: 1px solid #beaad4;
  border-radius: 21px; background: #fff8f2; box-shadow: 0 12px 30px #57457526;
  text-align: center;
}
.dialog h2 { font-size: clamp(22px, 4vw, 29px); margin: 0; }
.dialog p { font-size: .91rem; color: #6f5d89; margin: 7px 0 16px; }
#start-form { display: grid; gap: 12px; }
#name-label { display: grid; gap: 5px; font-size: .8rem; text-align: left; }
#player-name { width: 100%; height: 40px; padding: 0 10px; background: #fbf4fc; border: 1px solid #d6c2e5; border-radius: 8px; }
.primary { border: 1px solid #6e4b9b; border-radius: 10px; background: #7a56a8; color: #fff; min-height: 41px; font-weight: 750; }
.primary:hover { background: #674293; }
.shortcut { display: block; color: #6f5d89; margin-top: 11px; font-size: .75rem; }
.controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 13px;
  background: #fff8f2; border: 1px solid #e1d1e9; border-radius: 15px;
  padding: 9px 12px; margin-top: 12px;
}
.controls button { display: flex; align-items: center; gap: 7px; border: 0; padding: 2px; border-radius: 7px; background: transparent; font-size: .87rem; }
kbd { font: inherit; font-size: .79rem; font-weight: 750; padding: 5px 8px; background: #eee4f8; border: 1px solid #cdb9dd; border-radius: 7px; }
#mode-hint { margin: 0 0 0 auto; }
@media (max-width: 660px) {
  .shell { padding-top: 14px; }
  .top { gap: 10px; flex-wrap: wrap; margin-bottom: 11px; padding-bottom: 10px; }
  .brand svg { width: 38px; height: 38px; }
  .brand div { gap: 8px; }
  .game { height: clamp(420px, 64vh, 545px); }
  .hud { left: 8px; top: 9px; }
  .score-card, .stage-card { min-width: 109px; padding: 5px 8px; }
  .score-row { flex-direction: column; gap: 0; }
  .leaderboard { top: 11px; right: 8px; width: min(162px, 43%); }
  .records li { gap: 3px; grid-template-columns: 13px minmax(0, 1fr) 23px max-content; font-size: .74rem; padding-inline: 2px; }
  .records .mode { font-size: .68rem; }
  .board-head h2 { font-size: .88rem; }
  .dialog { padding: 15px; }
  #mode-hint { margin-left: 0; width: 100%; font-size: .8rem; }
}

.controls .connect-sensor {
  padding: 5px 10px; border: 1px solid #cdb9dd; background: #eee4f8;
  border-radius: 8px; font-weight: 650;
}
.controls .connect-sensor:hover:not(:disabled) { background: #e6d8f7; }
