:root { --cream: #f5ecd5; color-scheme: light; font-family: serif; background: var(--cream); color: #000; --card-width: 144px; --card-height: 202px; --hand-height: calc(var(--card-height) / 2 + 10px); --player-bar-height: 2.5rem; --opponent-bar-height: var(--player-bar-height); --piece-size: 42px; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--cream); color: #000; }
button, input { font: inherit; color: #000; background: var(--cream); border: 1px solid #000; border-radius: 0; }
button { padding: 6px 10px; min-height: 2rem; cursor: pointer; }
button:not(.card):not(.piece) { border-radius: 999px; }
button:disabled { opacity: .45; cursor: default; }
input { padding: 8px; }
button:focus-visible, input:focus-visible, .card:focus-visible { outline: 2px solid #000; outline-offset: -2px; }
[hidden] { display: none !important; }
header { height: 43px; padding: 5px 12px; display: flex; gap: 16px; align-items: center; border-bottom: 1px solid #000; }
#session-tools { justify-content: flex-end; flex-shrink: 0; }
#connection { font-size: .875rem; }
#app { height: calc(100dvh - 43px); }
body.playing #app { height: 100dvh; }
.player-line #session-tools { height: 2rem; padding: 0; margin-left: auto; border: 0; align-items: center; }
.entry { max-width: 510px; margin: 80px auto; padding: 20px; height: auto; }
.entry form { display: flex; gap: 14px; flex-direction: column; }
.entry > button { margin: 14px 12px 0 0; }
.entry h1 { font-size: 26px; }
.entry label { display: flex; flex-direction: column; gap: 6px; }
.lobby { margin: 70px auto; max-width: 620px; padding: 20px; }
.lobby li { margin: 16px 0; }
.link-row { display: flex; gap: 8px; margin: 16px 0; }
.link-row input { flex: 1; min-width: 0; }
.table { display: grid; height: 100%; grid-template-rows: var(--opponent-bar-height) minmax(0,1fr) minmax(0,1fr) var(--hand-height) var(--player-bar-height); }
.player { display: contents; }
.player:first-child .player-line { grid-row: 1; }
.player:first-child .player-line { padding-inline: 8px; }
.player:first-child .board { grid-row: 2; margin-top: 6px; }
.player:nth-child(2) .board { grid-row: 3; margin-top: 6px; }
.player:nth-child(2) .player-line { grid-row: 5; }
.player-line { display: flex; gap: 12px; align-items: center; padding: 0 12px; min-height: var(--player-bar-height); line-height: 1.25rem; color-scheme: dark; background: #000; color: var(--cream); }
.bar-controls { display: flex; flex: 1; gap: 8px; min-width: 0; height: var(--player-bar-height); padding-block: .25rem; align-items: center; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; user-select: none; touch-action: pan-x; }
.bar-controls::-webkit-scrollbar { display: none; }
.bar-controls > * { flex-shrink: 0; }
.bar-controls.scrollable, .bar-controls.scrollable button { cursor: grab; }
.player-line button { padding: .3125rem 10px; line-height: 1.25rem; background: #000; color: var(--cream); border-color: var(--cream); white-space: nowrap; }
.player-line button:focus-visible { outline-color: var(--cream); }
.player-line button.drop-target { background: var(--cream); color: #000; }
.player-line .name { font-weight: bold; white-space: nowrap; }
.player-line .counts { font-size: .875rem; }
.opponent-tabs { display: flex; gap: 4px; align-items: center; min-width: 0; height: var(--player-bar-height); }
.opponent-tabs button { display: flex; gap: 6px; align-items: baseline; padding-inline: 7px; font-size: inherit; white-space: nowrap; min-width: 0; }
.opponent-tabs .tab-name { max-width: 90px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.opponent-tabs button[aria-pressed="true"] { background: var(--cream); color: #000; }
.board { position: relative; flex: 1; min-height: 125px; margin: 0 8px; border: 1px solid #000; overflow: hidden; user-select: none; touch-action: none; }
.board > .hint { position: absolute; inset: 8px; opacity: .65; pointer-events: none; }
.card { width: var(--card-width); height: var(--card-height); padding: 0; border: 0; display: inline-block; background: var(--cream); touch-action: none; user-select: none; cursor: grab; flex: 0 0 auto; }
/* Match Advanced TFRA's display trim: 2.5 × 3.5 card, 1/8 inch bleed per edge.
   This clips the untrimmed sample art in presentation; immutable assets stay intact. */
.art-window { position: relative; overflow: hidden; border: 0; border-radius: 4.8% / 3.4%; }
.art-window > img { display: block; position: absolute; left: 50%; top: 50%; width: 110%; max-width: none; height: auto; transform: translate(-50%, -50%); object-fit: contain; pointer-events: none; }
.board .card { position: absolute; }
.card.tapped { transform: rotate(90deg); }
.card.selected { outline: 1px dashed #000; outline-offset: 1px; }
.card.drag-origin { visibility: hidden; }
.card-back { display: flex; height: 100%; width: 100%; align-items: center; justify-content: center; background: #000; color: var(--cream); border: 1px solid var(--cream); border-radius: inherit; }
body.card-held, body.card-held *, body.bar-held, body.bar-held * { cursor: grabbing !important; }
.piles { display: flex; gap: 8px; align-items: baseline; flex-shrink: 0; }
.hand { flex: 1; min-width: 0; display: flex; min-height: 0; padding: 0 12px; align-items: flex-end; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; border-top: 0; position: relative; user-select: none; touch-action: pan-x; }
.hand::-webkit-scrollbar { display: none; }
.hand.scrollable { cursor: grab; }
.hand .card:focus-visible { outline-offset: -2px; }
.hand-cards { display: flex; flex: 0 0 auto; gap: 8px; min-height: calc(var(--card-height) / 2); margin-inline: auto; }
.hand .card { height: calc(var(--card-height) / 2); min-height: 0; border-radius: 4.8% 4.8% 0 0 / 6.8% 6.8% 0 0; }
.hand .card > img { top: calc(var(--card-height) / 2); }
.drop-target { outline: 2px dashed #000; outline-offset: -4px; }
#feedback { position: fixed; bottom: 8px; right: 12px; max-width: 420px; padding: 8px; margin: 0; background: var(--cream); border: 1px solid #000; z-index: 200; pointer-events: none; }
#feedback:empty { display: none; }
#menu { position: fixed; background: var(--cream); border: 1px solid #000; padding: 4px; z-index: 400; min-width: 170px; }
#menu button { display: block; width: 100%; text-align: left; border: none; }
#menu button:hover { outline: 1px solid #000; outline-offset: -2px; }
#preview { position: fixed; inset:auto; margin:0; padding:0; border:0; pointer-events: none; z-index: 300; background: var(--cream); width: min(360px, calc((100dvh - 24px) * 5 / 7), calc(100vw - 24px)); aspect-ratio: 5 / 7; }
.drag-ghost { position: fixed; z-index: 500; pointer-events: none; width: var(--card-width); height: var(--card-height); }
.drag-ghost.tapped { transform: rotate(90deg); }
.selection-box { position: fixed; z-index: 500; border: 1px dashed #000; pointer-events: none; }
.pile-tray { position: fixed; top: calc(var(--opponent-bar-height) + 6px); left: 15%; right: 15%; height: 45vh; overflow: hidden; display: flex; flex-direction: column; gap: 12px; padding: 15px; background: var(--cream); border: 1px solid #000; z-index: 100; }
.pile-tray-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: 0 0 auto; }
.pile-tray h2 { margin: 0; font-size: 1.125rem; }
.pile-tray-header .close { flex: 0 0 auto; }
.pile-tray-cards { display: flex; flex: 1; min-height: 0; flex-wrap: wrap; align-items: flex-start; align-content: flex-start; gap: 12px; overflow: auto; scrollbar-width: thin; scrollbar-color: #000 var(--cream); padding: 3px; }
.pile-tray-cards::-webkit-scrollbar { width: 6px; height: 6px; }
.pile-tray-cards::-webkit-scrollbar-thumb { background: #000; }
.pile-tray-cards::-webkit-scrollbar-track { background: var(--cream); }
.viewer-instruction { margin: 0; font-size: .875rem; }
.spellbook-instructions, .library-instructions { display: flex; flex-wrap: wrap; gap: 6px 24px; }
.pile-tray-header h2 { margin-right: auto; }
.pile-tray-cards { justify-content: center; }
.token-supply { --token-columns: 5; --token-gap: clamp(8px, 1.4vw, 18px); left: 5%; right: 5%; top: calc(var(--opponent-bar-height) + 6px); bottom: max(6vh, calc(var(--player-bar-height) + 8px)); height: auto; padding: clamp(8px, 1.2vw, 15px); }
.token-supply .pile-tray-cards { display: flex; flex-wrap: wrap; gap: var(--token-gap); overflow-x: hidden; }
.token-choice { width: calc((100% - (var(--token-columns) - 1) * var(--token-gap)) / var(--token-columns)); height: auto; aspect-ratio: 5 / 7; }
.token-click-count { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); padding: 2px 10px; background: var(--cream); color: #000; font-size: 28px; font-weight: bold; line-height: 1.2; pointer-events: none; }
.token-click-count.shake { animation: token-count-shake 280ms ease-out; }
@keyframes token-count-shake {
  0%, 100% { transform: translateX(-50%) rotate(0); }
  20% { transform: translateX(calc(-50% - 3px)) rotate(-4deg); }
  40% { transform: translateX(calc(-50% + 3px)) rotate(4deg); }
  60% { transform: translateX(calc(-50% - 2px)) rotate(-2deg); }
  80% { transform: translateX(calc(-50% + 2px)) rotate(2deg); }
}
@media (prefers-reduced-motion: reduce) { .token-click-count.shake { animation: none; } }
.piece-shelf { display: flex; flex-wrap: wrap; flex-shrink: 0; gap: 8px 12px; align-items: flex-start; }
.custom-marker-controls { display: flex; flex: 1 1 260px; min-width: 0; gap: 12px; align-items: flex-start; }
.custom-marker-controls input { flex: 1; min-width: 0; width: 150px; }
.custom-marker-controls button { flex-shrink: 0; white-space: nowrap; }
.piece-choice { position: relative; padding-bottom: 24px; }
.piece-click-count { bottom: 0; padding: 0 4px; font-size: 16px; line-height: 1.25rem; }
.piece-shelf input { max-width: 220px; }
.piece-shelf button, .piece-shelf input { height: 2rem; padding-block: .25rem; }
.pending-selections { position: fixed; right: 12px; bottom: calc(var(--hand-height) + var(--player-bar-height) + 4px); display: flex; gap: 6px; z-index: 90; }
.viewer-dragging .pile-tray { visibility: hidden; pointer-events: none; }
.viewer-backdrop { position: fixed; inset: var(--opponent-bar-height) 0 var(--player-bar-height); background: rgba(0,0,0,.25); z-index: 95; }
.viewer-dragging .viewer-backdrop { visibility: hidden; pointer-events: none; }
.player-line { position: relative; z-index: 110; }
.pending-selections { z-index: 110; }
.life { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.life button { padding-inline: 5px; }
.life-total { min-width: 22px; text-align: center; }
.player-line { gap: 8px; min-width: 0; }
.piles { gap: 6px; }
.player-line button { padding-inline: 7px; }
.piece { width: var(--piece-size); height: var(--piece-size); padding: 5px; cursor: grab; touch-action: none; user-select: none; z-index: 10; }
.board .piece { position: absolute; }
.piece.marker { border-radius: 50%; font-size: 10px; overflow-wrap: anywhere; line-height: 11px; }
.piece.die { display: grid; grid-template-columns: repeat(3,1fr); grid-template-rows: repeat(3,1fr); gap: 3px; border-radius: 4px; }
.pip { border-radius: 50%; background: #000; }
.piece.drag-origin { visibility: hidden; }
.piece-ghost { position: fixed; pointer-events: none; z-index: 500; }
.attached-piece-ghost { z-index: 501; }
@media (max-height: 760px) { :root { --cream: #f5ecd5; --card-width: 112px; --card-height: 157px; } }
@media (max-width: 1000px) { .player-line { gap: 7px; } .counts { display: none; } }
@media (max-width: 1000px) {
  .table:has(.opponent-tabs) { --opponent-bar-height: calc(var(--player-bar-height) * 2); }
  .player:first-child .player-line:has(.opponent-tabs) { flex-wrap: wrap; align-content: flex-start; row-gap: 0; }
  .opponent-tabs { flex-basis: 100%; flex-shrink: 0; }
  .player:first-child .player-line:has(.opponent-tabs) > .bar-frame { flex-basis: 100%; }
}
@media (max-width: 650px) {
  .player-line #session-tools { gap: 8px; }
  .player-line #connection { font-size: 0; display: inline-flex; align-items: center; justify-content: center; height: 2rem; }
  .player-line #connection::before { content: ''; display: block; width: 8px; height: 8px; border: 1px solid currentColor; border-radius: 50%; }
  .player-line #connection[data-status="Connected"]::before { background: currentColor; }
}
@media (max-width: 1000px) { .token-supply { --token-columns: 4; } }
@media (max-width: 700px) { .token-supply { --token-columns: 3; } }
@media (max-width: 480px) { .token-supply { --token-columns: 2; } }

.scroll-frame { display: flex; align-items: center; min-width: 0; gap: 4px; }
.bar-frame { flex: 1; height: var(--player-bar-height); }
.hand-frame { grid-row: 4; min-height: 0; align-items: stretch; padding-inline: 8px; }
.scroll-arrow { flex: 0 0 auto; min-width: 2rem; height: 2rem; padding: 0 4px; font-size: 1.5rem; line-height: 1; }
.hand-frame .scroll-arrow { align-self: center; }
.scroll-arrow[aria-disabled="true"] { opacity: .4; cursor: default; }
.card:focus-visible::after { content: ''; position: absolute; inset: 0; border: 2px solid var(--cream); box-shadow: inset 0 0 0 2px #000; border-radius: inherit; pointer-events: none; z-index: 2; }
.pile-tray-cards:focus-visible { outline: 2px solid #000; outline-offset: -2px; }

.scroll-arrow svg { display: block; width: 1rem; height: 1rem; margin: auto; pointer-events: none; }
.art-window > img.trimmed-art { width: 100%; height: 100%; object-fit: fill; }
.hand .card > img.trimmed-art { height: var(--card-height); }
.draft-lobby { margin: 24px auto; max-width: 850px; }
.draft-seats, .draft-settings { display:flex; flex-wrap:wrap; gap:12px; margin-block:16px; align-items:center; }
.draft-seats > span { padding:6px 10px; border:1px solid #000; }
.draft-stepper { display:flex; align-items:center; gap:6px; border:1px solid #000; padding:8px; }
.draft-stepper > span:first-child { min-width:8rem; }
.setting-value { min-width:1.5rem; text-align:center; }
.draft-settings button[aria-pressed="true"] { background:#000; color:var(--cream); }
.draft-screen, .construction-screen { display:flex; flex-direction:column; height:100%; min-height:0; gap:8px; padding:8px; }
.draft-screen h1, .construction-screen h1 { font-size:1.25rem; margin:0; }
.draft-heading { display:flex; flex-wrap:wrap; align-items:center; gap:12px; flex-shrink:0; }
.draft-turn { font-size:1.25rem; font-weight:bold; }
.draft-screen h2, .construction-screen h2 { font-size:1rem; margin:0; padding:4px; }
.phase-toolbar { display:flex; flex-wrap:wrap; align-items:center; gap:8px; padding:4px 8px; background:#000; color:var(--cream); flex-shrink:0; }
.phase-toolbar button { background:#000; color:var(--cream); border-color:var(--cream); }
.phase-toolbar button:focus-visible { outline-color:var(--cream); }
.draft-status > span { border:1px solid var(--cream); padding:6px 10px; }
.draft-status-frame { flex-wrap:nowrap; }
.draft-status { height:auto; padding-block:0; white-space:nowrap; }
.draft-status:focus-visible { outline:2px solid var(--cream); outline-offset:-2px; }
.phase-cards { display:flex; flex:1; min-height:0; min-width:0; gap:10px; padding:4px; flex-wrap:wrap; align-content:flex-start; overflow:auto; scrollbar-width:thin; scrollbar-color:#000 var(--cream); }
.phase-cards:focus-visible { outline:2px solid #000; outline-offset:-2px; }
.draft-pack { border:1px solid #000; }
.draft-stacks { flex:none; flex-wrap:nowrap; align-items:flex-start; padding:6px; gap:12px; }
.draft-card-stack { display:flex; flex-direction:column; flex:0 0 var(--card-width); }
.draft-card-stack > .card + .card { margin-top:calc(var(--card-height) * -.78); }
.draft-drop-line { position:fixed; z-index:502; background:#000; box-shadow:0 0 0 1px var(--cream); pointer-events:none; }
.drafted-cards { min-width:0; flex-shrink:0; }
.drafted-cards .draft-stacks { max-height:38dvh; overflow:auto; }
.drafted-cards .phase-cards:empty { display:none; }
.flex-reserve { inset:43px 0 auto; width:min(900px, calc(100% - 24px)); max-height:calc(100dvh - 55px); padding:12px; border:1px solid #000; background:var(--cream); color:#000; overflow:auto; scrollbar-width:thin; }
.flex-reserve::backdrop { background:rgb(0 0 0 / .35); }
.flex-reserve .draft-heading { justify-content:space-between; }
.flex-reserve .phase-cards { max-height:65dvh; }
.draft-waiting { margin:0; }
.build-zones { flex:1; min-height:0; display:grid; grid-template-columns:2fr 2fr 1fr; gap:8px; }
.construction-zone { display:flex; flex-direction:column; min-width:0; min-height:0; border:1px solid #000; }
.construction-zone h2 { flex-shrink:0; border-bottom:1px solid #000; }
.starting-zones { min-width:0; min-height:0; display:grid; grid-template-rows:1fr 1fr; gap:8px; }
.basic-picker { display:flex; gap:10px; overflow:auto; scrollbar-width:thin; padding:4px; flex-shrink:0; }
@media (max-width:800px) { .build-zones { grid-template-columns:1fr 1fr; } .starting-zones { grid-column:1 / -1; grid-template-columns:1fr 1fr; grid-template-rows:1fr; } }
