:root {
  color-scheme: dark;
  --page: #171810;
  --panel: #24241a;
  --panel-light: #2f2e20;
  --line: #59503a;
  --ink: #f5ead7;
  --muted: #c8bba0;
  --gold: #e8bd70;
  --green: #b9d29c;
  --rust: #f0aa94;
  --serif: Georgia, "Times New Roman", serif;
  font-family: system-ui, sans-serif;
  font-synthesis: none;
  background: var(--page);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 280px;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 17% 0%, #42402a 0%, transparent 48rem),
    radial-gradient(ellipse at 100% 25%, #38251a 0%, transparent 36rem),
    var(--page);
}

h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; }
p { line-height: 1.5; }
code { overflow-wrap: anywhere; }
a { color: var(--gold); }
button, input, select { font: inherit; }
button, summary, select { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }

.shell { width: min(1360px, 100% - 48px); margin-inline: auto; }
.muted { color: var(--muted); }
.eyebrow { color: var(--gold); font-size: .75rem; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; }
.empty { color: var(--muted); font-size: .875rem; }

.masthead {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 14px;
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 12px; font: 600 1.22rem var(--serif); text-decoration: none; color: var(--ink); }
.brand small { display: block; margin-top: 4px; font: 500 .72rem system-ui, sans-serif; color: var(--muted); }
.brand-mark { display: grid; place-items: center; flex: 0 0 42px; height: 42px; border: 1px solid var(--gold); border-radius: 50%; color: var(--gold); font-size: 1.36rem; }
.masthead-actions, .known-seats { display: flex; flex-wrap: wrap; gap: 8px; }
.masthead-controls, .language-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.masthead-controls { justify-content: flex-end; gap: 12px; }
.language-controls .button { min-width: 44px; padding-inline: 9px; }
.language-controls .button[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); background: #39321f; }

.button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-light);
  color: var(--ink);
  padding: 8px 14px;
  font-weight: 650;
  transition: background-color .18s, border-color .18s;
}

.button:hover:enabled { border-color: var(--gold); }
.button.primary { background: var(--gold); color: #241c11; border-color: #f0d397; }
.button.primary:hover:enabled { background: #f5cf8c; }
.button.quiet { background: transparent; }
.button:disabled { opacity: .55; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.welcome { display: grid; grid-template-columns: 1.2fr 1fr; align-items: center; gap: clamp(24px, 7vw, 100px); min-height: min(70vh, 580px); padding-block: 36px; }
.welcome-copy h1 { margin: 8px 0 12px; font-size: clamp(3rem, 8vw, 6rem); line-height: .99; }
.welcome-copy > :last-child { color: var(--muted); font-size: 1.1rem; max-width: 34ch; }
.entry-panel { display: grid; gap: 16px; padding: clamp(18px, 4vw, 32px); box-shadow: 0 14px 32px #0005; }
.entry-panel h2 { font-size: 1.65rem; }
.entry-panel form { display: grid; gap: 10px; }
.entry-panel form label, .action-menu-label { color: var(--ink); font-size: .88rem; font-weight: 650; }
.entry-panel input, .action-menu {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #1b1c14;
  color: var(--ink);
}

.notice { margin-block: 14px; padding: 10px 14px; background: var(--panel-light); border: 1px solid var(--line); border-radius: 8px; }
.notice.error { border-color: #a05f50; color: var(--rust); }
#notice:not(.error):has(+ .table:not([hidden])) {
  position: fixed; z-index: 9; right: 12px; bottom: 12px; margin: 0; max-width: calc(100% - 24px);
  padding: 5px 9px; font-size: .8rem; pointer-events: none; box-shadow: 0 2px 10px #171810b0;
}

.table { padding-block: 16px 48px; }
.table-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.table-heading h1 { margin: 3px 0; font-size: clamp(2rem, 4vw, 3rem); line-height: 1.04; }
.table-heading h1:focus, .section-heading h2:focus:not(:focus-visible) { outline: none; }
.table-jump { display: none; }
.next-seat { display: block; margin-top: 12px; }
.computer-tag { border-color: #7d8362; color: var(--green); }
.score { display: flex; gap: 8px; }
.score-part { min-width: 92px; display: grid; gap: 3px; padding: 9px 13px; background: #28281d; border: 1px solid var(--line); border-radius: 8px; }
.score-part > span { color: var(--muted); font-size: .75rem; }
.score-part > strong { font: 600 1.6rem/1 var(--serif); }
.score-part:first-child > strong { color: var(--green); }
.score-part:last-child > strong { color: var(--rust); }
.table-controls { display: grid; justify-items: start; gap: 10px; max-width: 390px; }
.pass-control { display: flex; align-items: start; gap: 10px; width: 100%; }
.pass-button { flex: none; min-width: 72px; }
.pass-copy { align-self: center; font-size: .75rem; }
.pass-copy p + p { margin-top: 3px; color: var(--gold); }

.table-arena {
  min-width: 0;
  display: grid;
  grid-template: ". north ." "west board east" ". south ." / minmax(120px, 1fr) minmax(0, 3.5fr) minmax(120px, 1fr);
  align-items: start;
  gap: 8px;
  padding: 10px;
  border: 1px solid #655a40;
  border-radius: 16px;
  background: radial-gradient(ellipse at center, #393321, #252419 60%, #1f2017);
}
.arena-seat { min-width: 0; }
.arena-north, .arena-south { justify-self: center; width: min(100%, 510px); }
.arena-north { grid-area: north; }
.arena-south { grid-area: south; }
.arena-west { grid-area: west; }
.arena-east { grid-area: east; }
.arena-west, .arena-east { margin-top: 56px; }
.player { min-width: 0; display: flex; flex-direction: column; gap: 6px; padding: 9px; border: 1px solid var(--line); border-radius: 9px; background: #29291d; }
.arena-north .player, .arena-south .player, .side-match .player {
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; gap: 4px 6px; padding: 7px;
}
.arena-north .player-reserve, .arena-south .player-reserve, .side-match .player-reserve { grid-column: 2; grid-row: 1 / span 3; }
.player.free-player { border-color: #657052; }
.player.shadow-player { border-color: #775649; background: #33271e; }
.arena-seat .player.viewer { border-color: var(--gold); }
.player.waiting { box-shadow: inset 0 3px 0 var(--gold); }
.player h2 { font-size: 1.02rem; overflow-wrap: anywhere; }
.player-info { color: var(--muted); font-size: .75rem; line-height: 1.4; }
.arena-north .player-info, .arena-south .player-info { font-size: .7rem; }
.player-reserve { min-width: 0; min-height: 66px; flex: 1; display: grid; align-content: start; gap: 6px; padding: 6px; border: 1px dashed var(--line); border-radius: 7px; background: #1c1e16; }
.arena-north .player-reserve, .arena-south .player-reserve, .side-match .player-reserve { min-height: 53px; }
.viewer .player-reserve { border-color: #a78952; }
.reserve-title { color: var(--muted); font-size: .88rem; }
.reserve-empty { color: var(--muted); font-size: .72rem; }
.player-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { display: inline-block; padding: 2px 7px; border: 1px solid var(--line); border-radius: 20px; color: var(--muted); font-size: .7rem; line-height: 1.3; }
.tag.attention { color: var(--gold); border-color: #9f7d4c; }
.table-arena.side-match {
  grid-template-areas: "north east" "board board" "south west";
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.side-match .arena-seat { width: min(100%, 348px); margin-top: 0; }
.side-match .arena-north, .side-match .arena-south { justify-self: end; }
.side-match .arena-west, .side-match .arena-east { justify-self: start; }

.table-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(245px, .29fr); gap: 14px; align-items: start; }
.table-center, .table-side { min-width: 0; display: grid; gap: 14px; }
.board, .hand-panel, .actions-panel, .history-panel { min-width: 0; padding: clamp(12px, 2vw, 20px); }
.board { grid-area: board; padding: 10px; background: radial-gradient(ellipse at 50% 0%, #3e3a26, transparent 90%), #24251b; }
.board.map-board { background: linear-gradient(135deg, #282417bb, #222218e8), url("/materials/assets/backgrounds/middle-earth-map.jpg") center 39% / cover, #24251b; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.section-heading h2 { font-size: 1.35rem; }
.board .section-heading { margin-bottom: 5px; }
.board .drag-instructions { margin-bottom: 6px; font-size: .75rem; }

.locations, .card-list { display: grid; gap: 9px; }
.locations, .extra-location-slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.extra-locations { grid-column: 1 / -1; display: grid; gap: 8px; margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.extra-locations h3 { font-size: .95rem; }
.extra-location-slots { display: grid; gap: 9px; }
.location { min-width: 0; display: grid; align-content: start; gap: 6px; padding: 8px; min-height: 92px; border: 1px solid #7a6d4d; border-radius: 8px; background: linear-gradient(140deg, #494031, #27291e); }
.location.path { border-color: #738461; background: linear-gradient(140deg, #374434, #242d22); }
.location.empty-slot { min-height: 67px; align-content: center; justify-items: center; gap: 3px; border-style: dashed; background: #1d2017a8; text-align: center; }
.location-emblem { color: #a28b60; font: 1.25rem/1 var(--serif); }
.location .eyebrow { letter-spacing: .085em; font-size: .69rem; }
.location.empty-slot .empty { font-size: .72rem; }
.location > .art-trigger .face-illustration { aspect-ratio: 3.5; max-height: 73px; }
.location > .art-trigger .face-rules { -webkit-line-clamp: 2; }
.location > .art-trigger > .asset-image { max-height: 94px; object-fit: contain; }
.player-reserve .card-list { grid-template-columns: 1fr; gap: 6px; max-height: 230px; overflow: auto; padding: 2px; scrollbar-width: thin; }
.arena-north .player-reserve .card-list, .arena-south .player-reserve .card-list, .side-match .player-reserve .card-list { max-height: 120px; }
.player-reserve .card { position: relative; padding: 4px; }
.player-reserve .face-illustration { aspect-ratio: 2.4; }
.player-reserve .face-body { padding: .34rem; }
.player-reserve .face-rules { -webkit-line-clamp: 2; }
.player-reserve .drag-handle { position: absolute; top: 6px; right: 6px; width: 44px; padding: 0; }
.location .card-list { grid-template-columns: repeat(auto-fit, minmax(min(100%, 105px), 1fr)); }
.card-list { grid-template-columns: repeat(auto-fill, minmax(min(100%, 135px), 1fr)); }
.card { min-width: 0; display: grid; align-content: start; gap: 6px; padding: 10px; border: 1px solid #6d5c40; border-radius: 7px; background: linear-gradient(135deg, #413625, #2f2a1e); }
.card.playable { border-color: #8b9a69; }
.art-trigger { display: grid; gap: 8px; width: 100%; min-height: 44px; padding: 0; border: 0; background: none; color: var(--ink); text-align: left; }
.art-trigger strong { font: 600 1rem/1.2 var(--serif); overflow-wrap: anywhere; }
.location > .art-trigger strong { font-size: 1.12rem; }
.art-trigger:hover strong, .art-trigger:focus-visible strong { color: var(--gold); }
.card-drag-source { cursor: grab; user-select: none; }
.card-drag-source img { -webkit-user-drag: none; }
.card-drag-active { cursor: grabbing; opacity: .55; }
.drag-instructions { font-size: .84rem; margin-bottom: 12px; }
.drag-handle {
  display: grid;
  place-items: center;
  justify-self: end;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--gold);
  background: #28251b;
  cursor: grab;
  touch-action: none;
}
.card-drag-ghost {
  position: fixed;
  z-index: 20;
  top: 0;
  left: 0;
  width: 116px;
  padding: 7px;
  color: var(--ink);
  font: 650 .8rem/1.25 system-ui, sans-serif;
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 8px;
  box-shadow: 0 10px 28px #000a;
  pointer-events: none;
}
.card-drag-ghost img { display: block; width: 100%; max-height: 110px; object-fit: contain; margin-bottom: 6px; }
.card-drop-zone {
  display: grid;
  place-items: center;
  min-height: 50px;
  margin-top: 10px;
  padding: 8px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}
#event-zone { min-height: 38px; margin: 0; padding: 6px 10px; font-size: .82rem; }
.drop-allowed { outline: 2px dashed var(--green); outline-offset: -2px; }
.drop-current { outline: 3px solid var(--gold); box-shadow: inset 0 0 0 3px #e8bd7038; color: var(--ink); }
.option-face { display: flex; align-items: center; gap: 8px; }
.option-face img { flex: none; border-radius: 3px; }
.equipped-card { grid-template-columns: 36px minmax(0, 1fr); align-items: center; padding-top: 6px; border-top: 1px solid var(--line); }
.equipped-card strong { font-size: .88rem; }
.asset-image { display: block; width: 100%; height: auto; border-radius: 6px; box-shadow: 0 5px 14px #1119; }
.location .card .asset-image, .player .card .asset-image { max-height: 118px; object-fit: contain; }
.card-meta { color: var(--muted); font-size: .72rem; line-height: 1.35; overflow-wrap: anywhere; }
.card-values { color: var(--ink); }
.private-zone { padding-top: 10px; margin-top: 12px; border-top: 1px solid var(--line); }
.private-zone summary { min-height: 32px; font-size: .9rem; }
.private-zone[open] .card-list { margin-top: 8px; }

.decision { margin-bottom: 12px; padding: 9px 10px; border-left: 3px solid var(--gold); border-radius: 4px; background: #37301e; color: var(--ink); }
.action-menu { margin-top: 5px; }
.action-form { display: grid; gap: 11px; margin-top: 12px; }
.action-form fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.action-form legend { margin-bottom: 6px; color: var(--ink); font-size: .86rem; font-weight: 650; }
.option-list { display: grid; gap: 5px; }
.option { display: grid; grid-template-columns: 1rem minmax(0, 1fr) auto; align-items: center; gap: 7px; min-height: 38px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: .83rem; line-height: 1.3; cursor: pointer; }
.option input { margin: 0; accent-color: var(--gold); }
.option:has(input:checked) { border-color: #ad8d54; background: #40341f; }
.option:has(input:disabled) { opacity: .55; cursor: default; }
.option-order { color: var(--gold); font-size: .72rem; }
.action-form .button { justify-self: start; max-width: 100%; }

.history { max-height: 350px; overflow: auto; margin: 0; padding: 0 0 0 1.35rem; color: var(--muted); font-size: .82rem; line-height: 1.42; }
.history li { padding: 6px 0 6px 4px; overflow-wrap: anywhere; }
.history li + li { border-top: 1px solid #47402c; }

.card-preview { width: min(860px, 100% - 24px); max-height: calc(100dvh - 24px); padding: clamp(14px, 3vw, 24px); border: 1px solid #8f7650; border-radius: 13px; background: #25231a; color: var(--ink); box-shadow: 0 20px 72px #000b; }
.card-preview[open] { animation: preview-enter .18s ease-out; }
.card-preview::backdrop { background: #15120dce; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.preview-languages { display: flex; gap: 6px; }
.preview-languages [aria-pressed="true"] { border-color: #e5bc72; color: var(--gold); background: #3b301f; }
.preview-body { display: grid; grid-template-columns: minmax(0, 1.03fr) minmax(0, 1fr); align-items: start; gap: clamp(14px, 4vw, 28px); }
.preview-body:has(.preview-figure[hidden]) { grid-template-columns: 1fr; }
.preview-figure { min-width: 0; display: grid; justify-items: center; gap: 8px; margin: 0; }
.preview-figure .asset-image { width: auto; max-width: 100%; max-height: 68dvh; object-fit: contain; }
.preview-figure figcaption { text-align: center; font-size: .8rem; }
.preview-copy { min-width: 0; overflow-wrap: anywhere; }
.preview-copy h2 { margin: 4px 0 12px; font-size: clamp(1.5rem, 4.2vw, 2.4rem); line-height: 1.1; }
.preview-text { display: grid; gap: 10px; }
.preview-rules { white-space: pre-wrap; }
.preview-source { font-size: .8rem; }

@keyframes preview-enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 1000px) {
  .table-controls { display: flex; align-items: center; max-width: none; gap: 14px; }
  .pass-control { width: auto; }
  .pass-copy { max-width: 240px; }
}

@media (min-width: 701px) {
  .location > .art-trigger > .localized-card-face { display: grid; grid-template-columns: minmax(0, .47fr) minmax(0, 1fr); }
  .location > .art-trigger .face-illustration { aspect-ratio: auto; height: 72px; border-right: 1px solid var(--face-rim); }
  .location > .art-trigger .face-body { gap: 3px; padding: 4px 6px; }
  .location > .art-trigger .face-name { font-size: clamp(.84rem, 7cqi, 1.02rem); }
  .arena-north .player-reserve .card-list, .arena-south .player-reserve .card-list, .side-match .player-reserve .card-list { max-height: 98px; }
}

@media (max-width: 1080px) {
  .table-layout { grid-template-columns: minmax(0, 1fr); }
  .table-side { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}

@media (max-width: 850px) {
  .table-side { grid-template-columns: minmax(0, 1fr); }
  .table-jump {
    position: sticky;
    top: 0;
    z-index: 8;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
    margin: 0 0 12px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #232419;
    box-shadow: 0 3px 14px #171810b0;
  }
  .table-jump a {
    display: grid;
    place-items: center;
    min-height: 42px;
    border-radius: 6px;
    color: var(--ink);
    font-size: .78rem;
    font-weight: 650;
    text-decoration: none;
  }
  .table-jump a:hover, .table-jump a:focus-visible { color: var(--gold); background: var(--panel-light); }
  #players, #board-title, #hand-title, #actions-title { scroll-margin-top: 66px; }
}

@media (max-width: 700px) {
  .table-arena {
    grid-template-areas: "north east" "board board" "west south";
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 7px;
  }
  .table-arena .arena-seat { width: 100%; }
  .arena-west, .arena-east { margin-top: 0; }
  .board { padding: 7px; }
  .location { padding: 5px; }
}

@media (max-width: 620px) {
  .shell { width: calc(100% - 24px); }
  .masthead { flex-wrap: wrap; gap: 10px; }
  .masthead-controls { justify-content: flex-start; }
  .brand { gap: 8px; }
  .brand-mark { flex-basis: 35px; height: 35px; }
  .welcome { grid-template-columns: 1fr; min-height: 0; gap: 26px; }
  .table { padding-top: 18px; }
  .table-arena .player { display: flex; padding: 7px; }
  .preview-body { grid-template-columns: 1fr; }
  .preview-figure .asset-image { max-height: 46dvh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
