
:root {
  color-scheme: dark;
  --ink: #edf5ff;
  --muted: #9aafc0;
  --gold: #e8bd63;
  --edge: #35495b;
  --tile: #183247;
  --tile-dark: #142a3c;
}

* { box-sizing: border-box; }

/* Shared interface font, including native controls and inherited placement hints. */
input, select, textarea { font-family: var(--ui-font); }

body {
  min-width: 0;
  height: 100vh;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--ui-font);
  background:
    radial-gradient(circle at 50% 10%, #385675 0, transparent 38%),
    linear-gradient(135deg, #07131e, #102334 52%, #060b10);
}

.game-table {
  display: flex;
  width: min(1180px, 100vw);
  height: 100vh;
  flex-direction: column;
  margin: 0 auto;
  padding: 14px 32px 8px;
  background: linear-gradient(90deg, rgba(179, 138, 74, .08), transparent 12%, transparent 88%, rgba(179, 138, 74, .08));
}

.game-header, .status-bar { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.game-header { flex: 0 0 auto; border-bottom: 1px solid rgba(232, 189, 99, .45); padding-bottom: 9px; }
.eyebrow { margin: 0 0 2px; color: var(--gold); font: 700 .7rem/1 var(--ui-font); letter-spacing: .2em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.5rem); letter-spacing: .2em; text-shadow: 0 2px 10px #000; }

button {
  padding: 10px 14px;
  border: 1px solid var(--gold);
  border-radius: 4px;
  color: #1a1720;
  background: linear-gradient(#f5d88d, #c7953f);
  font: 700 .78rem/1 var(--ui-font);
  cursor: pointer;
}
button:hover { filter: brightness(1.12); }

.player-area { display: grid; flex: 0 0 auto; justify-items: center; gap: 3px; padding: 4px 0; }
.opponent-area { padding-top: 7px; }
.hand { display: flex; min-height: 31px; align-items: center; justify-content: center; }
.card, .card-back { width: 29px; height: 40px; margin-left: -6px; border: 1px solid #bfdbed; border-radius: 4px; box-shadow: 0 3px 6px #03080d; }
.card { display: grid; place-items: center; background: linear-gradient(145deg, #305d77, #142b3b); font: 700 .53rem/1 var(--ui-font); transform: rotate(-5deg); }
.card:nth-child(2) { transform: rotate(-2deg); }.card:nth-child(3) { transform: rotate(0); }.card:nth-child(4) { transform: rotate(2deg); }.card:nth-child(5) { transform: rotate(5deg); }
.card-back { background: repeating-linear-gradient(45deg, #273c50 0 4px, #a78445 4px 6px); }

.playmat {
  position: relative;
  isolation: isolate;
  display: grid;
  width: min(540px, 60vw, calc(100vh - 325px));
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  padding: 6px;
  border: 1px solid rgba(213, 233, 241, .22);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(9, 27, 40, .88), rgba(31, 51, 63, .72));
  box-shadow: inset 0 0 18px rgba(0, 0, 0, .45), 0 4px 12px rgba(0, 0, 0, .3);
  overflow: hidden;
}
.playmat::before {
  position: absolute;
  z-index: 0;
  inset: 0;
  background: center / cover url("assets/player-mat-concept.jpg");
  content: "";
  opacity: .09;
}
.playmat > * { position: relative; z-index: 1; }
.mat-slot, .mat-zone {
  min-width: 0;
  aspect-ratio: .72;
  border: 1px solid rgba(220, 243, 250, .35);
  border-radius: 3px;
  background: linear-gradient(135deg, rgba(190, 225, 236, .21), rgba(104, 144, 161, .08));
  box-shadow: inset 0 1px rgba(255, 255, 255, .14), 0 3px 6px rgba(0, 0, 0, .26);
}
.mat-slot { backdrop-filter: blur(2px); }
.playmat :is(.mat-slot, .mat-zone), .market-slots .mat-slot {
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
@media (hover: hover) {
  .playmat :is(.mat-slot, .mat-zone):hover, .market-slots .mat-slot:hover {
    border-color: #c2ecd397;
    box-shadow: inset 0 0 12px #b1e5d52b, 0 0 9px #b1e5d538;
  }
}
.playmat :is(.mat-slot, .mat-zone):focus-visible, .market-slots .mat-slot:focus-visible {
  outline: 1px solid #c2ecd3; outline-offset: 2px;
}
.mat-zone { display: grid; place-items: center; padding: 3px; }
.named-zone { color: #eaf5f5; font: 600 clamp(.32rem, .65vw, .5rem)/1 var(--ui-font); letter-spacing: .025em; text-align: center; text-shadow: 0 1px 2px #000; }
.named-zone img { display: block; width: 66%; max-height: 64%; object-fit: contain; filter: drop-shadow(0 1px 2px #000); }
.named-zone.library img { width: 82%; }
.named-zone.recycling img { width: 86%; }
.named-zone span { margin-top: 1px; }

.board-section { display: grid; min-height: 0; flex: 1 1 auto; place-items: center; perspective: 1000px; padding: 3px 0; }
.board-frame { width: min(520px, 56vw, calc(100vh - 440px)); padding: 8px; border: 2px solid #b38a4a; border-radius: 4px; background: linear-gradient(135deg, #563e22, #22170d 55%, #71542c); box-shadow: 0 20px 28px rgba(0,0,0,.58), inset 0 0 16px #000; transform: rotateX(29deg); transform-origin: center center; }
.board { display: grid; grid-template-columns: repeat(16, 1fr); aspect-ratio: 1; border: 1px solid #8eacc0; background: #0b1c29; }

.tile { position: relative; min-width: 0; aspect-ratio: 1; border: 1px solid rgba(154, 192, 212, .15); color: transparent; background: var(--tile); cursor: pointer; }
.tile:nth-child(16n + 1), .tile:nth-child(16n + 2), .tile:nth-child(16n + 3), .tile:nth-child(16n + 4), .tile:nth-child(16n + 5), .tile:nth-child(16n + 6), .tile:nth-child(16n + 7), .tile:nth-child(16n + 8) { background: var(--tile-dark); }
.tile.hidden::after { position: absolute; inset: 15%; border: 1px solid rgba(184, 215, 230, .18); border-radius: 50%; content: ""; }
.tile.revealed { color: #edfaff; }
.tile.revealed::before { position: absolute; inset: 0; display: grid; place-items: center; content: attr(data-symbol); font: 700 clamp(.5rem, 1.2vw, .9rem)/1 var(--ui-font); }
.tile.neutral { --tile-art: url("assets/tiles/neutral.png"); }
.tile.mountain { --tile-art: url("assets/tiles/mountain.png"); }
.tile.portal { --tile-art: url("assets/tiles/portal.png"); }
.tile.blackhole { --tile-art: url("assets/tiles/blackhole.png"); }
.tile.treasure { --tile-art: url("assets/tiles/treasure.png"); }
.tile.stronghold-earth { --tile-art: url("assets/tiles/stronghold-earth.png"); }
.tile.stronghold-dark { --tile-art: url("assets/tiles/stronghold-dark.png"); }
.tile.stronghold-water { --tile-art: url("assets/tiles/stronghold-water.png"); }
.tile.stronghold-light { --tile-art: url("assets/tiles/stronghold-light.png"); }
.tile.stronghold-fire { --tile-art: url("assets/tiles/stronghold-fire.png"); }
.tile.stronghold-air { --tile-art: url("assets/tiles/stronghold-air.png"); }
.tile.air { --tile-art: url("assets/tiles/air.png"); }
.tile.earth { --tile-art: url("assets/tiles/earth.png"); }
.tile.fire { --tile-art: url("assets/tiles/fire.png"); }
.tile.water { --tile-art: url("assets/tiles/water.png"); }
.tile.light { --tile-art: url("assets/tiles/light.png"); }
.tile.dark { --tile-art: url("assets/tiles/dark.png"); }
/* Artwork replaces the temporary letters only after the tile is revealed. */
.board .tile.revealed {
  background: #182a30 var(--tile-art) center / contain no-repeat;
}
.tile.revealed::before { content: none; }
.tile.movable { outline: 2px solid #79f0c0; outline-offset: -3px; box-shadow: inset 0 0 12px rgba(121, 240, 192, .55); }
.tile.selected { outline: 3px solid #ffe18c; outline-offset: -3px; z-index: 2; }
.piece { position: absolute; z-index: 3; top: 50%; left: 50%; display: grid; width: 74%; aspect-ratio: 1; place-items: center; border: 2px solid #f9db8d; border-radius: 50%; color: #13202a; background: radial-gradient(circle at 35% 30%, #fff2bf, #c88e32 72%); box-shadow: 0 2px 5px #000; font: 800 clamp(.45rem, 1.05vw, .78rem)/1 var(--ui-font); transform: translate(-50%, -50%) rotateX(-29deg); }
.piece.player-two { border-color: #cce7ff; background: radial-gradient(circle at 35% 30%, #e8f5ff, #477ba5 72%); }

.status-bar { min-height: 25px; flex: 0 0 auto; border-top: 1px solid rgba(232, 189, 99, .35); padding-top: 7px; color: #d9e6ed; font: .72rem/1.2 var(--ui-font); }
#setup-status { color: var(--muted); text-align: right; }

@media (max-height: 700px) {
  .game-table { padding-top: 8px; }
  .card, .card-back { width: 24px; height: 34px; }
  .hand { min-height: 25px; }
  .playmat { gap: 3px; padding: 4px; }
  h1 { font-size: 1.5rem; }
}

@media (max-width: 700px) {
  .game-table { padding-left: 12px; padding-right: 12px; }
  #setup-status { display: none; }
}

/* One camera and one fitted surface for the entire physical table. */
html, body { width: 100%; height: 100%; }
.game-table {
  /* Screen-space controls follow the viewport, including ultrawide monitors. */
  width: 100%; max-width: none; height: 100dvh;
  padding: 16px 16px 12px;
  background: none;
}
.game-header { min-width: 0; gap: 12px; }
.header-controls { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px 12px; min-width: 0; }
.tile-revealer { display: flex; gap: 3px; padding: 5px; margin: 0; border: 1px solid #b5e2d633; border-radius: 9px; font: 11px var(--ui-font); }
.tile-revealer legend { color: #c0d6d0; padding: 0 5px; }
.tile-revealer small { color: #e8bd63; font-size: 8px; letter-spacing: .1em; margin-left: 5px; }
.tile-revealer label { position: relative; cursor: pointer; }
.tile-revealer input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; }
.tile-revealer span { display: block; padding: 6px 9px; border: 1px solid transparent; border-radius: 5px; color: #8fa9a1; }
.tile-revealer input:checked + span { background: #a7edcd20; color: #e7fff3; border-color: #a7edcd66; }
.tile-revealer input:focus-visible + span { outline: 2px solid #c2ffe2; outline-offset: 2px; }
@media (max-width: 750px) { .game-header { flex-wrap: wrap; } .header-controls { gap: 8px; } }
.game-header h1 { font-size: clamp(1.2rem, 2.6vw, 2rem); }
.game-header .brand-logo {
  position: relative; flex: 0 0 auto; width: clamp(210px, 23vw, 300px);
  aspect-ratio: 1610 / 352; margin: 0; overflow: hidden; line-height: 0;
}
/* Frame the visible logo (x=200, y=852, 1610×352); preserve the original PNG. */
.brand-logo img {
  position: absolute; display: block; width: 124.223603%; max-width: none;
  height: auto; left: -12.42236%; top: -242.045455%;
  filter: drop-shadow(0 1px 1px #0006);
}
@media (max-width: 700px) { .game-header .brand-logo { width: 220px; max-width: 65vw; } }
@media (max-height: 600px) and (min-width: 701px) { .game-header .brand-logo { width: 210px; } }
#new-game { flex-shrink: 0; }
.table-stage { position: relative; flex: 1; min-height: 0; min-width: 0; }
.table-fit {
  position: absolute; top: 50%; left: 50%; width: 940px;
  transform: translate(calc(-50% + var(--pan-x, 0px)), calc(-50% + var(--pan-y, 0px))) scale(var(--table-scale, .5));
  transform-origin: center;
}
.table-plane {
  --mat-slot-width: 58.6px;
  --table-tilt: 39deg;
  /* Screen-facing sprites compensate the board's foreshortening, not their images. */
  --piece-camera-compensation: 1.286759566;
  --piece-camera-compensation: calc(1 / cos(var(--table-tilt)));
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 22px; width: 940px; padding: 24px 20px;
  transform: perspective(2400px) rotateX(var(--table-tilt));
  transform-origin: center;
  border: 0;
  background: none;
  box-shadow: none;
}
/* Four independent edges; never stretch the arena to include the mats. */
.royale-side-area[hidden], .royale-market[hidden] { display:none !important; }
.mat-seat-label { display:none; }
.game-table[data-format='battle-royale'][data-camera='default'] :is(.table-fit,.table-plane) { width:900px; }
.game-table[data-format='battle-royale'][data-camera='default'] .table-plane { height:900px; padding:0; display:block; }
.game-table[data-format='battle-royale'][data-camera='default'] .board-section { position:absolute; left:200px; top:200px; width:500px; height:500px; padding:0; margin:0; }
.game-table[data-format='battle-royale'][data-camera='default'] .player-area { position:absolute; width:500px; left:200px; top:732px; margin:0; padding:0; }
.game-table[data-format='battle-royale'][data-camera='default'] .opponent-area { top:24px; }
.game-table[data-format='battle-royale'][data-camera='default'] .playmat { --mat-slot-width:42px; width:500px; gap:6px; padding:10px; }
.game-table[data-format='battle-royale'][data-camera='default'] .royale-west { left:-158px; top:382px; transform:rotate(90deg); }
.game-table[data-format='battle-royale'][data-camera='default'] .royale-east { left:558px; top:382px; transform:rotate(-90deg); }
.game-table[data-format='battle-royale'] .royale-side-area .playmat { transform:none; }
/* Keep edge pieces and their crown/readout layer in front of mat captions. */
.game-table[data-format='battle-royale'] .player-area { z-index: 1; }
.game-table[data-format='battle-royale'] .board-section { z-index: 2; }
.game-table[data-format='battle-royale'] .mat-seat-label { display:block; position:absolute; left:10px; bottom:calc(100% + 6px); max-width:95%; color:var(--mat-owner-color); font:10px var(--ui-font); letter-spacing:.04em; white-space:nowrap; }
.game-table[data-format='battle-royale'] .playmat { border-color:color-mix(in srgb,var(--mat-owner-color) 30%,transparent); }
.game-table[data-format='battle-royale'] .mat-current { box-shadow:0 0 18px color-mix(in srgb,var(--mat-owner-color) 18%,transparent); }
.game-table[data-format='battle-royale'] .mat-eliminated { opacity:.45; }
.game-table[data-format='battle-royale'] > .opponent-hand-anchor { display:none; }
.game-table[data-format='battle-royale'] .board-section { --board-art-top:0px; --board-art-bottom:0px; }
.game-table[data-format='battle-royale'] .arena-scenery { display:block; inset:0; }
.royale-stone-surface { position:absolute; inset:0; width:500px; height:500px; border:2px solid #7d828761; box-shadow:0 12px 36px #0008,0 0 0 5px #181b1e; filter:saturate(.35) brightness(.85); }
.game-table[data-format='battle-royale'][data-camera='mat'] .royale-side-area { display:none; }
.royale-market { margin:0 0 10px; border-bottom:1px solid #ffffff17; padding-bottom:8px; }
.royale-market > summary { display:flex; align-items:center; gap:8px; list-style:none; color:#e2e6ea; cursor:pointer; font:12px var(--ui-font); padding:4px 0; }
.royale-market > summary::-webkit-details-marker { display:none; }
.royale-market > summary img { width:20px; height:20px; object-fit:contain; opacity:.8; }
.royale-market > summary small { margin-left:auto; color:#9ca5b0; }
.market-chevron { transition:transform .2s; }
.royale-market[open] .market-chevron { transform:rotate(180deg); }
.royale-market .market-panel { position:static; transform:none; width:100%; padding:10px 0 2px; border:0; background:none; box-shadow:none; backdrop-filter:none; }
.royale-market .market-emblem { display:none; }
.royale-market .market-slots { grid-template-columns:repeat(6,minmax(0,1fr)); gap:4px; }
.royale-market .market-card small { display:none; }
.royale-market .market-slots .mat-slot { min-width:0; }
.summary-roster.royale-roster { grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; }
.royale-roster .roster-pair { min-width:0; }
.player-area, .opponent-area { width: 720px; padding: 0; gap: 14px; }
.playmat.opponent-mat { transform: rotate(180deg); transform-origin: center; }
.hand { height: 46px; min-height: 0; }
.card, .card-back { width: auto; height: 44px; aspect-ratio: 11 / 15; }
.playmat {
  width: 680px; height: auto;
  grid-template-columns: repeat(10, var(--mat-slot-width));
  grid-template-rows: repeat(2, auto);
  padding: 10px; gap: 8px;
}
.mat-slot, .mat-zone { min-height: 0; aspect-ratio: 11 / 15; }
.named-zone { font-size: 8px; grid-template-rows: minmax(0, 1fr); }
.named-zone img { height: 100%; max-height: 42px; }
.playmat::before { display: none; }
.board-section { width: 720px; flex: none; padding: 0; perspective: none; }
.board-frame { width: 500px; height: 500px; transform: none; padding: 9px; }
.board {
  width: 100%; height: 100%; min-width: 0; min-height: 0;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  grid-template-rows: repeat(16, minmax(0, 1fr));
}
.tile { padding: 0; min-height: 0; width: 100%; height: 100%; border-radius: 0; }
.piece { transform: translate(-50%, -50%); font-size: 11px; }
.board .tile .board-piece {
  /* This zero-height anchor is the contact point, not the sprite's centre. */
  top: 62%; width: 72%; height: 0; aspect-ratio: auto;
  transform: translate(-50%, 0); transform-origin: 50% 0;
  border: 0; border-radius: 0; background: none; box-shadow: none; overflow: visible;
  pointer-events: none;
}
.board-piece::before {
  content: ''; position: absolute; left: 8%; top: -3px; width: 84%; height: 5px;
  border-radius: 50%; background: #0005; filter: blur(1px);
}
.piece-visual {
  position: absolute; bottom: 0; left: 0; width: 100%;
  transform-origin: 50% 100%; transform: scaleY(var(--piece-camera-compensation));
}
.piece-art { display: block; width: 100%; height: auto; pointer-events: none; filter: drop-shadow(0 1px 1px #0009); transition: filter 240ms ease; }
.board .tile.king-ready .piece-art { filter: drop-shadow(0 0 2px var(--piece-glow)) drop-shadow(0 0 4px var(--piece-glow)); }
.piece-badge { position: absolute; left: 50%; top: -6px; transform: translateX(-50%); z-index: 5; white-space: nowrap; pointer-events: none; background: none; border: 0; padding: 0; box-shadow: none; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.king-crown { top: auto; bottom: calc(100% + 2px); width: 10px; line-height: 0; opacity: .92; }
.king-crown img { display: block; width: 100%; height: auto; filter: drop-shadow(0 0 2px #ffe5a6); }
.player-two .king-crown img { filter: drop-shadow(0 0 2px #a9d7ff); }
.creature-stats { top: auto; bottom: calc(100% + 2px); color: #fff; font: bold 10px/1 var(--ui-font); }
/* Readouts share a board-level layer: a hovered/selected tile or taller rear
   piece cannot cover a neighbour's Power. Invisible art retains exact sizing. */
.board-frame { position: relative; }
.board-piece-labels { position: absolute; inset: 0; z-index: 30; pointer-events: none; }
.board-piece-labels .board-piece {
  width: 4.5%; height: 0; aspect-ratio: auto; transform: translate(-50%,0);
  border: 0; border-radius: 0; background: none; box-shadow: none; overflow: visible; pointer-events: none;
}
.board-piece-labels .piece-art { visibility: hidden; }
.board-piece-labels .board-piece::before { content: none; }
.board .tile .board-piece:not(.piece-with-inline-label) .piece-badge { visibility: hidden; }
.board .tile:has(.piece) { z-index: 4; }
.board .tile.piece-in-transit { z-index: 12; }
.king-moving .table-stage { pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  .playmat :is(.mat-slot, .mat-zone), .market-slots .mat-slot { transition: none; }
}
.status-bar { gap: 12px; font-size: 11px; }
/* Decorative arena skin is independent of tile types and game state. */
:root { --arena-skin: url("assets/forest-arena.svg"); }
body { background: radial-gradient(ellipse at 50% 40%, #253e3c, #101d27 58%, #060d15); }
.table-plane { gap: 30px; }
.board-section { position: relative; isolation: isolate; }
.arena-scenery {
  position: absolute; z-index: -1; inset: -28px 0;
  background: var(--arena-skin) center / 100% 100% no-repeat;
  pointer-events: none; filter: drop-shadow(0 18px 14px #0009);
}
.board-frame {
  background: linear-gradient(135deg, #85918890, #293c3890);
  border-color: #b2c8b49c; box-shadow: 0 6px 0 #182c2c, 0 12px 22px #0006;
}
.board { background: #183d3833; border-color: #afdbb488; }
.board .tile.hidden { background: rgba(22, 47, 53, .42); border-color: #b5dac039; }
.board .tile.hidden:nth-child(even) { background: rgba(40, 67, 64, .32); }
.board .tile.hidden::after { border-color: #d0e7dc18; }
.playmat { background: linear-gradient(135deg, #1b34424d, #38555138); border-color: #a9d9d62b; box-shadow: 0 5px 12px #0004; }
.player-hand {
  position: relative; z-index: 10; flex: 0 0 auto;
  height: clamp(100px, 17vh, 165px); min-height: 0; padding-top: 26px;
  gap: 0; align-items: flex-end;
}
.player-hand .card {
  --fan: 0deg; --lift: 0px;
  position: relative; display: flex; align-items: flex-end; justify-content: center;
  width: auto; height: clamp(108px, 15vh, 176px); aspect-ratio: 11 / 15; flex-shrink: 0;
  margin: 0 -8px; padding: 14px 4px;
  border: 2px solid #a7bca3; border-radius: 9px;
  background: radial-gradient(ellipse at 50% 30%, #81bbb14d, transparent 55%), linear-gradient(150deg, #2e5662, #101e2b);
  color: #f0e6bc; font: 700 12px var(--ui-font); letter-spacing: .12em;
  transform: translateY(var(--lift)) rotate(var(--fan)); transform-origin: center bottom;
  box-shadow: 0 2px 0 #56766e, 0 5px 7px #0006, inset 0 0 0 5px #101e27;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}
.player-hand .card::before {
  content: ""; position: absolute; inset: 10px 9px 35px;
  border: 1px solid #a5d4ca50; border-radius: 4px;
  background: radial-gradient(circle at 50% 45%, #aad5c733, transparent 60%);
}
.player-hand .card:nth-child(1) { --fan: -9deg; --lift: 7px; }
.player-hand .card:nth-child(2) { --fan: -4deg; --lift: 2px; }
.player-hand .card:nth-child(4) { --fan: 4deg; --lift: 2px; }
.player-hand .card:nth-child(5) { --fan: 9deg; --lift: 7px; }
.player-hand .card:hover, .player-hand .card:focus-visible {
  z-index: 20; transform: translateY(-36px) rotate(0) scale(1.22);
  border-color: #f4dda0; outline: 2px solid #b5e2d6;
  box-shadow: 0 16px 28px #000a, 0 0 22px #87d5bb55; filter: none;
}
.status-bar { position: relative; z-index: 12; background: transparent; border-top: 0; min-height: 26px; }
.player-dock { display: grid; grid-template-columns: minmax(0, 1fr) 290px; align-items: end; gap: 24px; flex: 0 0 auto; padding: 6px 0 8px; }
.player-dock .player-hand { min-width: 0; }
.player-summary { position: relative; z-index: 11; padding: 10px 12px; border: 1px solid #b5e2d62b; border-radius: 12px; background: linear-gradient(135deg, #243d45cc, #0d1d29e6); box-shadow: 0 8px 24px #0005; font: 10px var(--ui-font); color: #b5cac5; }
.summary-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.summary-name { color: #edf6ec; font: 600 14px var(--ui-font); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.coin-balance { display: flex; align-items: center; gap: 6px; color: #f5f8f6; font-size: 17px; }
.coin-balance img { width: 28px; height: 30px; object-fit: contain; }
.token-exchange { position: absolute; bottom: calc(100% + 8px); right: 0; width: min(290px, calc(100vw - 32px)); box-sizing: border-box; padding: 12px; border: 1px solid #b5e2d650; border-radius: 12px; background: #10252bf5; backdrop-filter: blur(18px); box-shadow: 0 12px 36px #0008; color: #d5e9e4; }
.token-exchange[hidden] { display: none; }
.exchange-heading { display: flex; align-items: center; justify-content: space-between; font-size: 12px; }
.token-exchange p { margin: 8px 0; line-height: 1.4; }
.exchange-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 6px; }
.exchange-options > div { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0; border-radius: 8px; background: #ffffff06; }
.exchange-options img { width: 30px; height: 30px; object-fit: contain; }
.exchange-options small { font-size: 9px; color: #a4bcb8; }
.exchange-options > div > div { display: flex; align-items: center; gap: 7px; }
#exchange-toggle, .token-exchange button { border: 1px solid #c4e6dc35; border-radius: 6px; background: #ffffff09; color: #dbede8; cursor: pointer; padding: 3px 7px; font: inherit; }
#exchange-toggle { font-size: 18px; }
.token-exchange button:disabled { opacity: .3; cursor: default; }
.token-exchange button:not(:disabled):hover, #exchange-toggle:not(:disabled):hover { background: #b5e2d62a; }
.token-exchange button:focus-visible, #exchange-toggle:focus-visible { outline: 2px solid #b5e2d6; outline-offset: 2px; }
#exchange-confirm { width: 100%; padding: 8px; color: #f4d791; border-color: #f4d79155; }
#exchange-hint { min-height: 28px; color: #a4bcb8; }
.summary-strongholds { display: flex; align-items: center; justify-content: space-between; }
.summary-strongholds strong { color: #e1ece6; margin-left: 3px; }
#summary-forts { display: flex; gap: 2px; }
#summary-forts img { width: 21px; height: 21px; object-fit: contain; opacity: .22; filter: grayscale(1); }
#summary-forts .controlled { opacity: 1; filter: drop-shadow(0 0 3px #a7dbb8); }
.summary-tokens { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin: 8px 0; }
.summary-tokens span { display: flex; gap: 3px; align-items: center; justify-content: center; }
.summary-tokens img { width: 24px; height: 24px; object-fit: contain; }
.summary-tokens strong { color: #eef4ef; font-variant-numeric: tabular-nums; }
#summary-coins { color: #fff; }
#exchange-toggle { transition: color 180ms ease, box-shadow 180ms ease, border-color 180ms ease; }
#exchange-toggle:disabled { opacity: .28; cursor: not-allowed; filter: none; }
#exchange-toggle.trade-ready {
  color: #ddffeb; border-color: #b6edce80;
  text-shadow: 0 0 6px #a0edc078;
  box-shadow: 0 0 9px #9fecc52a, inset 0 0 5px #9fecc512;
}
.bank-value, .summary-tokens > span { position: relative; }
.bank-value { display: inline-block; }
.bank-credited { animation: bank-credit 1000ms cubic-bezier(.22, .7, .3, 1) var(--bank-delay, 0ms) both; }
.bank-gain, .summary-tokens .bank-gain {
  position: absolute; display: block; left: 50%; top: -2px;
  color: var(--bank-color, #e4f5eb); font: 700 11px/1 var(--ui-font);
  white-space: nowrap; pointer-events: none; opacity: 0;
  text-shadow: 0 0 5px var(--bank-color, #e4f5eb);
  animation: bank-gain-rise 1000ms ease-in-out var(--bank-delay, 0ms) both;
}
@keyframes bank-credit {
  0% { transform: scale(1); filter: drop-shadow(0 0 0 transparent); }
  28% { transform: scale(1.13); filter: drop-shadow(0 0 5px var(--bank-color)); }
  65% { transform: scale(1.03); filter: drop-shadow(0 0 2px var(--bank-color)); }
  100% { transform: scale(1); filter: none; }
}
@keyframes bank-gain-rise {
  0% { transform: translate(-50%, 1px); opacity: 0; }
  25%, 65% { opacity: 1; }
  100% { transform: translate(-50%, -20px); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .bank-credited { animation: none; }
  .bank-gain, .summary-tokens .bank-gain { animation: none; display: none; }
  #exchange-toggle { transition: none; }
}
.summary-investments { display: grid; gap: 4px; border-top: 1px solid #c9e5d51c; padding-top: 7px; }
.investment-track { display: grid; grid-template-columns: 23px repeat(3, 1fr) 65px; gap: 6px; align-items: center; }
.investment-track > img { width: 20px; height: 20px; object-fit: contain; }
.investment-tier { border: 1px solid #bbddcc30; border-radius: 4px; padding: 5px 3px; text-align: center; color: #829d94; background: #142a30; font-size: 11px; }
.investment-tier:disabled { filter: none; }
.investment-tier.investment-ready { color: #ffe7ab; border-color: var(--gold); background: #604e263d; }
.investment-tier:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.investment-tier.achieved { color: #dcffee; background: #85d7ad28; border-color: #8fd8b5; }
.investment-track output { font-size: 9px; text-align: right; }
@media (max-width: 850px) {
  .player-dock { grid-template-columns: minmax(0, 1fr) 250px; gap: 10px; }
  .player-summary { padding: 8px; }
  .summary-tokens img { width: 19px; height: 19px; }
  #summary-forts img { width: 17px; height: 17px; }
  .player-dock .player-hand .card { height: 100px; }
}
@media (prefers-reduced-motion: reduce) { .player-hand .card { transition: none; } }

/* Original 825 × 1125 artwork: proportional crop trims only the outer black margin. */
.hand-hidden { height: 82px; gap: 4px; }
.hand-hidden .card-back {
  display: block;
  height: 78px; width: auto; aspect-ratio: 11 / 15; flex-shrink: 0;
  margin-left: -8px; border: 1px solid #9a9586; border-radius: 5px;
  background: #050606 url("assets/card-back.png") center / 112% auto no-repeat;
  box-shadow: 0 4px 9px #0009;
}

/* Opponent cards face the camera, preserving the artwork's width/height ratio. */
.opponent-hand-anchor { flex: 0 0 auto; height: clamp(48px, 8vh, 76px); }
.opponent-hand-anchor .hand-hidden .card-back { height: 100%; width: auto; aspect-ratio: 11 / 15; transform: perspective(600px) rotateX(-5deg) rotate(var(--back-fan, 0deg)); box-shadow: 0 2px 0 #646b60, 0 4px 6px #0006; }
.opponent-hand-anchor .card-back:nth-child(1) { --back-fan: -7deg; }
.opponent-hand-anchor .card-back:nth-child(2) { --back-fan: -3deg; }
.opponent-hand-anchor .card-back:nth-child(4) { --back-fan: 3deg; }
.opponent-hand-anchor .card-back:nth-child(5) { --back-fan: 7deg; }
/* Floating cutout presentation: no shared panel, blur or shadow behind either hand. */
.opponent-hand-anchor .hand-hidden, .player-dock, .player-dock .player-hand {
  background: transparent; border: 0; box-shadow: none; backdrop-filter: none;
  overflow: visible;
}
.game-header { border-bottom-color: transparent; }
.phase-tracker {
  position: absolute; z-index: 5; left: 0; top: 50%; transform: translateY(-50%);
  width: 140px; padding: 14px 10px;
  border: 1px solid #b5e2d61f; border-radius: 16px;
  background: linear-gradient(145deg, #20394160, #0c1b2360);
  backdrop-filter: blur(12px); font-family: var(--ui-font);
}
#phase-player { margin: 0 0 12px; color: #abc1bd; font-size: 10px; letter-spacing: .08em; text-align: center; }
.phase-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.phase-list li { display: flex; align-items: center; gap: 9px; min-height: 38px; padding: 5px 8px; color: #849898; font-size: 11px; border: 1px solid transparent; border-radius: 9px; }
.phase-list img { width: 27px; height: 27px; object-fit: contain; opacity: .35; transition: filter 180ms ease, opacity 180ms ease; }
.phase-list .is-complete { color: #759e93; }
.phase-list .is-current { color: #e6fff4; background: #90edc715; border-color: #a0f5d339; }
.phase-list .is-current img { opacity: 1; filter: drop-shadow(0 0 4px #8fffc8) drop-shadow(0 0 9px #67deb4); }
#next-phase { width: 100%; margin-top: 14px; padding: 10px 4px; background: #b1e2d514; border: 1px solid #b6edda45; color: #d9f4ea; border-radius: 8px; font-size: 10px; line-height: 1.3; }
#next-phase:hover { background: #b1e2d52b; }
#next-phase:focus-visible { outline: 2px solid #b5f4d8; outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.table-stage { container-type: size; }
.market-panel {
  position: absolute; z-index: 5; left: 820px; top: 50%;
  transform: translate(-50%, -50%) rotate(90deg);
  transform-origin: center;
  width: max-content;
  padding: 10px;
  border: 1px solid #a9d9d62b; border-radius: 12px;
  background: linear-gradient(135deg, #1b34424d, #38555138);
  box-shadow: 0 5px 12px #0004; backdrop-filter: blur(12px);
}
.market-emblem { display: block; width: 28px; height: 28px; object-fit: contain; margin: 0 auto 12px; opacity: .85; }
.market-slots { display: grid; grid-template-columns: repeat(6, var(--mat-slot-width)); gap: 8px; }
.market-slots .mat-slot { width: 100%; aspect-ratio: 11 / 15; }
@media (max-height: 720px) {
  .phase-tracker { padding: 8px; }
  .phase-list { gap: 3px; }
  .phase-list li { min-height: 29px; padding: 3px 6px; }
  .phase-list img { width: 23px; height: 23px; }
  #phase-player { margin-bottom: 6px; }
  #next-phase { margin-top: 8px; padding: 7px 3px; }
}
@media (max-width: 650px) { .phase-tracker { width: 90px; } .phase-list li { gap: 4px; padding: 3px; font-size: 9px; } }
@media (max-width: 600px) {
  #new-game { max-width: 140px; padding: 8px; font-size: 10px; }
  .game-table { padding: 10px; }
}

/* Screen-space hand and HUD, independent of tabletop camera zoom. */
.table-stage { overflow: visible; touch-action: none; user-select: none; }
/* Let the table render behind the cutout hand, not stop at the dock boundary.
   The viewport still clips the scene; screen-space controls stay above it. */
.game-table { isolation: isolate; }
.table-stage { z-index: 0; }
.game-header { position: relative; z-index: 20; }
.opponent-hand-anchor .hand-hidden { position: fixed; z-index: 10; left: 50%; top: 80px; transform: translateX(-50%); padding: 5px 0; pointer-events: none; }
.player-dock { z-index: 10; pointer-events: none; }
.player-dock :is(.card, .player-summary) { pointer-events: auto; }
.player-dock { position: relative; display: block; height: clamp(168px, 24dvh, 235px); padding: 0 0 12px; }
.player-dock .player-hand { position: absolute; bottom: 18px; left: 50%; transform: translate(-50%, var(--hand-retreat, 0px)); transition: transform 320ms cubic-bezier(.22,.75,.25,1); height: auto; padding: 0 14px; gap: 0; }
.player-dock .player-hand:has(.card:focus-visible) { transform: translate(-50%, 0); }
.game-table[data-placing='true'] .player-hand {
  transform: translate(-50%, var(--placement-hand-retreat, 240px));
  opacity: .25;
  pointer-events: none;
}
.game-table[data-placing='true'] .player-hand .card { pointer-events: none; }
#placement-hint {
  position: fixed; bottom: 16px; z-index: 24; transform: translateX(-50%);
  max-width: min(420px, 48vw); padding: 10px 18px; border-radius: 24px;
  background: #151a20ed; border: 1px solid #ffffff30; color: #edf2f7;
  box-shadow: 0 8px 32px #0006; backdrop-filter: blur(16px);
  font-family: var(--ui-font); font-size: 12px; font-weight: 500; line-height: 1.4; pointer-events: auto;
}
#placement-hint:disabled { opacity: 1; cursor: default; }
#placement-hint[hidden] { display: none; }
.game-table[data-battle-focus='true'] .player-hand {
  transform: translate(-50%, var(--battle-hand-retreat, 220px));
  transition: transform 800ms cubic-bezier(.22,.75,.25,1), opacity 500ms ease;
  opacity: .38;
  pointer-events: none;
}
.game-table[data-battle-focus='true'] .player-hand .card { pointer-events: none; }
.game-table .hand-hidden { transition: opacity 400ms ease; }
.game-table[data-battle-focus='true'] .hand-hidden { opacity: 0; }
.game-table[data-battle-focus='false'] .player-hand {
  transition: transform 800ms cubic-bezier(.22,.75,.25,1), opacity 500ms ease;
  opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
  .game-table[data-battle-focus] .player-hand { transition: none; }
  .game-table .hand-hidden { transition: none; }
}
@media (prefers-reduced-motion: reduce) { .player-dock .player-hand { transition: none; } }
.player-dock .player-hand .card { height: clamp(145px, 21dvh, 212px); width: min(22%, 155px); flex: 0 1 auto; min-width: 0; margin: 0 -5px; font-size: clamp(10px, 1vw, 14px); }
.player-dock .player-summary { position: absolute; right: 0; bottom: 12px; width: 290px; }
body, button, select, label, .tile, #exchange-toggle, .token-exchange button, .tile-revealer label, .investment-tier:disabled { cursor: url('assets/elven-cursor.svg') 3 2, auto; }
input:is([type="checkbox"], [type="radio"], [type="color"], [type="range"]), input::file-selector-button { cursor: url('assets/elven-cursor.svg') 3 2, pointer; }
input:disabled, select:disabled { cursor: not-allowed; }
button:disabled, .token-exchange button:disabled { cursor: not-allowed; }
.table-stage.is-panning, .table-stage.is-panning * { cursor: grabbing; }
@media (max-width: 1000px) {
  .player-dock { height: clamp(230px, 35dvh, 300px); }
  .player-dock .player-summary { bottom: 0; width: 100%; height: 100px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; padding: 8px 12px; }
  .summary-heading { margin-bottom: 0; }
  .summary-investments { grid-column: 2; grid-row: 1 / 3; border: 0; padding: 0; }
  .summary-strongholds { grid-column: 1; }
  .summary-tokens { grid-column: 1 / -1; margin: 4px 0 0; }
  .player-dock .player-hand { bottom: 116px; }
  .player-dock .player-hand .card { height: clamp(118px, 17dvh, 178px); width: auto; flex: 0 0 auto; aspect-ratio: 11 / 15; }
}
@media (max-width: 700px) {
  .phase-tracker { left: 0; top: 0; transform: none; width: 100%; padding: 5px; display: flex; align-items: center; gap: 5px; border-radius: 9px; }
  #phase-player { display: none; }
  .phase-list { display: flex; flex: 1; gap: 1px; justify-content: space-around; }
  .phase-list li { flex-direction: column; gap: 2px; padding: 3px; font-size: 8px; }
  .phase-list img { width: 21px; height: 21px; }
  #next-phase { width: 70px; flex: 0 0 70px; margin: 0; font-size: 9px; }
  .player-dock .player-hand .card { height: clamp(100px, 16dvh, 145px); max-width: 22%; flex-shrink: 1; margin: 0 -4px; padding-bottom: 12px; }
  .player-dock { height: clamp(224px, 33dvh, 268px); }
  .player-dock .player-summary { gap: 0 8px; padding: 6px; }
  .investment-track { gap: 3px; grid-template-columns: 18px repeat(3, 1fr) 52px; }
  .investment-track output { font-size: 8px; }
  .summary-strongholds { gap: 3px; font-size: 9px; }
  #summary-forts { gap: 0; }
  #summary-forts img { width: 13px; height: 13px; }
  .header-controls { width: 100%; justify-content: space-between; }
  .game-table { padding: 6px 10px; }
  .game-header { gap: 5px; padding-bottom: 4px; }
  .opponent-hand-anchor { height: 38px; }
  .player-hand .card:hover, .player-hand .card:focus-visible { transform: translateY(-20px) scale(1.12); }
}
@media (max-height: 600px) and (min-width: 701px) {
  .player-dock { height: 145px; }
  .player-dock .player-summary { width: 250px; height: auto; display: block; }
  .player-dock .player-hand { bottom: 15px; }
  .player-dock .player-hand .card { height: 118px; }
  .opponent-hand-anchor { height: 36px; }
  .game-table { padding-top: 6px; padding-bottom: 6px; }
}
.player-dock .player-hand .card { width: auto; max-width: none; flex: 0 0 auto; height: min(clamp(145px, 21dvh, 212px), var(--hand-card-limit, 212px)); }
@media (max-width: 1000px) { .player-dock .player-hand .card { height: min(clamp(118px, 17dvh, 178px), var(--hand-card-limit, 178px)); } }
@media (max-width: 700px) { .player-dock .player-hand .card { height: min(clamp(100px, 16dvh, 145px), var(--hand-card-limit, 145px)); } }
@media (max-height: 600px) and (min-width: 701px) { .player-dock .player-hand .card { height: min(118px, var(--hand-card-limit, 118px)); } }
@media (max-height: 500px) and (max-width: 700px) { body { overflow-y: auto; } .game-table { min-height: 600px; } }

/* Only the artwork fades: kings, focus rings and movement indicators stay legible. */
.board .tile { --element-glow: #b8d6cb; --reveal-motion: tile-earth; isolation: isolate; }
.board .tile.air, .board .tile.stronghold-air { --element-glow: #dbeef3; --reveal-motion: tile-air; }
.board .tile.earth, .board .tile.stronghold-earth { --element-glow: #a7cc72; --reveal-motion: tile-earth; }
.board .tile.fire, .board .tile.stronghold-fire { --element-glow: #ff9561; --reveal-motion: tile-fire; }
.board .tile.water, .board .tile.stronghold-water { --element-glow: #65d8ff; --reveal-motion: tile-water; }
.board .tile.light, .board .tile.stronghold-light { --element-glow: #fff0ad; --reveal-motion: tile-light; }
.board .tile.dark, .board .tile.stronghold-dark { --element-glow: #bd8df5; --reveal-motion: tile-dark; }
.board .tile.treasure { --element-glow: #edc779; --reveal-motion: tile-light; }
.board .tile.portal { --element-glow: #8fe5da; --reveal-motion: tile-air; }
.board .tile.blackhole { --element-glow: #ae9fdb; --reveal-motion: tile-dark; }
.board .tile.revealed { background: rgba(22, 47, 53, .2); }
.board .tile.revealed::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: var(--tile-art) center / contain no-repeat;
  opacity: .26; transition: opacity 180ms ease;
}
.board .tile.revealed::after {
  content: ""; position: absolute; inset: 5%; z-index: 1; pointer-events: none;
  border: 1px solid var(--element-glow); border-radius: 22%;
  background: radial-gradient(circle, transparent 25%, var(--element-glow) 100%);
  box-shadow: 0 0 7px var(--element-glow), inset 0 0 6px var(--element-glow);
  opacity: 0; transition: opacity 180ms ease;
}
.board .tile.revealed.is-revealing::before { animation: tile-art-reveal 2800ms ease-out var(--reveal-delay, 0ms) backwards; }
.board .tile.revealed.is-revealing::after { animation: var(--reveal-motion) 1150ms ease-in-out var(--reveal-delay, 0ms) backwards; }
.tile-sparks { position: absolute; inset: 0; z-index: 2; pointer-events: none; transform: rotate(var(--spark-angle)); }
.tile-sparks i {
  --drift: -8px; --rise: -13px; --wait: 0ms;
  position: absolute; left: 48%; top: 50%; width: 3px; height: 3px;
  border-radius: 50%; background: var(--element-glow); opacity: 0;
  box-shadow: 0 0 4px var(--element-glow);
  animation: var(--spark-motion, elemental-motes) 1050ms ease-out calc(var(--reveal-delay, 0ms) + var(--wait)) backwards;
}
.tile-sparks i:nth-child(2) { --drift: 10px; --rise: -7px; --wait: 110ms; width: 2px; height: 2px; }
.tile-sparks i:nth-child(3) { --drift: 3px; --rise: -17px; --wait: 210ms; }
.board .tile.fire, .board .tile.stronghold-fire { --spark-motion: ember-motes; }
.board .tile.air, .board .tile.stronghold-air { --spark-motion: wind-motes; }
.board .tile.water, .board .tile.stronghold-water { --spark-motion: water-motes; }
.board .tile.dark, .board .tile.stronghold-dark { --spark-motion: void-motes; }
.board .tile.light, .board .tile.stronghold-light { --spark-motion: light-motes; }
.board .tile.revealed:focus-visible::before { opacity: .56; }
.board .tile.revealed:focus-visible::after { opacity: .19; }
.board .tile:focus-visible { outline: 2px solid #d9eade; outline-offset: -2px; }
@media (hover: hover) {
  .board .tile.revealed:hover { filter: none; }
  .board .tile.revealed:hover::before { opacity: .56; }
  .board .tile.revealed:hover::after { opacity: .19; }
}
@keyframes tile-art-reveal {
  0% { opacity: .12; } 12%, 30% { opacity: 1; } 65% { opacity: .5; } 100% { opacity: .26; }
}
@keyframes tile-air {
  0% { opacity: 0; transform: rotate(-80deg) scale(.3, .6); border-radius: 50% 20%; }
  25% { opacity: .4; transform: rotate(15deg) scale(.85, .6); }
  52% { opacity: .26; transform: rotate(100deg) scale(.7, 1); border-radius: 20% 50%; }
  72% { opacity: .32; transform: rotate(185deg) scale(1, .7); }
  100% { opacity: 0; transform: rotate(260deg) scale(1.1); border-radius: 50%; }
}
@keyframes tile-earth {
  0% { opacity: 0; transform: translateY(12%) scale(.65); }
  22% { opacity: .4; transform: translate(-3%, -2%) rotate(-5deg) scale(.9); }
  38% { opacity: .3; transform: translate(3%, 2%) rotate(4deg) scale(.95); }
  56% { opacity: .36; transform: translate(-1%, -1%) rotate(-2deg) scale(1); }
  100% { opacity: 0; transform: translateY(0) scale(1.05); }
}
@keyframes tile-fire {
  0% { opacity: 0; transform: translateY(15%) scale(.6, .4); border-radius: 60% 30% 45% 35%; }
  22% { opacity: .5; transform: translate(-4%, -3%) skewX(-10deg) scale(.85, 1); }
  42% { opacity: .32; transform: translate(5%, -8%) skewX(12deg) scale(.65, 1.1); border-radius: 20% 70% 30% 60%; }
  62% { opacity: .45; transform: translate(-3%, -11%) skewX(-8deg) scale(.8, .95); }
  100% { opacity: 0; transform: translateY(-23%) scale(.4, 1.2); border-radius: 70% 20% 60% 30%; }
}
@keyframes tile-water {
  0% { opacity: 0; transform: scale(.25); border-radius: 50%; }
  25% { opacity: .4; transform: rotate(-12deg) scale(1, .75); border-radius: 35% 55%; }
  48% { opacity: .25; transform: rotate(8deg) scale(.8, 1); border-radius: 55% 35%; }
  70% { opacity: .32; transform: rotate(-5deg) scale(1.05, .9); }
  100% { opacity: 0; transform: scale(1.15); border-radius: 50%; }
}
@keyframes tile-light {
  0% { opacity: 0; transform: rotate(45deg) scale(.35); }
  25% { opacity: .5; transform: rotate(70deg) scale(.8); }
  48% { opacity: .24; transform: rotate(85deg) scale(.65); }
  68% { opacity: .38; transform: rotate(110deg) scale(.9); }
  100% { opacity: 0; transform: rotate(135deg) scale(1.05); }
}
@keyframes tile-dark {
  0% { opacity: 0; transform: rotate(30deg) scale(1.05); border-radius: 50%; }
  25% { opacity: .4; transform: rotate(-30deg) scale(.85, 1); border-radius: 35% 60%; }
  48% { opacity: .28; transform: rotate(-100deg) scale(.95, .65); }
  70% { opacity: .4; transform: rotate(-170deg) scale(.5, .7); border-radius: 60% 35%; }
  100% { opacity: 0; transform: rotate(-250deg) scale(.08); border-radius: 50%; }
}
@keyframes elemental-motes {
  0% { opacity: 0; transform: translate(0, 4px) scale(.5); }
  25% { opacity: .6; }
  55% { opacity: .4; transform: translate(var(--drift), -5px) rotate(60deg); }
  100% { opacity: 0; transform: translate(var(--drift), 6px) rotate(120deg) scale(.3); }
}
@keyframes ember-motes {
  0% { opacity: 0; transform: translate(0, 5px) scale(.5); }
  25% { opacity: .7; transform: translate(calc(var(--drift) * -.3), -3px); }
  58% { opacity: .45; transform: translate(var(--drift), -8px) scale(.7); }
  100% { opacity: 0; transform: translate(calc(var(--drift) * .4), var(--rise)) scale(.2); }
}
@keyframes wind-motes {
  0% { opacity: 0; transform: rotate(0deg) translateX(3px) scaleX(2); }
  25% { opacity: .5; }
  65% { opacity: .3; transform: rotate(180deg) translateX(var(--drift)) scaleX(3); }
  100% { opacity: 0; transform: rotate(300deg) translateX(14px) scaleX(1); }
}
@keyframes water-motes {
  0% { opacity: 0; transform: translate(0, 2px) scale(.5); }
  28% { opacity: .55; transform: translate(calc(var(--drift) * .5), -7px) scale(.8, 1.3); }
  60% { opacity: .35; transform: translate(var(--drift), -3px); }
  100% { opacity: 0; transform: translate(var(--drift), 7px) scale(1.8, .2); }
}
@keyframes light-motes {
  0% { opacity: 0; transform: translate(0, 0) rotate(45deg) scale(.2); }
  30% { opacity: .65; transform: translate(var(--drift), var(--rise)) rotate(90deg) scale(1); }
  60% { opacity: .3; transform: translate(var(--drift), var(--rise)) rotate(150deg) scale(.5); }
  100% { opacity: 0; transform: translate(var(--drift), var(--rise)) rotate(210deg) scale(.1); }
}
@keyframes void-motes {
  0% { opacity: 0; transform: rotate(0deg) translateX(var(--drift)) scale(1); }
  30% { opacity: .55; }
  65% { opacity: .35; transform: rotate(-140deg) translateX(calc(var(--drift) * .5)) scale(.7); }
  100% { opacity: 0; transform: rotate(-240deg) translateX(0) scale(.1); }
}
@media (prefers-reduced-motion: reduce) {
  .tile-sparks { display: none; }
  .board .tile.revealed::before, .board .tile.revealed::after,
  .board .tile.revealed.is-revealing::before, .board .tile.revealed.is-revealing::after { animation: none; transition: none; }
}

/* Elemental vignettes share a single clock, including when the board rerenders. */
.board .tile.is-revealing:has(.element-scene) { z-index: 1; }
.board .tile.selected { z-index: 3; }
.element-scene {
  position: absolute; width: 160%; height: 160%; left: -30%; top: -35%;
  z-index: 2; overflow: visible; pointer-events: none; opacity: 0;
  filter: drop-shadow(0 0 2px var(--element-glow));
  animation: elemental-scene 2800ms linear var(--reveal-delay, 0ms) both;
}
.element-scene * { pointer-events: none; }
.element-scene g, .element-scene .fx-drop, .element-scene .fx-splash, .element-scene .fx-ripple, .fx-vines path, .fx-cracks path {
  transform-box: view-box; transform-origin: 50px 65px;
  animation-duration: 2600ms; animation-delay: var(--reveal-delay, 0ms);
  animation-timing-function: ease-in-out; animation-fill-mode: both;
}
.fx-flame { animation-name: flame-dance; transform-origin: 50px 85px !important; }
.fx-flame-middle { animation-name: flame-inner; }
.fx-flame-core { animation-name: flame-heart; }
.fx-embers { animation-name: rising-embers; }
.fx-drop { animation-name: falling-drop; }
.fx-water-impact { animation-name: splash-arrival; }
.fx-splash { animation-name: splash-crown; transform-origin: 50px 76px !important; }
.fx-ripple { animation-name: spreading-ripple; transform-origin: 50px 74px !important; }
.fx-droplets { animation-name: splash-droplets; }
.fx-rock { animation-name: rock-impact; }
.fx-cracks path { stroke-dasharray: 1; animation-name: ground-crack; }
.fx-vines path { stroke-dasharray: 1; animation-name: growing-vines; }
.fx-leaves { animation-name: unfurl-leaves; }
.fx-tornado { animation-name: tornado-wobble; transform-origin: 50px 85px !important; }
.fx-wind-leaves { animation-name: orbiting-leaves; transform-origin: 50px 45px !important; }
.fx-sunbeam { animation-name: sun-column; transform-origin: 50px 0 !important; }
.fx-sun { animation-name: sun-turn; transform-origin: 50px 43px !important; }
.fx-star { animation-name: star-one; transform-origin: 50px 50px !important; }
.fx-star-two { animation-name: star-two; }
.fx-star-three { animation-name: star-three; }
.fx-skull { animation-name: skull-awaken; }
.fx-bat { animation-name: escaping-bat; }
.fx-bat-1 { animation-name: escaping-bat-late; }
.fx-bat-2 { animation-name: escaping-bat-last; }
.fx-bat-wings { animation-name: bat-flutter; transform-origin: 50px 68px !important; }
@keyframes elemental-scene { 0% { opacity: 0; } 6%, 78% { opacity: 1; } 100% { opacity: 0; } }
@keyframes flame-dance {
  0% { transform: scale(.3, .1); opacity: 0; }
  12% { transform: scale(.9, .8) skewX(-9deg); opacity: .9; }
  24% { transform: scale(.85, 1.1) skewX(8deg); }
  38% { transform: scale(1, .85) skewX(-10deg); }
  52% { transform: scale(.8, 1.15) skewX(9deg); }
  67% { transform: scale(.95, .95) skewX(-6deg); }
  82% { transform: scale(.65, 1) skewX(5deg); opacity: .8; }
  100% { transform: scale(.2, .1); opacity: 0; }
}
@keyframes flame-inner {
  0%, 5% { transform: scale(.2); opacity: 0; }
  18%, 45%, 72% { transform: scale(.85, 1.12) skewX(-12deg); opacity: 1; }
  30%, 58% { transform: scale(1.1, .88) skewX(8deg); }
  100% { transform: scale(.1); opacity: 0; }
}
@keyframes flame-heart {
  0% { opacity: 0; transform: scale(.1); }
  20%, 50%, 75% { opacity: .9; transform: scale(1, 1.15); }
  35%, 65% { opacity: .7; transform: scale(.7, .9); }
  100% { opacity: 0; transform: scale(.1); }
}
@keyframes rising-embers {
  0%, 15% { opacity: 0; transform: translateY(30px); }
  30% { opacity: .9; transform: translate(-4px, 8px); }
  50% { transform: translate(5px, -10px); }
  75% { opacity: .6; transform: translate(-6px, -32px); }
  100% { opacity: 0; transform: translate(3px, -46px); }
}
@keyframes falling-drop {
  0% { transform: translateY(-65px) scale(.7, 1.25); opacity: 0; }
  8% { opacity: 1; }
  24% { transform: translateY(27px) scale(.85, 1.2); opacity: 1; }
  29% { transform: translateY(32px) scale(1.6, .15); opacity: .7; }
  33%, 100% { transform: translateY(32px) scale(2, 0); opacity: 0; }
}
@keyframes splash-arrival { 0%, 24% { opacity: 0; } 28%, 75% { opacity: 1; } 100% { opacity: 0; } }
@keyframes splash-crown {
  0%, 24% { transform: scale(.25, .05); }
  38% { transform: scale(1, 1.2); }
  55% { transform: scale(1.1, .65); }
  78%, 100% { transform: scale(1.2, .02); opacity: 0; }
}
@keyframes spreading-ripple {
  0%, 25% { transform: scale(.1); opacity: 0; }
  32% { opacity: .9; }
  70% { transform: scale(1.6, 1.2); opacity: .5; }
  100% { transform: scale(1.85, 1.4); opacity: 0; }
}
@keyframes splash-droplets {
  0%, 25% { transform: translateY(25px) scale(.4); opacity: 0; }
  36% { opacity: 1; }
  50% { transform: translateY(-16px) scale(1.1); }
  76% { transform: translateY(28px) scale(1.3, .6); opacity: .3; }
  82%, 100% { opacity: 0; }
}
@keyframes rock-impact {
  0% { transform: translateY(-70px) rotate(-22deg); opacity: 0; }
  8% { opacity: 1; }
  25% { transform: translateY(6px) rotate(6deg) scale(1.1, .85); }
  32% { transform: translateY(-5px) rotate(-4deg); }
  40%, 85% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { opacity: 0; }
}
@keyframes ground-crack { 0%, 24% { stroke-dashoffset: 1; opacity: 0; } 27% { opacity: 1; } 43%, 80% { stroke-dashoffset: 0; opacity: .9; } 100% { stroke-dashoffset: 0; opacity: 0; } }
@keyframes growing-vines { 0%, 36% { stroke-dashoffset: 1; opacity: 0; } 40% { opacity: 1; } 80%, 100% { stroke-dashoffset: 0; } }
@keyframes unfurl-leaves { 0%, 53% { opacity: 0; transform: scale(.5); } 78% { opacity: 1; transform: scale(1.08); } 90%, 100% { transform: scale(1); } }
@keyframes tornado-wobble {
  0% { opacity: 0; transform: scale(.15, .3); }
  15% { opacity: .85; transform: skewX(-12deg) scale(.85, 1); }
  32% { transform: skewX(13deg) scale(1, .88); }
  48% { transform: skewX(-10deg) scale(.88, 1.1); }
  65% { transform: skewX(9deg) scale(1.05, .95); }
  80% { opacity: .7; transform: skewX(-7deg); }
  100% { opacity: 0; transform: scale(1.1, .1); }
}
@keyframes orbiting-leaves {
  0% { opacity: 0; transform: rotate(0) scale(.5); }
  15% { opacity: 1; }
  40% { transform: rotate(220deg) scale(.85); }
  70% { transform: rotate(470deg) scale(1); opacity: .9; }
  100% { transform: rotate(650deg) scale(1.5); opacity: 0; }
}
@keyframes sun-column { 0% { opacity: 0; transform: scaleX(.1) rotate(-12deg); } 18%, 60% { opacity: .8; transform: scaleX(1) rotate(0); } 85% { opacity: .4; transform: scaleX(.6) rotate(8deg); } 100% { opacity: 0; transform: scaleX(.1) rotate(12deg); } }
@keyframes sun-turn { 0% { opacity: 0; transform: rotate(0) scale(.1); } 22% { opacity: .9; transform: rotate(25deg) scale(1); } 70% { opacity: .7; transform: rotate(100deg) scale(1.1); } 100% { opacity: 0; transform: rotate(150deg) scale(.3); } }
@keyframes star-one { 0%, 20% { opacity: 0; transform: scale(.5); } 36%, 65% { opacity: 1; transform: scale(1); } 48%, 100% { opacity: 0; transform: scale(.6); } }
@keyframes star-two { 0%, 35% { opacity: 0; transform: scale(.4); } 50%, 78% { opacity: 1; transform: scale(1); } 62%, 100% { opacity: 0; transform: scale(.5); } }
@keyframes star-three { 0%, 45% { opacity: 0; transform: scale(.3); } 65%, 86% { opacity: 1; transform: scale(1); } 75%, 100% { opacity: 0; transform: scale(.5); } }
@keyframes skull-awaken { 0% { opacity: 0; transform: scale(.7); } 20% { opacity: .9; transform: scale(1.05); } 35% { opacity: .6; transform: scale(1); } 55% { opacity: 1; transform: scale(1.06); } 80% { opacity: .6; transform: scale(1); } 100% { opacity: 0; transform: scale(.9); } }
@keyframes escaping-bat {
  0%, 30% { opacity: 0; transform: translate(0, 0) scale(.05); }
  38% { opacity: 1; transform: translate(0, -2px) scale(.4); }
  62% { transform: translate(calc(var(--bat-x) * .5), -18px) rotate(var(--bat-turn)) scale(.8); }
  88%, 100% { opacity: 0; transform: translate(var(--bat-x), var(--bat-y)) rotate(var(--bat-turn)) scale(1); }
}
@keyframes escaping-bat-late {
  0%, 42% { opacity: 0; transform: scale(.05); }
  50% { opacity: 1; transform: translate(0, -2px) scale(.4); }
  72% { transform: translate(calc(var(--bat-x) * .5), -22px) rotate(var(--bat-turn)) scale(.8); }
  96%, 100% { opacity: 0; transform: translate(var(--bat-x), var(--bat-y)) rotate(var(--bat-turn)); }
}
@keyframes escaping-bat-last {
  0%, 50% { opacity: 0; transform: scale(.05); }
  58% { opacity: 1; transform: translate(0, -4px) scale(.4); }
  78% { transform: translate(6px, -30px) rotate(-10deg) scale(.7); }
  100% { opacity: 0; transform: translate(var(--bat-x), var(--bat-y)) scale(.9); }
}
@keyframes bat-flutter {
  0%, 20%, 40%, 60%, 80%, 100% { transform: scaleX(1); }
  10%, 30%, 50%, 70%, 90% { transform: scaleX(.4); }
}
@media (prefers-reduced-motion: reduce) { .element-scene { display: none; } .element-scene, .element-scene * { animation: none !important; } }

/* Independent hover layer: never interferes with reveal effects or tile clicks. */
.tile-hover-light {
  position: absolute; inset: -1px; z-index: 4; pointer-events: none;
  color: var(--element-glow); opacity: 0; transition: opacity 150ms ease-out;
}
.tile-hover-light, .tile-hover-light * { pointer-events: none; }
.tile-hover-light::before {
  content: ""; position: absolute; inset: 0; border: 1.5px solid currentColor;
  border-radius: 2px;
  box-shadow: 0 0 3px currentColor, 0 0 9px currentColor, 0 0 17px color-mix(in srgb, currentColor 65%, transparent), inset 0 0 7px currentColor;
}
.tile-light-needle {
  position: absolute; width: 125%; height: 145%; left: -12.5%; bottom: 56%;
  overflow: visible; transform-origin: 50% 85%;
  filter: drop-shadow(0 0 3px currentColor) drop-shadow(0 0 7px currentColor);
}
.tile-light-needle path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.needle-bloom { stroke: currentColor; stroke-width: 3; }
.needle-core { stroke: #f5fffb; stroke-width: .8; opacity: .95; }
.board .tile:focus-visible { z-index: 5; }
.board .tile:focus-visible .tile-hover-light { opacity: 1; }
.board .tile:focus-visible .tile-light-needle { animation: hovering-frequency 900ms ease-in-out infinite; }
@media (hover: hover) {
  .board .tile:hover { z-index: 5; filter: none; }
  .board .tile:hover .tile-hover-light { opacity: 1; }
  .board .tile:hover .tile-light-needle { animation: hovering-frequency 900ms ease-in-out infinite; }
}
@keyframes hovering-frequency {
  0%, 100% { transform: translateY(0) scaleY(.88); }
  24% { transform: translateY(-2px) scaleY(1.04); }
  44% { transform: translateY(-1px) scaleY(.94); }
  68% { transform: translateY(-3px) scaleY(1.08); }
  84% { transform: translateY(-1px) scaleY(.96); }
}
.playmat:has(.library-stack) { overflow: visible; }
.library, .recycling, .graveyard { position: relative; isolation: isolate; }
/* Keep the opposing Library's stack, lift and counter facing the viewer,
   while its slot stays in the rotated mat's original location. */
.opponent-mat .library { transform: rotate(180deg); transform-origin: center; }
.library-stack { position: absolute; inset: 6px; pointer-events: none; }
.library-card {
  position: absolute; inset: 0; border: 1px solid #9aab9b; border-radius: 3px;
  background: #263d40; box-shadow: 0 1px 1px #0008;
  transform: translate(calc(var(--layer) * .08px), calc(var(--layer) * -.55px));
}
.library-card:last-child {
  background: #15292c url('assets/card-back.png') center / 112% auto no-repeat;
  border-color: #c4c0a5;
}
.library .library-count, .recycling .library-count, .graveyard .library-count {
  position: absolute; z-index: 2; left: 50%; top: 25%; margin: 0;
  transform: translate(-50%, calc(-1 * var(--deck-height, 0px)));
  min-width: 25px; padding: 3px 5px; border-radius: 5px;
  background: transparent; border: 0; opacity: .72;
  color: #fff9db; font: 700 20px/1 var(--ui-font);
  font-variant-numeric: tabular-nums; text-align: center;
  text-shadow: 0 1px 3px #000; pointer-events: none;
}
.market-slots .mat-slot { position: relative; }
.market-card { display: flex; position: absolute; inset: 2px; flex-direction: column; justify-content: center; align-items: center; gap: 5px; background: linear-gradient(145deg, #315357, #142934); border: 1px solid #adcab48c; border-radius: 3px; }
.market-card img { width: 65%; object-fit: contain; }
.market-card small { color: #e6e0bf; font: 7px var(--ui-font); text-align: center; }
.hand-overflow {
  position: fixed; inset: 0; margin: auto; display: none;
  width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  overflow: auto; padding: 28px; border: 1px solid #cce5d82f; border-radius: 20px;
  background: linear-gradient(145deg, #1b333b, #101e28); box-shadow: 0 25px 90px #0008;
  font: 13px/1.5 var(--ui-font); color: #e2ece6;
}
.hand-overflow[open] { display: grid; gap: 12px; animation: overflow-arrive 240ms ease-out; }
.hand-overflow::backdrop { background: #040e1780; backdrop-filter: blur(5px); }
.hand-overflow h2 { margin: 0; font: 600 23px/1.2 var(--ui-font); letter-spacing: -.025em; }
.hand-overflow p { margin: 0; }
.overflow-eyebrow { color: #bcd8c7; font-size: 9px; letter-spacing: .2em; }
#overflow-label { color: #a8bcba; }
.overflow-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.hand-overflow button { padding: 13px 8px; border-radius: 8px; font: 600 12px var(--ui-font); background: #b7d8c6; border: 1px solid #c9ead6; color: #15332c; }
#overflow-recycle { background: #ffffff05; border-color: #b6d7cb3d; color: #d9e8e2; }
.hand-overflow button:focus-visible { outline: 2px solid #c3f4d8; outline-offset: 3px; }
.overflow-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 10px; max-height: min(40dvh, 320px); overflow-y: auto; padding: 4px; }
:is(.hand-overflow, .market-dialog) .overflow-choice {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-width: 0; aspect-ratio: 11 / 15; padding: 8px 4px;
  background: linear-gradient(145deg, #305659, #122832); color: #e5eee0;
  border: 1px solid #b8d8c650; font: 600 10px/1.3 var(--ui-font);
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}
.overflow-choice img { width: 52%; aspect-ratio: 1; object-fit: contain; }
.overflow-choice small { font-size: 8px; color: #b7cabc; letter-spacing: .06em; }
.hand-overflow .overflow-choice[aria-pressed='true'] { border-color: #d3f3c5; background: linear-gradient(145deg, #3d6760, #1e383b); box-shadow: 0 0 0 2px #bce6cd70, 0 0 12px #95d0ab20; }
#overflow-selection { min-height: 20px; font-size: 12px; color: #cce4d7; }
@media (prefers-reduced-motion: reduce) { .hand-overflow .overflow-choice { transition: none; } }
.overflow-footnote { text-align: center; color: #8ba7a0; font-size: 10px; }
.hand-overflow button:disabled { opacity: .35; }
.table-fit { will-change: transform; }
.card-transfer-busy .table-stage, .card-transfer-busy .player-dock { pointer-events: none; }
.card-transfer-busy .player-dock :is(.card, .player-summary) { pointer-events: none; }
.card-flight {
  position: fixed; z-index: 1000; pointer-events: none; transform-origin: top left;
  border: 1px solid #c5cab1; border-radius: 5px;
  background: #15292c url('assets/card-back.png') center / 112% auto no-repeat;
  box-shadow: 0 8px 18px #0006; will-change: transform, opacity;
}
.card-flight-face { display: grid; place-items: center; background: linear-gradient(145deg, #315357, #142934); }
.card-flight img { width: 65%; max-height: 65%; object-fit: contain; }
.player-dock .player-hand .card.has-card-art { padding: 0; background: #080b09; overflow: hidden; }
.player-hand .card.has-card-art::before { display: none; }
.card.has-card-art img, .field-card { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }
.field-card { position: absolute; inset: 0; }
.field-card-button { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; border-radius: 3px; background: none; }
.summon-slot-choice { position: absolute; inset: 0; width: 100%; height: 100%; border: 1px solid #c8f0bc; border-radius: 4px; background: #b2e8ab1a; color: #e0f9d5; font: 24px var(--ui-font); box-shadow: inset 0 0 14px #a0dfad2b, 0 0 9px #b6ecb955; }
.summon-slot-choice:hover, .summon-slot-choice:focus-visible { background: #c5f1b73b; outline: 2px solid #e1ffd6; outline-offset: 2px; }
.board .tile.summon-destination { outline: 3px solid #ddffb5; outline-offset: -3px; box-shadow: inset 0 0 12px #c4ef9c80; }
#water-choice-content { flex-direction: row; flex-wrap: wrap; max-height: 65vh; overflow-y: auto; padding: 4px; }
#light-choice-content { flex-direction: row; flex-wrap: wrap; max-height: 65vh; overflow-y: auto; padding: 4px; }
#fire-choice-content { flex-direction: row; flex-wrap: wrap; max-height: 65vh; overflow-y: auto; padding: 4px; }
#fire-choice-content > p { flex-basis: 100%; }
#fire-choice-content .light-card-choice { display: inline-flex; flex-direction: column; gap: 8px; width: 142px; margin: 4px; }
#fire-choice-content .card-art-frame { height: 160px; width: 118px; }
#light-choice-content > p { flex-basis: 100%; }
#light-choice-content .light-card-choice { display: inline-flex; flex-direction: column; gap: 8px; width: 142px; margin: 4px; }
#light-choice-content .card-art-frame { height: 160px; width: 118px; }
#water-choice-content > p { flex-basis: 100%; }
#water-choice-content .water-card-choice { display: inline-flex; flex-direction: column; gap: 8px; width: 142px; margin: 4px; vertical-align: top; }
#water-choice-content .water-card-choice .card-art-frame { height: 160px; width: 118px; }
#water-choice-content .water-card-choice[aria-pressed="true"] { outline: 2px solid #71cbe8; outline-offset: 2px; }
.field-card-button.summon-arrival { animation: summon-mat-arrival 560ms cubic-bezier(.2,.7,.25,1) var(--summon-delay, 0ms) both; }
/* Reuse the board's elemental scenes, sized to the larger playing-mat slots. */
.playmat:has(.summon-element-wrap) { overflow: visible; }
.playmat .mat-slot:has(.summon-element-wrap) { z-index: 6; }
.summon-element-wrap {
  position: absolute; z-index: 6; width: 145%; aspect-ratio: 1;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  pointer-events: none;
}
.summon-element-wrap .element-scene { width: 100%; height: 100%; left: 0; top: 0; }
.opponent-mat .summon-element-wrap { transform: translate(-50%, -50%) rotate(180deg); }
/* Royale scenes/cards face their seat, not the viewer. Never add the old
   opposite-seat counter-rotation to a left/right mat. */
.game-table[data-format='battle-royale'] .playmat .summon-element-wrap { transform:translate(-50%,-50%); }
.game-table[data-format='battle-royale'] .playmat .library { transform:none; }
.game-table[data-format='battle-royale'] .library-card { transform:translate(calc(var(--layer) * var(--stack-step-x,0px)),calc(var(--layer) * var(--stack-step-y,-.35px))); }
.game-table[data-format='battle-royale'] .playmat .library-count { top:50%;left:50%;transform:translate(calc(-50% + var(--stack-top-x,0px)),calc(-50% + var(--stack-top-y,0px))) rotate(var(--stack-counter-angle,0deg));font-size:16px; }
@keyframes summon-mat-arrival {
  0% { transform: scale(.92); box-shadow: 0 0 0 2px var(--summon-color), 0 0 24px var(--summon-color); filter: brightness(1.35); }
  42% { transform: scale(1.055); box-shadow: 0 0 0 7px transparent, 0 0 15px var(--summon-color); filter: brightness(1.12); }
  100% { transform: scale(1); box-shadow: 0 0 0 12px transparent, 0 0 0 transparent; filter: brightness(1); }
}
@media (prefers-reduced-motion: reduce) { .field-card-button.summon-arrival { animation: none; box-shadow: none; } .summon-element-wrap { display: none; } }
.board .tile.unit-linked-hover { z-index: 8; outline: 2px solid var(--piece-glow); outline-offset: -2px; }
.board .tile.unit-linked-hover .piece-art { filter: drop-shadow(0 0 3px var(--piece-glow)) drop-shadow(0 0 7px var(--piece-glow)); }
.field-card-button.unit-linked-hover { outline: 2px solid var(--piece-glow); box-shadow: 0 0 8px var(--piece-glow), 0 0 17px var(--piece-glow); z-index: 5; }
.stat-normal { color: #fff; }
.stat-boosted { color: #7cf5a1; }
.stat-damaged { color: #ff777e; }
.card-inspector { position: absolute; right: 0; bottom: calc(100% + 10px); width: 310px; max-width: calc(100vw - 24px); max-height: min(68dvh, calc(100dvh - 235px)); overflow-y: auto; overscroll-behavior: contain; padding: 14px; border: 1px solid #b9dacf50; border-top-color: var(--piece-glow); border-radius: 14px; background: linear-gradient(145deg, #1a3039f5, #0b1923fa); box-shadow: 0 14px 36px #0009; color: #e2ece7; font: 12px/1.45 var(--ui-font); pointer-events: auto; }
.card-inspector[hidden] { display: none; }
.inspector-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.inspector-heading h2 { margin: 0; font: 600 18px/1.2 var(--ui-font); }
.inspector-heading button { background: #ffffff0a; border: 1px solid #ffffff20; color: #edf5ef; border-radius: 7px; font-size: 20px; width: 30px; height: 30px; padding: 0; }
.card-inspector h3 { margin: 12px 0 5px; font-size: 11px; letter-spacing: .07em; text-transform: uppercase; }
.card-inspector p { margin: 4px 0; }
.inspector-hero { display: grid; grid-template-columns: 88px 1fr; gap: 12px; align-items: start; }
.inspector-hero img { width: 88px; height: auto; max-height: 132px; object-fit: contain; border-radius: 5px; }
.inspector-eyebrow, .inspector-muted { font-size: 10px; color: #a9bfbb; }
.inspector-stat { display: block; font: bold 26px/1.2 var(--ui-font); margin-top: 5px; }
.inspector-movement { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.inspector-movement h3 { margin-top: 0; }
.spell-piece-badge img { width: 18px; height: 18px; object-fit: contain; }
.movement-diagram { display: grid; grid-template-columns: repeat(3, 30px); grid-template-rows: repeat(3, 30px); flex-shrink: 0; text-align: center; font: bold 22px/30px var(--ui-font); }
.movement-center { display: grid; place-items: center; border: 2px solid #eeeeee; border-radius: 50%; background: #292929; color: #fff; z-index: 1; font-size: 19px; }
.movement-arrow { position: relative; display: grid; place-items: center; }
.movement-arrow::before { content: ''; position: absolute; inset: 1px; background: currentColor; clip-path: polygon(50% 0, 100% 44%, 79% 44%, 79% 100%, 21% 100%, 21% 44%, 0 44%); transform: rotate(var(--arrow-angle)); }
.movement-infinity-icon { width: 20px; height: 20px; object-fit: contain; }
.movement-d8-icon { width: 24px; height: 24px; object-fit: contain; }
.direction-active { color: #f1f6ef; } .direction-inactive { color: #8ca9a329; }
.inspector-readiness { color: #cbe1ad; font-size: 10px; }
/* Dominant flat arrow color sampled from the original Arkaneth JPG. */
.movement-diagram .direction-mandatory { color: #fcb30f; }
.direction-mandatory small { position: relative; z-index: 1; color: #211b0a; font: bold 12px/1 var(--ui-font); text-align: center; }
.card-traits { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 7px; }
.card-traits > span { display: inline-flex; align-items: center; gap: 4px; color: #deebe7; font-size: 10px; }
.card-traits img, .inspector-hero .card-traits img { width: 20px; height: 20px; object-fit: contain; }
.spell-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.spell-actions button { padding: 7px 9px; border: 1px solid #bcd6cb44; border-radius: 7px; background: #d8ede90a; color: #dfefe6; font: 11px var(--ui-font); }
.spell-actions button[aria-pressed="true"] { background: #c4e9db22; border-color: #d2eddfaa; }
.spell-actions button:disabled { opacity: .4; cursor: not-allowed; }
.spell-actions p { width: 100%; }
.field-card-back { background: #15262d url('assets/card-back.png') center / cover no-repeat; }
.portal-vortex { position: absolute; inset: -12%; z-index: 12; border-radius: 50%; pointer-events: none; background: radial-gradient(ellipse, #edfaffd9 0%, #68dbe54a 16%, #915bf84d 35%, transparent 68%); mix-blend-mode: screen; animation: portal-bloom 1000ms ease-in-out both; animation-delay: var(--portal-delay); }
.portal-traveler { z-index: 14; pointer-events: none; }
.darkhole-fall { position: absolute; inset: 0; z-index: 15; pointer-events: none; }
.darkhole-fall-rim { position: absolute; inset: 7%; border-radius: 50%; background: radial-gradient(ellipse, #000 22%, #0c051ec9 48%, #78609b66 61%, transparent 73%); animation: darkhole-rim 420ms ease-out both; animation-delay: var(--fall-delay); }
.darkhole-falling-piece { animation: darkhole-drop 420ms cubic-bezier(.55,.05,.9,.4) both; animation-delay: var(--fall-delay); }
@keyframes darkhole-drop { 0% { opacity: 1; transform: translate(-50%, 0) scale(1); filter: brightness(1.15); } 30% { opacity: 1; transform: translate(-50%, 4px) scale(.8); } 100% { opacity: 0; transform: translate(-50%, 14px) scale(.025); filter: brightness(.15); } }
@keyframes darkhole-rim { 0%, 100% { opacity: 0; transform: scale(.65); } 35% { opacity: .9; transform: scale(1.12); } }
@media (prefers-reduced-motion: reduce) { .darkhole-falling-piece, .darkhole-fall-rim { animation: darkhole-fade 140ms ease-out both; animation-delay: var(--fall-delay); } }
@keyframes darkhole-fade { from { opacity: .7; } to { opacity: 0; } }
.portal-vortex i { position: absolute; inset: calc(8% + var(--ring) * 9%); border: 2px solid transparent; border-top-color: #c6faff; border-left-color: #977bff; border-radius: 43% 57% 48% 52%; box-shadow: 0 0 8px #67dfe788, inset 0 0 6px #ac79fb80; filter: drop-shadow(0 0 3px #ad8bff); animation: portal-swirl 1000ms cubic-bezier(.4,0,.2,1) both; animation-delay: var(--portal-delay); }
@keyframes portal-bloom { 0% { opacity: 0; transform: scale(.25); } 22% { opacity: 1; transform: scale(1.08); } 64% { opacity: .9; transform: scale(.95); } 100% { opacity: 0; transform: scale(.18); } }
@keyframes portal-swirl { from { transform: rotate(calc(var(--ring) * 100deg)) scale(.6); } to { transform: rotate(calc(640deg + var(--ring) * 100deg)) scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .portal-vortex { animation-name: portal-soft-fade; } .portal-vortex i { animation: none; } }
@keyframes portal-soft-fade { 0%, 100% { opacity: 0; } 25%, 65% { opacity: .75; } }
.field-card-button.mage-cast-ready { box-shadow: 0 0 7px #d4c9ff77; }
.special-ready-icon, .linked-equip-icon {
  position: absolute; left: 50%; top: -28px; width: 15px; height: 21px;
  object-fit: contain; pointer-events: none; z-index: 8; transform: translateX(-50%);
  filter: drop-shadow(0 0 3px #fff) drop-shadow(0 0 7px var(--piece-glow, #ffe5bd));
}
.special-ready-icon { animation: special-ready-float 2.6s ease-in-out infinite; }
.board .tile .piece-visual.special-ability-ready .piece-art {
  filter: drop-shadow(0 0 3px var(--piece-glow)) drop-shadow(0 0 6px var(--piece-glow));
}
.field-card-button.special-ability-ready {
  outline: 1px solid color-mix(in srgb, var(--piece-glow) 65%, transparent);
  box-shadow: 0 0 9px color-mix(in srgb, var(--piece-glow) 45%, transparent);
}
.field-card-button .special-ready-icon { top: -25px; width: 18px; height: 24px; }
.linked-equip-icon { left: calc(50% + 18px); top: -13px; width: 15px; height: 15px; opacity: 0; transition: opacity 150ms ease; }
.unit-linked-hover .linked-equip-icon, .unit-linked-hover > .linked-equip-icon { opacity: 1; }
.field-card-button > .linked-equip-icon { top: -20px; }
@keyframes special-ready-float {
  0%, 100% { transform: translate(-50%, 0); opacity: .8; }
  50% { transform: translate(-50%, -4px); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .special-ready-icon { animation: none; }
  .linked-equip-icon { transition: none; }
}
.dev-card-tools { position: relative; font-size: 11px; }
.dev-card-tools summary { cursor: url('assets/elven-cursor.svg') 3 2, pointer; padding: 7px; }
.dev-card-tools[open] { background: #142024; padding: 8px; border: 1px solid #46605b; border-radius: 8px; z-index: 20; }
.dev-card-tools label, .dev-card-tools small { display: block; max-width: 190px; margin: 5px 0; }
.dev-card-tools select { display: block; width: 100%; background: #192d30; color: #f4f6ef; border: 1px solid #46605b; padding: 6px; }
.ability-choice-panel {
  position: fixed; z-index: 60; left: 50%; bottom: clamp(120px, 20vh, 220px); transform: translateX(-50%);
  width: min(410px, calc(100vw - 24px)); padding: 15px 18px; border: 1px solid #a6e9ff55; border-radius: 14px;
  background: #102733ed; color: #f0faff; box-shadow: 0 10px 36px #0008; backdrop-filter: blur(12px); font: 12px/1.5 var(--ui-font);
}
.ability-choice-panel[hidden] { display: none; }
.ability-choice-panel { max-height: 48vh; overflow-y: auto; }
.ability-choice-panel strong { display: block; font-size: 15px; }
.ability-choice-panel p { margin: 6px 0 10px; }
.ability-choice-panel button { margin: 4px; }
.ability-choice-panel .light-card-choice { display: inline-flex; flex-direction: column; gap: 8px; width: 130px; vertical-align: top; }
.ability-choice-panel .light-card-choice .card-art-frame { width: 100%; height: auto; aspect-ratio: 11 / 15; }
.board .tile.ability-target-selected { outline: 2px solid #b0f2ff; outline-offset: -2px; box-shadow: inset 0 0 14px #55c8ffb3; }
.death-search .overflow-cards { max-height: min(52vh, 480px); overflow-y: auto; overscroll-behavior: contain; padding: 8px; }
.board .tile.mage-cast-ready .piece-art { filter: drop-shadow(0 0 3px #d4c9ff) drop-shadow(0 0 5px #a690d777); }
.mage-cast-selected { outline: 2px solid #e6dcff; outline-offset: 1px; }
.position-map { display: grid; grid-template-columns: 16px repeat(16, 1fr); grid-template-rows: repeat(17, 1fr); gap: 2px; width: min(100%, 226px); aspect-ratio: 1; margin: 6px auto; }
.map-label { display: grid; place-items: center; font: 8px/1 var(--ui-font); color: #adc0b9; }
.map-cell { border: 1px solid #91b2a523; background: #74968712; border-radius: 1px; }
.map-cell.is-position { background: var(--piece-glow); border-color: #fff; box-shadow: 0 0 6px var(--piece-glow); }
.map-cell.is-occupied { position: relative; }
.map-cell.is-occupied::after { content: ''; position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #ffffffe6; top: 50%; left: 50%; transform: translate(-50%, -50%); }
.inspector-position-tile { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; color: #d9e8e2; text-transform: capitalize; }
.inspector-position-tile img, .inspector-tile-hidden { width: 32px; height: 32px; border-radius: 5px; object-fit: contain; }
.inspector-tile-hidden { display: grid; place-items: center; background: #ffffff08; border: 1px solid #ffffff20; color: #b5c9c1; }
@media (max-width: 1000px) { .card-inspector { width: 300px; max-height: min(65dvh, calc(100dvh - 190px)); } }
@media (max-height: 500px) { .card-inspector { max-height: 60dvh; } }
.player-hand .card.summon-ready { box-shadow: 0 0 10px #b1da7e70; }
.player-hand .card[aria-pressed='true'] { outline: 2px solid #cff3ad; }
.market-card.has-card-art { display: block; inset: 0; padding: 0; border: 0; gap: 0; overflow: hidden; background: #080b09; }
.market-card.has-card-art .card-art-frame { position: absolute; inset: 0; width: 100%; height: 100%; }
.market-card.has-card-art img { width: 100%; height: 100%; }
.market-card.has-card-art small { display: none; }

.player-hand .card:hover, .player-hand .card:focus-visible {
  border-color: var(--hand-glow); outline: 1px solid var(--hand-glow);
  box-shadow: 0 16px 28px #000a, 0 0 9px var(--hand-glow), 0 0 25px color-mix(in srgb, var(--hand-glow) 65%, transparent);
}
.market-card.market-empty { background: #c9e4d505; border: 1px dashed #d0e9dc35; color: #d9f1e19c; font: 300 24px var(--ui-font); transition: background 180ms ease, box-shadow 180ms ease; }
.market-card.market-empty:hover, .market-card.market-empty:focus-visible { background: #c9e4d519; box-shadow: inset 0 0 14px #bcebc436; }
.market-dialog { box-sizing: border-box; width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); overflow-y: auto; padding: 24px; color: #edf6ee; background: linear-gradient(145deg, #1b3038f5, #0c1a24fa); border: 1px solid #c4e5d938; border-radius: 18px; box-shadow: 0 24px 90px #0009; }
.market-dialog::backdrop { background: #02080bb0; backdrop-filter: blur(7px); }
.market-dialog h2 { margin: 0; font: 600 22px var(--ui-font); }
#market-description { color: #b6ccc7; font: 14px/1.6 var(--ui-font); }
#investment-dialog { font: 13px/1.5 var(--ui-font); }
#investment-dialog :is(h2, button) { font-family: inherit; }
#investment-description { color: #b6ccc7; font-size: 14px; line-height: 1.6; }
#market-choices { max-height: min(48dvh, 420px); overflow-y: auto; overscroll-behavior: contain; }
#market-choices.market-purchase-preview { grid-template-columns: minmax(100px, 155px); justify-content: center; }
.market-dialog .overflow-choice:is(:hover, :focus-visible) { border-color: #d3f3c5; box-shadow: 0 0 12px #95d0ab50; }
#market-buy { display: block; margin: 20px 0 0 auto; padding: 12px 20px; border: 1px solid #c6e8d270; border-radius: 9px; background: #c6e8d21c; color: #edf6ee; }
#market-buy[hidden] { display: none; }
#market-buy:disabled { opacity: .4; }
.battle-impact { position: absolute; z-index: 12; width: 125%; height: 125%; left: -12.5%; top: -25%; object-fit: contain; pointer-events: none; filter: drop-shadow(0 0 5px #fff4cd); animation: battle-impact 650ms ease-out var(--battle-delay, 0ms) both; }
.match-result { align-self: center; padding: 8px 18px; border: 1px solid #d9d0a266; border-radius: 8px; color: #f8ecc7; background: #29352ce8; font: bold 14px var(--ui-font); }
.match-result[hidden] { display: none; }
@keyframes battle-impact { 0% { opacity: 0; transform: scale(.6) rotate(-12deg); } 18% { opacity: 1; transform: scale(1.12) rotate(4deg); } 55% { opacity: .9; transform: scale(1); } 100% { opacity: 0; transform: scale(1.18); } }
@media (prefers-reduced-motion: reduce) { .battle-impact { animation-name: battle-impact-reduced; } }
@keyframes battle-impact-reduced { 0%, 75% { opacity: 1; } 100% { opacity: 0; } }
:is(.hand-overflow, .market-dialog) .overflow-choice.has-card-art { padding: 0; gap: 0; }
.overflow-choice.has-card-art img { width: 100%; aspect-ratio: 11/15; }
.overflow-choice.has-card-art :is(span, small) { display: none; }
.card-flight.has-card-art img { width: 100%; height: 100%; max-height: none; }
.graveyard .library-stack { inset: 2px; }
.graveyard .library-count { top: 50%; left: 50%; right: auto; transform: translate(-50%, calc(-50% - var(--deck-height, 0px))); }
.graveyard:has(.library-card) > img { visibility: hidden; }
.mat-zone[role='button']:focus-visible { outline: 2px solid #c9ecd9; outline-offset: 3px; }
.inspector-heading h2 { display: flex; align-items: center; gap: 7px; }
.inspector-element { width: 25px; height: 25px; object-fit: contain; flex-shrink: 0; }
.summon-cost-icons { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 7px 0; }
.summon-cost-token { display: inline-flex; align-items: center; gap: 4px; }
.summon-cost-token img { width: 25px; height: 25px; object-fit: contain; }
.summon-cost-token strong { color: #f1f6ed; font: bold 15px var(--ui-font); }
.card-inspector .ability-heading { display: flex; align-items: center; gap: 8px; }
.ability-heading img { width: 21px; height: 28px; object-fit: contain; }
.pile-inspector { width: min(760px, calc(100vw - 28px)); max-height: calc(100dvh - 36px); margin: auto; padding: 22px; border: 1px solid #b9dacf45; border-radius: 18px; color: #e4eee8; background: linear-gradient(145deg, #1c343d, #0c1b24); box-shadow: 0 24px 80px #0009; font: 13px/1.5 var(--ui-font); overflow: hidden; }
.pile-inspector[open] { display: flex; flex-direction: column; gap: 10px; }
.pile-inspector::backdrop { background: #030c1680; backdrop-filter: blur(5px); }
.pile-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-shrink: 0; }
.pile-heading h2 { margin: 0; font: 600 22px var(--ui-font); }
.pile-eyebrow { margin: 0 0 5px; font-size: 9px; letter-spacing: .18em; color: #a8c7ba; }
.pile-heading button { width: 36px; height: 36px; padding: 0; border: 1px solid #b9dacf40; border-radius: 8px; color: #edf5ef; background: #ffffff08; font-size: 25px; }
#pile-description { margin: 0; color: #a8bfba; font-size: 11px; }
.pile-cards { overflow-y: auto; overscroll-behavior: contain; min-height: 0; max-height: 66dvh; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 4px; scrollbar-color: #637f77 transparent; }
.pile-card { display: flex; align-items: start; gap: 12px; padding: 12px; border: 1px solid #c2ded321; border-radius: 12px; background: #ffffff04; }
.pile-card-art, .pile-token-art { width: 88px; max-height: 128px; object-fit: contain; flex-shrink: 0; border-radius: 5px; }
.pile-token-art { width: 44px; }
.pile-card h3 { margin: 0 0 4px; font: 600 14px var(--ui-font); }
.pile-card p { margin: 4px 0; font-size: 10px; color: #b6ccc4; }
.pile-card .movement-diagram { margin-top: 6px; grid-template-columns: repeat(3, 24px); grid-template-rows: repeat(3, 24px); font-size: 18px; line-height: 24px; }
.pile-card .movement-center { font-size: 16px; border-width: 1.5px; }
.pile-card .movement-infinity-icon { width: 16px; height: 16px; }
.pile-card .movement-d8-icon { width: 18px; height: 18px; }
.pile-card .direction-mandatory small { font-size: 10px; }
.pile-empty { padding: 32px 12px; grid-column: 1 / -1; text-align: center; color: #aac4b7; }
.pile-inspector :focus-visible { outline: 2px solid #bfe9d1; outline-offset: 2px; }
@media (max-width: 600px) { .pile-inspector { padding: 16px; } .pile-cards { grid-template-columns: 1fr; } }
@keyframes overflow-arrive { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@media (prefers-reduced-motion: reduce) { .hand-overflow[open] { animation: none; } }
.table-stage.is-panning .tile .tile-hover-light { opacity: 0; }
.card-art-frame { display: block; position: relative; width: 100%; height: 100%; aspect-ratio: 11 / 15; overflow: hidden; border-radius: inherit; }
.card-art-frame img { display: block; width: 100%; height: 100%; max-width: none; max-height: none; object-fit: contain; transform: scale(var(--card-art-zoom, 1.1)); transform-origin: center; pointer-events: none; }
.inspector-hero .inspector-card-art { width: 88px; height: auto; border-radius: 5px; }
.pile-card .pile-card-art { width: 88px; height: auto; flex-shrink: 0; }
:is(.hand-overflow, .market-dialog) .overflow-choice.has-card-art .card-art-frame { display: block; }
.table-stage.is-panning .tile .tile-light-needle { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .tile-hover-light { transition: none; }
  .board .tile .tile-light-needle,
  .board .tile:hover .tile-light-needle,
  .board .tile:focus-visible .tile-light-needle { animation: none; }
}
.dice-result-icon { width: 44px; height: 44px; object-fit: contain; vertical-align: middle; margin-right: 12px; }
#earth-choice-cards > p { grid-column: 1 / -1; }
#earth-choice-cards:not([data-choice-type="search"]) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#earth-choice .overflow-choice:not(.has-card-art) { aspect-ratio: auto; min-height: 70px; padding: 12px; font-size: 13px; }
/* Control changes never relocate cards between playing mats. */
.field-card-button.controlled-card { outline: 2px solid var(--piece-glow); box-shadow: 0 0 9px var(--piece-glow); }
.control-owner-label { position: absolute; bottom: 2px; left: 2px; right: 2px; background: #111e; color: #fff; font-size: 9px; padding: 2px; border-top: 2px solid var(--piece-glow); }
.dark-choice-content { display: flex; flex-direction: column; gap: 12px; }
.dark-choice-content input { width: 100%; padding: 10px; margin-top: 6px; color: #fff; background: #18131f; border: 1px solid #a88cbc; border-radius: 6px; }
.dark-choice-content button { padding: 10px; }

/* Camera presets change presentation only; the same board/mat nodes stay alive. */
.game-table[data-camera='board'] .table-plane,
.game-table[data-camera='mat'] .table-plane { --table-tilt: 0deg; --piece-camera-compensation: 1; transform: none; gap: 0; }
.game-table[data-camera='board'] .table-fit,
.game-table[data-camera='board'] .table-plane { width: 540px; }
.game-table[data-camera='board'] .board-section { width: 500px; }
.game-table[data-camera='board'] .table-plane > :is(.player-area, .market-panel),
.game-table[data-camera='board'] > :is(.opponent-hand-anchor, .player-dock),
.game-table[data-camera='board'] .arena-scenery { display: none; }
.game-table[data-camera='mat'] .table-fit,
.game-table[data-camera='mat'] .table-plane { width: 720px; }
.game-table[data-camera='mat'] .table-plane > :is(.opponent-area, .board-section, .market-panel),
.game-table[data-camera='mat'] > .opponent-hand-anchor { display: none; }
.game-table[data-camera='mat'] .table-plane > .player-area { width: 680px; }
.camera-selector input { cursor: url('assets/elven-cursor.svg') 3 2, auto; }

/* Two independent panels: phases above the bottom-left glass history. */
:root { --history-width: clamp(300px, 26vw, 400px); --history-height: clamp(220px, 36dvh, 400px); }
.game-table > :is(.table-stage, .player-dock) { margin-left: calc(var(--history-width) + 12px); }
.status-bar.sr-only { position: absolute; min-height: 0; border: 0; padding: 0; }
.table-stage { touch-action: auto; }
.table-fit { touch-action: none; }
.phase-tracker { position: fixed; left: 16px; top: auto; bottom: calc(var(--history-height) + 28px); transform: none; width: 240px; padding: 16px 12px; min-height: 0; max-height: none; display: flex; flex-direction: column; overflow: visible; pointer-events: auto; }
.phase-list li { min-height: 44px; font-size: 13px; }
.phase-list img { width: 30px; height: 30px; }
#phase-player { font-size: 12px; }
#next-phase { font-size: 12px; padding: 11px 5px; }
.phase-tracker > :is(.phase-list, #phase-player, #next-phase) { flex-shrink: 0; }
.phase-list { margin: 0; padding: 0; }
.action-log { position: fixed; z-index: 12; left: 16px; bottom: 16px; width: var(--history-width); height: var(--history-height); min-height: 0; display: flex; flex-direction: column; margin: 0; padding: 16px; border: 1px solid #c4e7d52b; border-radius: 16px; background: linear-gradient(145deg, #29434b99, #0c1b23b8); -webkit-backdrop-filter: blur(18px) saturate(130%); backdrop-filter: blur(18px) saturate(130%); box-shadow: inset 0 1px 0 #ffffff0d, 0 8px 28px #0003; font: 12px/1.5 var(--ui-font); overflow: hidden; pointer-events: auto; }
.action-log header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 3px 7px; }
.action-log h2 { margin: 0; font: 600 14px var(--ui-font); color: #dcefe6; }
.action-log header > span { color: #8cd4b7; font-size: 8px; letter-spacing: .15em; }
#action-log-list { min-height: 0; flex: 1; margin: 0; padding: 0 3px 0 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #526f67 transparent; touch-action: pan-y; list-style: none; }
.action-log > :is(header, button) { flex-shrink: 0; }
.log-entry { display: flex; align-items: flex-start; gap: 6px; padding: 6px 2px; color: #c2d4ce; border-bottom: 1px solid #c4e7d510; overflow-wrap: anywhere; }
.log-owner { flex: 0 0 20px; font-size: 10px; color: #9cc9b6; padding-top: 3px; }
.log-entry[data-player='p2'] .log-owner { color: #a7bfec; }
.log-parts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 7px; min-width: 0; }
.log-fragment { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.log-fragment img { width: 22px; height: 28px; object-fit: contain; flex: 0 0 22px; }
.log-phase { display: block; margin-top: 10px; padding: 7px; border: 1px solid #acd9c322; border-radius: 7px; background: #a4d6bf09; color: #ecfaf2; }
.log-phase:first-child { margin-top: 0; }
.log-phase .log-owner { display: block; padding: 0 0 3px; font-size: 11px; }
.log-phase .log-parts { font-weight: 600; }
.log-winner { color: #ffe8a5; }
#action-log-latest { margin-top: 5px; width: 100%; padding: 5px; background: #a5d9c313; color: #c3e8d5; border: 1px solid #b3dbc52c; font: 10px var(--ui-font); }
#action-log-latest[hidden] { display: none; }
#action-log-list:focus-visible { outline: 1px solid #b5f4d8; outline-offset: 2px; }
@media (max-width: 700px) {
  :root { --history-width: min(400px, calc(100vw - 20px)); --history-height: 22dvh; }
  .game-table { padding-bottom: calc(var(--history-height) + 96px); }
  .game-table > :is(.table-stage, .player-dock) { margin-left: 0; }
  .phase-tracker { left: 10px; top: auto; bottom: calc(var(--history-height) + 22px); transform: none; width: calc(100vw - 20px); padding: 6px; flex-direction: row; flex-wrap: nowrap; max-height: none; overflow: visible; align-items: center; }
  .phase-tracker > .phase-list { flex: 1; }
  .phase-list li { min-height: 36px; font-size: 9px; }
  .phase-list img { width: 24px; height: 24px; }
  #next-phase { font-size: 10px; padding: 8px 3px; }
  .action-log { left: 10px; bottom: 10px; padding: 10px 12px; border-radius: 12px; }
  .action-log header { padding-bottom: 3px; }
}
@media (max-height: 760px) and (min-width: 701px) {
  .phase-tracker { padding: 10px; }
  .phase-list { gap: 4px; }
  .phase-list li { min-height: 32px; padding: 3px 6px; }
  .phase-list img { width: 26px; height: 26px; }
  #phase-player { margin-bottom: 6px; }
  #next-phase { margin-top: 8px; padding: 8px 4px; }
}
@media (max-height: 650px) and (min-width: 701px) {
  .phase-tracker { width: var(--history-width); }
  #phase-player { display: none; }
  .phase-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Player profile placeholder, independent of cards and camera transforms. */
.summary-heading { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 8px; margin-bottom: 10px; }
.summary-player-identity { grid-column: 2; grid-row: 1; min-width: 0; container-type: inline-size; }
.summary-player-line { display: flex; align-items: center; gap: 4px; }
.summary-player-line .summary-name { min-width: 0; }
#summary-league { flex: none; display: flex; align-items: center; }
#summary-league .rank-symbol { width: 20px; height: 20px; }
.summary-league-label { font: 600 10px var(--ui-font); margin-inline-start: 3px; }
@container (max-width: 140px) { .summary-league-label { display: none; } }
#summary-country { display: block; }
#summary-country:empty { display: none; }
#summary-country .player-flag { display: block; width: 16px; height: 12px; margin: 2px 0 0; }
.summary-roster .roster-seat .player-identity { display: grid; grid-template-columns: minmax(0,max-content) auto; justify-content: start; column-gap: 3px; row-gap: 1px; }
.summary-roster .player-identity > .player-flag { grid-column: 1 / -1; grid-row: 2; width: 14px; height: 10px; margin: 0; }
.summary-heading .coin-balance { grid-column: 3; grid-row: 1; justify-self: end; min-width: 0; }
.summary-avatar { grid-column: 1; grid-row: 1; align-self: center; position: relative; width: 44px; height: 44px; overflow: hidden; border: 1px solid var(--ui-border); border-radius: 13px; background: linear-gradient(145deg, #ffffff16, #ffffff04); box-shadow: inset 0 1px 0 #ffffff12, 0 3px 10px #0003; }
.summary-avatar svg { display: block; width: 100%; height: 100%; padding: 4px; fill: #c5c5c538; stroke: #dedede80; stroke-width: 1.2; }
.summary-avatar > img { width: 100%; height: 100%; object-fit: cover; display: block; }
#summary-avatar-label { position: absolute; right: 3px; bottom: 2px; padding: 1px 3px; border-radius: 4px; background: #242424e6; color: var(--ui-text); font: 600 8px/1.2 var(--ui-font); }
@media (max-width: 1000px) and (min-height: 601px), (max-width: 700px) {
  .player-dock { height: clamp(262px, 39dvh, 332px); }
  .player-dock .player-summary { height: 132px; }
  .player-dock .player-hand { bottom: 148px; }
  .summary-heading { grid-column: 1 / -1; grid-row: 1; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 8px; margin-bottom: 4px; }
  .summary-heading .coin-balance { grid-column: 3; grid-row: 1; }
  .summary-avatar { grid-column: 1; grid-row: 1; width: 36px; height: 36px; border-radius: 11px; }
  .summary-strongholds { grid-row: 2; }
  .summary-investments { grid-row: 2; }
  .summary-tokens { grid-row: 3; }
}

/* Top view reserves a separate screen-space rail; zoom/pan cannot cover its inspector. */
.player-summary > .card-inspector {
  bottom: calc(100% + 12px);
  height: var(--inspector-available-height, 40dvh);
  max-height: var(--inspector-available-height, 40dvh);
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.game-table[data-camera='board'] .table-stage { clip-path: inset(0 var(--board-inspector-rail, 0px) 0 0); }
.game-table[data-camera='board'] > .card-inspector {
  position: fixed; z-index: 12; left: var(--board-inspector-left); top: var(--board-inspector-top);
  right: auto; bottom: auto; width: var(--board-inspector-width); max-width: none;
  max-height: var(--board-inspector-height); overflow-wrap: anywhere;
}
.game-table[data-camera='board'][data-inspector-compact='true'] > .card-inspector { padding: 12px; }
.game-table[data-camera='board'][data-inspector-compact='true'] .inspector-hero { grid-template-columns: minmax(0, 1fr); }
.game-table[data-camera='board'][data-inspector-compact='true'] .inspector-movement { padding: 8px; gap: 8px; flex-wrap: wrap; }
/* Persistent Dark spell state stays visible on the playing mat. */
.oracle-element-marker,.greed-counter-marker { position:absolute; z-index:5; top:-10px; right:-8px; width:32px; height:32px; border-radius:50%; background:#21132e; border:2px solid #d4b2ff; box-shadow:0 0 12px #b074e688; pointer-events:none; }
.oracle-element-marker { object-fit:contain; }
.greed-counter-marker { display:grid; place-items:center; color:#fff0bf; font:bold 18px/1 var(--ui-font); }

/* Explicit placement state, shared by local and online inspectors. */
.spell-actions button[aria-pressed="true"] {background:#dbe9e826;border-color:#dfefef9c;box-shadow:inset 0 0 0 1px #ffffff20;color:#fff;}
.spell-orientation-status {padding:9px 11px;border-left:2px solid #d4e2df;color:#e8efed;background:#ffffff06;border-radius:4px;line-height:1.5;}

/* Reuse the account portrait crop in the in-game player panel. */
#summary-portrait[hidden] { display: none; }
.summary-avatar.has-portrait > svg,
.summary-avatar.has-portrait > #summary-avatar-label { display: none; }
