:root {
  color-scheme: light;
  --bg: #efeeeb;
  --surface: #fffefa;
  --paper: #292728;
  --soft: #4e4948;
  --muted: #605b5a;
  --red: #842f29;
  --line: #d5d0ca;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-size: 16px;
  background: var(--bg);
  color: var(--paper);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
a { color: var(--red); text-underline-offset: .18em; }
a:hover { color: #60201b; }
button, input, select, textarea { font: inherit; }
button, .button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: .55rem .85rem; border: 1px solid #bdb6ad; border-radius: .28rem; color: var(--paper); background: var(--surface); cursor: pointer; font-weight: 650; }
button:hover, .button:hover { background: #f3efea; border-color: #8d7c73; }
button.primary, .button.primary { color: #fff; background: var(--red); border-color: var(--red); }
button.primary:hover, .button.primary:hover { background: #68241f; }
button.ghost, .button.ghost { background: transparent; }
button.subtle { min-height: 40px; padding: .35rem .55rem; background: transparent; border-color: transparent; color: var(--red); font-size: .9rem; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid #a7423c; outline-offset: 3px; }
input, select, textarea { width: 100%; min-height: 44px; background: #fff; color: var(--paper); border: 1px solid #bdb6ad; border-radius: .28rem; padding: .6rem .7rem; }
select { appearance: none; padding-right: 1.8rem; background: linear-gradient(45deg, transparent 50%, #5d5551 50%) right 12px center / 5px 5px no-repeat, linear-gradient(135deg, #5d5551 50%, transparent 50%) right 7px center / 5px 5px no-repeat, #fff; }
input[type=checkbox] { width: 1.15rem; min-height: 1.15rem; accent-color: var(--red); }
textarea { min-height: 5rem; resize: vertical; }
label { display: grid; gap: .4rem; color: var(--soft); font-size: .92rem; }
label.check { display: flex; align-items: flex-start; gap: .45rem; min-height: 2rem; }
label.check input { flex-shrink: 0; margin: .1rem .1rem 0 0; }
fieldset { margin: 0; padding: .8rem; border: 1px solid var(--line); min-width: 0; }
legend { color: var(--soft); padding: 0 .4rem; }
h1, h2, h3, p { margin-top: 0; }
p { color: var(--soft); line-height: 1.65; }
small, .meta { color: var(--muted); font-size: .88rem; }
.site-header { background: #282627; color: #f8f4ed; }
.topbar, .shell { width: min(1140px, calc(100% - 2.75rem)); margin-inline: auto; }
.topbar { min-height: 58px; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.site-header a { color: inherit; text-decoration: none; }
.site-header a:hover { text-decoration: underline; }
.brand { font-weight: 750; font-size: 1.12rem; }
nav { display: flex; gap: clamp(.8rem, 4vw, 2rem); align-items: center; white-space: nowrap; font-size: .93rem; }
.shell { min-width: 0; }
#main { padding-block: 1.8rem 3rem; min-height: min(74vh, 760px); }
.home-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; max-width: 900px; margin-inline: auto; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: .32rem; padding: clamp(.85rem, 3vw, 1.4rem); min-width: 0; }
.panel h1, .panel h2 { font-size: 1.35rem; margin-bottom: .85rem; }
.section-label { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.section-label h1, .section-label h2, .section-label p { margin-bottom: 0; }
.form-grid, .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.filters { grid-template-columns: 1.35fr repeat(4, minmax(0, 1fr)); }
.form-stack { display: grid; gap: .85rem; }
.form-stack > .button, .form-stack > button { justify-self: start; }
.button-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.inline-count { color: var(--red); }
.room-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.room-head h1 { margin-bottom: .25rem; font-size: 1.5rem; }
.room-head p { margin-bottom: 0; }
.room-code { font-family: ui-monospace, monospace; letter-spacing: .08em; color: var(--red); overflow-wrap: anywhere; }
.room-layout { display: grid; grid-template-columns: minmax(230px, .82fr) minmax(0, 2.3fr); gap: 1rem; align-items: start; }
.stage-bar { display: flex; gap: .55rem; flex-wrap: wrap; margin-bottom: 1rem; color: var(--soft); font-size: .87rem; }
.stage-bar span { padding: .2rem .25rem; }
.stage-bar .active { color: var(--red); box-shadow: inset 0 -2px var(--red); font-weight: 750; }
.seat-list { list-style: none; display: grid; gap: .45rem; padding: 0; margin: 0; }
.seat-list li { border: 1px solid var(--line); border-radius: .28rem; padding: .65rem; overflow-wrap: anywhere; }
.seat-list li.me { border-color: #a4756b; }
.seat-main { display: flex; align-items: center; justify-content: space-between; gap: .35rem; }
.seat-name { font-weight: 700; }
.seat-actions { display: flex; flex-wrap: wrap; }
.tag { display: inline-block; background: #f1efeb; border-radius: .2rem; padding: .15rem .4rem; color: var(--soft); font-size: .83rem; }
.tag.lord { background: #efe4cb; color: #66400f; }
.tag.team-a { background: #f4e2df; color: #762b25; }
.tag.team-b { background: #e1eaef; color: #254f65; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 152px), 1fr)); gap: .8rem; }
.cards.candidates { display: flex; overflow: auto; padding: .2rem .2rem .6rem; scroll-snap-type: x proximity; }
.cards.candidates > article { flex: 0 0 154px; scroll-snap-align: start; }
.war-card { background: var(--surface); border: 1px solid var(--line); border-radius: .28rem; overflow: hidden; display: grid; min-width: 0; align-content: start; }
.war-card.chosen { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.card-face { aspect-ratio: 2 / 3; background: #292728; }
.card-face img { width: 100%; height: 100%; object-fit: contain; }
.card-info { padding: .7rem; display: grid; align-content: start; gap: .35rem; }
.card-info h3 { margin: 0; font-size: 1.09rem; overflow-wrap: anywhere; }
.card-info .subtle { justify-self: start; padding-left: 0; }
.card-info button[aria-pressed=true] { background: #f4e2df; border-color: var(--red); }
.quick-skills { margin: 0; font-size: .91rem; overflow-wrap: anywhere; }
.player-switch { display: flex; overflow-x: auto; gap: .45rem; padding: .2rem .2rem .65rem; margin: 0 -.2rem .55rem; }
.player-switch button { flex: 0 0 auto; gap: .35rem; max-width: min(75%, 17rem); padding-inline: .65rem; overflow-wrap: anywhere; }
.player-switch button[aria-pressed="true"] { border-color: var(--red); color: var(--red); background: #f6e9e5; }
.picked-list { display: grid; gap: 1rem; }
.picked-card { display: flex; align-items: flex-start; gap: 1.15rem; padding: .8rem 0 1rem; border-top: 1px solid var(--line); }
.picked-art { flex: 0 1 15rem; margin: 0; display: grid; place-items: center; background: #292728; border-radius: .28rem; overflow: hidden; }
.picked-art button { padding: 0; border: 0; width: 100%; background: transparent; }
.picked-art img { display: block; width: 100%; max-height: 25rem; object-fit: contain; }
.photo-full { display: block; margin-inline: auto; max-width: 100%; max-height: 75dvh; object-fit: contain; }
.picked-copy { flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; }
.picked-copy h3 { font-size: 1.32rem; margin-bottom: .28rem; }
.picked-meta { font-size: .9rem; margin-bottom: .75rem; }
.skill-list { margin: 0; display: grid; gap: .65rem; }
.skill-list dt { font-weight: 700; }
.skill-list dd { margin: .2rem 0 0; color: var(--soft); }
.source-line, .card-source { font-size: .92rem; margin-block: .75rem .2rem; }
.local-photo-actions .subtle { padding-left: 0; }
.page-stack { display: grid; gap: 1rem; }
.page-actions { margin-top: 1rem; }
.site-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .7rem; padding: 1rem 0 1.5rem; color: var(--muted); font-size: .88rem; border-top: 1px solid var(--line); }
#notice { position: fixed; bottom: 1.1rem; right: 1.1rem; width: min(31rem, calc(100% - 2.2rem)); padding: .8rem 1rem; background: #282627; color: #fff; border-radius: .32rem; box-shadow: 0 4px 14px #0003; z-index: 4; }
#notice:empty { display: none; }
dialog { width: min(680px, calc(100% - 1.5rem)); max-height: calc(100dvh - 1.5rem); overflow: auto; border: 1px solid var(--line); border-radius: .32rem; padding: clamp(.9rem, 4vw, 1.5rem); background: var(--surface); color: var(--paper); }
dialog::backdrop { background: #171616aa; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: .7rem; margin-bottom: 1rem; }
.dialog-head h2 { margin: 0; }
.role-tile { display: grid; align-content: center; justify-items: center; text-align: center; min-height: 236px; width: min(100%, 205px); margin: 0 auto 1rem; padding: 1rem; gap: .65rem; border: 3px double #c29863; background: radial-gradient(#553721, #241711); border-radius: .45rem; color: #ffe0aa; }
.role-tile strong { font-size: 2.12rem; }
.role-tile.flipped { animation: flip .32s ease-out both; }
.role-tile.lord { color: #ffe1a1; background: radial-gradient(#755322, #382b12); }
.role-tile.loyal { color: #c6eef5; background: radial-gradient(#245463, #172d37); }
.role-tile.rebel { color: #ffc1b2; background: radial-gradient(#813b32, #3d1919); }
.role-tile.spy { color: #e6c8fa; background: radial-gradient(#57345e, #311d34); }
.center { text-align: center; justify-content: center; }
.detail-rule { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.detail-rule.large { font-size: 1.23rem; }
.detail-art { max-width: min(100%, 16rem); height: auto; }
.choice-list { display: flex; flex-wrap: wrap; gap: .35rem .8rem; max-height: 9rem; overflow: auto; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: .7rem; }
.result-grid section { border: 1px solid var(--line); padding: .8rem; border-radius: .35rem; min-width: 0; overflow-wrap: anywhere; }
.warn { color: var(--red); }
.skip { position: absolute; left: -100vw; }
.skip:focus { z-index: 5; top: 1rem; left: 1rem; background: var(--surface); padding: .5rem; }
@media (max-width: 780px) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters label:first-child { grid-column: 1 / -1; }
  .room-layout { grid-template-columns: 1fr; }
  .room-layout > aside { order: 2; }
  .seat-list { grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); }
}
@media (max-width: 540px) {
  .topbar, .shell { width: calc(100% - 1.3rem); }
  .topbar { min-height: 57px; }
  .brand { gap: .35rem; font-size: 1rem; }
  nav { gap: .7rem; font-size: .82rem; }
  #main { padding-top: 1rem; }
  .picked-card { display: grid; gap: .85rem; }
  .picked-art { width: min(100%, 13rem); margin-inline: auto; }
  .picked-art img { max-height: 19rem; }
  .home-panels { grid-template-columns: 1fr; }
  .form-grid { gap: .55rem; }
  .cards.candidates > article { flex-basis: 138px; }
}
@keyframes flip { from { transform: rotateY(80deg); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; } }
