/* Native table, composed against official Arena gameplay references.
   Artwork, state and legal actions remain owned by the published Forge DTO. */
.playing {
  --bg: #171d22; --field: #20272b; --ink: #f0eee7; --muted: #bec6c9;
  --accent: #ead09a; --line: #465259; --card-width: 136px; --card-height: 116px;
  background: var(--bg);
}
.playing .toolbar { height: 48px; background: #11171b; border-bottom-color: #374248; }
.playing #status:empty { display: none; }
.playing #error { position: fixed; z-index: 90; left: 16px; top: 50px; max-width: 65ch; padding: 12px; background: #351f1a; }
#match { position: relative; display: block; height: calc(100dvh - 48px); min-height: 0; overflow: visible; }
.playmat {
  position: relative; display: grid; height: 100%; min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 96px minmax(140px, 1fr) minmax(140px, 1fr) 92px 190px 26px;
  overflow: hidden; background: radial-gradient(ellipse at 50% 48%, #414747, #2b3337 60%, #192126);
}
/* Player medallions anchor the full-width board; command cards stay beside them. */
.seat, .seat.opponent { position: relative; grid-column: 1; grid-row: 4; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 0; border: 0; z-index: 3; }
.seat.opponent { grid-row: 1; }
.seat-heading { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0; width: 120px; }
.seat-heading .player-target { position: relative; width: 78px; height: 78px; padding: 0; border: 3px solid #8b8270; border-radius: 50%; background: #1b252a; }
.portrait-art { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.player-label { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-size: 11px; white-space: nowrap; color: var(--ink); }
.seat.opponent .player-label { bottom: auto; top: 0; left: auto; right: calc(100% + 12px); transform: none; font-size: 13px; }
.player-target[data-priority=true] { border-color: var(--accent); box-shadow: 0 5px 18px #0006; }
.seat-heading strong { position: absolute; top: 52px; left: 50%; transform: translateX(-50%); padding: 2px 12px; min-width: 58px; text-align: center; border-radius: 12px; background: #121b20; color: var(--ink); font: 700 30px/1.1 Georgia,serif; pointer-events: none; }
.seat-heading > span { margin-top: 7px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.command-row { position: absolute; left: calc(50% + 72px); top: 25px; flex-direction: row; gap: 6px; margin: 0; }
.command-row .card { width: 48px; height: 67px; min-height: 0; background: #182126; box-shadow: 0 4px 8px #0006; }
.command-row .card-art { display: block; position: absolute; inset: 0; overflow: hidden; border-radius: inherit; }
.command-row .card-art img { display: block; transform: none; }
.command-row .card .card-name { display: none; position: absolute; inset: auto 0 0; min-height: 0; padding: 3px; font-size: 11px; background: #10171ae8; max-height: 30px; overflow: hidden; }
.command-row .state, .command-row .badge { display: none; }
.command-row .card.image-missing .card-name { display: block; max-height: none; }
.battlefield, .battlefield.yours { grid-column: 1; grid-row: 2; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 1fr auto; align-items: center; gap: 8px; padding: 8px 22px; min-height: 0; overflow: auto; }
.battlefield.yours { grid-row: 3; }
.battlefield:not(.yours) { grid-template-rows: auto 1fr; }
.battlefield:not(.yours) .land-row { grid-row: 1; }
.battlefield:not(.yours) > .card-row:not(.land-row) { grid-row: 2; }
.card-row { justify-content: center; gap: 12px; }
/* A crowded row shrinks its cards (--row-scale, set by table-battlefield.js) before it has to scroll. */
.card-row { --cw: calc(var(--card-width) * var(--row-scale, 1)); --ch: calc(var(--card-height) * var(--row-scale, 1)); }
.land-row { margin: 0; justify-content: flex-start; padding: 10px 0 10px 5%; gap: 6px; }
.battlefield.yours .land-row { padding-right: 25%; }
.battlefield .empty { position: absolute; left: 22px; right: 22px; text-align: center; opacity: .45; font-size: 12px; pointer-events: none; }
.battlefield.drop-hover { background: #34453c; outline-color: #b9d7ac; }
.battlefield .card { width: var(--cw, var(--card-width)); height: var(--ch, var(--card-height)); border-radius: 8px; background: #10171a; box-shadow: 0 6px 12px #0007; transition: transform 230ms cubic-bezier(.16, 1, .3, 1), filter 150ms ease-out; }
.card-art { display: block; }
.battlefield .card-art { position: absolute; inset: 3px; overflow: hidden; border-radius: 6px; }
.battlefield .card-art img { width: 100%; height: 100%; aspect-ratio: auto; object-fit: cover; border-radius: inherit; }
.battlefield .card-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(#10171ae6, transparent 35%, transparent 68%, #10171ada); pointer-events: none; }
.battlefield .card .card-name { position: absolute; top: 4px; left: 0; right: 0; min-height: 0; padding: 3px 8px; font-size: 11px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.battlefield .card .badge { z-index: 2; right: 5px; bottom: 4px; padding: 1px 6px; background: #182126; color: #fff; font: 700 16px/1.2 Georgia,serif; }
.battlefield .card .state { top: auto; bottom: 4px; left: 5px; max-width: 85%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.battlefield .card:has(.badge:not([hidden])) .state { max-width: calc(100% - 48px); }
.battlefield .card.tapped { margin: 0 12px; transform: rotate(14deg) translateY(3px); filter: brightness(.72); }
.battlefield .card:hover, .battlefield .card:focus-visible { transform: translateY(-5px); filter: brightness(1.08); z-index: 4; }
.battlefield .card.tapped:hover, .battlefield .card.tapped:focus-visible { transform: rotate(14deg) translateY(-3px); }
.battlefield .card.targetable { outline-color: #9ccee0; }
.battlefield .card.selected { outline-color: var(--accent); }
.land-row .card { width: calc(var(--cw) * .735); height: calc(var(--ch) * .707); }
.land-row .card .card-name { font-size: 11px; }
/* Controls float over the board instead of reserving a permanent sidebar. */
.rail { position: absolute; inset: 0; display: block; padding: 0; border: 0; overflow: visible; pointer-events: none; }
.rail > * { pointer-events: auto; }
.rail > section { margin: 0; padding: 0; border: 0; }
.phase-bar { position: static; width: 100%; margin: 0 0 8px; display: flex; justify-content: flex-end; gap: 8px; padding: 0; border: 0; font-size: 11px; pointer-events: none; z-index: 3; }
.phase-bar #phase { color: var(--accent); }
.phase-bar #priority { white-space: nowrap; }
.rail #decision { position: absolute; right: 22px; bottom: 38px; width: 216px; padding: 0; border: 0; z-index: 12; }
#decision-heading { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
#prompt { margin: 0 0 10px; padding: 0 4px; font-size: 12px; line-height: 1.4; max-height: 120px; overflow: auto; }
.decision-actions { gap: 8px; }
#decision > .decision-actions { justify-content: flex-end; }
#ok { min-width: 148px; padding: 10px 18px; background: linear-gradient(#f4d292, #e5b663); border-color: #f2d49a; border-radius: 14px; color: #211b14; font: 700 18px/1.2 Georgia,serif; box-shadow: 0 5px 12px #0005; }
#ok:hover:not(:disabled) { background: #ffe1a9; }
#cancel { padding: 5px 10px; font-size: 12px; }
.rail .stack { display: none; position: absolute; right: 18px; top: 25%; width: 218px; max-height: 42%; overflow: auto; padding: 12px; background: #11191bf2; border-radius: 8px; z-index: 10; }
#match[data-stack=true] .stack { display: block; }
.stack h2 { font-size: 12px; }
#stack button { background: #263238; border-color: #566468; font-size: 12px; }
#match[data-choosing=true] #decision { width: min(420px, calc(100% - 32px)); top: 20%; bottom: auto; max-height: 70%; overflow: auto; padding: 18px; background: #121b20fa; border-radius: 8px; }
#match[data-choosing=true] #prompt { font-size: 14px; max-height: none; }
.match-menu { position: absolute; top: 12px; right: 18px; z-index: 35; }
.match-menu > summary { padding: 6px 10px; border-radius: 6px; font-size: 12px; color: var(--muted); background: #152026e8; }
.match-menu-panel { position: absolute; top: 40px; right: 0; width: 310px; max-height: calc(100dvh - 132px); overflow: auto; padding: 18px; border-radius: 8px; background: #11191bfa; box-shadow: 0 8px 24px #0007; }
.match-menu-panel h2 { font-size: 13px; }
.match-menu-panel label { font-weight: 400; font-size: 12px; }
.match-menu-panel select { max-width: 100%; }
.match-menu-panel details { margin: 14px 0; font-size: 12px; }
.match-menu-panel #phase-stops-form { position: static; width: 100%; max-height: none; padding: 12px 0; border: 0; }
.match-menu-panel .game-log { padding: 0; }
.match-menu-panel .devtools { padding: 0; border: 0; }
.runtime-credit { font-size: 11px; margin: 12px 0 0; }
/* The full hand remains visible, as requested, even though Arena can tuck it. */
.hand { grid-column: 1; grid-row: 5; overflow: hidden; padding: 0 250px; border: 0; background: linear-gradient(transparent, #11191d9e); }
.hand h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.hand .card-row { height: 190px; min-height: 0; align-items: flex-end; justify-content: safe center; padding: 18px 20px 22px; overflow-x: auto; overflow-y: hidden; }
.hand .card { width: 106px; flex-shrink: 0; margin-left: -28px; transform-origin: 50% 100%; transform: translateY(var(--hand-rise, 0px)) rotate(var(--hand-angle, 0deg)); z-index: var(--hand-order, 0); box-shadow: 0 5px 12px #0007; transition: transform 180ms cubic-bezier(.16, 1, .3, 1); }
.hand .card:first-child { margin-left: 0; }
.hand .card .card-name { display: none; }
.hand .card-art { aspect-ratio: 488 / 680; }
.hand .card.image-missing .card-name, .hand .card.face-down .card-name { display: block; position: absolute; inset: 0; padding: 12px 8px; white-space: normal; overflow-wrap: anywhere; background: var(--field); color: var(--ink); }
.hand .card .badge { bottom: 7px; }
.hand .card .state { max-width: 90%; }
.hand .card:hover, .hand .card:focus-visible { transform: translateY(-12px) rotate(0deg) scale(1.06); z-index: 25; }
.drag-source { opacity: .4; }
.zones { grid-column: 1; grid-row: 6; padding: 3px 12px; background: #121b20; font-size: 12px; overflow: auto; }
.zones[open] { position: absolute; bottom: 0; left: 0; right: 0; z-index: 40; max-height: 45%; }
.zones .card { width: 90px; }
.details-rail { display: block; position: fixed; left: 18px; top: 74px; width: 252px; max-height: calc(100dvh - 106px); padding: 14px; overflow: auto; z-index: 45; background: #11191bf5; border: 0; border-radius: 8px; box-shadow: 0 12px 32px #0008; visibility: hidden; pointer-events: none; }
body[data-inspecting=true] .details-rail { visibility: visible; pointer-events: auto; }
.details-rail #inspect-image { margin-top: 12px; }
.details-rail h2 { font-size: 14px; }
.details-rail #inspect-text { font-size: 12px; max-height: 18dvh; overflow: auto; }
#mana { position: absolute; right: calc(100% + 12px); top: 44px; display: flex; max-width: 230px; gap: 3px; }
#mana button { padding: 3px 6px; font-size: 11px; }
.waiting .playmat { filter: saturate(.65) brightness(.85); }
.life-delta { position: absolute; top: 38px; right: -6px; z-index: 4; color: var(--error); font-size: 20px; font-weight: 700; pointer-events: none; }
.life-delta[data-gain=true] { color: #bee2c4; }
@media (max-height: 1000px) and (min-width: 701px) {
  /* The two battlefields share what is left after the fixed rows (90 + 86 + 150 + 24 + 48 toolbar). A tapped card's rotated box is
     about 1.25 x its height, so the card size follows the viewport height instead of clipping against the row or the other side. */
  .playing { --card-height: clamp(52px, calc(((100dvh - 398px) / 2 - 36px) / 1.32), 116px); --card-width: calc(var(--card-height) * 1.1667); }
  .playmat { grid-template-rows: 90px minmax(110px, 1fr) minmax(110px, 1fr) 86px 150px 24px; }
  .land-row .card { width: calc(var(--cw) * .75); height: calc(var(--ch) * .6875); }
  .battlefield, .battlefield.yours { padding: 8px 16px; gap: 8px; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr); grid-template-rows: 1fr; }
  .battlefield .land-row, .battlefield:not(.yours) .land-row { grid-column: 1; grid-row: 1; padding: 0; }
  .battlefield > .card-row:not(.land-row), .battlefield:not(.yours) > .card-row:not(.land-row) { grid-column: 2; grid-row: 1; }
  .seat-heading .player-target { width: 64px; height: 64px; }
  .seat-heading strong { top: 42px; font-size: 26px; }
  .command-row { top: 14px; }
  .hand .card-row { height: 150px; padding-top: 14px; }
  .hand .card { width: 90px; }

}
@media (min-width: 701px) and (max-width: 1100px) {
  .hand { padding-left: 20px; padding-right: 250px; }
  .battlefield { padding-right: 240px; }
}
@media (max-width: 700px) {
  #match { height: auto; overflow: visible; }
  .playmat { height: auto; min-height: calc(100dvh - 48px); grid-template-rows: 100px 180px 180px 100px 156px 26px; }
  .playing { --card-width: 96px; --card-height: 84px; }
  .battlefield, .battlefield.yours { padding: 10px; gap: 8px; }
  .land-row { padding: 0; }
  .battlefield.yours .land-row { padding-right: 0; }
  .land-row .card { width: 78px; height: 60px; }
  .card-row { gap: 8px; }
  .seat-heading .player-target { width: 66px; height: 66px; }
  .seat-heading strong { top: 43px; font-size: 26px; }
  .command-row { left: calc(50% + 65px); top: 18px; }
  .command-row .card { width: 48px; height: 54px; }
  .seat.opponent .player-label { right: calc(100% + 8px); }
  #mana { top: 35px; right: calc(100% - 4px); max-width: 114px; flex-wrap: wrap; }
  .hand { padding: 0 8px; }
  .hand .card-row { height: 156px; justify-content: flex-start; padding: 16px 14px 10px; }
  .hand .card { width: 90px; }
  .phase-bar { top: 6px; bottom: auto; left: 12px; right: auto; width: auto; flex-direction: column; gap: 0; align-items: flex-start; }
  .rail { position: relative; padding: 16px; background: #121b20; }
  .rail #decision { position: static; width: 100%; }
  #decision > .decision-actions { justify-content: flex-start; }
  .rail .stack { position: static; width: 100%; max-height: 300px; margin-top: 20px; }
  #match[data-choosing=true] #decision { position: static; width: 100%; max-height: none; padding: 0; }
  .match-menu { position: absolute; top: auto; bottom: 100%; right: 8px; margin-bottom: 4px; }
  .match-menu-panel { top: auto; bottom: 36px; width: min(310px, calc(100vw - 32px)); }
  .details-rail { width: 200px; top: 64px; right: 10px; left: auto; max-height: 70dvh; }
}
@media (prefers-reduced-motion: reduce) { .playing .card { transition: none; } }
#priority-hold { display: block; margin: 8px 0 0 auto; padding: 3px 8px; font-size: 11px; background: #162027; border-color: #465259; }
#priority-hold[aria-pressed=true] { color: var(--accent); border-color: var(--accent); }
#hold-status { margin: 4px 0 0; font-size: 11px; color: var(--muted); text-align: right; }

/* Arena's right-hand stack uses visible cards, including an ability face. */
.rail .stack { top: 16%; bottom: 264px; width: 224px; max-height: none; padding: 8px; background: transparent; border-radius: 0; }
.stack-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.stack-heading h2 { flex: 1; margin: 0; font-size: 12px; }
#expand-stack { padding: 3px 7px; font-size: 11px; }
#stack li { margin: 0 0 8px; }
#stack .stack-card { display: flex; position: relative; flex-direction: column; gap: 0; width: 100%; min-height: 40px; padding: 4px; border: 0; border-radius: 8px; background: #10191e; color: var(--ink); box-shadow: 0 5px 12px #0007; text-align: left; overflow: hidden; }
#stack .stack-card:hover { background: #223139; }
.stack-card-heading { display: flex; flex-direction: column; gap: 2px; padding: 4px 6px 6px; }
.stack-title { font-size: 12px; font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; }
.stack-order { font-size: 11px; color: var(--muted); }
.stack-card[data-next=true] .stack-order { color: var(--accent); }
.stack-picture { display: block; width: 100%; aspect-ratio: 488 / 680; object-fit: cover; border-radius: 4px; }
.stack-kind { display: none; }
.stack-description { padding: 8px 6px; font-size: 12px; line-height: 1.45; white-space: pre-wrap; max-height: 170px; overflow: auto; }
.stack-card[data-kind=Spell]:not(.image-missing):not(.without-art) .stack-description { display: none; }
.stack-card:not([data-kind=Spell]) .stack-picture { aspect-ratio: 4 / 3; }
.stack-card:not([data-kind=Spell]) .stack-kind { display: block; padding: 4px 6px; background: #314047; color: var(--ink); font-size: 11px; }
.stack-targets, .stack-owner { padding: 4px 6px; font-size: 11px; color: var(--muted); line-height: 1.35; overflow-wrap: anywhere; }
.stack-owner { text-align: right; }
#stack[data-expanded=false] .stack-entry:not(:first-child) .stack-picture,
#stack[data-expanded=false] .stack-entry:not(:first-child) .stack-description,
#stack[data-expanded=false] .stack-entry:not(:first-child) .stack-kind,
#stack[data-expanded=false] .stack-entry:not(:first-child) .stack-targets,
#stack[data-expanded=false] .stack-entry:not(:first-child) .stack-owner { display: none; }
.stack-card.targetable { outline: 3px solid #9ccee0; outline-offset: -3px; }
.stack-source { outline: 2px dashed var(--accent); outline-offset: 3px; }
.stack-targeted { outline: 2px solid var(--accent); outline-offset: 3px; }
#target-links { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 9; }
#target-links > g path { fill: none; stroke: var(--accent); stroke-width: 2; opacity: .9; }
#target-links marker path { fill: var(--accent); }
.stack-entry { animation: stack-arrive 220ms cubic-bezier(.16, 1, .3, 1); }
@keyframes stack-arrive { from { opacity: .4; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }
@media (max-height: 1000px) and (min-width: 701px) {
  .rail .stack { top: 70px; bottom: 250px; width: 198px; }
}
@media (prefers-reduced-motion: reduce) { .stack-entry { animation: none; } }
.stack-card[data-kind=Spell] .stack-picture { width: min(100%, 164px); align-self: center; }
@media (max-height: 1000px) and (min-width: 701px) {
  .stack-card[data-kind=Spell] .stack-picture { width: 140px; }
}
/* Keep pile controls reachable when a long stack scrolls. */
.stack-heading { position: sticky; top: 0; z-index: 2; padding: 6px; border-radius: 6px; background: #121b20; }
.rail .stack { scroll-padding-top: 40px; }
.stack-entry { scroll-margin-top: 40px; }
#stack .stack-card:not([data-kind=Spell]) { border-radius: 8px 8px 30px 30px; padding-bottom: 10px; }
/* The absolute mana tray needs an intrinsic width instead of shrink-to-fit. */
.seat-heading #mana { width: max-content; max-width: 230px; flex-direction: row; flex-wrap: wrap; }
.seat-heading #mana { top: auto; bottom: 8px; }
/* Separate scroll lanes keep a large board from wrapping behind either seat.
   Every permanent retains its own native ID, focus target and action. */
@media (min-width: 701px) {
  .battlefield, .battlefield.yours { overflow: hidden; }
  .battlefield > .card-row {
    min-width: 0; max-width: 100%; flex-wrap: nowrap;
    justify-content: safe center; align-items: center;
    overflow-x: auto; overflow-y: hidden; padding: 16px;
    scroll-padding-inline: 16px; scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
  }
  .battlefield > .land-row { justify-content: flex-start; }
  .battlefield > .card-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
}
@media (max-height: 1000px) and (min-width: 701px) {
  .battlefield, .battlefield.yours {
    grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
    grid-template-rows: minmax(0, 1fr);
  }
  .battlefield > .card-row, .battlefield.yours > .land-row { height: 100%; padding: 16px; }
  @media (max-height: 700px) { .battlefield > .card-row, .battlefield.yours > .land-row { padding: 10px 16px; } }
}
/* An inspected hand card stays the original button as it rises above the fan.
   A fitted fan can overflow upward; exceptionally large hands keep scrolling. */
@media (min-width: 701px) {
  .hand { overflow: visible; z-index: 8; }
  .hand .card-row { gap: 0; overflow: visible; padding-inline: 24px; }
  .hand .card { margin-left: var(--hand-overlap, -28px); transition: transform 180ms cubic-bezier(.16, 1, .3, 1), translate 180ms cubic-bezier(.16, 1, .3, 1); }
  .hand .card:first-child { margin-left: 0; }
  .hand .card:hover, .hand .card:focus-visible { transform: translateY(-12px) rotate(0deg) scale(1.75); z-index: 25; }
  .hand .card:has(~ .card:is(:hover, :focus-visible)) { translate: -20px 0; }
  .hand .card:is(:hover, :focus-visible) ~ .card { translate: 20px 0; }
  .hand .card-row[data-overflow=true] { overflow-x: auto; overflow-y: hidden; }
  .hand .card-row[data-overflow=true] .card { translate: none; }
  .hand .card-row[data-overflow=true] .card:hover,
  .hand .card-row[data-overflow=true] .card:focus-visible { transform: translateY(-8px) rotate(0deg) scale(1.04); }
}
@media (prefers-reduced-motion: reduce) {
  .hand .card { transition: none; }
}
/* Original slate playmat: one static raster, quiet beneath native card state. */
.playmat {
  background-color: var(--field);
  background-image: linear-gradient(#10181922, #10181911), url('assets/playmat-stone-v1.png'), radial-gradient(ellipse at 50% 48%, #414747, #2b3337 60%, #192126);
  background-size: cover;
  background-position: center;
}
/* A metal portrait housing and chamfered life plate echo the reference's
   player anchors; turn ownership and priority remain distinct native facts. */
.playmat { grid-template-rows: 120px minmax(140px, 1fr) minmax(140px, 1fr) 120px 190px 26px; }
.seat-heading { width: 128px; }
.seat-heading .player-target {
  width: 86px; height: 86px; padding: 4px; border: 0;
  background: linear-gradient(135deg, #b8b3a4, #555b59 36%, #242e32 60%, #817962);
  box-shadow: 0 5px 12px #0008;
}
.seat-heading .portrait-art { background: #172125; }
.seat-heading .player-target[data-turn=true] { background: linear-gradient(135deg, #f1d89b, #b29a64 40%, #665336 68%, #dbc38b); }
.seat-heading .player-target::before {
  content: ''; display: none; position: absolute; top: -5px; left: calc(50% - 7px);
  width: 14px; height: 7px; background: var(--accent); clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.seat-heading .player-target[data-turn=true]::before { display: block; }
.seat-heading .player-target::after {
  content: ''; display: none; position: absolute; top: 5px; right: 3px;
  width: 10px; height: 10px; border: 2px solid #172125; border-radius: 50%; background: #9ccee0;
}
.seat-heading .player-target[data-priority=true]::after { display: block; }
.seat .player-label, .seat.opponent .player-label {
  left: auto; right: calc(100% + 14px); top: 30px; bottom: auto;
  transform: none; font-size: 13px; color: var(--ink);
}
.seat-heading strong {
  isolation: isolate; top: 62px; min-width: 74px; padding: 2px 14px 5px;
  border-radius: 0; background: linear-gradient(135deg, #b0a388, #4b514d 60%, #85734e);
  clip-path: polygon(10% 0, 90% 0, 100% 20%, 92% 88%, 50% 100%, 8% 88%, 0 20%);
  font-variant-numeric: tabular-nums; pointer-events: auto;
}
.seat-heading strong::before { content: ''; position: absolute; inset: 2px; z-index: -1; background: #172125; clip-path: inherit; }
.seat-heading > span { margin-top: 14px; color: #c7d0d0; }
@media (max-height: 1000px) and (min-width: 701px) {
  .playmat { grid-template-rows: 104px minmax(110px, 1fr) minmax(110px, 1fr) 102px 150px 24px; }
  .seat-heading .player-target { width: 72px; height: 72px; }
  .seat-heading strong { top: 50px; font-size: 26px; }
  .seat-heading > span { margin-top: 12px; }
  .seat .player-label, .seat.opponent .player-label { top: 25px; }
}
/* Attachments peek from beneath their host, retaining every native button. */
.permanent-group {
  --group-card-width: var(--cw, var(--card-width)); --group-card-height: var(--ch, var(--card-height)); --peek: 24px;
  position: relative; flex: 0 0 auto; margin-inline: var(--host-gap, 0px);
  width: calc(var(--group-card-width) + var(--attachment-peeks) * var(--peek)); height: var(--group-card-height);
}
.land-row .permanent-group { --group-card-width: calc(var(--cw) * .735); --group-card-height: calc(var(--ch) * .707); }
.permanent-group > .card {
  position: absolute; left: calc((var(--attachment-peeks) - var(--attachment-index)) * var(--peek));
  top: calc(var(--attachment-index) * 3px); z-index: var(--attachment-order);
}
.permanent-group > .card.tapped { margin: 0; }
.permanent-group > .card:hover, .permanent-group > .card:focus-visible { z-index: 20; }
.permanent-group .attachment-toggle {
  position: absolute; top: calc(100% + 2px); left: calc(var(--attachment-peeks) * var(--peek));
  white-space: nowrap; padding: 0; min-height: 16px; border: 0; border-radius: 0;
  background: #142025; color: var(--muted); font-size: 12px; line-height: 16px; z-index: 25;
}
.permanent-group[data-expanded=false] > .attachment-card:is(.targetable, .selected, .stack-targeted, .stack-source) { outline-offset: -3px; }
.attachment-toggle:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.permanent-group[data-expanded=false] > .attachment-card:not(:hover):not(:focus-visible) :is(.card-name, .state, .badge, .counter-badge) { visibility: hidden; }
.permanent-group[data-expanded=true] { display: flex; align-items: flex-start; gap: 8px; width: max-content; }
.permanent-group[data-expanded=true] > .card { position: relative; left: auto; top: auto; }
.permanent-group[data-expanded=true] .attachment-toggle { left: 0; }
.counter-badge { display: none; }
.battlefield .counter-badge:not([hidden]) {
  display: block; position: absolute; top: 28px; left: 6px; max-width: calc(100% - 12px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; z-index: 2;
  padding: 2px 5px; font-size: 11px; line-height: 1.2; color: var(--ink); background: #20342d;
}
@media (max-height: 1000px) and (min-width: 701px) {
  .land-row .permanent-group { --group-card-width: calc(var(--cw) * .75); --group-card-height: calc(var(--ch) * .6875); }
}

/* A quiet turn ladder above the action; exact steps remain in native settings. */
#phase-track { display: flex; width: 244px; gap: 2px; margin: 0 0 10px -28px; justify-content: flex-end; }
#phase-track[hidden] { display: none; }
#phase-track .phase-step { position: relative; flex: 1 0 auto; min-width: 0; padding: 7px 2px 11px; border: 0; border-bottom: 1px solid #687277; border-radius: 0; background: #11191de0; color: #bec6c9; font-size: 12px; line-height: 1.2; white-space: nowrap; box-shadow: none; }
#phase-track .phase-step[aria-current=step] { color: #f8e1ab; border-bottom-color: #f8e1ab; background: #3b3425; }
#phase-track .phase-step[aria-current=step]::before { content: ''; position: absolute; bottom: -4px; left: calc(50% - 3px); width: 6px; height: 6px; background: #f8e1ab; transform: rotate(45deg); }
#phase-track .phase-step:hover { color: #fff; background: #36434a; }
#phase-track .phase-step:focus-visible { outline: 2px solid #9ccee0; outline-offset: 2px; z-index: 1; }
#phase-track .phase-stop-marker { position: absolute; width: 4px; height: 4px; bottom: 3px; left: calc(50% - 2px); background: #ead09a; border-radius: 50%; }
#phase-track[data-seat=others] .phase-stop-marker { background: #9ccee0; }
#phase-track .phase-step[data-stops="0"] .phase-stop-marker { display: none; }
#match[data-choosing=true] #phase-track { display: none; }

@media (min-width: 901px) {
  .match-menu:has(#phase-settings[open]) .match-menu-panel { width: 360px; }
  #phase-stops-form thead th:not(:first-child) { white-space: nowrap; font-size: 12px; }
  #phase-stops-form td { width: 76px; }
}

/* Library arrangement uses full offered cards around an unnamed fixed block. */
#match[data-arranging=true] #decision { left: 50%; right: auto; top: 24px; bottom: auto; transform: translateX(-50%); width: min(1000px, calc(100% - 48px)); height: min(660px, calc(100% - 48px)); max-height: calc(100% - 48px); display: flex; flex-direction: column; padding: 24px; background: #121b20fa; box-shadow: 0 16px 40px #0008; }
#match[data-arranging=true] .phase-bar, #match[data-arranging=true] #decision > .decision-actions, #match[data-arranging=true] #priority-hold, #match[data-arranging=true] #hold-status { display: none; }
#match[data-arranging=true] #prompt { font: 700 22px/1.25 Georgia, serif; margin-bottom: 12px; }
#choice .arrange-destinations { display: flex; gap: 16px; margin: 16px 0; }
.arrange-destination { flex: 1; padding: 14px; text-align: center; border: 1px dashed #8c9b9f; color: #f0eee7; font-size: 14px; }
#choice .arrange-options { display: flex; align-items: flex-start; gap: 24px; max-height: none; overflow: auto; padding: 8px 4px 16px; }
#choice .arrange-card { flex: 0 0 176px; padding: 0; border: 0; }
.arrange-position { display: block; margin-bottom: 8px; font-size: 12px; color: #bec6c9; }
#choice .arrange-face { display: block; position: relative; padding: 0; width: 164px; height: 228px; overflow: hidden; background: #202c32; border: 0; border-radius: 8px; box-shadow: 0 6px 14px #0007; }
.arrange-face img { display: block; width: 100%; height: 100%; object-fit: contain; }
.arrange-name { position: absolute; bottom: 0; left: 0; right: 0; padding: 6px; background: #11191bf2; font-size: 14px; }
.arrange-face:has(img:not([hidden])) .arrange-name { position: static; display: block; }
.arrange-face:hover { filter: brightness(1.1); }
.arrange-face:focus-visible { outline: 2px solid #ead09a; outline-offset: 3px; }
#choice .arrange-card .decision-actions { display: flex; flex-wrap: wrap; gap: 4px; }
#choice .arrange-card button[data-move] { font-size: 12px; padding: 6px 9px; }
.arrange-library { display: flex; flex-direction: column; justify-content: center; flex: 0 0 164px; align-self: stretch; min-height: 228px; padding: 20px; background: #202a2f; border: 1px solid #65747b; text-align: center; font-size: 14px; }
.arrange-library span { display: block; margin-top: 12px; color: #bec6c9; }
#choice .arrange-status { min-height: 21px; margin: 4px 0 12px; font-size: 14px; color: #bec6c9; }

#choice .arrange-peek { float: right; margin: 0 0 12px 16px; font-size: 14px; }
#match[data-arrange-peeking=true] #decision { left: auto; right: 22px; top: auto; bottom: 38px; transform: none; width: 280px; padding: 16px; }
#match[data-arrange-peeking=true] #prompt { font: 600 14px/1.4 system-ui, sans-serif; }
#match[data-arrange-peeking=true] #choice > :not(.arrange-intro) { display: none; }
#match[data-arrange-peeking=true] #choice .arrange-peek { float: none; margin: 0; }

#match[data-arranging=true] #choice { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#match[data-arranging=true] #prompt { flex-shrink: 0; }
#choice .arrange-intro { display: flex; align-items: flex-start; gap: 16px; flex-shrink: 0; }
#choice .arrange-intro p { flex: 1; margin: 0; font-size: 14px; }
#choice .arrange-intro .arrange-peek { float: none; margin: 0; flex-shrink: 0; }
#choice .arrange-destinations { flex-shrink: 0; margin: 12px 0; }
#choice .arrange-options { flex: 1; min-height: 0; margin: 0; }
#choice .arrange-status, #match[data-arranging=true] #choice > button.primary { flex-shrink: 0; }
#match[data-arranging=true] #choice > button.primary { align-self: center; }
#match[data-arrange-peeking=true] #decision { height: auto; display: block; }
#match[data-arrange-peeking=true] #choice > .arrange-intro { display: block; }
#match[data-arrange-peeking=true] .arrange-intro p { display: none; }

/* Token piles: identical tokens share one stack with a count pill; each token is still its own native button. */
.permanent-group[data-pile=true] { --peek: calc(9px * var(--row-scale, 1)); }
.permanent-group[data-pile=true] > .card { top: calc(var(--attachment-index) * -2px); }
.permanent-group[data-pile=true] > .card.pile-card[data-attachment-index='0'] { box-shadow: 0 6px 12px #000a; }
.permanent-group[data-pile=true] .attachment-toggle {
  top: -9px; left: auto; right: -6px; min-height: 22px; padding: 0 8px; border-radius: 11px;
  background: #2b3a40; border: 1px solid #5d6d74; color: #f0eee7; font: 700 13px/20px Georgia, serif; z-index: 30;
}
.permanent-group[data-pile=true] .attachment-toggle:hover { color: var(--accent); text-decoration: none; }
.permanent-group[data-pile=true][data-expanded=true] .attachment-toggle { left: 0; right: auto; }

/* ===== Table design v2 (desktop) =====
   Player medallions (life, portrait, counts, command cards) sit in the corners by the action window; each side's lands take the
   row the medallion used to occupy; the hand is tucked a quarter of its height below the window and rises on hover. */
@media (min-width: 701px) {
  .playing { --card-height: clamp(52px, calc(((100dvh - 380px) / 2 - 36px) / 1.32), 116px); --card-width: calc(var(--card-height) * 1.1667); --hand-w: 106px; --tuck: calc(var(--hand-w) * 1.3934 * .25); }
  /* overflow: clip cannot be scrolled by focus or hover, so the tucked hand never shifts the board. */
  .playmat { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr) auto 132px; overflow: clip; }
  /* Lands: direct children of the playmat, in the rows above and below the creature rows. */
  .playmat > .land-row { grid-column: 1; display: flex; flex-wrap: nowrap; align-items: center; justify-content: safe center; gap: 6px; min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; z-index: 2; }
  #opponent-lands { grid-row: 1; padding: 10px 330px 10px 22px; }
  #your-lands { grid-row: 4; padding: 10px 500px 10px 22px; }
  .playmat > .land-row.drop-hover { background: #34453c55; }
  .playmat > .land-row .card { width: calc(var(--cw) * .75); height: calc(var(--ch) * .6875); }
  .playmat > .land-row .permanent-group { --group-card-width: calc(var(--cw) * .75); --group-card-height: calc(var(--ch) * .6875); }
  #opponent-permanents, #your-permanents { grid-column: auto; grid-row: auto; }
  .battlefield, .battlefield.yours, .battlefield:not(.yours) { grid-column: 1; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); padding: 8px 22px; gap: 0; }
  .battlefield { grid-row: 2; }
  .battlefield.yours { grid-row: 3; }
  .battlefield > .card-row:not(.land-row), .battlefield:not(.yours) > .card-row:not(.land-row) { grid-column: 1; grid-row: 1; height: auto; align-self: stretch; padding: 10px 16px; }
  /* Medallion corners. The seat sections stop being grid rows and anchor to the playmat. */
  .seat, .seat.opponent { position: absolute; grid-row: auto; z-index: 9; padding: 0; pointer-events: none; }
  .seat > * { pointer-events: auto; }
  .seat:not(.opponent) { right: 252px; bottom: 142px; flex-direction: row-reverse; align-items: flex-end; gap: 10px; }
  .seat.opponent { right: 150px; top: 8px; flex-direction: row-reverse; align-items: flex-start; gap: 10px; }
  .seat .command-row, .seat.opponent .command-row { position: static; transform: none; left: auto; top: auto; margin: 0; align-self: center; }
  .seat .seat-heading { padding-bottom: 26px; }
  .seat .player-label, .seat.opponent .player-label { top: calc(100% + 40px); bottom: auto; left: 50%; right: auto; transform: translateX(-50%); font-size: 12px; }
  .seat .seat-heading > span { margin-top: 18px; }
  .seat:not(.opponent) #mana { right: auto; left: calc(100% + 8px); top: auto; bottom: 0; max-width: 200px; }
  /* Hand: a quarter of every card sits below the window edge; hovering lifts it fully into view. */
  .hand { overflow: visible; }
  .hand .card-row { height: 132px; padding: 14px 24px 0; overflow: visible; }
  .hand .card-row[data-overflow=true] { overflow-x: auto; overflow-y: visible; }
  .hand .card { width: var(--hand-w); margin-bottom: calc(var(--tuck) * -1); }
  .hand .card:hover, .hand .card:focus-visible { transform: translateY(calc(var(--tuck) * -1 - 12px)) rotate(0deg) scale(1.75); }
  .hand .card-row[data-overflow=true] .card:hover, .hand .card-row[data-overflow=true] .card:focus-visible { transform: translateY(calc(var(--tuck) * -1 - 8px)) rotate(0deg) scale(1.04); }
  /* Graveyards & exile: a small chip at the bottom-left instead of a full-width bar. */
  .zones { position: absolute; left: 10px; bottom: 10px; z-index: 30; grid-row: auto; padding: 4px 10px; border-radius: 6px; background: #121b20e6; }
  .zones[open] { left: 0; right: 0; bottom: 0; padding: 8px 12px; border-radius: 0; }
  .rail #decision { bottom: 18px; }
  /* The stack sits below the opponent's corner medallion. */
  .rail .stack { top: 214px; }
}

/* Auto-pass countdown: the Pass priority button fills over the 6 seconds (compositor-driven, so it keeps moving even while the page
   is busy). Interrupting freezes it in an outlined "paused" state. */
#ok { position: relative; overflow: hidden; isolation: isolate; }
#ok[data-autopass=counting]::before { content: ''; position: absolute; inset: 0; z-index: -1; background: #fff6; transform-origin: 0 50%; animation: autopass-fill 3s linear forwards; }
#ok[data-autopass=paused] { outline: 2px dashed var(--accent); outline-offset: 2px; }
@keyframes autopass-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) { #ok[data-autopass=counting]::before { animation: none; transform: scaleX(.5); } }
.autopass-setting { display: block; margin: 0 0 12px; }

/* Mana/tap symbols (see mana-symbols.js): the token text stays in the DOM but is hidden behind the drawn icon. */
.mana { display: inline-block; width: 1.4em; height: 1.4em; margin: 0 .08em; vertical-align: -.34em; overflow: hidden; white-space: nowrap; text-indent: 3em; color: transparent; font-size: inherit; line-height: 1; background-size: contain; background-repeat: no-repeat; background-position: center; border-radius: 50%; box-shadow: 0 1px 1px #0008; user-select: all; }

/* The same fill on a notice's Continue button. */
#choice > button.primary { position: relative; overflow: hidden; isolation: isolate; }
#choice > button.primary[data-autopass=counting]::before { content: ''; position: absolute; inset: 0; z-index: -1; background: #fff6; transform-origin: 0 50%; animation: autopass-fill 3s linear forwards; }
#choice > button.primary[data-autopass=paused] { outline: 2px dashed var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { #choice > button.primary[data-autopass=counting]::before { animation: none; transform: scaleX(.5); } }
