@font-face { font-family: Cinzel; src: url('/fonts/cinzel.woff2') format('woff2'); font-weight: 400 700; font-display: swap; }
@font-face { font-family: Spectral; src: url('/fonts/spectral.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Spectral; src: url('/fonts/spectral-semibold.woff2') format('woff2'); font-weight: 600 700; font-display: swap; }
@font-face { font-family: "Noto Serif Thai"; src: url('/fonts/noto-serif-thai.woff2') format('woff2'); font-weight: 400 700; font-display: swap; unicode-range: U+0E00-0E7F; }
@font-face { font-family: "Fira Code"; src: url('/fonts/fira-code.woff2') format('woff2'); font-weight: 500; font-display: swap; }

:root {
  color-scheme: dark;
  font-family: var(--appearance-font, Spectral, "Noto Serif Thai", Georgia, serif);
  --heading: var(--appearance-font, Cinzel, "Noto Serif Thai", Georgia, serif);
  --bg: #1a0f0a;
  --surface: #2c1a10;
  --raised: #3d2517;
  --edge: #5c3d2e;
  --text: #f5e6d3;
  --muted: #bfa98a;
  --accent: #e9bd62;
  --gold: #ca8a04;
  --danger: #991b1b;
  --accent-low: #ca8a0426;
  --page-gutter: clamp(22px, 4vw, 58px);
}

* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(ellipse at top right, #3d2517, transparent 48rem), var(--bg); color: var(--text); font-size: 1rem; line-height: 1.7; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; opacity: .35; box-shadow: none; }
a { color: inherit; text-decoration: none; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.remote-navigation { scroll-padding-top: 118px; }
.remote-navigation :focus { outline: 3px solid var(--accent); }
svg { flex: 0 0 auto; vertical-align: middle; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3, strong { line-height: 1.3; }
h1, h2, h3 { font-family: var(--heading); }
h1 { font-size: clamp(2rem, 3vw, 2.55rem); }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
p { color: var(--muted); }
small, .muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.layout { min-height: 100vh; display: flex; flex-direction: column; }
.brand { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 9px; width: max-content; color: #fff5e7; font: 700 1.25rem/1.2 Poppins, system-ui, sans-serif; letter-spacing: -.035em; white-space: nowrap; }
.brand strong { color: #ffd16e; font-weight: inherit; line-height: inherit; }
.brand-mark { display: block; width: 38px; height: 38px; flex: 0 0 auto; }
.topbar { position: sticky; top: 0; z-index: 2; background: #1a0f0af2; border-bottom: 1px solid var(--edge); backdrop-filter: blur(12px); }
.topbar-inner { display: flex; align-items: center; gap: 12px; min-height: 64px; max-width: 1430px; margin-inline: auto; padding-inline: var(--page-gutter); }
.topbar-inner:has(.main-nav) { flex-direction: column; gap: 6px; padding-block: 8px 6px; }
.main-nav { max-width: 100%; display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; padding: 3px; border: 1px solid var(--edge); border-radius: 10px; background: var(--surface); }
.main-nav a { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 4px 10px; min-height: 44px; border: 1px solid transparent; border-radius: 6px; color: var(--muted); font: 600 .88rem/1.25 var(--heading); white-space: nowrap; }
.main-nav a:hover { background: var(--raised); color: var(--text); }
.main-nav a[aria-current] { color: var(--accent); background: linear-gradient(90deg, #ca8a043b, #ca8a0410); border-color: #ca8a0473; box-shadow: inset 0 -2px var(--gold); }
.main-nav svg { width: 16px; height: 16px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-actions :is(.top-tv, .top-settings) { padding-inline: 10px; white-space: nowrap; }
.profile-button { min-height: 42px; display: flex; align-items: center; gap: 9px; padding: 4px 11px 4px 5px; color: var(--text); background: var(--surface); border: 1px solid var(--edge); border-radius: 99px; max-width: 132px; }
.profile-button span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { flex: 0 0 auto; display: grid; place-items: center; position: relative; overflow: hidden; background: #581c87; color: var(--accent); width: 31px; height: 31px; border-radius: 50%; font-weight: 700; text-transform: uppercase; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
main { flex: 1; width: 100%; max-width: 1430px; margin: 0 auto; padding: 32px var(--page-gutter) 54px; }
.button, .icon-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; width: max-content;
  min-height: 40px; max-width: 100%; padding: 8px 16px; border: 1px solid var(--edge); border-radius: 4px;
  color: var(--text); background: var(--raised); font: 600 .94rem/1.35 var(--heading);
  transition: border-color 230ms, background-color 230ms, box-shadow 230ms;
}
.button:hover, .icon-button:hover, .profile-button:hover { border-color: #ca8a04; }
.button.primary { background: var(--gold); border-color: #daa520; color: var(--bg); box-shadow: 0 2px 8px #ca8a0433; }
.button.primary:hover { background: #e2a634; }
.button.subtle { background: transparent; color: var(--muted); }
.button.danger { background: var(--danger); color: var(--text); border-color: #b91c1c; }
.button.danger:hover { background: #7f1d1d; }
.button.small { min-height: 36px; padding: 6px 11px; font-size: .85rem; }
.button svg, .icon-button svg { width: 17px; height: 17px; }
.icon-button { padding: 0; width: 37px; height: 37px; min-height: 37px; flex: 0 0 auto; }
.icon-button[aria-pressed="true"], .list-button[aria-pressed="true"] { color: var(--accent); border-color: #ca8a04; }
.icon-button[aria-pressed="true"] svg { fill: var(--accent); }
.text-link { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 650; font-size: .94rem; }
.text-link:hover { text-decoration: underline; }
.text-link svg { width: 16px; height: 16px; }
.hero {
  position: relative; display: flex; align-items: center; min-height: 410px; overflow: hidden;
  border: 1px solid #8b632e; border-radius: 6px;
  background: linear-gradient(90deg, #1a0f0aed, #1a0f0a38 58%, #1a0f0a00), url('/quest-stage.jpg') 50% 48% / cover, #2c1a10;
  box-shadow: 0 4px 20px #ca8a0426;
}
.hero::before, .hero::after { content: ''; position: absolute; pointer-events: none; inset: 8px; border: 1px solid #d5a04d54; border-radius: 2px; }
.hero::after { inset: 12px; border-color: transparent; background:
  linear-gradient(#e9bd62, #e9bd62) left top / 19px 1px,
  linear-gradient(#e9bd62, #e9bd62) left top / 1px 19px,
  linear-gradient(#e9bd62, #e9bd62) right bottom / 19px 1px,
  linear-gradient(#e9bd62, #e9bd62) right bottom / 1px 19px; background-repeat: no-repeat; }
.hero-content { position: relative; z-index: 1; width: min(61%, 585px); padding: 44px 0 44px clamp(30px, 5vw, 72px); }
.hero h1 { font-size: clamp(2.5rem, 4.7vw, 4.65rem); line-height: 1.18; }
.hero h1 em { color: var(--accent); font-style: normal; }
.hero p { margin: 21px 0 25px; color: #f5e6d3; max-width: 36ch; }
.hero-search { width: min(100%, 455px); }
.quick-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 18px 0 30px; }
.quick-card { min-width: 0; display: flex; align-items: center; gap: 12px; min-height: 88px; background: linear-gradient(130deg, var(--raised), var(--surface)); border: 1px solid var(--edge); border-top-color: #9d743c; border-radius: 4px; padding: 16px; box-shadow: 0 2px 8px #ca8a0414; }
.quick-card:hover { border-color: #ca8a04; background: var(--raised); }
.quick-card > span:nth-child(2) { flex: 1; min-width: 0; }
.quick-card strong, .quick-card small { display: block; }
.quick-card small { margin-top: 4px; }
.quick-card > svg { width: 16px; height: 16px; color: var(--muted); }
.tile-icon { width: 42px; height: 42px; display: inline-grid; place-items: center; flex: 0 0 auto; background: linear-gradient(145deg, #581c8744, var(--bg)); color: var(--accent); border: 1px solid #9d743c; border-radius: 4px; }
.section-heading, .page-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-heading { margin-bottom: 12px; }
.page-heading { align-items: flex-end; margin-bottom: 26px; }
.page-heading p { margin: 8px 0 0; }
.empty { display: grid; justify-items: center; gap: 9px; padding: 32px 20px; text-align: center; background: linear-gradient(145deg, #302016, #26160f); border: 1px solid #654531; border-radius: 4px; }
.empty .button { margin-top: 4px; }
.stack { display: grid; gap: 13px; min-width: 0; }
.stack > .section-heading { margin-bottom: 0; }
.panel { background: linear-gradient(135deg, #352116, var(--surface)); padding: 24px; border: 1px solid var(--edge); border-top-color: #9d743c; border-radius: 4px; min-width: 0; box-shadow: 0 3px 12px #ca8a0418; }
.panel h2 + p { margin-top: 8px; }
.panel p + .button { margin-top: 12px; }
.columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; align-items: start; }
.columns.playlists { grid-template-columns: minmax(160px, .6fr) minmax(0, 1.4fr); }
.columns.history { grid-template-columns: minmax(0, 1.6fr) minmax(0, .8fr); }
.leaderboard { margin: 0; padding-inline-start: 22px; }
.leaderboard li { padding: 5px 0; }
.leaderboard span { color: var(--accent); margin-inline-start: 10px; }
.list-button { width: 100%; justify-content: flex-start; text-align: left; }
.list-button span { margin-left: auto; color: var(--muted); }
.now { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.now > div { flex: 1 1 160px; }
.queue-tools, .search-tools { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.catalog-pagination { justify-content: center; margin-block: 12px; }
.queue-tools { margin: 18px 0; }
.queue-tools label { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); }
label { display: grid; gap: 6px; }
input, select { min-width: 0; color: var(--text); border: 1px solid var(--edge); background: #2c1a10; padding: 9px 11px; border-radius: 8px; width: 100%; }
select { width: auto; }
.inline-check, .catalog-source { display: flex; align-items: center; gap: 8px; }
.inline-check input { width: 18px; height: 18px; accent-color: var(--gold); }
.search-box { display: grid; gap: 15px; margin-bottom: 22px; }
.search-field { --search-background: var(--input, var(--surface)); min-width: 0; display: flex; align-items: center; gap: 6px; padding: 6px; background: var(--search-background); border: 1px solid var(--edge); border-radius: 18px; }
.search-entry { flex: 1; min-width: 0; align-self: stretch; display: flex; align-items: center; gap: 10px; padding-inline: 8px 4px; border-radius: 12px; }
.search-entry > svg { color: var(--accent); }
.search-field input { appearance: none; flex: 1; padding-inline: 0; border: 0; background: transparent; }
.search-field input:is(:autofill, :-webkit-autofill) { box-shadow: inset 0 0 0 100px var(--search-background); -webkit-text-fill-color: var(--text); }
.search-field input::placeholder { color: var(--muted); opacity: 1; }
.search-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.search-field input:focus-visible { outline: none; }
.search-field input::-webkit-search-cancel-button { appearance: none; }
.search-field .search-clear { background: transparent; border-color: transparent; }
.search-field .search-clear[hidden], [data-search-status]:empty { display: none; }
.search-submit {
  flex: 0 0 auto; min-height: 44px; border-color: transparent; border-radius: 12px; white-space: nowrap;
  color: var(--on-primary, var(--bg));
  background: var(--primary, linear-gradient(110deg, #ffffff29, transparent) var(--gold));
  box-shadow: 0 3px 12px var(--glow, var(--accent-low));
}
.search-submit:enabled:hover { filter: brightness(1.12); }
.search-tools span, .search-fallback p { color: var(--muted); font-size: .88rem; }
.quota-info { width: 28px; height: 28px; min-height: 28px; margin-inline-start: 4px; color: var(--accent); vertical-align: middle; }
.quota-popover {
  --quota-width: min(28rem, calc(100% - 2rem));
  width: var(--quota-width); max-height: min(24rem, calc(100% - 2rem)); overflow: auto;
  padding: 14px; color: var(--text); font-size: .88rem; box-shadow: 0 8px 24px #0008;
}
.quota-popover details { margin-top: 8px; }
.quota-popover ul { margin: 4px 0 0; padding-inline-start: 20px; overflow-wrap: anywhere; }
@supports (top: anchor(bottom)) {
  .quota-popover {
    position-anchor: auto; inset: auto; margin: 0; top: calc(anchor(bottom) + 6px);
    left: clamp(1rem, anchor(left), calc(100% - var(--quota-width) - 1rem));
    position-try-fallbacks: flip-block;
  }
}
.search-categories { display: flex; flex-wrap: wrap; gap: 7px; min-width: 0; margin: 0; padding: 0; border: 0; }
.search-categories legend { padding: 0; margin-bottom: 6px; color: var(--muted); font-size: .88rem; }
.search-categories label { cursor: pointer; }
.search-categories label:has(input:checked) { color: var(--accent); background: var(--accent-low); }
.search-categories label:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.search-fallback { padding: 12px 15px; }
.search-fallback p { margin-top: 6px; }
.song-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--song-card-width, 225.5px)), 1fr)); gap: 14px; }
.song-grid:has([data-action="catalogSave"]) { --song-card-width: 258.5px; }
.song-card { position: relative; container-type: inline-size; display: flex; flex-direction: column; min-width: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--edge); border-radius: 12px; }
.song-card.selected { outline: 2px solid var(--accent); outline-offset: 1px; }
.song-art { position: relative; flex: 0 0 auto; width: 100%; display: block; padding: 0; aspect-ratio: 16 / 9; overflow: hidden; border: 0; background: #3d2517; color: var(--text); }
.song-art:focus-visible { outline-offset: -3px; }
.remote-navigation .song-art:focus { outline-offset: -3px; }
.song-art img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
.art-preview, .duration, .song-rating, .song-favorite, .song-playback-status { position: absolute; background: color-mix(in srgb, var(--bg) 88%, transparent); border-radius: 999px; }
.art-preview { inset: auto auto 8px 8px; display: grid; place-items: center; width: 31px; height: 31px; }
@media (hover: hover) and (pointer: fine) {
  .art-preview { inset: 50% auto auto 50%; translate: -50% -50%; width: 40px; height: 40px; opacity: 0; transition: opacity 180ms; }
  .song-art:hover .art-preview, .song-art:focus-visible .art-preview { opacity: 1; }
  .song-card:hover .song-body h3 { color: var(--accent); }
}
.duration, .song-rating, .song-playback-status { padding: 2px 7px; font-size: .8rem; line-height: 1.15; }
.duration { inset: auto 8px 8px auto; }
.song-rating { inset: 8px auto auto 8px; color: var(--accent); pointer-events: none; }
.song-playback-status { inset: 8px auto auto 8px; padding-block: 4px; font-weight: 600; pointer-events: none; }
.song-favorite { inset: 8px 8px auto auto; width: 26px; height: 26px; min-height: 26px; border: 0; --button-radius: 50%; }
.song-favorite svg { width: 15px; height: 15px; }
.song-favorite:hover { color: var(--accent); }
.song-body { flex: 1; display: flex; flex-direction: column; gap: 7px; padding: 13px; }
.song-body h3, .song-body p { overflow-wrap: anywhere; }
.song-card:has(:focus-visible) .song-body h3, .song-card.selected .song-body h3 { color: var(--accent); }
.song-body p { font-size: .87rem; }
.row-actions, .ratings { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.song-actions { display: flex; justify-content: safe center; align-items: center; gap: 4px; min-width: 0; overflow-x: auto; margin: auto -5px -5px; padding: 5px; }
.song-actions > .button { flex: 0 0 auto; min-height: 37px; white-space: nowrap; }
.song-actions > .icon-button { flex: 0 1 37px; min-width: 26px; }
@container (width < 370px) {
  .song-actions [data-action="catalogSave"] { flex: 0 1 37px; min-width: 26px; padding-inline: 0; }
  .song-actions [data-action="catalogSave"] span { display: none; }
}
@container (width < 260px) {
  .song-actions:has(.icon-button) [data-action="add"] { padding-inline: 5px; }
  .song-actions:has(.icon-button) [data-action="add"] svg { display: none; }
}
.track-row { display: flex; align-items: center; gap: 12px; padding: 10px; background: var(--surface); border: 1px solid var(--edge); border-radius: 11px; }
.panel .track-row { background: var(--bg); }
.track-title { overflow-wrap: anywhere; flex: 1 1 90px; min-width: 0; }
.track-title small { display: block; margin-top: 3px; }
.queue-number, .count { color: var(--accent); background: var(--accent-low); padding: 2px 8px; border-radius: 6px; font-size: .85rem; }
.queue-number { min-width: 2rem; text-align: center; }
.queue-thumbnail { flex: 0 0 auto; width: clamp(44px, 8vw, 64px); height: auto; aspect-ratio: 16 / 9; object-fit: cover; background: var(--raised); border-radius: 6px; }
.track-row:has(.queue-number) .row-actions { gap: 4px; }
.room-queue {
  position: sticky; bottom: 0; z-index: 3; width: 100%;
  margin-bottom: env(safe-area-inset-bottom, 0); color: var(--text); background: var(--surface);
  border-top: 2px solid var(--accent);
  box-shadow: 0 -5px 20px #0005;
}
.room-queue-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px var(--page-gutter); }
.room-queue-paged { padding-inline: 8px; }
.room-queue-paged .room-queue-info { flex: 1; }
.room-queue-page-number { white-space: nowrap; font-variant-numeric: tabular-nums; }
.room-queue-info { display: flex; align-items: baseline; gap: 8px; min-width: 0; line-height: 1.25; }
.room-queue-info > div { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; flex: 0 1 auto; min-width: 0; }
.room-queue-info strong { color: var(--accent); max-width: min(34ch, 100%); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-queue-info .count { display: inline-block; padding: 1px 6px; white-space: nowrap; }
.room-queue-request-count { cursor: pointer; border: 1px solid currentColor; line-height: inherit; }
.room-queue-request-count:hover { background: var(--raised); }
.room-queue-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.room-queue-controls { display: flex; align-items: center; gap: 4px; }
.room-queue-bar .icon-button, .room-queue-items .icon-button { width: 32px; height: 32px; min-height: 32px; }
.room-queue-controls .button { min-height: 32px; padding-block: 4px; }
.room-queue-controls [aria-expanded="false"] svg { transform: rotate(180deg); }
.room-queue-items {
  --queue-row-gap: 2px;
  max-height: 70vh;
  max-height: 70dvh;
  overflow: auto; overscroll-behavior: contain;
  padding: 3px var(--page-gutter); border-top: 1px solid var(--edge);
}
.room-queue-items .track-row { min-height: 36px; gap: 8px; padding: 1px 6px; line-height: 1.2; }
.room-queue-items .track-row + .track-row { margin-top: var(--queue-row-gap); }
.room-queue-items .queue-number { min-width: 1.5rem; padding: 1px 4px; }
.room-queue-items .queue-thumbnail { width: 42px; }
.room-queue-items .track-title { display: flex; align-items: baseline; gap: 6px; font-size: .9rem; }
.room-queue-items .track-title > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-queue-items .track-title small { margin-top: 0; }
.room-queue-requests > p { color: var(--muted); font-size: .82rem; line-height: 18px; margin: 0 0 3px; }
.room-queue-requests:not(:last-child) { margin-bottom: var(--queue-row-gap); }
.room-queue-requests .button { min-height: 32px; padding: 3px 8px; white-space: nowrap; }
.room-queue-empty { padding: 4px 0; text-align: center; }
.room-share { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.qr { width: 144px; height: 144px; border: 5px solid white; border-radius: 9px; }
.room-code { font: 500 1.95rem "Fira Code", monospace; letter-spacing: .09em; color: var(--accent); }
.room-share .button { margin-top: 6px; }
.expanded-qr .qr { width: min(64vw, 270px); height: auto; aspect-ratio: 1; }
.live { color: #75e294; }
.party-dashboard { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: start; gap: clamp(12px, 2vw, 22px); }
.party-dashboard > .stack { gap: inherit; }
.party-dashboard .panel { border-radius: 10px; }
.party-invite, .guest-room-card { background: linear-gradient(120deg, var(--accent-low), transparent 74%) var(--surface); }
.party-invite { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; }
.party-invite .stack { gap: 8px; }
.party-invite h2 { font-size: clamp(1.3rem, 2.5vw, 1.9rem); overflow-wrap: anywhere; }
.party-invite .qr { display: block; width: clamp(92px, 25vw, 144px); height: auto; aspect-ratio: 1; }
.party-status { display: flex; align-items: center; gap: 6px; width: fit-content; padding: 2px 9px; border-radius: 99px; background: color-mix(in srgb, currentColor 13%, transparent); font-size: .82rem; }
.party-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.party-code { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 10px; }
.party-code .room-code { font-size: clamp(1.35rem, 4vw, 1.95rem); line-height: 1.2; }
.party-invite > .row-actions { grid-column: 1 / -1; }
.party-invite > .row-actions, .party-rules > .row-actions { padding-top: 12px; border-top: 1px solid var(--edge); }
.party-panel-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 1.1rem; }
.party-panel-title svg { color: var(--accent); }
.party-requests .party-empty { display: grid; place-items: center; min-height: 104px; margin: 0; padding: 14px; border: 1px dashed var(--edge); border-radius: 6px; text-align: center; }
.party-requests .track-row, .party-access { display: flex; flex-wrap: wrap; }
.party-requests .track-row > .row-actions { margin-inline-start: auto; }
.party-access { align-items: center; justify-content: space-between; gap: 8px; }
.member-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.member-list li { display: flex; align-items: center; gap: 8px; padding: 8px; background: var(--bg); border: 1px solid var(--edge); border-radius: 8px; }
.member-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.member-list .count { flex: 0 0 auto; }
.room-owner-form fieldset { padding: 10px; border: 1px solid var(--edge); border-radius: 6px; }
.room-owner-form legend { padding-inline: 4px; }
.room-owner-form .inline-check { min-height: 44px; cursor: pointer; }
.owner-key { color: var(--accent); font: 600 1.25rem ui-monospace, monospace; letter-spacing: .12em; }
.standalone .topbar-inner { justify-content: space-between; min-height: 74px; }
.standalone.join main { max-width: 920px; }
.guest-join { max-width: 32rem; margin-inline: auto; }
.guest-room-card { border-radius: 10px; }
.guest-workspace .guest-room-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.guest-room-identity { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.guest-room-identity > div { min-width: 0; }
.guest-room-identity h1 { font-size: clamp(1.35rem, 4vw, 1.9rem); overflow-wrap: anywhere; }
.guest-room-identity p { font-size: .88rem; }
.guest-room-identity .room-code { font-size: 1.2rem; }
.guest-join input, .guest-join button { min-height: 46px; font-size: 1rem; }
.guest-join button { width: 100%; }
.guest-profile { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.guest-singer { display: flex; align-items: center; gap: 6px; }
.guest-profile .button { min-height: 44px; }
.guest-workspace .search-box { margin: 8px 0 0; gap: 8px; }
.guest-my-songs, .guest-search-options { padding: 0 14px; }
.guest-workspace summary { padding-block: 9px; min-height: 44px; cursor: pointer; }
.guest-workspace details > .stack { padding-block: 3px 12px; }
.guest-my-songs .track-row { flex-wrap: wrap; }
.guest-workspace [data-guest-locked] { padding: 9px 14px; background: var(--accent-low); color: var(--accent); border-radius: 6px; }
.join [data-guest-request] { min-height: 44px; }
.stage { display: grid; gap: 14px; }
.player:has(.stage-idle) { display: grid; grid-template: 1fr auto / minmax(0, 1fr); min-height: 100dvh; }
.player:has(.stage-idle) > :is(.topbar, main) { grid-area: 1 / 1; }
.player:has(.stage-idle) > .topbar { align-self: start; }
.player:has(.stage-idle) > main { display: flex; max-width: none; padding: 0; }
.stage-idle {
  --stage-mark-size: clamp(56px, min(9vw, 15dvh), 112px);
  flex: 1; min-width: 0; grid-template-columns: minmax(0, 1fr);
  gap: clamp(16px, 3vw, 36px);
  padding: 0 clamp(16px, 3vw, 48px) clamp(16px, 3dvh, 36px);
  background: var(--stage-art,
    linear-gradient(90deg, #160c07ef 0%, #160c07b3 31%, transparent 76%),
    linear-gradient(0deg, #160c07df, transparent 74%), url('/quest-stage.jpg') center 44% / cover, var(--surface));
}
.stage-idle:has(.stage-invite:not([hidden])) { grid-template-columns: minmax(200px, 22%) minmax(0, 1fr) minmax(200px, 22%); }
.stage-idle:has(.stage-invite:not([hidden])) .stage-empty { grid-column: 2; }
.brand.stage-identity {
  flex-direction: row; gap: clamp(10px, 1.6vw, 22px);
  font-size: clamp(1.5rem, 4.2vw, calc(var(--stage-mark-size) * .6)); filter: drop-shadow(0 4px 14px #000c);
}
.stage-identity .brand-mark { width: var(--stage-mark-size); height: auto; }
.stage-empty { display: grid; justify-items: center; align-content: start; padding-block-start: max(76px, calc(50dvh - var(--stage-mark-size) / 2)); }
.stage-welcome { display: grid; justify-items: center; min-width: 0; max-width: min(100%, 42rem); text-align: center; }
.stage-context { display: flex; align-items: center; gap: 10px; color: var(--accent); font-size: clamp(.9rem, 1.5vw, 1.08rem); }
.stage-welcome .stage-context { margin-top: 8px; }
.stage-context span { overflow-wrap: anywhere; }
.stage-empty h1 { margin-block: 12px 6px; color: var(--text); overflow-wrap: anywhere; font-size: clamp(1.65rem, 3.6vw, 3.25rem); line-height: 1.15; }
.stage-description { max-width: 38ch; color: var(--text); font-size: clamp(1rem, 1.7vw, 1.24rem); }
.stage-idle .stage-bar { justify-content: center; margin-top: 12px; }
.stage-idle .stage-actions { justify-content: center; }
.stage-idle .stage-bar .button { min-height: 46px; }
.stage-idle .stage-bar .button.subtle { color: var(--text); background: var(--surface); }
.stage-invite:not([hidden]) {
  display: flex; align-self: end; flex-direction: column; align-items: flex-start; gap: 12px;
  min-width: 0; padding: clamp(18px, 2.5vw, 34px); border: 1px solid var(--edge); border-radius: var(--card-radius, 14px);
  background: linear-gradient(155deg, var(--surface), var(--bg));
}
.stage-invite .room-share { align-items: flex-start; gap: 13px; }
.stage-invite .qr { width: min(100%, 154px); height: auto; aspect-ratio: 1; }
dialog:has(.stage-search-panel) { width: min(960px, calc(100% - 24px)); }
.stage-search-panel .search-box { margin: 10px 0 0; }
.stage-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.stage-actions, .stage-transport { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.stage-actions .icon-button { width: 44px; height: 44px; }
.stage-actions .stage-search { min-height: 44px; }
.stage-transport { padding: 3px; background: var(--surface); border: 1px solid var(--edge); border-radius: 10px; }
.stage-transport .icon-button { border-color: transparent; border-radius: 7px; background: transparent; }
.stage-transport .icon-button:hover, .stage-transport .icon-button[aria-expanded="true"], .stage-transport .icon-button[aria-pressed="true"] {
  color: var(--accent); background: var(--accent-low); border-color: var(--edge);
}
.stage-transport .icon-button[aria-pressed="true"] svg { fill: none; }
.video-box { width: 100%; aspect-ratio: 16 / 9; background: #1a0f0a; overflow: hidden; border-radius: 10px; }
.stage .video-box { width: min(100%, 142vh); margin-inline: auto; }
.video-box iframe { display: block; width: 100%; height: 100%; border: 0; }
.player:has(.stage-playing) { height: 100dvh; min-height: 0; background: #0d0b09; }
.player:has(.stage-playing) > .topbar,
.player:has(.stage-playing) .room-queue-controls { display: none; }
.player:has(.stage-playing) > main { display: flex; min-height: min-content; max-width: none; padding: 0; }
.player:has(.stage-playing) > .room-queue { flex: none; position: static; }
.player:has(.stage-playing) .room-queue-items { max-height: min(34dvh, 290px); }
.stage-playing { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0; }
.stage-playing .video-box { flex: 1 1 0; width: 100%; min-height: 200px; aspect-ratio: auto; border-radius: 0; background: #000; }
.stage-playing .stage-bar {
  padding: 8px clamp(10px, 2vw, 28px);
  background: var(--bg); border-top: 1px solid var(--edge);
}
.stage-playing .stage-song { flex: 1 1 180px; min-width: 0; }
.stage-playing .stage-song h2 { overflow-wrap: anywhere; font-size: clamp(1rem, 2.2vw, 1.45rem); }
dialog { width: min(610px, calc(100% - 28px)); max-height: calc(100% - 30px); padding: 24px; color: var(--text); background: var(--surface); border: 1px solid #a97229; border-radius: 6px; box-shadow: 0 8px 32px #ca8a0445; }
dialog::backdrop { background: #1a0f0ad9; backdrop-filter: blur(4px); }
dialog > * + * { margin-top: 14px; }
.remote-keyboard { width: min(760px, calc(100% - 20px)); padding: clamp(12px, 2vw, 24px); }
.remote-keyboard output { display: block; min-height: 2.6em; padding: 6px 10px; overflow-x: auto; white-space: pre; background: var(--bg); border: 1px solid var(--edge); }
.remote-keyboard [hidden] { display: none; }
.remote-keyboard [aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.remote-keys { display: grid; gap: 5px; }
.remote-keys > div { display: flex; justify-content: center; gap: 4px; }
.remote-keys .button { flex: 0 1 3.2rem; min-width: 0; padding-inline: 0; font-family: inherit; font-size: 1.1rem; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; overflow-wrap: anywhere; }
#toast { position: fixed; z-index: 8; bottom: 23px; right: 23px; max-width: min(380px, calc(100% - 46px)); padding: 11px 16px; background: var(--accent); color: #1a0f0a; font-weight: 650; border: 1px solid #daa520; border-radius: 10px; box-shadow: 0 9px 28px #0009; pointer-events: none; }
.layout:has(.room-queue:not([hidden])) ~ #toast { top: 120px; bottom: auto; }

@media (max-width: 1020px) {
  .quick-card { gap: 8px; padding: 11px; }
  .quick-card > svg { display: none; }
  .quick-card .tile-icon { width: 35px; height: 35px; }
}
@media (max-width: 850px) {
  .brand { flex-direction: column; gap: 3px; font-size: .6875rem; }
  .topbar-actions .brand { flex-direction: row; gap: 6px; font-size: .875rem; }
  .brand-mark { width: 34px; height: 34px; }
}
@media (max-width: 800px) {
  :root { --page-gutter: 16px; }
  .main-nav a { flex-direction: column; gap: 4px; min-height: 46px; padding-inline: 8px; font-size: .8rem; }
  .top-tv span, .top-settings span { display: none; }
  .standalone .topbar { position: static; }
  .standalone .topbar-inner { min-height: 60px; }
  main { padding: 19px var(--page-gutter) 36px; }
  .hero { min-height: 360px; }
  .hero-content { width: min(75%, 510px); }
  .quick-links { gap: 8px; margin-bottom: 23px; }
  .party-dashboard { grid-template-columns: minmax(0, 1fr); }
  .stage-idle:has(.stage-invite:not([hidden])) { grid-template-columns: minmax(0, 1fr); }
  .stage-idle:has(.stage-invite:not([hidden])) .stage-empty { grid-column: 1; }
}
@media (max-width: 800px) and (min-height: 720px) {
  .stage-idle:has(.stage-invite:not([hidden])) .stage-empty,
  .stage-idle .stage-invite:not([hidden]) { grid-area: 1 / 1; }
  .stage-idle .stage-invite:not([hidden]) {
    align-self: start; justify-self: center; width: min(100%, 24rem);
    margin-top: 80px; max-height: calc(50dvh - var(--stage-mark-size) / 2 - 96px);
    padding: 12px 16px; gap: 7px; overflow: auto;
  }
  .stage-invite .qr { width: min(100%, 106px); }
}
@media (max-width: 600px) {
  .topbar-inner:has(.main-nav) { padding-inline: 12px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions :is(.top-tv, .top-settings) { padding-inline: 8px; }
  .main-nav { width: 100%; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
  .main-nav a { padding-inline: 0; }
  .main-nav a span, .profile-button span:last-child { display: none; }
  .main-nav svg { width: 20px; height: 20px; }
  .profile-button { padding-inline: 5px; }
  .join .song-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .join .song-card { display: grid; grid-template-columns: 80px minmax(0, 1fr); align-items: start; gap: 10px; padding: 9px; }
  .join .song-art { border-radius: 6px; }
  .join .song-rating { inset: 8px auto auto 8px; font-size: .7rem; }
  .join .song-body { padding: 0; gap: 2px; }
  .join .song-body h3 { font-size: 1rem; }
  .join .song-actions { margin: 4px 0 0; padding: 0; }
  .join .song-actions > .button { width: 100%; }
}
@media (max-width: 530px) {
  .hero { min-height: 340px; background-position: 55% 43%; }
  .hero-content { width: 100%; padding: 28px 23px; }
  .hero p { color: #f5e6d3; max-width: 29ch; margin: 14px 0 18px; }
  .quick-links, .columns, .columns.playlists, .columns.history { grid-template-columns: 1fr; }
  .quick-card { min-height: 63px; }
  .quick-card > svg { display: inline; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 9px; }
  .page-heading p { margin-top: 5px; }
  .track-row { gap: 7px; }
  .track-row .tile-icon { width: 33px; height: 33px; }
  .track-row:has([data-action="moveToTop"]) { display: grid; grid-template-columns: auto auto minmax(0, 1fr); }
  .track-row:has([data-action="moveToTop"]) .row-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .room-queue-bar, .room-queue-items { padding-inline: 8px; }
  .room-queue-info, .room-queue-items .track-title { display: block; }
  .room-queue-info strong, .room-queue-info .count { font-size: .82rem; }
  .room-queue-items .track-title > strong { display: block; }
  .search-form .button { padding-inline: 8px; }
  .panel { padding: 14px; }
  .stage-idle { background-position: center, center, 64% 40%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
