:root { color-scheme: dark; --ink: #f4e6bd; --paper: #0b2432; --muted: #b4b6a1; --teal: #188b89; --pink: #e33e78; --gold: #e5b345; font-family: system-ui, sans-serif; color: var(--ink); background: var(--paper); }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; background: #071b2b; }
main { max-width: 960px; margin: auto; padding: 16px 24px; }
h1, h2, h3, p { margin: 0 0 12px; }
h1, h2, h3 { font-family: Georgia, serif; }
h1 { font-size: 32px; letter-spacing: -1px; }
h1 span { color: var(--gold); font-style: italic; font-weight: 400; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.site-header h1 { margin: 0; }
.site-header .eyebrow { display: none; }
.eyebrow { font-size: 10px; letter-spacing: 1.8px; text-transform: uppercase; color: var(--muted); }
#status { font-size: 12px; color: var(--ink); max-width: 300px; margin: 0; }
#status:empty { display: none; }
.panel { padding: 20px; background: #102e3b; border: 1px solid #e5b34560; border-radius: 4px; margin: 20px 0; }
.welcome { position: relative; max-width: 700px; margin: 18px auto 0; text-align: center; }
.welcome-art { position: relative; height: clamp(220px, 38dvh, 360px); overflow: hidden; margin-bottom: 16px; }
.welcome-art > img:first-child { width: 100%; height: 100%; object-fit: cover; opacity: .65; mask-image: linear-gradient(transparent, black 12%, black 75%, transparent); }
.welcome-art .welcome-human, .welcome-art .welcome-demon { position: absolute; width: 34%; top: 15%; filter: drop-shadow(0 12px 14px #0009); }
.welcome-human { left: 14%; transform: rotate(-9deg); }
.welcome-demon { right: 14%; transform: rotate(9deg); }
.welcome h2 { font-size: clamp(32px, 6vw, 50px); line-height: 1.07; margin-bottom: 22px; }
.welcome h2 em { color: var(--pink); font-weight: 400; }
.welcome-actions { display: flex; gap: 12px; justify-content: center; }
.welcome-actions button { min-width: 145px; min-height: 52px; font-size: 16px; }
.text-button { background: transparent; border: 0; color: var(--muted); margin: 12px 0; }
#developer-settings { margin-top: 16px; text-align: left; padding: 12px; border: 1px dashed var(--muted); }
label { display: grid; gap: 6px; margin-bottom: 14px; font-size: 13px; }
input, select, button { font: inherit; color: inherit; min-height: 44px; }
input, select { width: 100%; padding: 10px; border: 1px solid #e5b34570; border-radius: 3px; background: #081e2a; }
button { border: 1px solid var(--gold); border-radius: 3px; background: #112c39; padding: 9px 14px; cursor: pointer; font-size: 12px; font-weight: 650; box-shadow: inset 0 0 0 2px #081b27; transition: background .15s; }
button:enabled:hover { background: #225562; }
button:disabled { opacity: .4; cursor: not-allowed; }
button.primary { background: var(--gold); color: #0b2432; border-color: #f2cf75; box-shadow: inset 0 0 0 2px #c29230; }
button.primary:enabled:hover { background: #f0c964; }
:focus-visible { outline: 3px solid var(--pink); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.controls label { flex: 1; margin: 0; }
.room-head { display: grid; grid-template-columns: 1fr auto; gap: 14px; }
#invite-link, .room-head form { grid-column: 1 / -1; }
.players { padding-left: 20px; font-size: 13px; line-height: 2; }
#table-menu { position: absolute; right: max(12px, calc((100vw - 912px) / 2)); top: 12px; z-index: 5; }
#table-menu > summary { display: grid; place-items: center; width: 44px; height: 44px; cursor: pointer; list-style: none; font-size: 20px; color: var(--gold); }
#table-menu > summary::-webkit-details-marker { display: none; }
.menu-content { position: absolute; right: 0; min-width: 190px; padding: 12px; background: #0b2432; border: 1px solid var(--gold); box-shadow: 0 8px 24px #0009; }
.menu-content .controls { display: grid; margin-bottom: 8px; }
.menu-content > button { width: 100%; margin-bottom: 6px; }
#solo-save-status:empty { display: none; }
.playing .site-header { height: 36px; margin-bottom: 5px; padding-right: 44px; }
.playing h1 { font-size: 22px; }
.playing #status { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); background: #091e2af0; padding: 8px 12px; border: 1px solid var(--gold); z-index: 8; }
.playing #status:empty { display: none; }
.table-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; margin-bottom: 8px; color: var(--muted); }
.table-heading p { margin: 0; }
#turn-hint { color: #f3c35e; font-weight: 700; }
#your-role { font-size: 10px; }
.rack { max-width: 540px; margin: 0 auto; }
.hand-cards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; padding: 0; margin: 0; list-style: none; }
.hand-card { position: relative; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.inspect-card { padding: 0; background: transparent; border: 0; box-shadow: none; border-radius: 3px; width: 100%; display: flex; justify-content: center; }
.inspect-card:enabled:hover { background: #e5b34518; }
.card-art { display: block; width: 100%; height: auto; object-fit: contain; aspect-ratio: .4; max-height: 230px; filter: drop-shadow(0 3px 3px #0007); }
.card-art.back-art { aspect-ratio: auto; object-fit: contain; }
.card-district { font-size: 9px; color: var(--muted); }
.exchange-card { width: 100%; padding: 4px; min-height: 44px; font-size: 11px; }
.known-badge { position: absolute; top: 5px; right: 3px; font-size: 12px; color: var(--ink); background: #102537; border-radius: 50%; padding: 0 3px; }
.dealing { animation: deal-in .3s both; animation-delay: var(--deal-delay); }
@keyframes deal-in { from { transform: translateY(-6px); } to { transform: none; } }
.table-center { display: grid; grid-template-columns: 1fr 150px 1fr; gap: 0; max-width: 850px; margin: 4px auto 8px; align-items: center; }
.village-center { display: contents; }
.deck-side { grid-column: 1; grid-row: 1; justify-self: center; transform: translateX(-25px); }
.deck-side, .health-side, .discard-side { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.health-side { grid-column: 3; grid-row: 1; flex-direction: row; justify-content: center; }
.discard-side { grid-column: 1; grid-row: 1; justify-self: center; transform: translateX(25px); }
.deck-art { position: relative; width: 38px; transform: rotate(-5deg); }
.deck-art img { display: block; width: 100%; height: auto; filter: drop-shadow(3px 3px 0 #e5b34555); }
#deck-count { position: absolute; bottom: -6px; right: -6px; display: grid; place-items: center; background: #102537; border: 1px solid #e5b34590; padding: 2px 4px; font-size: 10px; border-radius: 3px; }
.pile-button { position: relative; min-width: 44px; width: 38px; height: 65px; border: 1px dashed #e5b34580; padding: 0; box-shadow: none; }
.pile-button .card-art { width: 100%; height: 65px; aspect-ratio: auto; }
.pile-button.has-cards { border: 0; background: none; }
.empty-pile { color: var(--gold); font-size: 22px; }
.has-cards .empty-pile { display: none; }
.health-side img { width: 32px; height: 32px; object-fit: contain; clip-path: circle(46%); }
#health { font: 650 16px system-ui, sans-serif; }
.rank-board { grid-column: 2; grid-row: 1; position: relative; width: 150px; height: 130px; margin: 0 auto; overflow: hidden; }
.rank-board-art { position: absolute; width: 225px; height: 150px; max-width: none; left: -37px; top: 0; transform: rotate(90deg); }
#color-rank { padding: 0; margin: 0; list-style: none; }
#color-rank li { position: absolute; width: 24px; text-align: center; transform: translate(-50%, -50%); transition: left .35s ease, top .35s ease; left: calc(30px + (var(--rank) - 1) * 41px); top: 90px; }
#color-rank li[style*="--rank: 0"] { left: 68px; top: 50px; }
.suit-icon { display: block; width: 24px; height: 24px; border-radius: 50%; background-image: url('/assets/icons-suits.webp'); background-size: 345% 230%; }
.suit-icon.crimson { background-position: 26.8% 6.5%; }
.suit-icon.violet { background-position: 73.2% 6.5%; }
.suit-icon.gold { background-position: 26.8% 92%; }
.suit-icon.moss { background-position: 73.2% 92%; }
.rank-label { display: block; color: var(--ink); font-size: 6px; font-weight: 650; margin-top: 1px; }
.village-map { grid-column: 1 / -1; grid-row: 2; position: relative; width: 100%; }
.village-map > img { width: 100%; height: auto; display: block; }
.district { position: absolute; transform: translate(-50%, -50%); min-height: 44px; min-width: 44px; padding: 2px 4px; border: 1px solid #f0ce7270; border-radius: 4px; background: #0b2432a8; color: #fff4d4; display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: none; }
.district:enabled:hover { background: #15485b; }
.district-number { font-size: 10px; font-weight: 650; }
.villagers { display: flex; gap: 1px; }
.villagers img { width: clamp(14px, 2.2vw, 25px); height: auto; }
.turn-area { display: flex; justify-content: center; align-items: center; gap: 14px; min-height: 44px; margin: 6px auto 10px; }
.match-controls { justify-content: center; }
#draw-area { display: flex; align-items: center; margin: 0; }
#drawn-art { width: 36px; }
#drawn-art .card-art { height: 85px; max-height: none; aspect-ratio: auto; }
.effect-panel { max-width: 700px; margin: 10px auto; padding: 12px; border-color: var(--teal); }
.effect-panel h2 { display: none; }
#effect-instruction { font-size: 12px; line-height: 1.5; }
.effect-panel .controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.effect-panel button { font-size: 11px; text-align: left; }
.effect-panel[data-power="4"] .controls { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.effect-panel[data-power="4"] button { text-align: center; padding: 5px 2px; }
.result-panel, #rematch { max-width: 700px; margin: 18px auto; }
#district-results { padding-left: 22px; line-height: 1.9; font-size: 13px; }
#continue-status, #rematch-status, #round-impact { font-size: 12px; line-height: 1.6; }
.discard-cards { list-style: none; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; padding: 0; }
.discard-cards .card-art { max-height: 150px; }
dialog { color: var(--ink); background: #0b2432; border: 1px solid var(--gold); border-radius: 4px; padding: 28px; width: min(480px, calc(100% - 24px)); max-height: calc(100dvh - 24px); overflow-y: auto; }
dialog::backdrop { background: #03101bd9; backdrop-filter: blur(3px); }
.dialog-close { position: absolute; top: 4px; right: 4px; border: 0; box-shadow: none; font-size: 24px; padding: 0; width: 44px; background: transparent; }
dialog h2 { padding-right: 25px; }
dialog p, dialog li { line-height: 1.7; font-size: 13px; }
dialog h3 { margin-top: 20px; }
#inspect-content > .card-art { height: min(450px, 55dvh); width: 100%; max-height: none; aspect-ratio: auto; margin: 16px auto; object-fit: contain; }
.district-portraits { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 20px 0; }
.district-portraits img { width: 100%; }
.opponent .inspect-card { height: 100px; }
.opponent .card-art { height: 100%; width: 100%; aspect-ratio: auto; max-height: none; object-fit: contain; }
.hand .card-art { height: 180px; width: 100%; aspect-ratio: auto; }
.legal-target .inspect-card { outline: 2px solid var(--pink); outline-offset: 2px; }
@media (max-width: 600px) {
  main { padding: 12px; }
  .site-header h1 { font-size: 27px; }
  .site-header { flex-wrap: wrap; }
  .welcome { margin-top: 14px; }
  .welcome-art { height: 230px; }
  .welcome-art .welcome-human, .welcome-art .welcome-demon { width: 43%; top: 12%; }
  .welcome-human { left: 5%; }
  .welcome-demon { right: 5%; }
  .welcome h2 { font-size: 38px; }
  .panel { padding: 16px; }
  .room-head { grid-template-columns: 1fr; }
  .room-head form { grid-column: auto; }
  .playing .site-header { flex-wrap: nowrap; }
  .playing h1 { font-size: 22px; }
  .table-heading { font-size: 10px; }
  #your-role { font-size: 9px; }
  .hand-cards { gap: 6px; }
  .opponent .inspect-card { height: 76px; }
  .hand .card-art { height: 145px; }
  .table-center { grid-template-columns: 1fr 120px 1fr; margin-left: -12px; margin-right: -12px; }
  .rank-board { transform: scale(.8); margin: -13px -15px; }
  .village-map { margin-top: 0; }
  .villagers img { width: 15px; }
  .district { padding: 2px; }
  .deck-art, .pile-button { width: 30px; }
  .pile-button, .pile-button .card-art { height: 55px; }
  .health-side { flex-direction: column; }
  .health-side img { width: 28px; height: 28px; }
  .match-controls { gap: 6px; }
  .match-controls button { padding: 8px 12px; }
  #drawn-art .card-art { height: 70px; }
  .turn-area { margin-bottom: 6px; }
}
@media (orientation: landscape) and (max-height: 550px) {
  main { max-width: 900px; padding: 8px 16px; }
  #game-table { display: grid; grid-template-columns: 150px minmax(0, 1fr) 150px; gap: 6px; align-items: center; }
  .table-heading { grid-column: 1 / -1; margin: 0; }
  .opponent { grid-column: 1; grid-row: 2; }
  .hand { grid-column: 3; grid-row: 2; }
  .hand-cards { gap: 4px; }
  .hand-card .card-art, .opponent .inspect-card { height: 74px; }
  .hand-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .table-center { grid-column: 2; grid-row: 2; grid-template-columns: 1fr 90px 1fr; margin: 0; width: 100%; max-width: 360px; justify-self: center; }
  .rank-board { transform: scale(.5); margin: -32.5px -37.5px; }
  .villagers img { width: 12px; }
  .turn-area, .effect-panel, .result-panel, #rematch { grid-column: 1 / -1; }
  .welcome-art { height: 160px; }
  .welcome { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 12px; }
  .welcome-art { grid-row: span 3; margin: 0; }
  .welcome h2 { font-size: 30px; margin: 0; }
  .welcome .text-button { margin: 0; }
}
@media (min-width: 601px) and (min-height: 551px) {
  .table-center { grid-template-columns: 1fr 90px 1fr; max-width: min(850px, max(420px, calc((100dvh - 550px) * 2))); }
  .rank-board { transform: scale(.6); margin: -26px -30px; }
  .opponent .inspect-card { height: 75px; }
  .hand .card-art { height: 135px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
/* The table fits the viewport, with room reserved for both hands. */
.playing main { max-width: 960px; padding: 8px 12px; }
.playing .site-header { display: contents; }
.playing .site-header > div { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.playing #room { min-height: 0; }
.playing #game-table { --hand-height: clamp(140px, 22dvh, 185px); --opponent-height: clamp(76px, 12.5dvh, 108px); --board-height: 140px; --draw-height: 125px; height: calc(100dvh - 16px); min-height: 0; display: flex; flex-direction: column; gap: 4px; }
.table-heading { flex: 0 0 24px; min-height: 24px; margin: 0 42px 0 0; }
#round-pips { display: flex; gap: 5px; }
#round-pips span { width: 7px; height: 7px; border: 1px solid #e5b3459c; transform: rotate(45deg); }
#round-pips .filled { background: var(--gold); }
#table-menu { top: 6px; }
.player-role-emblem { display: block; width: 24px; height: 24px; margin: 2px auto; flex: 0 0 auto; }
.opponent .player-role-emblem { position: absolute; top: -28px; left: 50%; transform: translateX(-50%); }
.playing .rack { width: 100%; max-width: 620px; margin: 0 auto; position: relative; padding: 0; flex: 0 0 auto; }
.playing .opponent { height: var(--opponent-height); max-width: 520px; }
.playing .hand { height: var(--hand-height); }
.playing .hand-cards { height: 100%; display: grid; grid-template-rows: minmax(0, 1fr); grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.playing .hand .hand-cards { height: calc(100% - 28px); }
.playing .hand-card, .playing .rack .inspect-card { height: 100%; min-height: 0; min-width: 0; }
.playing .rack .card-art { width: 100%; height: 100%; max-height: none; aspect-ratio: auto; object-fit: cover; object-position: top; border-radius: 5px; }
.active-rack::after { content: ''; position: absolute; bottom: -2px; left: 30%; right: 30%; height: 2px; background: var(--gold); box-shadow: 0 0 8px #e5b34570; }
.opponent-action { flex: 0 0 22px; max-width: 100%; margin: 0; font-size: 12px; line-height: 22px; text-align: center; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.playing .table-center { flex: 1 1 auto; min-height: 0; width: calc(100% + 24px); max-width: none; margin: 0 -12px; display: grid; grid-template-columns: 1fr 150px 1fr; grid-template-rows: var(--board-height) minmax(0, 1fr); align-items: center; }
.playing .rank-board { width: 150px; height: 130px; transform: scale(.85); margin: 0; overflow: visible; }
.rank-label { display: none; }
#trump-label { position: absolute; top: 111px; left: 0; width: 100%; text-align: center; margin: 0; font-size: 12px; color: var(--gold); }
#color-rank [data-trump='true'] .suit-icon { outline: 2px solid var(--gold); outline-offset: 3px; box-shadow: 0 0 12px #e5b34590; }
.playing .village-map { container-type: size; height: 100%; min-height: 0; width: 100%; aspect-ratio: auto; overflow: hidden; isolation: isolate; }
.playing .village-map > img { position: absolute; width: 120%; max-width: none; height: 100%; left: -10%; object-fit: fill; }
#village-districts { position: absolute; width: 120%; height: 100%; left: -10%; }
.playing .district { border: 0; background: none; box-shadow: none; padding: 0; }
.playing .district:enabled:hover { background: none; }
.map-numeral { position: absolute; width: 15px; height: 19px; transform: translateX(-50%); pointer-events: none; filter: drop-shadow(0 1px 1px #03121b); }
.playing .villagers { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }
.villager-face { display: block; width: 38px; height: 38px; border-radius: 50%; overflow: hidden; position: relative; border: 1px solid #e5b345bb; background: #113945; box-shadow: 0 2px 4px #000b; }
.villager-face img { position: absolute; width: 180%; height: 180%; max-width: none; object-fit: contain; left: -40%; top: -35%; }
.villager-face.corrupted { border: 3px solid #ff79ad; box-shadow: 0 0 0 2px #e8458b66, 0 0 14px #e8458bd0; }
.linked-district .villager-face { outline: 2px solid var(--gold); outline-offset: 2px; }
.playing .health-side { position: relative; width: 56px; height: 56px; justify-self: center; flex-direction: row; }
.health-side img { width: 34px; height: 34px; }
#health-pips { position: absolute; inset: 0; }
#health-pips i { position: absolute; width: 3px; height: 6px; top: 50%; left: 50%; border-radius: 2px; background: #e5b34525; transform: rotate(calc(var(--life) * 30deg)) translateY(-27px); }
#health-pips .alive { background: var(--gold); }
.deck-side { transform: translateX(-25px); }
.discard-side { transform: translateX(27px); }
.playing .deck-art { width: 40px; min-height: 44px; padding: 0; border: 0; background: none; box-shadow: none; margin: 0; }
.deck-art:disabled { opacity: .65; }
.deck-cue { position: absolute; top: -22px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 12px; color: var(--gold); }
.draw-arrow { display: inline-block; }
.deck-art:enabled .draw-arrow { animation: draw-arrow .9s ease-in-out infinite; }
.deck-art:enabled #deck-face img { animation: deck-ready 1.4s ease-in-out infinite; }
@keyframes draw-arrow { 50% { transform: translateY(4px); } }
@keyframes deck-ready { 50% { transform: translateY(-3px); filter: drop-shadow(0 0 10px #e5b34590); } }
#deck-face .card-art { aspect-ratio: .5; height: auto; object-fit: cover; object-position: top; border-radius: 4px; }
.deck-side { position: relative; padding-top: 22px; }
.playing .pile-button { width: 36px; height: 62px; }
.playing .pile-button .card-art { height: 62px; object-fit: cover; object-position: top; }
.playing .turn-area { flex: 0 0 auto; min-height: 0; height: 0; overflow: hidden; margin: 0; gap: 12px; transition: height .22s ease; }
.playing .turn-area:has(#call-round:not([hidden])) { height: 48px; }
.playing .turn-area:has(#draw-area:not([hidden])) { height: var(--draw-height); }
#drawn-art { width: 68px; height: var(--draw-height); }
#drawn-art .inspect-card { height: 100%; }
.playing #drawn-art .card-art { width: 100%; height: 100%; max-height: none; aspect-ratio: auto; object-fit: cover; object-position: top; border-radius: 4px; }
.match-controls button { width: 48px; height: 48px; padding: 10px; border-radius: 50%; color: var(--gold); }
.match-controls button svg, .known-badge svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#discard-drawn { width: auto; display: flex; align-items: center; gap: 6px; border-radius: 8px; padding: 8px 12px; }
.rank-inspect { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: transparent; box-shadow: none; padding: 0; border-radius: 16px; }
.rank-inspect:enabled:hover { background: #e5b34510; }
.rank-details { padding: 0; list-style: none; display: grid; gap: 10px; }
.rank-details li { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.rank-details .suit-icon { width: 32px; height: 32px; }
.swap-ready .inspect-card { outline: 1px solid var(--gold); outline-offset: 2px; filter: drop-shadow(0 0 6px #e5b34575); animation: swap-glow 2.5s ease-in-out infinite; }
@keyframes swap-glow { 0%, 100% { filter: drop-shadow(0 0 3px #e5b34540); } 50% { filter: drop-shadow(0 0 7px #e5b345bb); } }
.legal-target .inspect-card { outline: 2px solid var(--pink); outline-offset: 2px; }
.pair-selected .inspect-card { transform: translateY(-5px); outline: 2px solid var(--gold); }
.card-change { animation: card-change .22s ease-out; }
@keyframes card-change { from { transform: translateY(6px); } }
.known-badge { top: auto; bottom: 5px; right: 3px; display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--gold); color: var(--gold); background: #071b2bed; border-radius: 50%; padding: 3px; }
.known-badge svg { width: 19px; height: 19px; }
.playing .effect-panel { flex: 0 0 auto; padding: 0; margin: 0; border: 0; background: none; width: 100%; }
#effect-instruction { text-align: center; margin: 0; color: var(--gold); font-size: 12px; }
.effect-panel:not([data-power='7']) .controls { display: none; }
.effect-panel[data-power='7'] .controls { display: flex; justify-content: center; }
.effect-panel[data-power='7'] button { padding: 6px; border-radius: 50%; }
#round-result { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); border: 0; border-radius: 0; background: #071b2b; overflow: hidden; }
#round-result::backdrop { background: #03101b; }
.result-shell { max-width: 760px; height: 100%; margin: auto; display: flex; flex-direction: column; gap: 8px; }
#round-result h2 { text-align: center; font-size: 28px; margin: 0; }
#result-reason { text-align: center; color: var(--gold); margin: 0; font-size: 12px; }
#result-stats { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 18px; font-size: 12px; }
.matchup-heading { display: grid; grid-template-columns: 1fr 1fr 1fr; font-size: 11px; text-align: center; color: var(--muted); }
#district-results { flex: 1 1 auto; min-height: 0; display: grid; grid-template-rows: repeat(5, minmax(0, 1fr)); gap: 5px; list-style: none; padding: 0; margin: 0; }
#district-results li { display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: center; min-height: 0; text-align: center; border: 1px solid #e5b34535; border-radius: 6px; padding: 4px; }
.matchup-card { height: 100%; min-height: 0; display: flex; justify-content: center; }
.matchup-card .card-art { width: 64px; height: 100%; max-height: 115px; aspect-ratio: auto; object-fit: cover; object-position: top; border-radius: 4px; }
.matchup-card.won .card-art { outline: 2px solid var(--gold); outline-offset: 1px; }
.district-verdict { font-size: 12px; line-height: 1.4; }
#round-impact { margin: 0; text-align: center; }
.result-actions { flex: 0 0 auto; text-align: center; }
#round-result #continue, #round-result #request-rematch { min-height: 48px; width: min(100%, 420px); }
#round-result #rematch { margin: 0; }
#continue-status, #rematch-status { margin: 6px 0; }
#round-result #result-home { margin-left: 6px; }
body:has(#round-result[open]) { overflow: hidden; }
body:not(.playing):not(:has(#create-room:not([hidden]))) main { max-width: 700px; padding-top: 24px; }
body:not(.playing):not(:has(#create-room:not([hidden]))) .site-header { justify-content: center; text-align: center; }
body:not(.playing) .site-header h1 img { width: min(80vw, 360px); max-height: 60px; }
#lobby .controls { align-items: end; }
#lobby #role, #lobby #ready { height: 48px; }
.room-head { text-align: center; }
@media (min-width: 601px) and (min-height: 551px) {
  .playing #game-table { --board-height: 142px; }
  .playing .table-center { width: 100%; margin: 0; }
  .playing .rank-board { transform: none; }
  .villager-face { width: 44px; height: 44px; }
}
@media (max-height: 650px) and (orientation: portrait) {
  .playing #game-table { --hand-height: 126px; --opponent-height: 68px; --board-height: 76px; --draw-height: 76px; gap: 3px; }
  .playing .rank-board { transform: scale(.58); }
  .villager-face { width: 27px; height: 27px; }
  .playing .villagers { gap: 3px; }
  .playing .deck-art { width: 34px; }
  .deck-cue { top: -18px; font-size: 10px; }
  #round-result h2 { font-size: 23px; }
}
@media (orientation: landscape) and (max-height: 550px) {
  .playing #game-table { display: grid; grid-template-columns: minmax(100px, 1fr) minmax(160px, 2fr) minmax(100px, 1fr); grid-template-rows: 24px minmax(0, 1fr) auto auto; gap: 5px; --board-height: 76px; --draw-height: 60px; }
  .table-heading { grid-column: 1 / -1; grid-row: 1; }
  .opponent-action { grid-column: 2; grid-row: 1; font-size: 10px; }
  .playing .opponent { grid-column: 1; grid-row: 2; height: 100%; }
  .playing .hand { grid-column: 3; grid-row: 2; height: 100%; }
  .playing .hand-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .playing .table-center { grid-column: 2; grid-row: 2; width: 100%; height: 100%; margin: 0; grid-template-columns: 1fr 90px 1fr; }
  .playing .rank-board { transform: scale(.58); margin-left: -30px; }
  .playing .turn-area { grid-column: 1 / -1; grid-row: 3; }
  .playing .effect-panel { grid-column: 1 / -1; grid-row: 4; }
  .villager-face { width: 23px; height: 23px; }
  .playing .villagers { gap: 2px; }
  .playing .deck-art { width: 28px; }
  .playing .pile-button, .playing .pile-button .card-art { height: 44px; width: 25px; }
  .deck-cue { font-size: 10px; top: -16px; }
  #round-result { overflow: auto; }
  .result-shell { min-height: 470px; }
}
@media (prefers-reduced-motion: reduce) {
  .draw-arrow, .deck-art:enabled #deck-face img, .card-change { animation: none; }
  .deck-art:enabled { outline: 2px solid var(--gold); outline-offset: 3px; }
}

/* Landing page */
body:has(#create-room:not([hidden])) { --navy: #071b2b; --teal: #1f8a8f; --pink: #e8458b; --cobalt: #3a50b8; --mustard: #e8a93a; --cream: #f0dfb8; --print-ink: #0a0a0a; }
body:has(#create-room:not([hidden])) { background: linear-gradient(#071b2bdb, #071b2be6), url('/assets/board-village.webp') center / cover fixed; }
body:has(#create-room:not([hidden]))::after { content: ''; position: fixed; inset: 0; z-index: 30; pointer-events: none; opacity: .075; mix-blend-mode: screen; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 180 180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.48'/%3E%3C/svg%3E"); }
body:has(#create-room:not([hidden])) main { width: 100%; max-width: 880px; min-height: 100dvh; display: flex; flex-direction: column; gap: clamp(8px, 1.6vh, 18px); padding: 20px 24px 0; }
body:has(#create-room:not([hidden])) .site-header { position: relative; z-index: 1; justify-content: center; text-align: center; margin-top: auto; }
body:has(#create-room:not([hidden])) .site-header h1 { margin: 0; line-height: 1; }
body:has(#create-room:not([hidden])) .site-header h1 img { display: block; width: min(78vw, 410px); height: auto; max-height: 68px; object-fit: contain; }
body:has(#create-room:not([hidden])) .site-header .eyebrow { display: block; margin-bottom: 6px; }
body:has(#create-room:not([hidden])) .welcome { position: relative; z-index: 1; width: min(100%, 620px); max-width: none; margin: 0 auto; display: grid; justify-items: center; gap: clamp(10px, 1.8vh, 18px); text-align: center; }
.welcome-art { width: min(100%, 590px); height: clamp(190px, 31dvh, 295px); margin: 0 auto; border: 4px solid var(--print-ink); border-radius: 18px; outline: 2px solid var(--cream); outline-offset: -10px; box-shadow: 0 8px 0 var(--print-ink); background: var(--navy); }
.welcome-map { width: 100%; height: 100%; object-fit: cover; opacity: .86; }
.token-pair { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: clamp(10px, 4vw, 38px); }
.welcome-token { width: min(30vw, 214px); aspect-ratio: 1; perspective: 800px; }
.token-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .8s cubic-bezier(.2,.75,.2,1); }
.token-face { position: absolute; inset: 0; width: 100%; height: 100%; border: 4px solid var(--print-ink); border-radius: 50%; outline: 2px solid var(--cream); outline-offset: -9px; backface-visibility: hidden; object-fit: cover; box-shadow: 0 7px 0 #0009; }
.token-corrupted { transform: rotateY(180deg); }
.corrupted-token .token-inner { transform: rotateY(180deg); }
.welcome h2 { margin: 2px 0 0; font-size: clamp(34px, 5.2vw, 52px); line-height: 1.02; letter-spacing: -.035em; text-wrap: balance; }
.welcome h2 em { color: var(--pink); font-style: normal; font-weight: 800; }
.welcome-actions { width: min(100%, 460px); display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 2px auto 0; }
.welcome-actions button, .join-by-code button { min-height: 56px; padding: 9px 18px; border: 3px solid var(--print-ink); border-radius: 12px; box-shadow: 0 5px 0 var(--print-ink); color: var(--print-ink); font-size: 14px; font-weight: 800; display: grid; align-content: center; transition: transform .08s, box-shadow .08s, background .12s; }
.welcome-actions button.primary { display: grid; align-content: center; gap: 0; background: var(--mustard); color: var(--print-ink); border-color: var(--print-ink); box-shadow: 0 5px 0 var(--print-ink); }
.welcome-actions button small { font-size: 10px; font-weight: 650; }
.welcome-actions button.secondary, .join-by-code button.secondary { background: var(--cream); color: var(--print-ink); border-color: var(--print-ink); box-shadow: 0 5px 0 var(--print-ink); }
.welcome-actions button:enabled:hover, .join-by-code button:enabled:hover { filter: brightness(1.04); transform: translateY(-1px); }
.welcome-actions button:enabled:active, .join-by-code button:enabled:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--print-ink); }
.join-by-code { width: min(100%, 460px); display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; margin: 0 auto; }
.join-by-code input { min-width: 0; min-height: 48px; padding: 10px 14px; border: 2px solid var(--teal); border-radius: 10px; background: #0b2432; box-shadow: inset 0 0 0 1px var(--print-ink); color: var(--cream); font-size: 13px; }
.join-by-code input::placeholder { color: #d0c5a8; opacity: .88; }
.join-by-code input:focus-visible { border-color: var(--mustard); }
.join-by-code button { min-height: 48px; padding-inline: 15px; font-size: 12px; }
.rulebook-link { min-height: 44px; margin: 0; padding: 2px 7px; border: 0; box-shadow: none; background: transparent; color: #c9c3ae; font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
body:has(#create-room:not([hidden])) #status { max-width: 100%; text-align: center; }
body:has(#create-room:not([hidden])) #status:not(:empty) { padding: 7px 10px; border: 1px solid #f0dfb855; border-radius: 8px; background: #071b2bcc; }
body:has(#create-room:not([hidden])) #offline-status { position: absolute; }
body:has(#create-room:not([hidden])) #developer-settings { justify-self: center; width: min(100%, 420px); }
@media (max-width: 600px) {
  body:has(#create-room:not([hidden])) main { padding: 14px 16px 0; gap: 8px; }
  body:has(#create-room:not([hidden])) .site-header h1 img { width: min(78vw, 330px); max-height: 55px; }
  body:has(#create-room:not([hidden])) .site-header .eyebrow { margin-bottom: 3px; font-size: 9px; }
  body:has(#create-room:not([hidden])) .welcome { gap: 11px; }
  .welcome-art { width: min(100%, 430px); height: clamp(155px, 24dvh, 205px); border-radius: 15px; background: transparent; }
  .welcome-map { display: none; }
  .token-pair { gap: 0; }
  .welcome-token { width: min(42vw, 172px); }
  .welcome-token + .welcome-token { margin-left: -9px; }
  .welcome h2 { margin-top: 2px; font-size: clamp(36px, 10vw, 48px); }
  .welcome-actions { grid-template-columns: 1fr; gap: 10px; width: min(100%, 390px); }
  .welcome-actions button { width: 100%; min-height: 53px; }
  .join-by-code { width: min(100%, 390px); gap: 10px; }
  .join-by-code input, .join-by-code button { width: 100%; }
}
@media (max-height: 720px) and (min-width: 601px) {
  body:has(#create-room:not([hidden])) main { gap: 7px; padding-top: 12px; }
  body:has(#create-room:not([hidden])) .site-header h1 img { max-height: 46px; width: min(78vw, 350px); }
  body:has(#create-room:not([hidden])) .site-header .eyebrow { margin-bottom: 2px; font-size: 9px; }
  body:has(#create-room:not([hidden])) .welcome { gap: 8px; }
  .welcome-art { height: clamp(120px, 21dvh, 156px); }
  .welcome-token { width: min(26vw, 166px); }
  .welcome h2 { font-size: clamp(34px, 4.7vw, 43px); }
  .welcome-actions button { min-height: 48px; }
  .join-by-code input, .join-by-code button { min-height: 42px; }
}
@media (prefers-reduced-motion: reduce) {
  .token-inner, .welcome-actions button, .join-by-code button { transition: none; }
}

.site-header h1 img { display: block; width: min(65vw, 280px); max-height: 44px; object-fit: contain; }
@media (max-width: 600px) and (max-height: 650px) {
  .welcome-art { height: 110px; }
  .welcome-token { width: min(32vw, 140px); }
  .welcome h2 { font-size: 32px; }
}

/* Keep the landing actions in one screen, including smaller phones. */
body:has(#create-room:not([hidden])) main { min-height: 100dvh; padding-top: 12px; padding-bottom: 20px; justify-content: center; gap: clamp(16px, 3dvh, 28px); }
body:has(#create-room:not([hidden])) .site-header { margin-top: 0; flex-wrap: wrap; }
body:has(#create-room:not([hidden])) .site-header > div { width: min(100%, 620px); }
body:has(#create-room:not([hidden])) .site-header h1 img { width: 100%; max-height: none; }
body:has(#create-room:not([hidden])) .welcome { flex: 0 0 auto; align-content: center; gap: clamp(6px, 1.2dvh, 12px); }
body:has(#create-room:not([hidden])) .welcome-art { height: clamp(100px, 23dvh, 210px); }
body:has(#create-room:not([hidden])) .welcome-token { width: min(38vw, 180px, 21dvh); }
body:has(#create-room:not([hidden])) .welcome-actions { grid-template-columns: 1fr 1fr; gap: 10px; }
body:has(#create-room:not([hidden])) .welcome-actions button { min-width: 0; min-height: 52px; padding-inline: 8px; }
.human-token .token-inner { animation: token-flip 7s ease-in-out infinite; }
.corrupted-token .token-inner { animation: token-flip 7s ease-in-out infinite; animation-delay: -3.5s; }
@keyframes token-flip { 0%, 30% { transform: rotateY(0); } 45%, 80% { transform: rotateY(180deg); } 95%, 100% { transform: rotateY(360deg); } }
@media (max-height: 650px) and (orientation: portrait) {
  body:has(#create-room:not([hidden])) main { gap: 8px; }
  body:has(#create-room:not([hidden])) .welcome-art { height: 100px; }
  body:has(#create-room:not([hidden])) .welcome-token { width: 96px; }
  body:has(#create-room:not([hidden])) .welcome h2 { font-size: 30px; }
  body:has(#create-room:not([hidden])) .welcome-actions button { min-height: 48px; }
}
@media (orientation: landscape) and (max-height: 550px) {
  body:has(#create-room:not([hidden])) .site-header > div { width: 300px; }
  body:has(#create-room:not([hidden])) main { padding-bottom: 12px; gap: 8px; }
  body:has(#create-room:not([hidden])) .welcome { grid-template-columns: 1fr 1fr; column-gap: 20px; row-gap: 5px; }
  body:has(#create-room:not([hidden])) .welcome-art { grid-row: 1 / 5; height: 180px; }
  body:has(#create-room:not([hidden])) .welcome-token { width: 105px; }
  body:has(#create-room:not([hidden])) .welcome h2 { font-size: 27px; }
  body:has(#create-room:not([hidden])) .welcome-actions button { min-height: 44px; }
  .result-shell { min-height: 0; display: grid; grid-template-columns: 1fr 3fr; grid-template-rows: auto auto 1fr auto; gap: 6px 14px; }
  #round-result h2, #result-reason, #result-stats, #round-impact, .result-actions { grid-column: 1; }
  #round-result h2 { font-size: 22px; }
  #result-stats { font-size: 11px; align-content: start; }
  .matchup-heading { grid-column: 2; grid-row: 1; }
  #district-results { grid-column: 2; grid-row: 2 / 5; }
  #round-impact { display: none; }
  .result-actions { grid-row: 4; }
  #continue-status { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) { .token-inner { animation: none !important; } }

/* Size the portraits to the map when a drawn card needs extra room. */
.playing .villager-face { width: clamp(22px, min(10vw, 15cqh), 44px); height: clamp(22px, min(10vw, 15cqh), 44px); }
/* A drawn card shares the utility row, so the map keeps its space. */
@media (max-width: 999px) and (orientation: portrait) {
  .playing #game-table { position: relative; }
  .playing .turn-area { grid-column: 3; grid-row: 1; justify-self: center; flex-direction: column; gap: 4px; overflow: visible; width: 72px; }
  .playing .turn-area:has(#draw-area:not([hidden])) { height: auto; }
  .playing #drawn-art { width: 64px; height: 100px; }
  .playing .village-map { height: auto; max-height: 100%; aspect-ratio: 2; }
  .playing #discard-drawn { min-height: 36px; padding: 4px 7px; font-size: 11px; gap: 3px; }
  .playing #discard-drawn svg { width: 18px; height: 18px; }
  .playing .health-side { position: absolute; top: 0; right: 48px; width: 24px; height: 24px; }
  .playing .health-side img { width: 24px; height: 24px; }
  .playing #health-pips i { height: 4px; transform: rotate(calc(var(--life) * 30deg)) translateY(-17px); }
}
@media (max-height: 650px) and (orientation: portrait) {
  .playing #drawn-art { width: 42px; height: 66px; }
}
#opponent-last-play { color: var(--muted); font-size: 11px; border: 0; border-radius: 0; padding: 0; box-shadow: none; background: none; width: 100%; white-space: normal; line-height: 16px; flex-basis: auto; min-height: 22px; text-decoration: underline; text-decoration-color: #e5b34555; text-underline-offset: 3px; }
#activity-list { padding-left: 22px; font-size: 14px; line-height: 1.5; }
#activity-list li { margin-bottom: 12px; }
body.solo-test:has(#create-room:not([hidden])) .welcome-actions { grid-template-columns: 1fr; }
#test-version { margin: 0; color: var(--gold); font-size: 12px; text-align: center; }
@media (max-height: 650px) and (orientation: portrait) { .playing #game-table { --board-height: 108px; } .playing .deck-side { padding-top: 16px; } }
@media (orientation: landscape) and (max-height: 550px) {
  #opponent-last-play { position: absolute; top: 10px; right: 60px; max-width: 40%; font-size: 10px; }
  .playing .deck-side { padding-top: 10px; }
}

.district-state { display: block; color: var(--muted); font-size: 10px; line-height: 1.4; }

body:not(.playing):not(:has(#create-room:not([hidden]))) .site-header { padding-inline: 44px; }
.site-header > div { min-width: 0; }
.site-header h1 img { max-width: 100%; }
@media (min-width: 1000px) and (min-height: 551px) {
  .playing #game-table { position: relative; --hand-height: clamp(195px, 29dvh, 240px); --opponent-height: clamp(100px, 15dvh, 128px); }
  .playing .hand { max-width: 540px; }
  .playing .turn-area { position: absolute; right: 12px; bottom: 16px; width: 178px; gap: 8px; }
  .playing .turn-area .match-controls { flex-wrap: nowrap; }
  .playing #drawn-art { flex: 0 0 64px; width: 64px; }
  .playing #discard-drawn { padding-inline: 8px; }
}

#round-result #continue, #round-result #request-rematch { width: min(calc(100% - 70px), 420px); }
#round-result #result-home { width: 62px; min-height: 48px; padding: 6px; }
#round-result #rematch:not([hidden]) { display: contents; }
@media (min-width: 1000px) and (min-height: 551px) {
  .playing .table-center { width: min(100%, 700px); margin: 0 auto; }
  .playing .village-map { width: auto; max-width: 100%; aspect-ratio: 2; justify-self: center; }
  .playing .village-map > img { width: 100%; left: 0; }
  .playing #village-districts { width: 100%; left: 0; }
}
@media (max-width: 600px) and (orientation: portrait) {
}
@media (max-width: 360px) {
  .playing .deck-side { transform: translateX(-18px); }
}
@media (max-width: 340px) {
  .playing .discard-side { transform: translateX(34px); }
}
@media (max-width: 340px) {
}
