:root {
    color-scheme: dark;
    --bg: #101d18;
    --panel: #16251e;
    --felt: #243e32;
    --paper: #f2eadb;
    --muted: #afc0b0;
    --gold: #e2b978;
    --line: #46574b;
    --body: 'Inter', 'PingFang SC', 'Microsoft YaHei UI', system-ui, sans-serif;
    --display: 'Cormorant Garamond', 'Songti SC', 'SimSun', Georgia, serif;
    --mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-width: 280px; margin: 0; background: var(--bg); color: var(--paper); font: 400 15px/1.6 var(--body); }
button, select, input, textarea { font: inherit; }
button, select, input[type=checkbox], input[type=radio] { accent-color: var(--gold); }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
:focus-visible { outline: 2px solid #f3ce8e; outline-offset: 4px; }
h1, h2, p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.game { width: min(1280px, 100%); margin: 0 auto; padding: 0 38px 56px; }
.masthead { display: flex; gap: 12px; align-items: center; justify-content: space-between; min-height: 66px; border-bottom: 1px solid var(--line); }
.back { min-height: 44px; display: flex; align-items: center; color: var(--muted); text-decoration: none; font-size: 13px; letter-spacing: .025em; white-space: nowrap; }
.back:hover { color: var(--paper); }
.masthead-actions, .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.speed-control { display: flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--muted); font-size: 12px; }
.speed-control select { width: auto; }
.switch { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; color: var(--muted); font-size: 13px; }
.switch input { flex: none; width: 17px; height: 17px; margin: 0; }
.headline { display: flex; justify-content: space-between; align-items: end; gap: 16px; padding: 24px 0 22px; }
h1 { font: 650 clamp(36px, 5vw, 60px)/1.13 var(--display); letter-spacing: .025em; }
.headline p { color: var(--muted); margin-top: 6px; }
.lineup { flex: none; padding: 0 0 3px; font-size: 12px; text-align: right; }
.layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.playback {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px 16px;
    margin-bottom: 12px;
    padding: 11px 15px;
    border-inline-start: 3px solid #778575;
}
.playback[data-running=true] { position: sticky; top: 0; z-index: 4; border-inline-start-color: var(--gold); }
.playback[data-running=true][data-kind=private] { border-inline-start-color: #96bca7; }
.playback[data-kind=night] { background: #13251f; }
.playback[data-kind=dawn] { background: #262d21; }
.playback[data-kind=result] { border-inline-start-color: var(--gold); }
.playback-main { display: flex; align-items: flex-start; gap: 11px; min-width: 0; }
.playback-copy { min-width: 0; }
.playback h2 { color: var(--gold); font: 650 22px/1.22 var(--display); }
.playback p { margin-top: 5px; max-height: 5.6rem; overflow: auto; overscroll-behavior: contain; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.playback[data-running=true] .playback-main { min-height: 102px; }
.playback-count { color: var(--muted); font-size: 11px; }
.playback-count:empty { display: none; }
.table-column, .side { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.table {
    --rim: #8c7b54;
    --surface: #233c30;
    --mark: #d8ab69;
    position: relative;
    isolation: isolate;
    overflow: clip;
    width: 100%;
    min-width: 0;
    min-height: 360px;
    aspect-ratio: 1.53;
    background: #192a21;
    border: 1px solid var(--line);
    border-radius: 12px;
}
.table[data-light=day] { --rim: #d7a060; --surface: #3a4a35; --mark: #f0bf70; background: #2a3324; }
.table[data-light=night] { --rim: #718478; --surface: #203832; --mark: #b3c8b6; background: #152923; }
.felt {
    position: absolute;
    inset: 10% 7%;
    border-radius: 50%;
    border: 1px solid var(--rim);
    background: repeating-radial-gradient(ellipse at center, transparent 0 24px, #e1cb9121 25px 26px, transparent 27px 46px),
        radial-gradient(ellipse, var(--surface) 10%, #192d24 90%);
    box-shadow: inset 0 0 0 7px #16271d, inset 0 0 0 8px #9ba28743, inset 0 13px 42px #08130e68, 0 10px 20px #0d190f7a;
}
.felt::before, .felt::after { content: ''; position: absolute; inset: 48% 11%; border-top: 1px dashed #b6bb9b48; transform: rotate(90deg); }
.felt::after { transform: none; }
.phase-disc {
    position: absolute;
    z-index: 1;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: grid;
    place-content: center;
    text-align: center;
    gap: 5px;
    width: 139px;
    height: 139px;
    border: 1px solid var(--rim);
    border-radius: 50%;
    background: #15241b;
    box-shadow: 0 0 0 4px #8a8f6444;
}
.phase-label { color: var(--paper); font-size: 15px; font-weight: 650; }
.phase-count { color: var(--muted); font-size: 11px; }
.phase-symbol { width: 28px; height: 28px; display: block; place-self: center; border: 1px solid var(--mark); border-radius: 50%; position: relative; }
.phase-symbol::after { content: ''; position: absolute; inset: 4px; border: 1px dashed var(--mark); border-radius: 50%; }
[data-light=day] .phase-symbol { background: var(--mark); box-shadow: 0 0 14px #d7ae5e55; }
[data-light=day] .phase-symbol::after { border-color: #715123; }
[data-light=night] .phase-symbol { background: var(--mark); border: none; }
[data-light=night] .phase-symbol::after { inset: -4px -4px 4px 10px; background: #15241b; border: 0; }
.seats { position: absolute; inset: 0; list-style: none; padding: 0; margin: 0; }
.seat { position: absolute; left: var(--x); top: var(--y); width: 24%; transform: translate(-50%, -50%); text-align: center; }
.seat-button { width: min(100%, 112px); min-height: 44px; position: relative; display: inline-flex; gap: 6px; align-items: center; justify-content: center; background: #24342a; color: var(--paper); border: 1px solid #677868; border-radius: 9px; padding: 5px 5px; }
.seat-button[data-target=true] { background: #334437; border-color: #c8aa6c; }
.seat-button[data-target=true]:hover, .seat-button[aria-pressed=true] { background: #433e2d; border-color: var(--gold); }
.seat-button[data-active=true] { border-color: #ddc28e; box-shadow: 0 0 0 2px #ddc28e42; }
.seat-button[data-self=true] { border-color: #ccaa70; }
.seat-button[data-out=true] { color: var(--muted); background: #19261f; border-style: dashed; }
.seat-button[data-out=true] .avatar { filter: saturate(0.32); }
.avatar {
    --portrait: #d9b987;
    --avatar-size: 34px;
    isolation: isolate;
    flex: 0 0 auto;
    width: var(--avatar-size);
    height: var(--avatar-size);
    display: inline-grid;
    place-items: center;
    position: relative;
    overflow: hidden;
    border-radius: 50%;
    border: 1px solid color-mix(in srgb, var(--portrait) 64%, #314a3c);
    color: var(--portrait);
    background: radial-gradient(circle at center, color-mix(in srgb, var(--portrait) 23%, #18291f), #18291f 76%);
    font: 650 calc(var(--avatar-size) * .56)/1 var(--display);
}
.avatar::after { content: ''; position: absolute; inset: 3px; border: 1px solid color-mix(in srgb, var(--portrait) 36%, #1c2d23); border-radius: 50%; z-index: -1; }
.avatar img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; color: transparent; }
.avatar[data-portrait=ready] { border-radius: 16%; }
.seat-token { flex: none; position: relative; line-height: 1; }
.seat-token .avatar { --avatar-size: 33px; }
.seat-token .seat-number { position: absolute; right: -4px; bottom: -2px; width: 15px; height: 15px; font-size: 9px; }
.seat-number { display: inline-grid; flex: none; place-items: center; width: 22px; height: 22px; background: #101d18; color: var(--gold); border: 1px solid #7e8a7069; border-radius: 50%; font: 600 11px var(--mono); }
.seat-content { display: grid; justify-items: start; min-width: 0; }
.seat-name, .seat-note { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.seat-name { font-weight: 600; font-size: 13px; }
.seat-note { color: var(--muted); font-size: 10px; }
.seat-button[data-target=true] .seat-number, .seat-button[aria-pressed=true] .seat-number { color: #1d2519; background: var(--gold); border-color: var(--gold); }
.table[data-size='12'] .seat { width: 18%; }
.table[data-size='12'] .seat-button { min-height: 42px; }

.card { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.setup, .role, .turn { padding: 19px 21px; }
.setup h2, .turn h2, .archive h2, .rules-dialog h2 { font: 650 23px/1.3 var(--display); }
.setup form { display: grid; gap: 14px; margin: 14px 0 0; }
#mode-options { min-width: 0; padding: 0; border: 0; margin: 0; }
.setup label, .turn label, .setup legend { color: var(--muted); font-size: 13px; }
.mode-option { display: flex; align-items: start; gap: 9px; min-height: 44px; padding: 8px 0; }
.mode-option input { margin: 4px 0 0; }
.mode-option span { display: grid; gap: 1px; }
.mode-option strong { color: var(--paper); font-size: 15px; }
.mode-option small { color: var(--muted); font-size: 12px; }
.setup-field, .connection { display: grid; min-width: 0; gap: 5px; }
.setup-roles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.avatar-choice { grid-column: 1 / -1; }
.avatar-choice > div, .avatar-upload, .role-heading, .friend-header, .event-byline { display: flex; align-items: center; gap: 9px; }
.avatar-choice select { flex: 1; min-width: 0; }
.avatar-customize { margin-top: 9px; border-top: 1px solid var(--line); padding-top: 5px; }
.avatar-customize summary { padding-block: 8px; cursor: pointer; }
.avatar-customize .avatar-upload { margin-top: 7px; }
.avatar-upload > div:last-child { flex: 1; }
.avatar-customize > p { color: var(--muted); font-size: 12px; }
.avatar-customize > p.setup-status { color: var(--gold); }
.connection { padding: 0 0 12px; border-bottom: 1px solid var(--line); }
.connection input { margin-bottom: 4px; }
.connection p { color: var(--muted); font-size: 12px; }
.destination { overflow-wrap: anywhere; }
#destination { color: var(--gold); font-family: var(--mono); font-size: 11px; }
.setup-status { color: var(--gold); font-size: 13px; margin-top: 8px; }
.setup-status:empty { display: none; }
input:not([type=checkbox]):not([type=radio]), select, textarea { width: 100%; padding: 8px 10px; background: #1d2e24; border: 1px solid #647768; border-radius: 6px; color: var(--paper); min-height: 44px; }
select, textarea, input { max-width: 100%; }
textarea { display: block; resize: vertical; }
textarea::placeholder, input::placeholder { color: #afc0b081; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 6px 13px; border: 1px solid #647667; border-radius: 6px; background: #27392d; color: var(--paper); font: 600 13px/1.4 var(--body); }
.button:hover:enabled { background: #3a4d3c; }
.button.primary { color: #141d16; background: var(--gold); border-color: var(--gold); }
.button.primary:hover:enabled { background: #f6ce91; }
.button.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.button.quiet:hover:enabled { color: var(--paper); }
.button:disabled { opacity: .49; }
.button.wide { width: 100%; min-height: 49px; }
.role-top, .turn-head, .archive-top, .dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 13px; }
.role-top { align-items: start; }
.role h2 { color: var(--gold); font: 650 25px/1.1 var(--display); margin-top: 3px; }
.overline, .role-state { color: var(--muted); font-size: 12px; }
.role-state { padding: 2px 7px; border: 1px solid var(--line); border-radius: 4px; }
.role > p, .turn > p { color: var(--muted); font-size: 13px; margin-top: 8px; }
#role-tools { color: var(--gold); }
.turn form, .potions, #wait-actions { margin-top: 10px; }
.turn form .actions { margin-top: 8px; }
.speech-actions { justify-content: flex-end; }
#speech-count { margin-right: auto; font-size: 11px; color: var(--muted); }
.archive { overflow: hidden; }
.archive-top { padding: 16px 18px 10px; }
.archive-top p { color: var(--muted); font-size: 12px; text-align: right; }
.archive-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 14px; border-bottom: 1px solid var(--line); }
.archive-tabs button { min-height: 44px; background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font-size: 12px; }
.archive-tabs button[aria-pressed=true] { border-color: var(--gold); color: var(--gold); font-weight: 650; }
.feed { min-height: 255px; max-height: min(70vh, 620px); overflow: auto; padding: 6px 18px 14px; scrollbar-width: thin; scrollbar-color: #68786c transparent; overflow-wrap: anywhere; }
.feed-empty { padding: 18px 0; color: var(--muted); font-size: 13px; }
.feed-entry { padding: 12px 1px; border-bottom: 1px solid #46574b85; }
.feed-entry:last-child { border-bottom: 0; }
.event-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 10px; margin-bottom: 3px; }
.event-heading strong { color: var(--gold); font-size: 13px; }
.event-heading span { font-size: 11px; color: var(--muted); }
.event-byline .avatar { --avatar-size: 26px; }
.feed-entry > p { white-space: pre-wrap; font-size: 14px; }
.feed-entry[data-kind=private] { border-inline-start: 2px solid var(--muted); padding-inline-start: 9px; }
.vote-grid, .recap-seats { display: flex; flex-wrap: wrap; list-style: none; padding: 0; gap: 4px 7px; margin: 7px 0 0; }
.vote-grid li, .recap-seats li { padding: 3px 7px; background: #223529; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); font-size: 12px; }
.recap-summary { margin: 10px 0 4px; color: var(--gold); font-size: 19px; }
.archive-footer { border-top: 1px solid var(--line); padding: 10px 17px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
#developer summary { cursor: pointer; padding: 4px 0; }
#observations pre { max-height: 16rem; overflow: auto; white-space: pre-wrap; background: #142019; padding: 8px; color: var(--paper); font: 11px/1.5 var(--mono); }
.rules-dialog { width: min(560px, calc(100vw - 28px)); max-height: calc(100dvh - 36px); padding: 20px; margin: auto; color: var(--paper); background: var(--panel); border: 1px solid #6d7c67; border-radius: 10px; box-shadow: 0 15px 64px #07110d99; }
.rules-dialog::backdrop { background: #0d1914c9; }
.rules-dialog dl { margin: 10px 0 0; }
.rules-dialog dt { color: var(--gold); font-weight: 650; margin-top: 11px; }
.rules-dialog dd, .rules-dialog > p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.rules-dialog .actions { margin-top: 14px; }
.friend-picker { margin-top: 12px; }
.friend-picker label { color: var(--muted); font-size: 13px; }
.friend-header { margin-top: 12px; }
.friend-header h3 { margin: 0; font: 650 27px/1.2 var(--display); }
.friend-header .avatar { --avatar-size: 64px; }
#friend-voice { margin: 17px 0 0; padding-left: 13px; border-left: 2px solid var(--gold); color: var(--paper); }
.rules-dialog .portrait-credit { margin-top: 12px; font-size: 12px; }
.portrait-credit a { color: var(--muted); text-underline-offset: 3px; }

@media (max-width: 1060px) { .game { padding-inline: 23px; } .table { min-height: 326px; } }
@media (max-width: 780px) {
    .game { padding: 0 16px 34px; }
    .layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .table { min-height: 315px; max-height: 400px; }
    .headline { align-items: flex-start; flex-direction: column; gap: 5px; padding: 18px 0 15px; }
    .lineup { text-align: left; }
    .feed { max-height: 58vh; }
    .playback { grid-template-columns: minmax(0, 1fr); gap: 7px; }
    .playback-actions { justify-content: flex-end; }
    .playback-count { margin-right: auto; }
}
@media (max-width: 520px) {
    .table[data-size='12'] { aspect-ratio: auto; min-height: 0; display: grid; justify-items: stretch; gap: 11px; padding: 11px; }
    .table[data-size='12'] .felt { inset: 6% 1%; }
    .table[data-size='12'] .phase-disc { position: relative; justify-self: center; top: auto; left: auto; transform: none; width: 94px; height: 94px; }
    .table[data-size='12'] .seats { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
    .table[data-size='12'] .seat { position: relative; left: auto; top: auto; transform: none; width: auto; min-width: 0; }
    .table[data-size='12'] .seat-button { width: 100%; min-height: 48px; }
    .table[data-size='12'] .seat-token .avatar { --avatar-size: 24px; }
    .table[data-size='12'] .seat-name { font-size: 11px; }
}
@media (max-width: 420px) {
    .game { padding-inline: 10px; }
    .masthead { min-height: 54px; }
    .masthead-actions { gap: 4px; justify-content: flex-end; }
    .masthead .button { padding-inline: 5px; white-space: nowrap; }
    .table { min-height: 285px; }
    .seat-button { gap: 3px; border-radius: 6px; padding-inline: 3px; }
    .seat-token .avatar { --avatar-size: 24px; }
    .seat-token .seat-number { width: 13px; height: 13px; font-size: 8px; }
    .seat-name { font-size: 11px; }
    .seat-note { font-size: 9px; }
    .phase-disc { width: 99px; height: 99px; gap: 3px; }
    .phase-label { font-size: 13px; }
    .phase-symbol { width: 22px; height: 22px; }
    .setup, .role, .turn { padding: 13px 14px; }
    .archive-top { padding-inline: 13px; }
    .feed { padding-inline: 13px; }
    .connection input, #target, #speech { font-size: 16px; }
}
@media (max-width: 360px) {
    .masthead { flex-wrap: wrap; gap: 0; }
    .masthead .back { margin-right: auto; }
    .masthead-actions { display: contents; }
    .masthead .speed-control { order: 3; flex-basis: 100%; justify-content: flex-end; padding-bottom: 6px; }
}
@media (max-width: 345px) {
    .table[data-size='12'] { padding-inline: 6px; }
    .table[data-size='12'] .seats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .table[data-size='12'] .seat-token .avatar { --avatar-size: 24px; }
    .table[data-size='12'] .seat-button { gap: 4px; }
    .speed-control { gap: 3px; }
    .speed-control select { padding-inline: 4px; }
}
