:root {
  color-scheme: dark;
  --page: #17100c;
  --panel: #221710;
  --line: #503828;
  --gold: #e1ae71;
  --text: #f4e4cf;
  --muted: #bdab97;
  --serif: "Noto Serif CJK SC", "Songti SC", STSong, SimSun, Georgia, serif;
  --sans: "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 280px;
  min-height: 100svh;
  color: var(--text);
  background: radial-gradient(ellipse at 48% -10%, #392617 0%, var(--page) 64%);
  font: 400 14px/1.5 var(--sans);
}
button { color: inherit; font: inherit; }
button, .stage { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }
button:focus-visible, .stage:focus-visible {
  outline: 2px solid #f6c989;
  outline-offset: -4px;
}
button:disabled { cursor: default; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.45; stroke-linecap: round; stroke-linejoin: round; }
.hall-shell { width: min(1320px, calc(100% - 96px)); margin: 0 auto; }
.topbar { height: 83px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand, .utilities { display: flex; align-items: center; }
.brand { gap: 14px; }
.brand-mark {
  color: var(--gold);
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  border: 1px solid #795335;
  border-radius: 13px;
  background: linear-gradient(145deg, #46301f, #2b1d14);
  box-shadow: inset 0 0 0 3px #271a12;
}
.brand-mark svg { width: 29px; height: 29px; stroke-width: 1.15; }
h1, h2, p { margin: 0; }
h1 { font: 600 27px/1.2 var(--serif); letter-spacing: .13em; }
.utilities { gap: 9px; }
.utility, .close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #5a4030;
  border-radius: 9px;
  background: #2b1d15;
  color: #e9d4b9;
  font-size: 13px;
  cursor: pointer;
  transition: background-color .2s, border-color .2s;
}
.utility svg, .close svg { width: 19px; height: 19px; color: var(--gold); }
.utility[aria-pressed="false"] svg { color: #b9a291; }

.hall-frame {
  overflow: hidden;
  border: 1px solid #664832;
  border-radius: 14px;
  box-shadow: 0 24px 85px #09060577, 0 0 0 3px #422d1b32;
}
.stage {
  position: relative;
  isolation: isolate;
  height: clamp(365px, calc(100svh - 211px), 790px);
  min-height: min(546px, 40vw);
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 37%, #674022 1%, #352116 37%, #21150f 76%);
  touch-action: manipulation;
  user-select: none;
}
.stage.on-floor { cursor: crosshair; }
.hall-art, .stage-shade, .hall-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.hall-art { inset: auto; top: 0; left: 0; object-fit: fill; }
.stage-shade {
  background: linear-gradient(180deg, #140d0a75 0%, transparent 24%, transparent 83%, #150d0a61 100%),
              radial-gradient(ellipse at 50% 43%, transparent 53%, #120a0766);
}
.hall-caption {
  position: absolute;
  top: 22px;
  left: 24px;
  padding: 9px 14px 10px;
  border: 1px solid #c89e6f42;
  border-radius: 7px;
  background: #21160fe8;
  box-shadow: 0 5px 16px #0d080657;
  pointer-events: none;
}
.hall-caption h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 600 17px/1.45 var(--serif);
  letter-spacing: .12em;
}
.hall-caption h2::before {
  content: "";
  display: block;
  width: 6px;
  height: 6px;
  margin-right: 1px;
  border-radius: 50%;
  background: #e6ad69;
  box-shadow: 0 0 9px #eeb4749a;
}
.hall-caption p { margin-top: 3px; color: #e2c9ab; font-size: 12px; }
.scene-message {
  position: absolute;
  bottom: 18px;
  left: 50%;
  padding: 7px 14px;
  transform: translateX(-50%);
  border: 1px solid #9a6b45;
  border-radius: 6px;
  background: #23170fed;
  color: #f4dcc0;
  box-shadow: 0 4px 16px #150d0a80;
  white-space: nowrap;
  opacity: 1;
  transition: opacity .2s;
  pointer-events: none;
}
.scene-message:empty { opacity: 0; }

.actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid #664832; background: #241912; }
.action {
  min-width: 0;
  min-height: 79px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 19px;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
  transition: background-color .2s;
}
.action + .action { border-left: 1px solid #4b3427; }
.action-icon {
  flex: 0 0 43px;
  width: 43px;
  height: 43px;
  display: grid;
  place-items: center;
  color: var(--gold);
  background: #362419;
  border: 1px solid #66462f;
  border-radius: 10px;
}
.action-icon svg { width: 27px; height: 27px; }
.action-text { min-width: 0; }
.action strong {
  display: block;
  color: #f2dec5;
  font: 600 17px/1.25 var(--serif);
  letter-spacing: .055em;
  white-space: nowrap;
}
.action small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.action kbd {
  display: grid;
  place-items: center;
  flex: 0 0 22px;
  height: 23px;
  margin-left: auto;
  border: 1px solid #614735;
  border-radius: 5px;
  color: #cfad89;
  font: 12px/1 var(--sans);
}
.action.is-active { background: #46301f; }
.action:active, .utility:active, .close:active { background: #46301f; }
.hall-footer { padding: 12px 0 16px; text-align: center; color: #bba48e; font-size: 11px; letter-spacing: .08em; }
.hall-footer span { padding: 0 4px; }

.panel {
  width: min(420px, calc(100% - 30px));
  max-height: min(630px, calc(100dvh - 28px));
  padding: 21px 24px 24px;
  border: 1px solid #87613d;
  border-radius: 16px;
  background: radial-gradient(ellipse at 48% 46%, #42291a, #271a13 60%, #241911 100%);
  color: var(--text);
  box-shadow: 0 24px 85px #080503d9, inset 0 0 0 3px #d6a76a0b;
}
.panel::backdrop { background: #130d0acf; backdrop-filter: blur(5px); }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 15px; }
.panel-header h2 { font: 600 24px/1.3 var(--serif); letter-spacing: .12em; }
.close { flex: 0 0 40px; width: 40px; min-height: 40px; padding: 0; }
.panel-hint { color: var(--muted); margin-top: 5px; font-size: 13px; }
.instrument {
  width: 100%;
  display: block;
  margin: 10px auto 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  background: transparent;
  user-select: none;
}
.instrument canvas { display: block; width: 100%; height: auto; pointer-events: none; }
.beads-instrument { touch-action: none; }
.counter { display: flex; justify-content: center; align-items: baseline; gap: 7px; color: #d0ac87; font: 400 15px/1.15 var(--sans); font-variant-numeric: tabular-nums; }
.counter output { color: #f6d5a2; font: 400 33px/1.1 "STIX Two Text", Georgia, serif; }
.bead-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.reset {
  min-height: 42px;
  padding: 0 14px;
  color: #edd2b1;
  border: 1px solid #7d5838;
  border-radius: 7px;
  background: #362519;
  cursor: pointer;
}
.reset:disabled { opacity: .53; }
.guide { display: grid; margin: 18px 0 0; gap: 14px; }
.guide div + div { border-top: 1px solid #533928; padding-top: 12px; }
.guide dt { font: 600 16px/1.5 var(--serif); color: #f2d8b5; }
.guide dd { margin: 4px 0 0; color: #c9b39c; line-height: 1.75; }

@media (hover: hover) {
  .utility:hover, .close:hover { background: #3c291c; border-color: #8a6040; }
  .action:hover, .reset:enabled:hover { background: #3b291d; }
  .instrument:hover { background: #e4a6530a; border-color: #93664136; }
}
@media (max-width: 850px) {
  .hall-shell { width: calc(100% - 52px); }
  .action { gap: 10px; padding-inline: 12px; }
  .action small { font-size: 11px; }
  .action kbd { display: none; }
}
@media (max-width: 620px) {
  .hall-shell { width: calc(100% - 24px); }
  .topbar { height: 65px; }
  .brand { gap: 10px; }
  .brand-mark { width: 37px; height: 37px; border-radius: 10px; }
  .brand-mark svg { width: 25px; height: 25px; }
  h1 { font-size: 23px; letter-spacing: .11em; }
  .utilities { gap: 6px; }
  .utility { width: 42px; min-height: 42px; padding: 0; }
  .utility span { display: none; }
  .hall-frame { border-radius: 11px; }
  .stage { height: clamp(300px, calc(100svh - 185px), 735px); min-height: 0; }
  .hall-caption { top: 12px; left: 12px; padding: 7px 9px; }
  .hall-caption h2 { font-size: 15px; }
  .hall-caption p { font-size: 11px; margin-top: 2px; }
  .action { min-height: 76px; padding: 8px 3px; flex-direction: column; justify-content: center; gap: 4px; text-align: center; }
  .action-icon { flex-basis: 33px; width: 36px; height: 33px; border-radius: 7px; }
  .action-icon svg { width: 24px; height: 24px; }
  .action strong { font-size: 15px; }
  .action small { display: none; }
  .hall-footer { padding-top: 11px; padding-bottom: max(11px, env(safe-area-inset-bottom)); }
  .panel { padding: 16px 18px 20px; }
  .scene-message { bottom: 12px; padding-block: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

.actions { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.action { gap: 10px; padding-inline: 13px; }
.action small { line-height: 1.4; }
.stage.on-seat { cursor: pointer; }
.sit-clock {
  position: absolute;
  top: 22px;
  right: 24px;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid #9a6b4580;
  border-radius: 7px;
  background: #23170fed;
  color: #f4dcc0;
  font-variant-numeric: tabular-nums;
}
.sit-clock[hidden] { display: none; }
.sit-clock time { color: var(--gold); }
@media (max-width: 1150px) {
  .action kbd { display: none; }
}
@media (max-width: 1050px) {
  .actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stage { height: clamp(340px, calc(100svh - 290px), 720px); }
  .action:nth-child(n+4) { border-top: 1px solid #4b3427; }
  .action:nth-child(4) { border-left: 0; }
}
@media (max-width: 620px) {
  .stage { height: clamp(300px, calc(100svh - 240px), 680px); }
  .action { min-height: 65px; padding: 5px 3px; gap: 3px; }
  .sit-clock { top: 12px; right: 12px; gap: 7px; padding: 6px 8px; font-size: 12px; }
}

.locations { display:flex; gap:10px; align-items:center; justify-content:center; padding:6px 12px; background:#241912; border-bottom:1px solid #5a4030; color:#b79a80; }
.locations button { border:1px solid transparent; border-radius:6px; background:transparent; color:#ddc6ab; min-height:32px; padding:2px 15px; cursor:pointer; }
.locations button[aria-current] { color:#ffe0a8; background:#46301f; border-color:#775034; }
.locations button:hover { color:#ffe0a8; }
.stage { height:clamp(365px,calc(100svh - 257px),790px); }
.stage[data-scene="gate"], .stage[data-scene="court"] { background:#202727; }
.scene-door { position:absolute; z-index:2; left:50%; top:60%; transform:translate(-50%,-100%); min-height:41px; padding:4px 13px; background:#271a12ed; border:1px solid #d0a370; border-radius:7px; color:#fff0d3; white-space:nowrap; cursor:pointer; box-shadow:0 4px 20px #0d080787; }
.scene-door span { margin-left:6px; color:var(--gold); }
.scene-door:hover { background:#523924; }
.action[hidden], .scene-door[hidden] { display:none; }
.actions[data-scene="gate"] { grid-template-columns:repeat(2,minmax(0,1fr)); }
.actions[data-scene="court"] { grid-template-columns:repeat(3,minmax(0,1fr)); }
.actions[data-scene="gate"] #crouch, .actions[data-scene="court"] #bell { border-left:0; }
@media (max-width:1050px) {
  .stage { height:clamp(340px,calc(100svh - 337px),720px); }
  .actions[data-scene="gate"] .action, .actions[data-scene="court"] .action { border-top:0; }
}
@media (max-width:620px) {
  .stage { height:clamp(292px,calc(100svh - 287px),680px); }
  .locations { padding:3px 8px; }
  .locations button { min-height:38px; }
  .scene-door { min-height:44px; }
}
@media (max-width:340px) {
  .brand { gap:6px; }
  h1 { font-size:20px; }
  .utility { width:38px; }
}

.scene-door.back-door { top:auto; left:auto; bottom:12px; right:14px; transform:none; min-height:38px; background:#271a12db; }
@media (max-width:620px) {
  .scene-door.back-door { bottom:10px; right:10px; padding-inline:9px; min-height:40px; font-size:12px; }
}
.stage { overflow: clip; }

[hidden] { display: none !important; }
.stage-wrap { position: relative; }
.entry-screen {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 16px;
  background: #1a110bc4;
}
.entry-card {
  width: min(370px, 100%);
  padding: 24px 20px;
  text-align: center;
  border: 1px solid #8c6749;
  border-radius: 13px;
  background: #2a1b13f5;
  box-shadow: 0 12px 40px #0d080aa0;
}
.entry-card > svg { width: 37px; height: 37px; margin: 0 auto 8px; color: var(--gold); }
.entry-card h2 { font: 600 27px/1.35 var(--serif); letter-spacing: .16em; }
.entry-card p { margin: 9px 0 16px; color: #dbc4aa; }
.entry-primary {
  display: inline-grid;
  min-height: 42px;
  place-items: center;
  padding: 5px 15px;
  border: 1px solid #d7a76f;
  border-radius: 8px;
  background: #e2b67f;
  color: #28180e;
  font: 650 14px var(--sans);
  text-decoration: none;
  cursor: pointer;
}
.entry-primary:hover { background: #efc595; }
.account-link { display: inline-block; padding: 9px 0; color: #e3b780; }
.entry-card .account-link { display: block; margin-top: 7px; }
.account-form { display: grid; gap: 8px; margin-top: 16px; }
.account-form input {
  width: 100%;
  min-height: 44px;
  padding: 8px 11px;
  color: var(--text);
  background: #21160f;
  border: 1px solid #896747;
  border-radius: 7px;
  font: 16px var(--sans);
}
.account-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#account-name { max-width: 8em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.locations small { margin-left: 3px; color: var(--gold); font-variant-numeric: tabular-nums; }
.seat-map { position: absolute; inset: 0; pointer-events: none; }
.cushion-control {
  position: absolute;
  transform: translate(-50%, -50%);
  width: clamp(39px, 9vw, 68px);
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #f7e0b8;
  font: 650 10px var(--sans);
  text-shadow: 0 1px 3px #150b05;
  cursor: pointer;
  pointer-events: auto;
}
.cushion-control span { position: relative; top: 13px; white-space: nowrap; }
.cushion-control[data-state="taken"] { color: #e4c0ae; cursor: default; }
.cushion-control[data-state="mine"] { color: #ffda98; }
.cushion-control:hover, .cushion-control:focus-visible { background: #d7ad7440; }
@media (max-width: 620px) {
  #account.utility { width: 36px; }
  .locations button { padding-inline: 9px; }
}
@media (max-width: 340px) {
  .topbar { gap: 6px; }
  h1 { font-size: 18px; white-space: nowrap; }
  .utilities { gap: 4px; }
  .utility, #account.utility { width: 32px; }
  .brand-mark { width: 32px; }
}
