.tavern {
  --gold: #edc988;
  --muted-gold: #c9b384;
  --ink: #140e20;
  --panel: #20192c;
  background: radial-gradient(ellipse at 50% 55%, #302144, #110d1a 72%);
  color: #f8efd8;
}

.room-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px max(16px, calc((100% - 1180px) / 2)); min-height: 66px; border-bottom: 1px solid #795a4270; background: #100c18e8; }
.room-brand, .compendium { display: inline-flex; gap: 9px; align-items: center; white-space: nowrap; font-weight: 700; }
.room-brand { color: var(--gold); }
.room-brand .brand-symbol { width: 18px; height: 24px; }
.compendium { color: var(--gold); text-decoration: none; padding: 4px 9px; border: 1px solid #a985565c; border-radius: 8px; background: #2b2032; }
.compendium img { width: 34px; height: 30px; object-fit: contain; }
.compendium:hover { border-color: var(--gold); }
.tavern.home { background: linear-gradient(#100d1c30, #110d1ace 61%, #100d1c), url("/assets/room/crystal-hall.png") center 45% / cover no-repeat; }
.home-content { display: grid; justify-items: center; gap: 18px; width: min(100% - 30px, 630px); margin: auto; padding: clamp(26px, 8vh, 84px) 0 22px; text-align: center; }
.home-title h1 { color: #f9dfab; font-size: clamp(2rem, 7vw, 4.2rem); text-shadow: 0 4px #432933, 0 0 36px #c0935a55; }
.home-title h1 span { display: block; font-size: .62em; margin-top: 5px; }
.join-panel, .game-dialog { border: 1px solid #a58053; background: linear-gradient(145deg, #2b2036, #16101f); border-radius: 14px; box-shadow: inset 0 0 0 3px #d8a66d12, 0 14px 45px #08061080; }
.join-panel { width: min(100%, 360px); display: grid; gap: 9px; text-align: left; padding: 21px 22px 12px; }
.join-panel > label, .avatar-picker legend, .small-dialog label, #transfer-form label { color: #dbc7aa; font-size: .875rem; }
.join-panel > input, .small-dialog input[type="text"] { font: inherit; border: 1px solid #746080; border-radius: 8px; background: #110d19; color: #fff2db; min-height: 44px; width: 100%; padding: 8px 11px; }
.avatar-picker { min-inline-size: 0; padding: 0; margin: 0 0 4px; border: 0; }
.avatar-picker legend { padding: 0 0 6px; }
.avatar-options { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.avatar-option { display: grid; place-items: center; min-width: 0; min-height: 46px; padding-block: 2px; border: 1px solid transparent; border-radius: 8px; cursor: pointer; }
.avatar-option .avatar { display: block; width: min(100%, 42px); height: auto; aspect-ratio: 1; }
.avatar-option:hover, .avatar-option:has(input:checked) { border-color: #d9ad71; background: #443043; }
.avatar-option:has(input:checked) .avatar { border-color: #ffdf9a; }
.avatar-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
#pin { letter-spacing: .42em; font-size: 1.35rem; text-align: center; font-variant-numeric: tabular-nums; }
.join-panel .primary, .small-dialog .primary { margin-top: 3px; }
.form-status { color: #e8c8ab; font-size: .85rem; margin: 2px 0 0; line-height: 1.4; }
.form-status:empty { display: none; }

.game-button { min-height: 42px; padding: 6px 12px; font: inherit; color: #f3deaf; border: 1px solid #9b754d; border-radius: 7px; background: linear-gradient(#44334a, #2b2033); box-shadow: inset 0 1px #f5d4a124, 0 2px #120b18; white-space: nowrap; }
.game-button.primary { font-weight: 700; color: #261525; background: linear-gradient(#f7d89e, #c89756); border-color: #e5bd79; }
.game-button:hover:not(:disabled) { border-color: #ffe0a7; filter: brightness(1.14); }
.game-button:disabled { opacity: .48; cursor: default; }
.room-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-inline-start: auto; }
.room-content { width: min(1180px, 100% - 32px); margin: 16px auto 24px; }
.room-heading, .room-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.room-heading { padding-bottom: 8px; }
.room-identity { min-width: 0; }
.room-heading h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); margin: 3px 0 0; color: var(--gold); white-space: nowrap; }
.room-heading h1 span { letter-spacing: .14em; }
.room-state, .room-summary p, .memory-status p { color: #e6cba5; font-size: .875rem; margin: 0; overflow-wrap: anywhere; }
.room-state[data-offline="true"] { color: #ffae98; }
.arena {
  position: relative; isolation: isolate; min-height: clamp(490px, 70vh, 690px); border: 1px solid #896748;
  border-radius: 20px; background: linear-gradient(#110b1b40, #130d2566), var(--room-backdrop, url("/assets/room/crystal-hall.png")) center / cover;
  box-shadow: inset 0 0 65px #080611ba, 0 12px 40px #08060d90; overflow: hidden;
}
.arena::before { content: ""; position: absolute; inset: 12% 11%; border: 1px solid #f0ca8348; border-radius: 50%; box-shadow: 0 0 0 5px #2d1f3f64, inset 0 0 38px #2b174d77; z-index: -1; }
.table-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 1; width: min(310px, 42%); padding: 14px 12px; text-align: center; border: 1px solid #d3a06e70; border-radius: 14px; background: #170e27eb; color: var(--gold); }
.table-center h2 { margin: 5px 0; overflow-wrap: anywhere; }
.table-center p:not(.eyebrow) { margin: 5px 0 0; color: #ded0de; font-size: .875rem; }
.table-center p:empty, .room-state:empty { display: none; }
.table-center button { margin-top: 9px; }
.seats { margin: 0; padding: 0; list-style: none; }
.seat { position: absolute; left: var(--seat-x); top: var(--seat-y); transform: translate(-50%, -50%); min-width: 0; width: min(138px, 23%); display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; padding: 5px 4px; border-radius: 13px; background: #100d1cbd; border: 1px solid #a38b744b; }
.seat-portrait { position: relative; display: flex; align-items: center; max-width: 100%; }
.seat-portrait > .avatar { flex: none; }
.avatar { width: 46px; height: 46px; object-fit: contain; border-radius: 50%; background: #2c233b; border: 2px solid #98775f; }
.current-seat { border-color: #ffdc73; box-shadow: 0 0 17px #f9c64f5e; }
.current-seat .avatar { border-color: #ffd35c; box-shadow: 0 0 0 3px #ffd35c48; }
.solved-seat { border-color: #79d995; background: #12291fd9; box-shadow: 0 0 16px #5bd78955, inset 0 0 0 1px #79d94c40; }
.solved-seat .avatar { border-color: #a4f5ac; }
.solved-seat .seat-state { color: #b5efc4; }
.seat-name { color: #fff1d1; font-size: .96rem; line-height: 1.15; max-width: 100%; overflow-wrap: anywhere; }
.seat-state { color: #d2c0a9; font-size: .75rem; }
.card-name, .card-reveal, .hidden-card { max-width: 100%; border-radius: 5px; padding: 4px 6px; font: inherit; font-size: .84rem; line-height: 1.25; overflow-wrap: anywhere; }
.card-name { background: #564044; border: 1px solid #d7aa69; color: #fff1ce; min-height: 31px; }
.card-name:hover { background: #79513d; }
.card-reveal { color: #ffe39b; background: #533e35; }
.hidden-card { color: #d0bfe0; border: 1px dashed #a891b98c; }
.room-summary { min-height: 42px; padding: 9px 3px; }
.room-notices { display: flex; flex-wrap: wrap; min-width: 0; gap: 4px 12px; }
.room-summary p:empty { display: none; }
.memory-status { margin-inline-start: auto; display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 4px 8px; text-align: right; }
.memory-status .game-button { min-height: 36px; }
.banter-trigger { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; margin-inline-start: auto; flex: none; }
.seat:has(.seat-bubble:not([hidden])) { z-index: 2; }
.seat-bubble {
  --speech-surface: #3d2e47;
  --speech-rim: #a28bac;
  --tail-top: calc(50% - 4px);
  --tail-inset: var(--tail-top) auto auto -4px;
  --tail-angle: 45deg;
  position: absolute; inset: 50% auto auto calc(100% + 9px); translate: 0 -50%;
  width: max-content; max-width: min(180px, 36vw); min-width: 32px; padding: 6px 9px;
  color: #fff4de; background: linear-gradient(155deg, var(--speech-surface), #201827);
  border: 1px solid var(--speech-rim); border-radius: 8px 13px 10px 12px;
  box-shadow: inset 0 1px 0 #fff4de30, 0 2px 0 #100a14c0, 0 5px 14px #08050ccd;
  text-shadow: 0 1px 2px #100a14db;
  font-size: .875rem; line-height: 1.25; pointer-events: none;
  transform-origin: left center; animation: seat-speech var(--speech-duration) ease-out both;
}
.seat-bubble::before {
  content: ""; position: absolute; inset: var(--tail-inset); width: 8px; height: 8px;
  rotate: var(--tail-angle); background: var(--speech-surface); border: solid var(--speech-rim); border-width: 0 0 1px 1px;
}
.seat-bubble.banter-ironclad { --speech-surface: #572a32; --speech-rim: #cb7c83; }
.seat-bubble.banter-silent { --speech-surface: #364629; --speech-rim: #9bad72; }
.seat-bubble.banter-regent { --speech-surface: #593921; --speech-rim: #d8a166; }
.seat-bubble.banter-necrobinder { --speech-surface: #204649; --speech-rim: #7ab8b2; }
.seat-bubble.banter-defect { --speech-surface: #283e61; --speech-rim: #80acdf; }
.seat-bubble.banter-fool { --speech-surface: #4c315e; --speech-rim: #b49ad2; }
.seat-bubble:is(.banter-nndx-1, .banter-nndx-2, .banter-nndx-3, .banter-nndx-4) {
  --speech-surface: #50431e; --speech-rim: #d5b160;
}
.seat[data-bubble-side="left"] .seat-bubble {
  --tail-inset: var(--tail-top) -4px auto auto;
  --tail-angle: 225deg;
  inset-inline: auto calc(100% + 9px); transform-origin: right center;
}
.seat-near-top .seat-bubble { --tail-top: 8px; inset-block-start: 6px; translate: none; }
@keyframes seat-speech {
  from { opacity: 0; scale: .9; }
  5%, 91% { opacity: 1; scale: 1; }
  to { opacity: 0; }
}
@keyframes seat-speech-still { from, to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .seat-bubble { animation-name: seat-speech-still; }
}
.banter-options { display: grid; gap: 5px; }
.banter-option-text > strong { color: var(--gold); }
.banter-line { overflow-wrap: anywhere; }
.banter-defect { font-family: ui-monospace, monospace; font-size: .83em; }
.banter-fool { font-style: italic; }
.banter-option { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 44px; padding: 6px 9px; border: 1px solid #795e69; border-radius: 7px; background: #2d233b; color: #f8eedb; text-align: left; }
.banter-option:hover:not(:disabled) { border-color: var(--gold); background: #3b2b46; }
.banter-option:disabled { opacity: .6; }
.banter-option .banter-avatar { flex: none; width: 32px; height: 32px; object-fit: contain; }
.banter-option-text { display: grid; min-width: 0; gap: 3px; font-size: .875rem; }

.guess-celebration { position: fixed; inset: 0; z-index: 10; width: 100%; height: 100%; padding: 0; margin: 0; border: 0; background: transparent; overflow: hidden; pointer-events: none; }
.guess-celebration-title { position: absolute; z-index: 1; top: 15%; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); margin: 0; padding: 10px 20px; border: 1px solid #8fe3a7; border-radius: 10px; background: #12291ff5; box-shadow: 0 6px 30px #0b180f85; color: #d1ffd9; font-size: clamp(1.12rem, 4vw, 1.7rem); font-weight: 700; text-align: center; overflow-wrap: anywhere; }
.confetti-piece { position: absolute; top: -16px; width: 8px; height: 12px; border-radius: 1px; animation: confetti-fall linear both; }
.confetti-piece:nth-child(3n) { width: 7px; height: 7px; border-radius: 50%; }
@keyframes confetti-fall {
  from { transform: translate(0, 0) rotate(0); opacity: 1; }
  85% { opacity: 1; }
  to { transform: translate(var(--drift), calc(100dvh + 24px)) rotate(var(--spin)); opacity: 0; }
}

.game-dialog { width: min(600px, 100% - 24px); max-height: calc(100dvh - 20px); color: #f8eedb; border-radius: 13px; }
.game-dialog::backdrop { background: #080510c9; }
.dialog-panel { padding: 14px 16px; display: grid; gap: 12px; }
.game-dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.game-dialog h2 { color: #eac68c; overflow-wrap: anywhere; }
.game-dialog p { margin: 0; line-height: 1.45; }
#settings-form, #transfer-form { display: grid; gap: 9px; }
#settings-form > label, #guess-remaining { color: #dbc7aa; font-size: .875rem; }
#settings-form > .switch { min-height: 36px; cursor: pointer; }
.settings-group { margin: 0; border: 1px solid #a080645e; border-radius: 7px; min-width: 0; padding: 7px; }
.settings-group legend { color: #f7d69c; padding: 0 4px; }
.settings-chips { display: flex; gap: 5px; flex-wrap: wrap; }
.setting-chip { padding: 5px 7px; background: #31243b; border: 1px solid #695570; border-radius: 5px; cursor: pointer; font-size: .86rem; display: inline-flex; align-items: center; gap: 5px; }
.setting-chip input { accent-color: #e9ba76; margin: 0; }
.setting-chip:has(input:checked) { color: #ffe8b8; border-color: #d1a46b; background: #513843; }
#transfer-form { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
#transfer-form label { grid-column: 1 / -1; }
.small-dialog, .card-dialog { width: min(380px, 100% - 20px); }
.guess-matches { list-style: none; margin: -6px 0 0; padding: 0; display: grid; gap: 4px; }
.guess-match { width: 100%; min-height: 40px; padding: 6px 10px; text-align: left; overflow-wrap: anywhere; }
.card-dialog .dialog-panel { gap: 5px; }
.room-card-face { width: min(100%, 300px, calc((100dvh - 172px) * .75)); margin-inline: auto; }
.card-actions, .confirm-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; flex-wrap: wrap; }
.card-actions .switch { margin-right: auto; min-height: 38px; }

@media (max-width: 650px) {
  .room-bar { padding-inline: 11px; align-items: center; }
  .room-brand { font-size: .88rem; gap: 5px; }
  .room-actions .game-button { padding-inline: 7px; font-size: .78rem; min-height: 39px; }
  .play .compendium { padding-inline: 6px; gap: 4px; font-size: .85rem; }
  .play .compendium img { width: 27px; height: 25px; }
  .room-content { width: calc(100% - 18px); margin-top: 10px; }
  .room-heading { gap: 5px; }
  .seat { width: min(98px, 27%); }
  .avatar { width: 36px; height: 36px; }
  .seat-bubble { font-size: .78rem; }
  .seat:not(.seat-near-top) .seat-bubble {
    --tail-inset: auto auto -4px calc(50% - 4px);
    --tail-angle: -45deg;
    inset: auto auto calc(100% + 9px) 50%; translate: -50% 0; transform-origin: center bottom;
  }
  .seat:not(.seat-near-top)[data-bubble-side="right"] .seat-bubble { --tail-inset: auto auto -4px 14px; inset-inline: 0 auto; translate: none; }
  .seat:not(.seat-near-top)[data-bubble-side="left"] .seat-bubble { --tail-inset: auto 14px -4px auto; inset-inline: auto 0; translate: none; }
  .arena { min-height: 460px; background-position: 46% center; }
  .table-center { width: min(176px, 47%); padding: 9px 5px; }
  .table-center h2 { font-size: 1rem; }
  .table-center .eyebrow, .table-center p:not(.eyebrow) { font-size: .72rem; }
  .arena:has(.seat:nth-child(5)) { padding: 12px; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
  .arena:has(.seat:nth-child(5)) .table-center { position: static; transform: none; width: 100%; }
  .arena:has(.seat:nth-child(5)) .seats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .arena:has(.seat:nth-child(5)) .seat { position: static; width: auto; transform: none; }
  .arena:has(.seat:nth-child(5)) .seat .seat-bubble {
    --tail-inset: calc(50% - 4px) auto auto -4px;
    --tail-angle: 45deg;
    position: relative; inset: auto; translate: none; transform-origin: left center;
    width: auto; min-width: 0; max-width: none; margin-inline-start: 9px; text-align: start;
  }
}
