:root {
  --lobby-pattern: url('/art/lobby-pattern.svg');
}
:root[data-themed="true"] {
  --background: #211829;
  --surface: #30243b;
  --raised: #44324f;
  --edge: #8f799c;
  --border: #695574;
  --lobby-ink: #ceb3c0;
  --surface-sheen: linear-gradient(180deg, #fff0d712, transparent 8rem);
  --panel-depth: inset 0 0 0 2px #fff0d714, inset 0 1px #fff0d72b, 0 3px 3px #00000040;
}
:root[data-themed="true"][data-lobby-theme="green"] {
  --background: #101f1c;
  --surface: #1c302a;
  --raised: #2b443a;
  --edge: #8c9d7e;
  --border: #4e6b5a;
  --muted: #bfd0c5;
  --accent: #f3d39b;
  --selected-surface: #344e40;
  --selected-edge: #af9564;
  --shadow: #091410;
  --lobby-ink: #c7b38b;
}
:root[data-themed="true"][data-lobby-theme="navy"] {
  --background: #141d2b;
  --surface: #202e42;
  --raised: #30435d;
  --edge: #8299b5;
  --border: #526783;
  --muted: #bfcede;
  --accent: #f4d7a4;
  --selected-surface: #3b4b63;
  --selected-edge: #b7a07c;
  --shadow: #0c1420;
  --lobby-ink: #b2bbd1;
}
:root[data-themed="true"][data-lobby-theme="wine"] {
  --background: #29171d;
  --surface: #3d252e;
  --raised: #523441;
  --edge: #a48288;
  --border: #805b67;
  --muted: #e0c6cc;
  --accent: #f4d1a0;
  --selected-surface: #61414a;
  --selected-edge: #c29d7a;
  --shadow: #1a0e14;
  --lobby-ink: #cfac95;
}
:root[data-themed="true"] body { background: var(--background); }
.app:is([data-screen="login"], [data-screen="profile"], [data-screen="home"])::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--lobby-ink);
  mask-image: var(--lobby-pattern);
  mask-size: 320px 320px;
  mask-repeat: repeat;
  opacity: .14;
  pointer-events: none;
}
.app[data-screen="profile"]::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(ellipse 17rem 14rem at 50% 16rem, var(--background), transparent);
  opacity: .76;
  pointer-events: none;
}
:root[data-themed="true"] .lobby-tabs { background: var(--surface-sheen), var(--surface); }
:root[data-themed="true"] .profile-actions button { background: var(--surface); }
:root[data-themed="true"] #profileAppearance {
  border-color: var(--selected-edge);
  background: radial-gradient(circle at 50% 30%, var(--raised), var(--background) 80%);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--raised) 50%, transparent), inset 0 -3px #10091f40;
}
.appearance-intro { font-size: .8rem; color: var(--muted); margin: .65rem 0; }
.profile-palette { min-width: 0; margin: .3rem 0 0; padding: .55rem 0 0; border: 0; border-top: 1px solid var(--border); }
.profile-palette legend { padding: 0 .3rem 0 0; font-weight: 700; }
.palette-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; margin: 0; padding: 0; border: 0; }
.palette-choice { position: relative; display: grid; gap: .35rem; padding: .35rem; border: 1px solid var(--border); border-radius: var(--radius-plaque); cursor: pointer; }
.palette-choice input { position: absolute; width: 1px; height: 1px; min-height: 0; margin: 0; padding: 0; opacity: 0; }
.palette-choice:has(:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.palette-choice:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.palette-swatch { position: relative; display: block; height: 4.6rem; border-radius: .35rem; overflow: hidden; background: var(--preview-base); }
.palette-swatch::before { content: ''; position: absolute; inset: 0; background: var(--preview-ink); mask: var(--lobby-pattern) repeat 0 0 / 160px 160px; opacity: .3; }
.palette-caption { display: flex; justify-content: space-between; align-items: center; min-height: 1.5rem; font-size: .84rem; }
.palette-choice:has(:checked) .palette-caption::after { content: '已选'; color: var(--accent); font-size: .69rem; }
.palette-choice[data-theme="purple"] { --preview-base: #211829; --preview-ink: #ceb3c0; }
.palette-choice[data-theme="green"] { --preview-base: #101f1c; --preview-ink: #c7b38b; }
.palette-choice[data-theme="navy"] { --preview-base: #141d2b; --preview-ink: #b2bbd1; }
.palette-choice[data-theme="wine"] { --preview-base: #29171d; --preview-ink: #cfac95; }
@media (forced-colors: active) {
  .app:is([data-screen="login"], [data-screen="profile"], [data-screen="home"])::before, .app[data-screen="profile"]::after { display: none; }
  .palette-choice:has(:checked) { outline: 2px solid Highlight; }
}

/* Use the same surfaces in the room, including controls and detached dialogs. */
:root[data-themed="true"] .app[data-screen="room"] {
  background: var(--cloth), radial-gradient(ellipse at 50% 45%, var(--surface), var(--background) 71%);
}
:root[data-themed="true"] .table-felt::before {
  background: var(--cloth), radial-gradient(ellipse at 50% 42%, var(--raised), var(--surface) 75%);
  background-blend-mode: soft-light, normal;
}
:root[data-themed="true"] .controls {
  border-color: var(--edge);
  background: var(--surface-sheen), var(--cloth), var(--surface);
  background-blend-mode: normal, soft-light, normal;
  box-shadow: var(--panel-depth);
}
:root[data-themed="true"] .tool-face { background: var(--surface-sheen), var(--cloth), var(--surface); background-blend-mode: normal, soft-light, normal; border-color: var(--edge); }
:root[data-themed="true"] .seat-nameplate:not(.seat-reveal) { border-color: var(--edge); background: linear-gradient(var(--raised), var(--surface)); }
:root[data-themed="true"] .seat.own-seat .seat-nameplate:not(.seat-reveal) { border-color: var(--muted); }
:root[data-themed="true"] .seat.comparison-option .seat-nameplate { background: var(--selected-surface); border-color: var(--muted); }
:root[data-themed="true"] .seat.comparison-target .seat-nameplate,
:root[data-themed="true"] .seat.winning-seat .seat-nameplate:not(.seat-reveal) { background: linear-gradient(color-mix(in srgb, var(--raised) 75%, var(--accent)), var(--surface)); border-color: var(--accent); }
:root[data-themed="true"] .table-pot { background: var(--raised); }
:root[data-themed="true"] .room-separator { color: var(--muted); }
:root[data-themed="true"] .copy-icon::after { background: var(--background); }
:root[data-themed="true"] #notice { background: color-mix(in srgb, var(--surface) 86%, transparent); }
:root[data-themed="true"] .sound-option input:not(:checked) { background: var(--surface); border-color: var(--edge); }
.startup-status { margin-top: 2rem; }

:root[data-themed="true"] .chat-composer input { background: color-mix(in srgb, var(--background) 75%, transparent); border-color: var(--edge); }

/* Tint the inset cloth only; keep the card's pale frame and original ornament. */
:root[data-themed="true"] :is(.card.back, .seat-card-back, .blind-badge),
:root[data-themed="true"] .seat[data-cue="deal"] .seat-identity::after {
  background-image: linear-gradient(var(--raised), var(--raised)), url('/art/room-card.webp');
  background-size: 84% 90%, 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
  background-blend-mode: color, normal;
}
:root[data-themed="true"] .seat[data-cue="deal"] .seat-identity::after { box-shadow: -.18rem .12rem 0 var(--raised); }
:root[data-themed="true"] .seat.current .seat-identity::before {
  background: radial-gradient(ellipse,
    color-mix(in srgb, var(--accent) 65%, transparent) 0%,
    color-mix(in srgb, var(--accent) 40%, transparent) 29%,
    color-mix(in srgb, var(--edge) 35%, transparent) 52%, transparent 74%);
}
:root[data-themed="true"] .card-look-prompt {
  border-color: color-mix(in srgb, var(--accent) 26%, transparent);
  background: color-mix(in srgb, var(--background) 88%, transparent);
}
