:root {
  color-scheme: dark;
  --background: #100d19;
  --card: #1a1526;
  --line: #342946;
  --text: #f7f1ff;
  --muted: #b0a3c2;
  --purple: #bd9afb;
  --orange: #ff854b;
  --gold: #ffb47d;
  font: 16px/1.5 system-ui, "Microsoft JhengHei", "PingFang TC", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { max-width: 100%; overflow-x: hidden; }
body { margin: 0; min-width: 280px; max-width: 100%; min-height: 100vh; overflow-x: hidden; background: radial-gradient(ellipse at 61% 13%, #1e122e 0, transparent 53%), var(--background); color: var(--text); }
button, input, select { max-width: 100%; font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
h1, h2, p, ol { margin: 0; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--purple); outline-offset: 4px; }
.skip-link { position: fixed; z-index: 30; top: 8px; left: 8px; transform: translateY(-180%); padding: 9px 12px; border: 1px solid #b38fe1; border-radius: 8px; background: #20152f; color: #fff; font-weight: 800; }
.skip-link:focus { transform: translateY(0); }
.shell { width: min(1200px, calc(100% - 80px)); margin-inline: auto; }
.topbar { background: #120e1c; border-bottom: 1px solid #2d2339; }
.topbar-inner { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 900; font-size: 1.28rem; letter-spacing: -.065em; white-space: nowrap; }
.brand-mark { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; gap: 2px; color: #27121b; background: var(--orange); border-radius: 11px; }
.brand-mark i { width: 2px; height: 9px; border-radius: 2px; background: currentColor; }
.brand-mark i:nth-child(even) { height: 14px; }
.brand-mark i:nth-child(3) { height: 20px; }
.brand-accent, .bolt { color: var(--orange); }
.nav { display: flex; gap: 12px; align-items: center; }
.nav-button, .profile-button { padding: 8px 13px; min-height: 42px; border-radius: 9px; border: 1px solid transparent; background: transparent; white-space: nowrap; font-size: .9rem; font-weight: 700; color: var(--muted); }
.nav-button span { color: var(--purple); margin-right: 3px; }
.nav-button:hover, .profile-button:hover { color: var(--text); background: #2b1e3b; }
.help-button span { display: inline-grid; width: 16px; height: 16px; place-content: center; border: 1px solid currentColor; border-radius: 50%; font-size: .67rem; }
.profile-button { display: inline-flex; align-items: center; gap: 8px; border-color: #51406b; background: #241a34; color: #e5d4ff; }
#profile-label { max-width: 12rem; overflow: hidden; text-overflow: ellipsis; }
.person-icon { display: inline-block; position: relative; width: 14px; height: 16px; color: var(--purple); }
.person-icon::before, .person-icon::after { position: absolute; content: ""; border: 1.5px solid currentColor; }
.person-icon::before { width: 7px; height: 7px; border-radius: 50%; left: 3.5px; }
.person-icon::after { width: 13px; height: 7px; border-radius: 7px 7px 2px 2px; left: .5px; bottom: 0; }

.hero { position: relative; display: flex; align-items: center; min-height: 290px; margin: 28px 0 24px; padding: 35px 52px; overflow: hidden; isolation: isolate; border: 1px solid #513267; border-radius: 23px; background: radial-gradient(ellipse at 80% 36%, #69366b 0, transparent 49%), linear-gradient(111deg, #231437 1%, #351d4a 55%, #3a234d 100%); }
.hero::before { position: absolute; content: ""; inset: 0; z-index: -1; opacity: .6; background-image: radial-gradient(#e3b7ff2c .7px, transparent .8px); background-size: 11px 11px; mask-image: linear-gradient(90deg, transparent 13%, #000 60%); }
.hero-copy { position: relative; z-index: 2; }
.eyebrow { color: #eddcff; font-size: .9rem; font-weight: 750; letter-spacing: .18em; display: inline-flex; align-items: center; gap: 9px; border: 1px solid #8857a9; background: #2b1641b0; padding: 6px 11px; border-radius: 6px; }
.tiny-wave { color: #d7a5ff; letter-spacing: -.16em; margin-right: 2px; }
.hero h1 { margin: 8px 0 12px; font-size: clamp(3.3rem, 8.5vw, 7.35rem); letter-spacing: -.105em; font-weight: 950; line-height: 1.15; white-space: nowrap; }
.hero h1 span { color: var(--orange); }
.hero p { color: #decaef; font-size: clamp(1rem, 2vw, 1.25rem); font-weight: 590; }
.record-art { position: absolute; inset: 0 0 0 45%; pointer-events: none; }
.sweep { position: absolute; width: 100%; height: 67%; right: -3%; top: 19%; border: 1px solid #d190e55e; border-radius: 50%; transform: rotate(-23deg); }
.sweep-two { right: -5%; width: 98%; top: 10%; height: 85%; border-color: #d27df13b; }
.vinyl { position: absolute; top: 50%; right: 15%; width: clamp(220px, 25vw, 325px); aspect-ratio: 1; transform: translateY(-50%) rotate(-23deg); border-radius: 50%; border: 2px solid #6f5373; box-shadow: 12px 18px 30px #150b20a0, 0 0 55px #b770a442, inset 0 0 16px #000; display: grid; place-items: center; background: conic-gradient(from 10deg, #17132255 0%, #967a9b45 15%, #140e1acc 25%, #140e1a25 46%, #bd87934d 59%, #130d1bd9 80%, #17132255 100%), repeating-radial-gradient(circle, #241926 0 2px, #342638 2.5px 3px, #1a1421 3.5px 6px); }
.vinyl::after { position: absolute; content: ""; inset: 8%; border: 1px solid #b794a24a; border-radius: 50%; box-shadow: inset 0 0 0 2px #13101a; }
.record-label { width: 35%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; color: #2b1726; background: radial-gradient(circle, #ffc29c 3%, #f7a176 7% 32%, #ff9055 33% 36%, #ff8249 38%); border: 2px solid #e69b75; box-shadow: 0 0 0 5px #17101d, 0 0 0 6px #9a6775; }
.record-label span { font-size: clamp(2.3rem, 4.5vw, 4rem); line-height: 1; transform: rotate(23deg) translateY(-4%); text-shadow: 1px 1px #fff4; }
.art-bars { height: 40%; bottom: 13%; right: 4%; width: 68%; position: absolute; opacity: .37; background: repeating-linear-gradient(90deg, #fd80af 0 2px, transparent 2px 8px); clip-path: polygon(0 63%, 8% 56%, 13% 84%, 19% 29%, 24% 55%, 29% 18%, 34% 59%, 45% 44%, 60% 45%, 64% 30%, 69% 59%, 75% 24%, 80% 57%, 85% 12%, 90% 54%, 100% 63%, 91% 69%, 87% 88%, 81% 67%, 75% 96%, 69% 67%, 62% 95%, 55% 70%, 35% 71%, 25% 87%, 19% 74%, 14% 98%, 8% 70%); }
.art-spark, .art-note { position: absolute; color: #ffaf86; text-shadow: 0 0 17px #ffa17eba; }
.art-spark { top: 15%; right: 9%; font-size: 1.55rem; }
.art-note { bottom: 14%; left: 6%; font-size: 1.6rem; color: #e9aaf3; transform: rotate(-15deg); }

.layout { display: grid; grid-template-columns: minmax(0, 2.45fr) minmax(270px, 1fr); gap: 20px; align-items: start; }
.card { min-width: 0; overflow: hidden; background: var(--card); border: 1px solid var(--line); border-radius: 17px; }
.card-head { min-height: 65px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 20px; border-bottom: 1px solid var(--line); }
.card-head h2, .joker-card h2 { font-size: 1.04rem; font-weight: 780; }
.stage-label { display: flex; align-items: center; gap: 10px; }
.live-dot { width: 9px; height: 9px; margin-left: 2px; background: #cb99ff; border-radius: 100%; box-shadow: 0 0 0 4px #c694ff26; }
.phase, .count { white-space: nowrap; border-radius: 6px; font-size: .84rem; font-weight: 730; padding: 4px 9px; background: #2a1d3c; color: #dcc3ff; }
.phase[data-live="true"] { color: #ffd2b9; background: #512b31; }

/* Ten player seats around an interactive central table. */
.battle-room { padding: 16px 16px 12px; border-bottom: 1px solid #4a3259; background: linear-gradient(180deg, #241832, #181324); }
.battle-room-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 12px; }
.battle-room-head h3 { margin: 0; font-size: .97rem; color: #f3d9ff; font-weight: 800; }
.battle-room-head h3 span { color: var(--orange); margin-right: 5px; }
.battle-room-count { color: #d0bbdf; font-size: .79rem; font-weight: 700; }
.battle-room-floor { position: relative; min-width: 0; border-radius: 18px; border: 1px solid #4e3762; padding: 14px 12px; background: radial-gradient(ellipse at 50% 48%, #5933636e 0%, #3020415c 45%, transparent 80%), linear-gradient(#25172f, #1c1528); overflow: hidden; }
.battle-room-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; position: relative; z-index: 1; }
.battle-seat { position: relative; min-width: 0; min-height: 112px; padding: 8px 4px 7px; display: flex; align-items: center; flex-direction: column; justify-content: flex-end; gap: 3px; text-align: center; border-radius: 12px; border: 1px solid #624674; background: #352543; box-shadow: inset 0 3px 11px #160e24ad, 0 4px 9px #110b19ab; color: var(--text); transition: border-color .2s, box-shadow .2s; }
.battle-seat::before { content: ""; position: absolute; inset: 4px 10% auto; height: 20px; border: 1px solid #785b8f; border-bottom: 0; border-radius: 12px 12px 0 0; background: #513665; opacity: .65; pointer-events: none; }
.battle-seat-number { position: absolute; top: 5px; left: 7px; font: 700 .63rem/1 ui-monospace, Consolas, monospace; color: #c7b4d9; }
.battle-seat-avatar { display: grid; place-items: center; z-index: 1; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 50%; border: 2px solid #9f79c5; background: linear-gradient(135deg, #6e4298, #45305f); color: #fff2ff; font-size: .8rem; font-weight: 900; line-height: 1; box-shadow: 0 2px 8px #0005; }
.battle-seat-name { z-index: 1; width: 100%; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; line-height: 1.3; font-size: .8rem; font-weight: 780; }
.battle-seat-score { z-index: 1; width: 100%; font-size: .69rem; line-height: 1.35; color: #e3c9fd; overflow-wrap: anywhere; }
.battle-seat.is-empty { border-style: dashed; border-color: #75528b; background: #281e35; }
.battle-seat.is-empty:hover:not(:disabled), .battle-seat.is-empty:focus-visible { border-color: #ffb47d; background: #40304d; box-shadow: 0 0 14px #fc9f674e; }
.battle-seat.is-empty::before { opacity: .24; }
.battle-seat.is-empty .battle-seat-avatar { border-style: dashed; border-color: #8f6eab; background: #362845; color: #efb3ff; font-size: 1.2rem; }
.battle-seat.is-empty .battle-seat-name, .battle-seat.is-empty .battle-seat-score { color: #cab1dc; font-weight: 600; }
.battle-seat.is-me { border-color: #e9bcff; box-shadow: inset 0 0 0 1px #d298f4, 0 0 14px #c58bf94d; }
.battle-seat.is-answering { border-color: #ffbd71; box-shadow: inset 0 0 0 1px #ffad66, 0 0 18px #ffa25787; }
.battle-seat.is-answering .battle-seat-avatar { border-color: #ffc37f; background: linear-gradient(135deg, #b96e49, #7c3e5d); }
.battle-seat.is-correct { border-color: #79dbab; }
.battle-seat.is-correct .battle-seat-score { color: #9ee9c0; }
.battle-seat.is-wrong, .battle-seat.is-timeout { border-color: #d87d85; }
.battle-seat.is-wrong .battle-seat-score, .battle-seat.is-timeout .battle-seat-score { color: #ffb3af; }
.battle-seat:disabled { cursor: default; }
.battle-room-stage { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; width: min(90%, 305px); min-height: 72px; margin: 6px auto; padding: 5px 10px; gap: 0; text-align: center; color: #ffe2fa; background: #3b254e; border: 1px solid #c391f2; border-radius: 35px; box-shadow: 0 0 22px #d28ff532, inset 0 0 8px #b36add42; font-weight: 900; font-size: 1.02rem; letter-spacing: .02em; }
.battle-room-stage:hover:not(:disabled), .battle-room-stage:focus-visible { border-color: #ffb47d; background: #51315f; }
.battle-room-stage:disabled { border-color: #70588b; }
.battle-room-stage-icon { position: absolute; left: 18px; top: 14px; color: #ffb387; font-size: 1.4rem; }
.battle-room-stage-sub { color: #dab1ef; font-size: .69rem; font-weight: 650; }
.battle-room-note { padding: 9px 2px 0; text-align: center; color: #b5a4c6; font-size: .76rem; }
.stage-body { min-height: 300px; padding: 26px 22px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; }
.timer-label, .stage-hint { color: var(--muted); }
.timer-label { font-size: .9rem; font-weight: 650; }
.clock { color: var(--gold); font: 800 clamp(3.65rem, 8vw, 5rem)/1 ui-monospace, Consolas, monospace; letter-spacing: -.085em; font-variant-numeric: tabular-nums; padding-right: .085em; }
.clock span { color: var(--orange); }
.clock-track { width: min(80%, 240px); height: 5px; background: #32243f; border-radius: 50px; overflow: hidden; margin: 8px 0; }
.clock-track div, .question-track div { width: 100%; height: 100%; background: linear-gradient(90deg, #ad70ed, #ff935a); transform-origin: left; }
.stage-hint { min-height: 1.5em; overflow-wrap: anywhere; }
.primary, .secondary, .text-button { border-radius: 9px; border: 1px solid transparent; min-height: 44px; padding: 8px 16px; font-weight: 780; }
.primary { color: #21111b; background: var(--orange); box-shadow: 0 3px 0 #ba4d36; }
.primary:hover:not(:disabled) { background: #ff9b6b; }
.primary:active:not(:disabled) { box-shadow: 0 1px 0 #ba4d36; transform: translateY(2px); }
.primary:disabled { box-shadow: none; color: #c2abcf; background: #3c2e4a; }
.secondary { color: #ead9ff; background: #2b1e3c; border-color: #57416e; }
.secondary:hover:not(:disabled) { background: #432b5b; }
.secondary:disabled { opacity: .45; }
.text-button { padding: 4px 8px; min-height: 34px; color: var(--muted); background: transparent; text-decoration: underline; font-size: .9rem; }
.join { min-width: min(100%, 236px); min-height: 52px; margin-top: 8px; font-size: 1.05rem; }
.join .bolt { font-size: 1.3em; line-height: .8; vertical-align: -.05em; color: #2a131e; margin-right: 4px; }
.join:disabled .bolt { color: inherit; }
.stage-footer { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 14px 17px; border-top: 1px solid var(--line); background: #181222; }
.stage-footer div { display: flex; align-items: center; justify-content: center; gap: 10px; }
.stage-footer div + div { border-left: 1px solid var(--line); }
.stage-footer b, .stage-footer small { display: block; }
.stage-footer b { font-size: .93rem; }
.stage-footer small { color: var(--muted); font-size: .81rem; }
.metric-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: #302143; color: #d3adff; font-size: 1.11rem; position: relative; }
.clock-icon::before { content: ""; position: absolute; height: 15px; width: 15px; border: 1.5px solid currentColor; border-radius: 50%; }
.clock-icon::after { content: ""; position: absolute; width: 5px; height: 5px; top: 10px; left: 14px; border-left: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; }

.sidebar { display: grid; gap: 16px; }
.players .card-head { padding-inline: 16px; }
.side-icon { color: var(--purple); margin-right: 4px; }
.roster { list-style: none; padding: 10px 14px; display: grid; gap: 5px; }
.roster li { display: grid; grid-template-columns: 33px minmax(0, 1fr) auto; align-items: center; gap: 9px; min-height: 42px; border-radius: 7px; padding: 4px 8px; background: #21192f; }
.roster .position { display: grid; place-items: center; width: 26px; min-height: 25px; font: 700 .8rem/1 ui-monospace, Consolas, monospace; color: var(--purple); background: #30213f; border-radius: 5px; }
.roster .slot-name { min-width: 0; overflow-wrap: anywhere; font-size: .92rem; }
.roster .slot-stat { font-weight: 730; font-size: .87rem; color: #f6d0ae; }
.roster .empty .slot-name, .roster .empty .slot-stat { color: var(--muted); font-weight: 500; }
.roster .mine { box-shadow: inset 0 0 0 1px #77569f; }
.queue-note { padding: 10px 17px 12px; border-top: 1px solid var(--line); color: var(--muted); display: flex; justify-content: space-between; font-size: .87rem; gap: 15px; }
.queue-note strong { text-align: right; color: #ded0f0; }
.waiting-list .card-head { padding-inline: 15px; }
.waiting-info { padding: 13px 15px; color: #d4c0df; font-size: .78rem; line-height: 1.6; }
.waiting-provisional { font-weight: 800; color: #ffd2a6; }
.waiting-group { padding: 2px 12px 12px; }
.waiting-group + .waiting-group { border-top: 1px solid #483658; padding-top: 11px; }
.waiting-group h3 { color: #f0d8ff; font-size: .9rem; font-weight: 800; margin: 0 0 7px; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.waiting-group h3 small { color: var(--muted); font-size: .71rem; font-weight: 650; }
.waiting-rows { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; max-height: 310px; overflow-y: auto; scrollbar-width: thin; }
.waiting-rows li { min-width: 0; display: flex; align-items: center; gap: 8px; border-radius: 6px; background: #241b31; padding: 6px 8px; line-height: 1.3; }
.waiting-rows .waiting-number { color: #c99dff; font: 750 .74rem ui-monospace, Consolas, monospace; }
.waiting-rows .waiting-name { font-size: .83rem; overflow-wrap: anywhere; min-width: 0; }
.waiting-rows .waiting-mine { outline: 1px solid #bc91e9; background: #362247; }
.waiting-rows .waiting-empty { color: #a99abb; font-size: .76rem; font-style: italic; background: transparent; }
.joker-card { display: grid; grid-template-columns: 39px 1fr auto; align-items: center; gap: 11px; border: 1px solid #5b393e; border-radius: 13px; background: linear-gradient(105deg, #33212f, #27192a); padding: 13px 14px; }
.joker-icon { width: 36px; height: 37px; display: grid; place-items: center; font-size: 1.4rem; background: #50313a; color: #ffb98c; border-radius: 8px; }
.joker-card h2 { color: #ffd8b9; }
.joker-card p { color: #d2b3c6; font-size: .83rem; }
.joker-switch { width: 40px; height: 24px; border-radius: 40px; border: 1px solid #745268; padding: 3px; background: #3d2a42; }
.joker-switch span { display: block; width: 16px; height: 16px; border-radius: 50%; background: #ad91b4; transition: transform .15s ease; }
.joker-switch[aria-checked="true"] { background: #9c4f43; }
.joker-switch[aria-checked="true"] span { transform: translateX(15px); background: #ffb17e; }
.joker-switch:disabled { opacity: .58; }

.question-panel { gap: 10px; justify-content: start; }
.question-top { color: #dec1ff; width: 100%; display: flex; justify-content: space-between; text-align: left; }
.question-top strong { color: var(--gold); font: 700 1.1rem ui-monospace, Consolas, monospace; }
.question-track { height: 5px; border-radius: 30px; overflow: hidden; width: 100%; background: #32243f; }
.question-song { color: #ead7ff; margin-top: 8px; }
.question-song span:last-child { color: var(--muted); margin-left: 8px; }
.lyric { font-size: clamp(1.5rem, 4vw, 2.3rem); font-weight: 780; line-height: 1.3; overflow-wrap: anywhere; }
.question-panel .stage-hint { min-height: 3em; }
.answer-form { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; width: min(100%, 550px); }
input { min-height: 46px; min-width: 0; width: 100%; padding: 8px 12px; color: var(--text); background: #15101e; border: 1px solid #604b76; border-radius: 8px; }
input::placeholder { color: #a897bb; }
.mic { padding: 8px 12px; }
.mic[aria-pressed="true"] { color: var(--gold); }
.mic-icon { display: block; position: relative; width: 19px; height: 20px; }
.mic-icon::before { content: ""; position: absolute; left: 6px; top: 0; width: 7px; height: 13px; border: 1.5px solid currentColor; border-radius: 6px; }
.mic-icon::after { content: ""; position: absolute; left: 3px; top: 5px; width: 13px; height: 12px; border: solid currentColor; border-width: 0 1.5px 1.5px; border-radius: 0 0 8px 8px; }
.results { margin-top: 20px; }
.own-result { margin: 10px 16px 0; color: #f6caab; }
.page-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; min-height: 60px; gap: 10px 16px; color: #a491b6; font-size: .82rem; }
.page-footer span:first-child { color: #c8b6dc; font-weight: 800; }
.answer-count { margin: 7px 0 4px; color: #f4d68b; font-size: .9rem; font-weight: 700; line-height: 1.5; }
#catalog-stat { min-width: 0; overflow-wrap: anywhere; text-align: right; }

/* Shared chat and player portraits */
.chat-description { padding: 10px 14px; color: #cbb8db; font-size: .79rem; line-height: 1.5; }
.chat-messages { list-style: none; margin: 0; padding: 10px; height: 270px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; display: flex; flex-direction: column; gap: 7px; border-block: 1px solid var(--line); background: #15111f; }
.chat-line, .chat-empty { min-width: 0; border-radius: 9px; background: #2b203a; padding: 7px 9px; }
.chat-empty { color: var(--muted); font-size: .8rem; }
.chat-line-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 5px; }
.chat-line-top strong { color: #e6caff; font-size: .81rem; min-width: 0; overflow-wrap: anywhere; }
.chat-line-top time { color: #c4b1d5; font-size: .69rem; white-space: nowrap; }
.chat-line p { color: #fbf5ff; font-size: .88rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-form { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px; padding: 10px 10px 2px; }
.chat-form input { min-width: 0; font-size: 1rem; }
.chat-form button { min-width: 64px; min-height: 46px; }
.chat-bottom { padding: 2px 12px 11px; display: flex; gap: 8px; justify-content: space-between; color: var(--muted); font-size: .75rem; }
#chat-count[data-over="true"] { color: #ffb1a1; font-weight: 800; }
.chat-line-avatar, .slot-photo { flex: 0 0 auto; width: 27px; height: 27px; border-radius: 50%; object-fit: cover; border: 1px solid #ad85cb; }
.chat-line-header { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.slot-photo { grid-column: 2; width: 26px; height: 26px; }
.battle-seat-avatar { overflow: hidden; }
.battle-seat-avatar img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.mobile-shortcuts { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 6px; margin: 12px 0 17px; padding: 6px; border: 1px solid #60447d; border-radius: 13px; background: #22192f; }
.mobile-shortcuts a { min-width: 0; display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 48px; border-radius: 9px; font-weight: 750; color: #ebd3f7; background: #322344; text-align: center; }
.mobile-shortcuts a { touch-action: manipulation; }
.mobile-shortcuts a span:first-child { font-size: 1.2rem; }
.mobile-shortcuts a[aria-current="page"] { background: #613b79; color: white; box-shadow: inset 0 -3px 0 #ffb47d; }
.mobile-collapse { display: none; }
.function-page { display: none; padding: 20px; margin: 0 0 15px; }
.function-page > p { color: var(--muted); margin-bottom: 12px; }
.function-page .dialog-head { margin-bottom: 14px; }
.function-page .page-note { margin-top: 14px; font-size: .82rem; }
.page-back { display: grid; place-items: center; text-align: center; }
body[data-page="profile"] #profile-page, body[data-page="ranking"] #ranking-page,
body[data-page="rules"] #rules-page, body[data-page="admin"] #admin-page { display: block; }
body[data-page="ranking"] .layout, body[data-page="profile"] .layout,
body[data-page="rules"] .layout, body[data-page="admin"] .layout { display: none; }
body:not([data-page="play"]) #results { display: none; }
body[data-page="play"] .stage .battle-room { display: none; }
body[data-page="room"] .stage .stage-body, body[data-page="room"] .stage .stage-footer { display: none; }
body[data-page="play"] .sidebar, body[data-page="room"] .sidebar { display: none; }
body[data-page="chat"] .stage, body[data-page="queue"] .stage { display: none; }
body[data-page="chat"] .sidebar > :not(.chat-panel),
body[data-page="queue"] .sidebar > :not(.waiting-list):not(.players) { display: none; }
body[data-page="chat"] .sidebar > .chat-panel, body[data-page="queue"] .sidebar > .waiting-list { display: block; }
body[data-page="play"] .layout, body[data-page="room"] .layout,
body[data-page="chat"] .layout, body[data-page="queue"] .layout { grid-template-columns: minmax(0,1fr); }
body[data-page="chat"] .chat-panel .collapsible-content,
body[data-page="queue"] .waiting-list .collapsible-content { display: block; }
body[data-page="chat"] .chat-messages { min-height: 44dvh; height: min(65dvh, 570px); }
body:not([data-page="play"]) .hero { display: none; }
.admin-link { display: inline-block; margin-left: 10px; color: #cbb6e0; font-size: .77rem; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.admin-page { max-width: 940px; margin-inline: auto; }
.admin-form { display: grid; grid-template-columns: minmax(0,1fr); gap: 7px; margin: 10px 0; }
.admin-form > label, .admin-section > label { color: #e8d9ff; font-weight: 750; font-size: .83rem; }
.admin-form > input, .admin-form > select, .admin-section > select { width: 100%; max-width: 100%; font-size: 1rem; }
.admin-form > button { min-height: 48px; justify-self: start; }
#admin-status { margin: 8px 0; min-height: 1.5rem; color: #f2ca9c; font-size: .85rem; white-space: pre-wrap; }
.admin-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 8px 0; }
.admin-toolbar strong { margin-right: auto; color: #ccebc5; }
.admin-toolbar button { min-height: 43px; }
.admin-summary { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; margin: 9px 0 15px; }
.admin-summary span { display: grid; padding: 10px; border-radius: 8px; background: #2c2040; border: 1px solid #553b74; min-width: 0; }
.admin-summary b { font-size: 1.25rem; color: #f9d7a5; }
.admin-summary small { font-size: .71rem; color: #cab7da; }
.admin-section { border: 1px solid #5d447a; border-radius: 10px; padding: 12px; margin: 12px 0; background: #21172e; min-width: 0; }
.admin-section > summary { cursor: pointer; color: #f4e1ff; font-weight: 850; font-size: .99rem; padding-block: 3px; }
.admin-section > :not(summary) { margin-top: 11px; }
.admin-section > select { margin-top: 4px; min-height: 120px; }
.admin-section select option { padding: 6px 8px; }
.admin-note, .admin-cycle { color: #e7cde6; font-size: .81rem; line-height: 1.55; }
.admin-cycle { color: #ffd99d; font-weight: 800; }
.admin-search { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 7px; }
.admin-search > button { min-height: 46px; }
.admin-pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.admin-pagination > button { min-height: 43px; }
.admin-avatar-editor { padding: 11px; border-radius: 10px; border: 1px solid #52396c; background: #281c38; }
.admin-avatar-editor > h3 { font-size: .95rem; color: #e8c8fa; margin: 0 0 8px; }
.admin-avatar-editor > img { width: 90px; height: 90px; object-fit: cover; border-radius: 50%; border: 2px solid #c8a5ff; margin-bottom: 9px; }
.admin-avatar-editor > input { padding: 6px; }
.admin-audit { list-style: none; padding: 0; margin: 10px 0; max-height: 350px; overflow-y: auto; }
.admin-audit li { padding: 8px; border-bottom: 1px solid #493559; overflow-wrap: anywhere; color: #e2cfee; font-size: .8rem; }
.avatar-editor { display: grid; grid-template-columns: 90px minmax(0,1fr); align-items: start; gap: 12px; margin: 8px 0 15px; padding: 12px; background: #2a1d3a; border: 1px solid #664b7f; border-radius: 12px; }
.avatar-preview-wrap { width: 84px; height: 84px; border-radius: 50%; background: #47305f; border: 2px solid #b99ae0; display: grid; place-items: center; overflow: hidden; color: #f9dbff; font-size: 1.6rem; }
.avatar-preview-wrap img { display: block; width: 100%; height: 100%; object-fit: cover; }
.avatar-preview-wrap img[hidden] { display: none; }
.avatar-editor-options { min-width: 0; }
.avatar-editor-options label { color: #e3cefa; font-weight: 800; font-size: .86rem; }
.avatar-editor-options input { display: block; width: 100%; min-width: 0; min-height: 38px; border: 0; padding: 5px 0; font-size: .85rem; }
.avatar-editor-options p { font-size: .76rem; color: #d3badf; overflow-wrap: anywhere; }
.avatar-editor-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 9px 0 4px; }
.avatar-editor-actions button { min-height: 44px; font-size: .83rem; padding: 6px 11px; }
.avatar-status { min-height: 1.2em; }
.profile-icon { display: inline-block; width: 28px; height: 28px; border-radius: 50%; border: 1px solid #b49de1; object-fit: cover; }

dialog { border: 1px solid #604477; padding: 20px; border-radius: 16px; background: #21172e; width: min(92vw, 570px); max-height: 85dvh; color: var(--text); box-shadow: 0 14px 75px #090611c7; }
dialog::backdrop { background: #0b0712bd; backdrop-filter: blur(5px); }
dialog > p { margin: 0 0 12px; color: var(--muted); }
.dialog-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 10px; }
.dialog-head h2 { font-size: 1.29rem; }
.close { width: 37px; height: 37px; border: 1px solid #533b67; border-radius: 8px; background: #332343; font-size: 1.4rem; line-height: 1; }
#profile-form { display: grid; gap: 8px; }
#profile-form button { margin-top: 5px; justify-self: start; }
.inline-error { color: #ffaeaa; }
.ranking-list { padding-inline: 0; }
.rules { padding-left: 1.4em; color: #e8d8f6; }
.rules li { margin-block: 10px; }
.toast { position: fixed; z-index: 3; bottom: 20px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 24px); padding: 10px 14px; border: 1px solid #785b97; border-radius: 9px; background: #2a1a3b; color: #fff2ff; box-shadow: 0 8px 24px #13091dbb; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 900px) {
  .shell { width: calc(100% - 36px); }
  .hero { padding-inline: 32px; min-height: 251px; }
  .vinyl { right: 11%; }
  .layout { gap: 15px; grid-template-columns: minmax(0, 1.75fr) minmax(245px, 1fr); }
}
@media (max-width: 650px) {
  .page-footer { align-items: flex-start; flex-direction: column; gap: 5px; padding-block: 12px; }
  #catalog-stat { text-align: left; }
  .shell { width: calc(100% - 24px); }
  .topbar-inner { min-height: 60px; gap: 4px; }
  .brand { font-size: 1rem; gap: 6px; }
  .brand-mark { width: 30px; height: 30px; border-radius: 8px; }
  .nav { gap: 2px; }
  .nav-button, .profile-button { padding: 6px; font-size: .81rem; }
  .nav-button span { margin-right: 0; }
  .profile-button { gap: 4px; }
  #profile-label { max-width: 4.2rem; }
  .hero { padding: 22px 17px; min-height: 202px; margin: 14px 0; border-radius: 15px; }
  .hero h1 { font-size: clamp(2.8rem, 11vw, 4.5rem); margin-block: 7px; }
  .eyebrow { font-size: .75rem; letter-spacing: .08em; }
  .record-art { inset: 0 0 0 43%; opacity: .79; }
  .vinyl { right: -19%; width: clamp(162px, 45vw, 228px); }
  .art-note { display: none; }
  .art-spark { right: 8%; top: 8%; }
  .layout { grid-template-columns: 1fr; }
  .battle-room { padding: 11px 8px 10px; }
  .battle-room-head { margin-bottom: 9px; }
  .battle-room-head h3 { font-size: .87rem; }
  .battle-room-count { font-size: .7rem; }
  .battle-room-floor { padding: 8px 5px; border-radius: 12px; }
  .battle-room-row { gap: 4px; }
  .battle-seat { min-height: 96px; padding: 7px 2px 5px; border-radius: 8px; gap: 3px; }
  .battle-seat::before { height: 15px; }
  .battle-seat-number { top: 4px; left: 4px; font-size: .55rem; }
  .battle-seat-avatar { width: 31px; height: 31px; font-size: .68rem; border-width: 1.5px; }
  .battle-seat-name { font-size: .68rem; }
  .battle-seat-score { font-size: .59rem; }
  .battle-room-stage { min-height: 59px; margin: 5px auto; font-size: .88rem; padding: 4px 5px; }
  .battle-room-stage-icon { left: 15px; top: 11px; }
  .battle-room-stage-sub { font-size: .62rem; }
  .battle-room-note { font-size: .69rem; }
  .sidebar { gap: 12px; }
  .stage-body { min-height: 275px; padding: 16px 12px; }
  .stage-footer { padding: 12px 5px; }
  .stage-footer div { gap: 5px; }
  .metric-icon { width: 25px; height: 25px; }
  .clock-icon::after { left: 11px; top: 8px; }
  .stage-footer b { font-size: .85rem; }
  .stage-footer small { font-size: .74rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }

/* Phone portrait: a real play-first layout, not a scaled-down desktop page. */
@media (max-width: 650px) and (orientation: portrait), (max-width: 480px) {
  html { scroll-padding-top: 65px; }
  body { min-width: 0; overflow-x: clip; }
  .shell, .layout, .card, .stage, .sidebar, .stage-body, .answer-form { min-width: 0; max-width: 100%; }
  .shell { width: calc(100% - 16px); }
  .topbar-inner { min-height: 53px; gap: 2px; }
  .brand { font-size: .92rem; gap: 5px; letter-spacing: -.045em; }
  .brand-mark { width: 28px; height: 28px; }
  .nav { gap: 0; flex: 0 1 auto; min-width: 0; }
  .nav-button, .profile-button { min-width: 37px; min-height: 43px; padding: 5px; font-size: .75rem; }
  .profile-button { gap: 3px; }
  #profile-label { max-width: 3.5rem; }
  .hero { min-height: 0; margin: 8px 0; padding: 9px 13px 10px; border-radius: 10px; }
  .hero h1 { font-size: 1.94rem; margin: 0; letter-spacing: -.07em; line-height: 1.04; }
  .hero .eyebrow { padding: 0; background: none; border: none; font-size: .66rem; }
  .hero p { font-size: .72rem; margin-top: 2px; }
  .record-art { display: none; }
  .mobile-shortcuts { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 3px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 12; padding: 5px 5px calc(5px + env(safe-area-inset-bottom)); margin: 0; border: 1px solid #543c70; border-bottom: 0; border-radius: 12px 12px 0 0; background: #1b132aee; box-shadow: 0 -5px 18px #0d0914b9; backdrop-filter: blur(12px); }
  .mobile-shortcuts a { display: flex; flex-direction: column; justify-content: center; align-items: center; min-width: 0; min-height: 51px; gap: 0; padding: 1px 1px; border: 0; border-radius: 7px; font-size: 1rem; background: #2f2043; color: #f8e2ff; }
  .mobile-shortcuts a span:last-child { font-size: .68rem; font-weight: 750; }
  .mobile-shortcuts a[aria-current="page"] { background: #6d4386; box-shadow: inset 0 3px 0 #ffb47d; }
  body { padding-bottom: calc(77px + env(safe-area-inset-bottom)); }
  .layout { display: grid; grid-template-columns: minmax(0,1fr); gap: 9px; }
  .stage { display: flex; flex-direction: column; overflow: hidden; }
  .stage > .card-head { order: 0; padding: 9px 11px; }
  .stage > .stage-body { order: 1; padding: 12px 11px 14px; min-height: 0; }
  .stage > .battle-room { order: 2; }
  .stage > .stage-footer { order: 3; }
  .stage-body .clock { margin: 3px 0 5px; font-size: clamp(2.8rem, 14vw, 4rem); }
  .stage-body .timer-label { margin: 0; }
  .stage-body .stage-hint { margin: 2px 0 4px; font-size: .87rem; }
  .question-panel { gap: 9px; align-items: stretch; }
  .question-top { font-size: .95rem; }
  .question-song { text-align: center; margin-top: 0; font-size: .86rem; line-height: 1.35; }
  .lyric { font-size: clamp(1.26rem, 6.3vw, 1.8rem); line-height: 1.4; text-align: center; min-height: 2.8em; }
  .answer-count { margin: 0; font-size: .78rem; text-align: center; }
  .question-panel .stage-hint { min-height: 0; }
  .join { width: 100%; min-height: 55px; margin-top: 2px; font-weight: 900; font-size: 1.11rem; }
  #buzz { min-height: 61px; box-shadow: 0 4px 0 #ba4d36; }
  .answer-form { grid-template-columns: minmax(0, 1fr) 46px 66px; width: 100%; gap: 5px; }
  .answer-form input { font-size: 16px; min-width: 0; padding: 8px 9px; }
  .answer-form button { padding: 8px 7px; min-height: 48px; }
  .stage-footer { padding: 8px 3px; }
  .stage-footer div { min-width: 0; gap: 4px; padding: 0 3px; }
  .stage-footer small { font-size: .62rem; line-height: 1.25; }
  .stage-footer b { font-size: .79rem; }
  .metric-icon { display: none; }
  .battle-room { padding: 11px 7px 8px; }
  .battle-room-head { gap: 4px; }
  .battle-room-floor { padding: 7px 4px; }
  .battle-room-row { gap: 3px; }
  .battle-seat { min-height: 81px; padding: 6px 1px 5px; }
  .battle-seat-number { font-size: .53rem; }
  .battle-seat-avatar { width: 27px; height: 27px; }
  .battle-seat-name { font-size: .63rem; }
  .battle-seat-score { font-size: .56rem; }
  .battle-room-stage { min-height: 45px; margin: 4px auto; font-size: .83rem; }
  .battle-room-stage-icon { top: 8px; left: 13px; font-size: 1rem; }
  .battle-room-stage-sub { font-size: .61rem; }
  .battle-room-note { padding-top: 6px; font-size: .65rem; }
  .sidebar { gap: 9px; }
  .mobile-collapse { display: inline-flex; min-height: 43px; align-items: center; gap: 4px; margin-left: auto; border: 1px solid #775798; border-radius: 7px; background: #2e2140; padding: 5px 10px; font-weight: 800; font-size: .8rem; }
  .mobile-collapse[aria-expanded="true"] span { transform: rotate(180deg); }
  .chat-panel.is-collapsed .collapsible-content, .waiting-list.is-collapsed .collapsible-content { display: none; }
  body[data-page="chat"] .chat-panel.is-collapsed .collapsible-content,
  body[data-page="queue"] .waiting-list.is-collapsed .collapsible-content { display: block; }
  body[data-page="chat"] #chat-toggle, body[data-page="queue"] #waiting-toggle { display: none; }
  .chat-panel .card-head, .waiting-list .card-head { padding: 8px 9px; gap: 5px; }
  .chat-panel .card-head h2, .waiting-list .card-head h2 { font-size: .9rem; }
  .chat-panel .card-head .count, .waiting-list .card-head .count { font-size: .68rem; }
  .chat-messages { height: min(38dvh, 270px); }
  .chat-form input { font-size: 16px; }
  .players { display: none; }
  body[data-page="room"] .battle-room { display: block; }
  body[data-page="play"] .stage .battle-room { display: none; }
  body[data-page="room"] .stage .stage-body { display: none; }
  body[data-page="chat"] .chat-messages { height: min(56dvh, 500px); }
  .function-page { padding: 13px 10px; }
  .function-page .dialog-head h2 { font-size: 1.09rem; }
  .admin-summary { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; }
  .admin-summary span { padding: 8px; }
  .admin-summary b { font-size: 1.12rem; }
  .admin-section { padding: 9px; }
  .admin-toolbar { gap: 5px; }
  .admin-toolbar button, .admin-search button { font-size: .79rem; padding: 8px; }
  .admin-form input, .admin-form select, .admin-search input { font-size: 16px; }
  .admin-page { margin: 0 auto; }
  .avatar-editor { grid-template-columns: 68px minmax(0, 1fr); gap: 9px; padding: 9px; }
  .avatar-preview-wrap { width: 65px; height: 65px; }
  dialog { width: min(96vw, 570px); padding: 15px 11px; overflow-y: auto; }
  .page-footer { min-width: 0; }
  #catalog-stat { font-size: .72rem; }
}

@media (max-width: 360px) {
  .shell { width: calc(100% - 12px); }
  #open-ranking, #open-profile { display: none; }
  .help-button { width: 43px; padding-inline: 6px; font-size: 0; }
  .help-button span { margin: 0; font-size: .72rem; }
  .mobile-shortcuts { gap: 2px; padding-inline: 3px; }
  .mobile-shortcuts a { min-height: 50px; }
  .mobile-shortcuts a span:first-child { font-size: 1.05rem; }
  .mobile-shortcuts a span:last-child { font-size: .62rem; }
  .battle-room-head { align-items: flex-start; }
  .battle-room-count { width: 100%; }
  .battle-room-floor { padding-inline: 3px; }
  .battle-room-row { gap: 2px; }
  .battle-seat { min-height: 76px; padding-inline: 1px; }
  .battle-seat-avatar { width: 24px; height: 24px; }
  .battle-seat-name { font-size: .6rem; }
  .battle-seat-score { font-size: .53rem; line-height: 1.2; }
  .battle-room-stage { width: min(94%, 305px); }
  .chat-form { grid-template-columns: minmax(0,1fr) 58px; }
  .chat-form button { min-width: 0; padding-inline: 7px; }
}
