:root {
  color-scheme: dark;
  --background: #110e21;
  --panel: #201a34;
  --border: #413555;
  --text: #fff8ee;
  --muted: #c8bed9;
  --accent: #ffb168;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  line-height: 1.5;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--background); color: var(--text); }
h1, h2, p { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid #c7a0ff; outline-offset: 4px; }

.host-shell {
  --host-gap: clamp(14px, 1.4vw, 24px);
  display: flex;
  width: min(2080px, 100%);
  min-height: 100svh;
  flex-direction: column;
  gap: var(--host-gap);
  margin: auto;
  padding: clamp(16px, 2vw, 36px);
}
.host-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.host-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.host-header h1, .register-header h1 { font-size: clamp(1.7rem, 3vw, 2.35rem); letter-spacing: .07em; line-height: 1.2; }
.brand-mascot { display: block; height: auto; }

.host-grid {
  display: grid;
  flex: 1;
  grid-template-columns: clamp(248px, 24vw, 410px) minmax(0, 1fr) clamp(214px, 18vw, 298px);
  gap: var(--host-gap);
}
.draw-sidebar { display: grid; grid-template-rows: 1fr auto; gap: var(--host-gap); min-width: 0; }
.panel.mascot-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
  background: radial-gradient(ellipse at 50% 48%, #4b355d, transparent 68%), var(--panel);
}
.mascot-image {
  display: block;
  width: min(100%, 328px);
  height: auto;
  max-height: min(42vh, 380px);
  align-self: center;
  justify-self: center;
  object-fit: contain;
  filter: drop-shadow(0 14px 18px #0e091b99);
}
.stage, .panel { border: 1px solid var(--border); border-radius: 24px; }
.stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  min-height: 500px;
  padding: 18px;
  background: radial-gradient(ellipse at 50% 48%, #4b2c63 0%, #2c2048 46%, #20182f 83%);
}
.stage-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: baseline;
  gap: 10px 14px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.status-tag { grid-column: 1 / -1; justify-self: start; padding: 5px 12px; border: 1px solid #72618f; border-radius: 30px; color: var(--muted); font-size: .9rem; }
.status-tag[data-state="open"] { background: #282e38; border-color: #648174; color: #c3f0d7; }
.status-tag[data-state="closed"] { background: #402e39; border-color: #8b695f; color: #ffd3ad; }
.stat { color: var(--muted); font-size: .92rem; overflow-wrap: anywhere; }
.stat strong { color: var(--text); font-size: 1.2rem; font-variant-numeric: tabular-nums; }

.draw-area { position: relative; display: grid; flex: 1; min-width: 0; place-items: center; }
.draw-visuals { position: absolute; inset: 0; display: block; width: 100%; height: 100%; pointer-events: none; }
.draw-empty, .draw-result { position: relative; display: grid; justify-items: center; text-align: center; }
.draw-empty { gap: 10px; color: var(--muted); }
.draw-empty span { color: #ffcb8f; opacity: .76; font-size: clamp(3rem, 7vw, 5rem); line-height: 1; text-shadow: 0 0 28px #ffbf7766; }
.draw-result { isolation: isolate; max-width: 92%; gap: 8px; animation: reveal-result 460ms cubic-bezier(.18, .76, .26, 1) both; }
.draw-result::before { content: ""; position: absolute; z-index: -1; inset: -35px -55px; background: radial-gradient(ellipse, #2c1636bf, transparent 72%); pointer-events: none; }
.result-round, .result-id { color: #fff1d6; font-weight: 700; font-size: clamp(.94rem, 1.9vw, 1.2rem); text-shadow: 0 2px 7px #291322; }
.result-name { max-width: 100%; color: #ffe089; overflow-wrap: anywhere; font-size: clamp(2.6rem, 6.8vw, 5rem); line-height: 1.12; text-shadow: 0 0 24px #ffab5680, 0 3px 12px #291322; }
.result-name.long-name { font-size: clamp(1.5rem, 4vw, 3rem); }
.result-id { font-variant-numeric: tabular-nums; }
@keyframes reveal-result {
  from { opacity: 0; transform: translateY(9px) scale(.72); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.stage-controls { display: grid; gap: 10px; }
.primary-button, .quiet-button { border: 1px solid transparent; border-radius: 12px; padding: 9px 16px; font-weight: 700; }
.primary-button { background: var(--accent); color: #2d1831; box-shadow: 0 4px 0 #9e5d3a; }
.primary-button:hover:not(:disabled) { background: #ffc58f; }
.primary-button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #9e5d3a; }
.primary-button:disabled { background: #4b3b5d; color: #c8b9dc; box-shadow: none; }
.draw-button { min-height: 58px; font-size: 1.35rem; }
.stage-help { min-height: 2.8em; color: var(--muted); text-align: center; }
.quiet-button { background: #2e2443; border-color: #65567b; color: var(--text); }
.quiet-button:hover:not(:disabled) { background: #43345d; }
.quiet-button:disabled { border-color: var(--border); color: #aea3c0; }

.side-column { display: grid; grid-template-rows: auto 1fr; gap: var(--host-gap); min-width: 0; }
.panel { background: var(--panel); padding: 20px; }
.panel h2 { font-size: 1.15rem; }
.join-panel { display: grid; gap: 12px; justify-items: center; text-align: center; }
.qr-frame { width: min(100%, 216px); background: white; border-radius: 12px; overflow: hidden; }
.qr-frame img { display: block; width: 100%; height: auto; }
.join-hint, .empty-text { color: var(--muted); }
.join-link { max-width: 100%; color: #ffd0ac; font-size: .88rem; overflow-wrap: anywhere; }
.close-button { width: 100%; margin-top: 3px; }
.history-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.clear-button { padding: 5px 10px; font-size: .875rem; }
.clear-button:not(:disabled) { color: #ffd0cb; }
.history-list { list-style: none; display: grid; align-content: start; gap: 2px; margin: 0; padding: 0; max-height: 208px; overflow: auto; }
.history-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--border); }
.history-list strong { overflow-wrap: anywhere; }
.history-sequence, .history-id { color: var(--muted); font-size: .88rem; }

.register-page { min-height: 100vh; background: radial-gradient(ellipse at 50% 12%, #483261, var(--background) 70%); }
.register-shell { width: min(100%, 460px); margin: auto; padding: clamp(26px, 6vh, 62px) 20px 32px; }
.register-header { display: grid; justify-items: center; gap: 13px; margin-bottom: 28px; }
.register-header .brand-mascot { width: clamp(96px, 27vw, 136px); }
.register-panel { padding: 24px; }
.register-panel h2 { margin-bottom: 7px; }
.register-panel form { display: grid; gap: 8px; margin-top: 23px; }
.register-panel label { font-weight: 700; }
.register-panel input { min-width: 0; width: 100%; background: #171226; border: 1px solid #6d5c85; border-radius: 9px; color: var(--text); padding: 11px 12px; margin-bottom: 10px; }
.register-panel input::placeholder { color: #aa9cbe; }
.register-panel button { min-height: 46px; }
.form-message { margin-top: 16px; color: var(--muted); }
.form-message:empty { display: none; }
.form-message[data-state="error"] { color: #ffc3bd; }
.form-message[data-state="success"] { color: #c3f0d7; }

@media (max-width: 1000px) {
  .host-grid { grid-template-columns: minmax(220px, 1fr) minmax(0, 2fr); }
  .side-column { grid-column: 1 / -1; grid-template: auto / repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .host-grid { grid-template-columns: minmax(0, 1fr); }
  .mascot-image { max-height: 200px; }
  .stage { min-height: 340px; padding: 12px; }
  .side-column { grid-template: auto auto / minmax(0, 1fr); }
}

@media (max-width: 460px) {
  .host-header { flex-wrap: wrap; gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .host-page:not(.motion-enabled) .draw-result { animation: none; }
}
