:root {
  color-scheme: dark;
  --background: #11121c;
  --panel: #191b29;
  --control: #11131f;
  --line: #33364a;
  --text: #f4f2ff;
  --muted: #b8b8ce;
  --accent: #cabdff;
  --accent-strong: #b5a0ff;
  --mint: #a7f0ce;
  --sans: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-width: 280px;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(ellipse at 16% 32%, #221b37 0%, transparent 47%), var(--background);
  font: 1rem/1.55 var(--sans);
}
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, p { margin: 0; }
.shell { max-width: 1136px; margin-inline: auto; padding: 0 clamp(18px, 5vw, 48px) 56px; }
.masthead { min-height: 79px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 750; letter-spacing: .05em; }
.mark { display: grid; grid-template-columns: repeat(2, 7px); gap: 3px; padding: 6px; background: #332750; border-radius: 7px; }
.mark i { height: 7px; border-radius: 2px; background: var(--accent); }
.mark i:last-child { background: var(--mint); }
.header-meta { color: var(--muted); font-size: .875rem; }

.landing { display: grid; grid-template-columns: 1.2fr 1fr; align-items: center; gap: clamp(30px, 8vw, 112px); padding-top: clamp(66px, 13vh, 142px); }
.intro h1 { font-size: clamp(3.1rem, 7.55vw, 6.15rem); line-height: 1.07; font-weight: 850; letter-spacing: -.055em; }
.intro h1 span { color: var(--accent); }
.intro-copy { margin-top: 16px; font-size: clamp(1.15rem, 2.2vw, 1.5rem); color: var(--muted); }
.sample { margin-top: 31px; max-width: 413px; }
.sample-grid, .answer-digits, .guess-wheels { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(7px, 2vw, 12px); }
.sample-grid span, .answer-digits span {
  min-width: 0;
  display: grid;
  place-items: center;
  min-height: 68px;
  border: 1px solid #49415f;
  border-radius: 13px;
  background: #211d31;
  font: 700 clamp(1.8rem, 4.6vw, 3.3rem)/1 var(--mono);
}
.sample-grid span { aspect-ratio: 1.03; color: #b7accb; }
.sample-grid span:nth-child(-n+2) { background: #29223d; color: #eee8ff; border-color: #77649f; }
.sample-caption { display: flex; align-items: baseline; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; color: var(--muted); font-size: .875rem; margin-top: 12px; }
.sample-hits { color: var(--mint); }
.rule { margin-top: 25px; color: var(--muted); max-width: 30ch; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 19px; }
.entry { padding: clamp(22px, 4vw, 36px); box-shadow: 0 24px 60px #06071155; }
.entry h2 { font-size: 1.65rem; line-height: 1.2; }
.subtle { color: var(--muted); }
.entry > .subtle { margin-top: 8px; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin: 24px 0 21px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--control); }
.mode-switch button { padding: 9px 4px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: .9375rem; font-weight: 650; }
.mode-switch button[aria-pressed="true"] { background: #343046; color: var(--text); }
label { display: block; margin-bottom: 7px; font-size: .9375rem; font-weight: 630; }
.entry input { display: block; width: 100%; min-height: 49px; padding: 10px 13px; border: 1px solid #44465b; border-radius: 10px; color: var(--text); background: var(--control); }
.entry input::placeholder { color: #aaa9be; opacity: 1; }
#code-field { margin-top: 13px; }
#join-code { text-transform: uppercase; letter-spacing: .1em; }
#join-code::placeholder { letter-spacing: normal; }
.primary { min-height: 47px; padding: 10px 24px; border: 1px solid transparent; border-radius: 11px; background: var(--accent-strong); color: #1e1532; font-weight: 780; }
.primary:hover:not(:disabled) { background: #d5c9ff; }
.primary:disabled { background: #383549; color: #bcbbcf; }
.full { width: 100%; margin-top: 20px; }
.error { color: #ffb4b9; font-size: .9375rem; margin-top: 10px; }

.room { padding-top: clamp(28px, 6vw, 66px); }
.room-head { display: flex; justify-content: space-between; align-items: end; gap: 15px 20px; margin-bottom: 26px; }
.eyebrow { font-size: .875rem; font-weight: 700; color: var(--accent); }
.room h1 { font-size: clamp(2rem, 5.6vw, 3.6rem); line-height: 1.16; letter-spacing: -.045em; margin: 4px 0 8px; }
.code-button { flex: none; display: grid; justify-items: center; gap: 1px; padding: 8px 16px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); color: var(--muted); font-size: .875rem; }
.code-button:hover { border-color: var(--accent); }
#room-code { color: var(--accent); font: 750 1.15rem/1.45 var(--mono); letter-spacing: .14em; user-select: all; }
.room-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(218px, 280px); gap: 18px; align-items: start; }
.room-main { min-width: 0; display: grid; gap: 16px; }
.arena { text-align: center; padding: clamp(21px, 5vw, 39px); }
.arena .primary { min-width: min(100%, 190px); }
.answer-digits, .guess-wheels { max-width: 358px; margin-inline: auto; }
.invite { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 19px; align-items: center; justify-content: center; max-width: 535px; margin-inline: auto; padding: clamp(13px, 3vw, 19px); border: 1px solid var(--line); border-radius: 14px; background: var(--control); text-align: left; }
#invite-qr { display: block; max-width: 100%; height: auto; border-radius: 5px; background: #fff; image-rendering: pixelated; }
.invite h2 { font-size: 1.2rem; }
.invite .subtle { margin-top: 6px; }
.secondary { min-height: 43px; margin-top: 11px; padding: 6px 12px; border: 1px solid #665e84; border-radius: 9px; background: #29243d; color: var(--accent); font-weight: 700; }
.secondary:hover { border-color: var(--accent); }
#invite-url { display: block; margin-top: 7px; color: var(--accent); overflow-wrap: anywhere; font: .875rem/1.4 var(--mono); }
.arena .subtle { margin-top: 17px; }
.arena #start, .arena #restart { margin-top: 17px; }
.turn-status { width: fit-content; max-width: 100%; margin: 0 auto 17px; padding: 5px 12px; border-radius: 8px; background: #272638; color: var(--muted); font-weight: 680; overflow-wrap: anywhere; }
.turn-status.own-turn { background: #302647; color: #e7dcff; }
.room-tools { display: grid; justify-items: stretch; gap: 6px; flex: none; }
.voice-button { color: var(--accent); background: transparent; border: 1px solid var(--line); border-radius: 9px; padding: 6px 8px; font-size: .875rem; }
.voice-button[aria-pressed="true"] { background: #302647; }
.guess-label { font-weight: 650; }
.guess-wheels { --reel-row: 38px; margin-block: 12px 15px; }
.reel { position: relative; min-width: 0; border: 1px solid var(--line); border-radius: 11px; background: #141522; }
.reel::before { content: ''; position: absolute; top: var(--reel-row); left: 3px; right: 3px; height: var(--reel-row); border: 1px solid #6e5c9c; border-radius: 7px; background: #302647; pointer-events: none; }
.reel:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.reel-scroll { position: relative; height: calc(var(--reel-row) * 3); padding-block: var(--reel-row); overflow-y: auto; overscroll-behavior-y: contain; scroll-snap-type: y mandatory; scrollbar-width: none; border-radius: inherit; touch-action: pan-y; user-select: none; }
.reel-scroll::-webkit-scrollbar { display: none; }
.reel-scroll span { height: var(--reel-row); display: grid; place-items: center; scroll-snap-align: center; color: var(--muted); font-size: 1.125rem; cursor: pointer; }
.reel-scroll span.selected { color: var(--text); font-size: 1.65rem; font-weight: 780; }
.guess-status { color: var(--mint); margin-top: 8px; font-weight: 680; }
#result-heading { font-size: clamp(1.5rem, 4vw, 2.25rem); overflow-wrap: anywhere; }
.answer-digits { margin-top: 10px; }
.answer-digits span { border-color: #54816d; background: #1d332f; color: var(--mint); }
.players, .history { min-width: 0; padding: clamp(15px, 3vw, 24px); }
.panel-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; }
.panel-heading h2 { font-size: 1.125rem; }
.panel-heading .subtle { font-size: .875rem; }
.players ul, .history-list { margin: 13px 0 0; padding: 0; list-style: none; }
.players li { display: grid; grid-template-columns: 9px minmax(0,1fr) auto; align-items: center; gap: 8px; min-height: 43px; padding-block: 6px; border-top: 1px solid var(--line); }
.players strong { overflow-wrap: anywhere; }
.presence { width: 8px; height: 8px; border: 1px solid #a2a2bb; border-radius: 50%; }
.presence.online { background: #9debc5; border-color: #9debc5; }
.player-tags { font-size: .8125rem; color: var(--accent); }
#history-empty { margin-top: 10px; }
.history-list li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(65px, .65fr) auto; align-items: center; gap: 8px; border-top: 1px solid var(--line); min-height: 49px; padding-block: 7px; }
.attempt { color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.history-number { font: 750 1.2rem/1.3 var(--mono); letter-spacing: .1em; }
.score { border-radius: 6px; padding: 3px 7px; color: var(--accent); background: #2a243a; white-space: nowrap; font-size: .875rem; }
.score.perfect { color: var(--mint); background: #1c3831; }
#room-error { padding: 12px 16px; }
.copy-proxy { position: fixed; top: 0; left: 0; opacity: 0; }

@media (max-width: 740px) {
  .landing { grid-template-columns: minmax(0, 1fr); gap: 27px; padding-top: 38px; }
  .sample { margin-top: 21px; }
  .sample-grid span { min-height: 58px; max-height: 83px; }
  .rule { margin-top: 16px; max-width: none; }
  .intro-copy { margin-top: 9px; }
  .room-layout { grid-template-columns: minmax(0, 1fr); }
  .masthead { min-height: 59px; }
}
@media (max-width: 425px) {
  .room-head { align-items: start; }
  .room-head .subtle { font-size: .9375rem; }
  .code-button { padding-inline: 8px; }
  #room-code { font-size: 1rem; }
  .answer-digits span { min-height: 57px; }
  .invite { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; }
}
