/* Viewport card table; private game state and legal actions remain server-owned. */
.game-page .target-eligible { position: relative; outline: 2px solid #c79843; outline-offset: -2px; }
.game-page .target-selected { outline: 3px solid #ffdc83; box-shadow: 0 0 0 2px #916124, 0 0 18px #e1b65888; }
.target-picker { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; padding: 0; border: 0; border-radius: inherit; background: transparent; cursor: pointer; }
.target-picker:hover { background: #eab94e18; }
.self-general > .target-picker { inset: 0; width: 100%; height: 100%; }
.target-picker:focus-visible { outline: 3px solid #fff0a8; outline-offset: -4px; }
.target-eligible .seat-skills, .target-eligible .self-skills { position: relative; z-index: 3; pointer-events: none; }
.target-eligible .seat-skills button, .target-eligible .self-skills button { pointer-events: auto; }
.target-eligible .combat-health { pointer-events: none; }
.action-buttons :is([data-cmd="select-skill"],[data-formation="skill"])[aria-pressed="true"] { border-color: #a77022; background: #f5dfaa; }
.skill-effects { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 40; pointer-events: none; overflow: hidden; }
.damage-effect {
  position: fixed; z-index: 42; pointer-events: none; display: grid; place-items: center;
  border: 2px solid #eb806a; background: radial-gradient(ellipse, transparent 30%, #9e201b77);
  box-shadow: inset 0 0 24px #c4392b88; color: #fff0d8;
}
.damage-effect[data-mode="formation"] { z-index: 1101; }
.damage-effect.is-echo { z-index: 41; border-color: transparent; background: none; box-shadow: none; }
.damage-effect.is-echo[data-mode="formation"] { z-index: 1100; }
.damage-effect > b { font-size: clamp(30px, 4vw, 52px); line-height: 1; text-shadow: 0 2px 2px #300b08, 0 0 10px #dc493a; }
.damage-effect.is-echo > b { font-size: clamp(22px, 3vw, 40px); }
.recovery-effect {
  position: fixed; z-index: 42; pointer-events: none; overflow: hidden;
  display: grid; place-items: center; isolation: isolate;
  background: radial-gradient(ellipse at 50% 85%, #62e7a950, #2dbb7924 55%, transparent 80%);
  box-shadow: inset 0 0 18px #75e6ae80, 0 0 12px #4ada9738;
  color: #d8ffe6; contain: layout style;
}
.recovery-effect > b {
  position: relative; z-index: 1; margin-top: 30%; font: 700 clamp(22px, 3vw, 42px)/1 Georgia, serif;
  text-shadow: 0 2px 3px #103c29, 0 0 8px #1d925c, 0 0 18px #8bffc7;
}
.recovery-effect > i { position: absolute; left: 18%; top: 68%; opacity: 0; font: 700 17px/1 sans-serif; color: #a8f7cd; text-shadow: 0 0 6px #65ffc0; }
.recovery-effect > i:nth-child(2) { left: 74%; top: 60%; font-size: 12px; }
.recovery-effect > i:nth-child(3) { left: 42%; top: 80%; font-size: 10px; }
.recovery-effect[data-mode="formation"] { z-index: 1101; }
.equipment-effects { position: fixed; inset: 0; z-index: 42; overflow: hidden; pointer-events: none; }
.equipment-effects[data-mode="formation"] { z-index: 1101; }
/* Equipment feedback is anchored to the public equipment slot. */
.equipment-glow { position:absolute; box-sizing:border-box; border:1px solid #f5d37f; border-radius:3px; background:#efc76b18; box-shadow:0 0 8px #efc76b66,inset 0 0 5px #efc76b44; transform-origin:center; }
.equipment-edge { position:absolute; box-sizing:border-box; border:1px solid #f5d37f; border-radius:5px; }
.equipment-label { position:absolute; box-sizing:border-box; padding:4px 6px; text-align:center; color:#fff2c8; background:linear-gradient(90deg,#25221400,#252214ee 12% 88%,#25221400); font:12px/1.4 "Noto Sans SC",sans-serif; overflow:hidden; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow-wrap:anywhere; }
.equipment-old { position:absolute; inset:0; overflow:hidden; background:#302d20; color:#e5d5af; font:11px/1.4 "Noto Sans SC",sans-serif; }
.equipment-effects.is-still .equipment-glow { box-shadow:none; background:transparent; }

.card-motion-layer { position: fixed; inset: 0; z-index: 41; pointer-events: none; overflow: hidden; perspective: 900px; }
.card-flight, .draw-card, .discard-card {
  position: absolute; left: 0; top: 0; width: clamp(46px, 6.2vw, 72px); aspect-ratio: .72;
  border: 1px solid #d5bc7f; border-radius: 7px 3px 7px 3px; will-change: transform, opacity;
  box-shadow: 0 12px 24px #020909aa, 0 0 18px #e6bd5c42, inset 0 0 0 3px #fff3cd;
}
.card-flight {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: #2a3c32; background: repeating-linear-gradient(100deg, #7c613008 0 1px, transparent 1px 4px), linear-gradient(145deg, #fff6db, #d8c99e);
}
.card-flight > span { color: #8a6738; font-size: clamp(10px, 1.1vw, 14px); }
.card-flight > b { max-width: 88%; overflow: hidden; color: #263930; font-size: clamp(13px, 1.45vw, 18px); line-height: 1.15; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.card-flight > small { color: #846f49; font-size: clamp(8px, .8vw, 10px); letter-spacing: 1px; }
.discard-card { display: grid; place-items: center; border-color: #9f725c; color: #dfc29d; background: repeating-linear-gradient(45deg, #d7b27a0d 0 2px, transparent 2px 7px), linear-gradient(145deg, #442d2a, #1c2221); box-shadow: 0 10px 22px #020909aa, 0 0 16px #b66a4938, inset 0 0 0 3px #d3ad7b22; }
.discard-card > span { display: grid; width: 70%; aspect-ratio: 1; place-items: center; border: 1px solid #c39b6c88; border-radius: 50%; font-weight: 700; font-size: clamp(14px, 1.5vw, 20px); }
.draw-card { border: 0; background: transparent; box-shadow: none; transform-style: preserve-3d; }
.draw-card > span {
  position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden;
  border: 1px solid #c8a45f; border-radius: inherit; backface-visibility: hidden;
  box-shadow: 0 10px 22px #020909aa, 0 0 14px #dcb04b38, inset 0 0 0 3px #d8bd7733;
  transition: transform .4s ease-out; font-weight: 700;
}
.draw-card-back {
  color: #d6b974; background:
    radial-gradient(circle, transparent 22%, #c5a35b32 23% 25%, transparent 26%),
    repeating-linear-gradient(45deg, #d1b0640e 0 2px, transparent 2px 7px), linear-gradient(145deg, #253832, #101e20);
  letter-spacing: 3px; text-shadow: 0 1px 3px #000;
}
.draw-card-front { color: #293c32; background: linear-gradient(145deg, #fff6db, #d8c99e); transform: rotateY(180deg); font-size: clamp(11px, 1.25vw, 16px); }
.draw-card.revealed .draw-card-back { transform: rotateY(180deg); }
.draw-card.revealed .draw-card-front { transform: rotateY(360deg); }
.draw-count-burst, .discard-count-burst {
  position: absolute; transform: translate(-50%, -145%); padding: 2px 7px; border: 1px solid #d8b568;
  border-radius: 20px; color: #fff0bd; background: #172725e8; box-shadow: 0 3px 10px #0008;
  font-size: 13px; line-height: 1.25; text-shadow: 0 1px 3px #000;
}
.skill-ray-glow { stroke: #a75d16; stroke-width: 9; opacity: .45; }
.skill-ray { stroke: #ffe6a0; stroke-width: 3; }
.skill-ray, .skill-ray-glow { stroke-linecap: round; }
.skill-arrow { fill: #fff0b8; stroke: #b77c2b; stroke-width: 1; }
.skill-source, .skill-target { fill: #ffdf8522; stroke: #ffe6a0; stroke-width: 3; filter: drop-shadow(0 0 4px #b47724); }
.skill-effect-name { fill: #fff0bb; stroke: #584019; stroke-width: 3px; paint-order: stroke; font-size: 17px; font-weight: 700; }
@media (prefers-reduced-motion: reduce) {
  .draw-card > span { transition: none; }
  .card-flight, .draw-card, .discard-card { box-shadow: 0 4px 12px #020909aa, inset 0 0 0 2px #d8bd7733; }
}
:is(.in-battle,.in-formation) .site-header { display: none; }
:is(.in-battle,.in-formation) #app { max-width: none; padding: 0; }
:is(.in-battle,.in-formation) .pwa-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 80; }
.game-page .rotate-hint { display: none; }
.game-page .self-general > .portrait { display: none; }
.game-page .portrait:has(img) .portrait-name { display: none; }
.game-page .battle-log { position: fixed; z-index: 45; top: 60px; right: max(12px, env(safe-area-inset-right)); bottom: 12px; width: min(340px, calc(100vw - 24px)); box-shadow: 0 16px 60px #172a2444; }
.game-page .battle-log h3 { display: flex; align-items: center; justify-content: space-between; height: 50px; padding: 8px 14px; }
.game-page .battle-log button { font-size: 12px; padding: 5px 12px; }
.game-page #log-scroll { height: calc(100% - 50px); }
.game-page .game-layout { display: block; }
@media (orientation: landscape) and (min-width: 600px) {
  body:is(.in-battle,.in-formation) { overflow: hidden; padding: 0; background: #243c35; }
  :is(.in-battle,.in-formation) .game-page { height: 100dvh; padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 8px; }
  .game-page .game-heading { margin: 0; min-height: 42px; flex: 0 0 auto; color: #f5f2e9; align-items: center; }
  .game-page .game-heading h2 { font-size: 20px; margin: 0; }
  .game-page .game-heading .eyebrow { color: #c8d2ba; font-size: 10px; letter-spacing: 1px; }
  .game-page .game-heading .row { gap: 10px; }
  .game-page .game-heading .mode-pill { color: #243c35; }
  .game-page .game-heading button { color: #f5f2e9; border-color: #708274; min-height: 32px; }
  .game-page .game-heading button:hover { background: #3f594b; }
  .game-page .game-heading a { color: #f5f2e9; padding: 6px; }
  .game-page .game-layout { flex: 1; min-height: 0; }
  .game-page .table-column { height: 100%; display: grid; grid-template-rows: minmax(0, 1fr) clamp(170px, 28vh, 242px); border-color: #80947b; background: radial-gradient(ellipse at center, #e5e8d7, #bfcfba); box-shadow: inset 0 0 90px #47644338; }
  .battlefield { display: grid; min-height: 0; grid-template-columns: minmax(130px, 19%) 1fr 1fr minmax(130px, 19%); grid-template-rows: 1fr 1fr; gap: 12px 24px; padding: 20px 24px; }
  .battlefield .opponents { display: contents; }
  .battlefield .seat { align-self: center; justify-self: center; width: min(100%, 190px); max-height: 100%; min-height: 0; display: grid; grid-template-columns: 1fr; overflow: auto; scrollbar-width: thin; box-shadow: 0 5px 16px #243c3520; }
  .battlefield .seat[data-position="1"] { grid-column: 4; grid-row: 1 / 3; }
  .battlefield .seat[data-position="2"] { grid-column: 3; grid-row: 1; }
  .battlefield .seat[data-position="3"] { grid-column: 2; grid-row: 1; }
  .battlefield .seat[data-position="4"] { grid-column: 1; grid-row: 1 / 3; }
  .battlefield .seat.active { border-color: #af793a; box-shadow: 0 0 0 3px #c39954, 0 6px 24px #78552b40; }
  .battlefield .seat .portrait { width: 100%; min-width: 0; height: clamp(60px, 11vh, 120px); min-height: 0; }
  .battlefield .seat .portrait-glyph { font-size: 75px; }
  .battlefield .seat-info { padding: 6px 10px; }
  .battlefield .seat-info h3 { font-size: 17px; margin: 1px 0; }
  .battlefield .seat-info > .health, .battlefield .seat-info > .muted { display: inline-block; font-size: 11px; margin-right: 5px; }
  .battlefield .seat-skills { margin-top: 3px; }
  .battlefield .seat-skills details { display: inline-block; margin-right: 7px; border: 0; }
  .battlefield .seat-skills details[open] { display: block; }
  .battlefield .seat-skills summary { min-height: 25px; }
  .battlefield .table-center { grid-column: 2 / 4; grid-row: 2; min-height: 0; padding: 16px 6px 0; overflow: auto; }
  .battlefield > .table-watermark { font-size: clamp(42px, 7vw, 88px); letter-spacing: 18px; }
  .battlefield .deck-label { position: static; color: #596d52; margin-bottom: 8px; }
  .battlefield .current-event .eyebrow { font-size: 11px; letter-spacing: 1px; }
  .game-page .player-area { --player-card-width: 160px; display: grid; grid-template-columns: var(--player-card-width) minmax(0, 1fr) minmax(190px, 25%); gap: 14px; min-height: 0; padding: 10px 14px; background: #f7f4e9; }
  .self-general { position: relative; overflow: auto; min-height: 0; border-right: 1px solid #d9dccd; padding-right: 10px; }
  .game-page .self-general > .portrait { display: block; width: 46px; height: 56px; min-height: 0; float: left; margin: 0 8px 6px 0; border-radius: 4px; }
  .self-general > .portrait .portrait-caption, .self-general > .portrait .portrait-name { display: none; }
  .self-general > .portrait .portrait-glyph { font-size: 35px; }
  .game-page .self-heading, .game-page .self-heading > div { gap: 3px 6px; font-size: 10px; }
  .game-page .self-heading b { font-size: 19px; }
  .game-page .self-heading > span { font-size: 10px; }
  .game-page .self-skills { clear: both; display: block; margin: 6px 0 0; }
  .game-page .self-skills summary { padding: 5px 0; }
  .game-page .self-skills p { margin: 0; padding: 6px; }
  .game-page .self-general { align-self: end; height: 100%; }
  .hand-area { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
  .game-page .hand { flex: 1; min-height: 0; align-items: flex-end; justify-content: safe center; gap: 9px; padding: 0 4px; scrollbar-width: thin; }
  .game-page .playing-card { width: calc(var(--player-card-width) * .78); min-width: calc(var(--player-card-width) * .78); height: 78%; min-height: 0; }
  .game-page .playing-card b { font-size: 38px; }
  .game-page .card-tip { order: -1; flex-shrink: 0; text-align: center; font-size: 11px; line-height: 1.4; margin: 0 0 8px; max-height: 32px; overflow: auto; }
  .game-page .action-zone { min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: flex-end; padding: 0; border: 0; text-align: right; }
  .game-page .action-zone > p { width: 100%; flex-shrink: 0; min-height: 0; font-size: 12px; color: #526448; margin: 0; text-align: right; }
  .game-page .action-buttons { min-height: 0; overflow-y: auto; flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 6px; margin-top: 8px; padding: 1px; }
  .game-page .action-buttons button { width: 100%; padding: 8px 10px; min-height: 36px; font-size: 12px; flex: 0 0 auto; }
  .game-page .result { position: fixed; z-index: 50; top: 50%; left: 50%; transform: translate(-50%, -50%); margin: 0; width: min(620px, 85vw); max-height: calc(100dvh - 40px); overflow: auto; box-shadow: 0 0 0 100vmax #172a2477, 0 16px 80px #172a2466; }
}
@media (orientation: landscape) and (max-height: 600px) and (min-width: 600px) {
  :is(.in-battle,.in-formation) .game-page { padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: max(4px, env(safe-area-inset-bottom)); gap: 4px; }
  .game-page .game-heading { min-height: 32px; }
  .game-page .game-heading h2 { font-size: 16px; }
  .game-page .game-heading .eyebrow { font-size: 8px; }
  .game-page .game-heading .row { gap: 6px; }
  .game-page .game-heading button { padding: 5px 9px; }
  .game-page .mode-pill { display: none; }
  .game-page .table-column { grid-template-rows: minmax(0, 1fr) clamp(128px, 36vh, 178px); }
  .battlefield { grid-template-columns: minmax(112px, 20%) 1fr 1fr minmax(112px, 20%); gap: 4px 10px; padding: 8px 10px; }
  .battlefield .seat { grid-template-columns: 1fr; }
  .battlefield .seat .portrait { height: 100%; min-height: 74px; border-radius: 4px 0 0 4px; }
  .battlefield .seat .portrait-name { font-size: 12px; right: 5px; }
  .battlefield .seat .portrait-caption { display: none; }
  .battlefield .seat .portrait img { transform: scale(1.65); transform-origin: 50% 22%; }
  .battlefield .seat-info { padding: 3px 5px; }
  .battlefield .seat-info h3 { font-size: 13px; margin: 0; }
  .battlefield .seat .role { font-size: 9px; padding: 0 4px; }
  .battlefield .seat-info > .health, .battlefield .seat-info > .muted { font-size: 10px; line-height: 1.4; }
  .battlefield .seat-skills { font-size: 10px; margin: 0; }
  .battlefield .seat-skills summary { min-height: 24px; padding: 2px 0; }
  .battlefield .table-center { padding: 2px; }
  .battlefield .deck-label { font-size: 9px; margin-bottom: 3px; }
  .battlefield .current-event .eyebrow { font-size: 10px; }
  .game-page .player-area { --player-card-width: 118px; grid-template-columns: var(--player-card-width) minmax(0, 1fr) minmax(170px, 26%); padding: 5px 8px; gap: 8px; }
  .game-page .self-general > .portrait { width: 32px; height: 42px; margin-right: 5px; }
  .game-page .self-heading b { font-size: 15px; }
  .game-page .self-heading .health { font-size: 10px; }
  .game-page .self-heading .role { font-size: 9px; padding: 0 3px; }
  .game-page .self-skills { margin-top: 3px; }
  .game-page .self-skills summary { padding: 3px 0; }
  .game-page .hand { padding: 0 3px; gap: 6px; }
  .game-page .playing-card { width: calc(var(--player-card-width) * .78); min-width: calc(var(--player-card-width) * .78); min-height: 0; height: 78%; padding: 3px 6px; }
  .game-page .playing-card b { font-size: 30px; }
  .game-page .playing-card small { font-size: 8px; }
  .game-page .action-zone { padding: 0; }
  .game-page .action-zone > p { font-size: 11px; line-height: 1.5; }
  .game-page .action-buttons { margin-top: 4px; gap: 4px; }
  .game-page .action-buttons button { font-size: 11px; min-height: 27px; padding: 3px 8px; }
  .game-page .card-tip { font-size: 10px; max-height: 28px; }
}
@media (orientation: portrait), (max-width: 599px) {
  :is(.in-battle,.in-formation) .game-page { padding: 12px; }
  .game-page .rotate-hint { display: flex; gap: 10px; align-items: center; background: #e4e9dd; border: 1px solid #c7d2bd; border-radius: 8px; padding: 12px; margin-bottom: 14px; }
  .rotate-hint > span { font-size: 34px; }
  .rotate-hint b { font-size: 13px; }
  .rotate-hint p { font-size: 11px; margin: 3px 0 0; color: #68755e; }
  .rotate-hint button { font-size: 11px; padding: 7px; flex-shrink: 0; }
  .game-page .game-heading { gap: 8px; flex-wrap: wrap; }
  .game-page .game-heading h2 { font-size: 20px; }
  .game-page .game-heading .row { gap: 7px; flex-wrap: wrap; }
  .game-page .game-heading button { font-size: 11px; padding: 6px 8px; }
  .game-page .self-general { margin-bottom: 8px; }
}

/* Full-card artwork with readable information layered over the scene. */
.game-page .seat, .game-page .self-general {
  --card-inset: 4px; --hand-count-height: 10px; --equipment-stack-height: 54px;
  --equipment-bottom: calc(var(--card-inset) + var(--hand-count-height) + 6px);
  position: relative; isolation: isolate; background: #20342d; color: #fff4dd;
  border: 1px solid #9b987566; border-radius: 7px; overflow: auto;
}
.game-page .seat { display: flex; flex-direction: column; height: 260px; max-height: 100%; }
@media (orientation: landscape) and (min-width: 600px) {
  .battlefield { grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
}
.game-page .seat > .portrait, .game-page .self-general > .portrait {
  display: block; position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%;
  min-height: 0; margin: 0; float: none; border-radius: inherit; pointer-events: none;
}
.game-page .seat > .portrait img, .game-page .self-general > .portrait img {
  width: 100%; height: 100%; object-fit: cover; object-position: 50% 24%; transform: none;
}
.game-page .seat > .portrait::after, .game-page .self-general > .portrait::after {
  background: linear-gradient(180deg, #0c191300 50%, #0c191373 75%, #0c1913cc 100%);
}
.game-page .seat .portrait-name, .game-page .seat .portrait-caption { display: none; }
.game-page .seat-info { margin-top: auto; padding: 74px var(--card-inset) var(--card-inset); background: transparent; }
.game-page .seat-info h3, .game-page .self-heading b { color: #fff2d2; text-shadow: 0 1px 2px #07110fe6, 0 0 3px #07110f99; }
.game-page .seat-info > .health, .game-page .self-heading .health { color: #ffd39d; }
.game-page .seat-info > .muted, .game-page .self-heading > span { color: #ece5d4; }
.game-page .seat .role, .game-page .self-general .role { color: #f6e7c5; background: #172c24d9; border: 1px solid #d6c19455; }
.game-page .seat .role.lord { color: #ffe5b0; background: #762b22e8; }
.game-page .seat .role, .game-page .self-general .role {
  position: absolute; top: var(--card-inset); left: var(--card-inset); z-index: 4; margin: 0;
  box-shadow: 0 1px 4px #0005; pointer-events: none;
}
.game-page .hand-count {
  position: absolute; right: var(--card-inset); z-index: 4; color: #e7dcc2;
  padding: 0 2px 1px 0; text-align: right; pointer-events: none;
  font-size: var(--hand-count-height); line-height: 1; text-shadow: 0 1px 3px #000, 0 0 5px #000;
}
.game-page .seat-skills, .game-page .self-skills {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0; padding-right: calc(40% + 8px);
}
.game-page .seat-skills summary, .game-page .self-skills summary { color: #fff0cb; text-shadow: 0 1px 3px #000; }
.game-page .seat-skills p, .game-page .self-skills p { color: #fff2d7; background: #14271ff5; border-radius: 4px; padding: 7px; text-shadow: none; }
.game-page .seat-skills button, .game-page .self-skills button {
  min-height: 24px; max-width: 100%; overflow-wrap: anywhere; padding: 2px 3px; margin: 0; border: 0; background: transparent;
  color: #fff0cb; font: inherit; text-shadow: 0 1px 2px #07110fe6, 0 0 3px #07110f99; cursor: pointer;
}
.game-page .seat-skills button:hover, .game-page .self-skills button:hover { color: #fff; text-decoration: underline; }
.game-page .seat-skills button:focus-visible, .game-page .self-skills button:focus-visible { outline: 2px solid #ffe39b; outline-offset: 1px; }
.game-page .treasure-zone {
  position: absolute; right: var(--card-inset); bottom: var(--equipment-bottom); z-index: 1;
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px; width: min(76px, 40%); margin: 0; padding: 0;
  pointer-events: none;
}
.game-page .treasure-slot {
  flex-shrink: 0; min-width: 0; max-width: 100%; height: 25px; display: flex; align-items: center; gap: 3px; padding: 2px 5px;
  overflow: hidden; border: 1px solid #c9ac6c66; border-radius: 4px; color: #f8e7bd; background: #17241f66;
  font-size: 8px; line-height: 1; text-shadow: 0 1px 2px #000;
}
.game-page .treasure-slot small { flex: 0 0 auto; color: #d6b568; font-size: 7px; }
.game-page .treasure-slot b { overflow: hidden; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.game-page .treasure-slot.empty { width: 34px; margin: 0; justify-content: center; color: #ded4bbb3; border-style: dashed; background: #111b1940; }
.game-page .treasure-slot { pointer-events: auto; }
.skill-modal {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 18px;
  background: #10211bc9; backdrop-filter: blur(5px);
}
.skill-modal-card {
  position: relative; width: min(760px, calc(100vw - 36px)); max-height: calc(100dvh - 36px); overflow: auto;
  padding: 28px 30px; border: 1px solid #d8bd7c; border-radius: 10px;
  background: linear-gradient(145deg, #fffaf0, #e8ead9); color: #263c33;
  box-shadow: 0 24px 80px #07110daa, inset 0 0 0 3px #fff8df;
}
.skill-modal-card .eyebrow { color: #8a6735; }
.skill-modal-card h2 { margin: 7px 32px 12px 0; color: #263c33; font-size: 28px; }
.skill-modal-card p { margin: 0; font-size: 15px; line-height: 1.9; }
.skill-modal-close {
  position: absolute; top: 12px; right: 12px; width: 34px; min-height: 34px; padding: 0;
  border-radius: 50%; font-size: 23px; line-height: 1; color: #53675d; background: #ffffff99;
}
.game-page .self-general { display: flex; flex-direction: column; padding: var(--card-inset); }
.game-page .self-heading { margin-top: auto; padding-top: 40px; }
.game-page .self-skills { flex-shrink: 0; }
.game-page .seat.target-selected, .game-page .self-general.target-selected { box-shadow: inset 0 0 0 3px #ffdc83, 0 0 16px #e1b65888; }
@media (orientation: landscape) and (max-height: 600px) and (min-width: 600px) {
  /* Size all opponents from the same row, keeping the desktop portrait composition. */
  .game-page .seat, .game-page .self-general {
    --card-inset: 3px; --hand-count-height: 9px; --equipment-stack-height: 38px;
    --equipment-bottom: calc(var(--card-inset) + var(--hand-count-height) + 3px);
  }
  .battlefield { grid-template-rows: minmax(0, 1fr) clamp(24px, 8dvh, 40px); padding-top: 4px; }
  .game-page .seat { align-self: start; width: auto; height: min(100%, 156px); max-width: 100%; aspect-ratio: 3 / 4; overflow: hidden; }
  .battlefield .seat[data-position] { grid-row: 1; }
  .battlefield .seat[data-position="1"], .battlefield .seat[data-position="4"] { margin-top: clamp(36px, calc(3dvh + 28px), 42px); }
  .game-page .seat-info { flex: 0 1 auto; min-height: 0; width: 100%; margin-top: auto; padding: 22px var(--card-inset) var(--card-inset); overflow-y: auto; scrollbar-width: thin; }
  .game-page .seat-info h3 { padding-right: 18px; line-height: 1.2; }
  .game-page .seat-skills { line-height: 1.3; }
  .game-page .seat > .portrait img { object-position: 50% 22%; }
  .game-page .seat-skills button, .game-page .self-skills button { min-height: 20px; padding: 1px 2px; }
  .game-page .treasure-zone { width: min(48px, 40%); gap: 2px; }
  .game-page .treasure-slot { height: 18px; padding: 1px 3px; }
  .game-page .treasure-slot.empty { width: 24px; font-size: 0; }
  .game-page .treasure-slot.empty::after { content: '槽'; font-size: 7px; }
  .game-page .self-general { padding: var(--card-inset); }
  .game-page .self-heading { padding-top: 20px; }
  .game-page .self-heading > span { display: none; }
}
@media (orientation: portrait), (max-width: 599px) {
  .game-page .seat { height: 240px; }
  .game-page .self-general { min-height: 190px; }
  .game-page .self-general > .portrait img { object-position: 50% 22%; }
  .skill-modal-card { padding: 24px 22px; }
  .skill-modal-card h2 { font-size: 24px; }
}

/* Night campaign table: bronze inlay, low warm light and parchment cards. */
html:has(body:is(.in-battle,.in-formation)) { background: #101a1b; }
html:has(body:is(.in-battle,.in-formation))::backdrop { background: #101a1b; }
body:is(.in-battle,.in-formation) { background: #101a1b; color: #e8dec6; }
.game-page { background: radial-gradient(ellipse at 50% 0, #34403a, #111c1e 65%); }
.game-page .game-heading { color: #f0dfb6; }
.game-page .game-heading h2 { color: #f0dfb6; text-shadow: 0 2px 12px #d7aa5b33; letter-spacing: 2px; }
.game-page .game-heading .eyebrow { color: #b9b394; }
.game-page .game-heading a { color: #d7c8a6; }
.game-page .game-heading button { color: #e2d2ac; background: #14212399; border-color: #8e815855; }
.game-page .game-heading button:hover { background: #74603a44; border-color: #bc985f; }
.game-page .game-heading .mode-pill { color: #e5d1a4; background: #29332d; border: 1px solid #99835755; }
.game-page .table-column {
  position: relative; isolation: isolate; border: 0; border-radius: 0;
  background:
    radial-gradient(ellipse at 50% 42%, #61705a28 0, transparent 56%),
    radial-gradient(ellipse at 1% 45%, #d59a4930 0, transparent 28%),
    radial-gradient(ellipse at 99% 45%, #d59a4929 0, transparent 28%),
    repeating-linear-gradient(0deg, transparent 0 3px, #ffffff02 3px 4px),
    linear-gradient(135deg, #25322d, #17282a 48%, #222c26);
  box-shadow: inset 0 0 140px #030b10aa;
}
.game-page .battlefield { position: relative; isolation: isolate; }
.game-page .battlefield::before {
  content: ""; position: absolute; z-index: -1; inset: 12% 22%; border: 1px solid #d4b27320;
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(ellipse, transparent 48%, #b1965420 49%, transparent 49.4%, transparent 65%, #b1965418 65.3%, transparent 66%);
  box-shadow: 0 0 0 12px #b1965405, 0 0 0 13px #b1965410, inset 0 0 70px #d6b76c08;
}
.game-page .battlefield::after {
  content: none; position: absolute; z-index: -1; inset: 12px; pointer-events: none;
  background:
    linear-gradient(#c5a56866, #c5a56866) left top / 34px 1px,
    linear-gradient(#c5a56866, #c5a56866) left top / 1px 34px,
    linear-gradient(#c5a56866, #c5a56866) right top / 34px 1px,
    linear-gradient(#c5a56866, #c5a56866) right top / 1px 34px,
    linear-gradient(#c5a56844, #c5a56844) left bottom / 34px 1px,
    linear-gradient(#c5a56844, #c5a56844) left bottom / 1px 34px,
    linear-gradient(#c5a56844, #c5a56844) right bottom / 34px 1px,
    linear-gradient(#c5a56844, #c5a56844) right bottom / 1px 34px;
  background-repeat: no-repeat;
}
.game-page .seat, .game-page .self-general { border-color: #bba16c77; box-shadow: 0 12px 25px #0008, 0 0 0 3px #080f1244; }
.game-page .seat.active, .game-page .self-general.active { border-color: #f3d091; box-shadow: 0 0 0 2px #a58549, 0 0 30px #f3bb4a40, 0 10px 30px #0008; }
/* Shared by identity and formation cards; only the narrow edge carries motion. */
.action-border {
  position: absolute; top: calc(-1 * var(--frame-top)); left: calc(-1 * var(--frame-left)); z-index: 8;
  width: calc(100% + var(--frame-left) + var(--frame-right)); height: calc(100% + var(--frame-top) + var(--frame-bottom));
  overflow: hidden; pointer-events: none; border-radius: inherit;
  filter: drop-shadow(0 0 2px #ffd67e);
}
.game-page .action-border rect { width: calc(100% - 1.5px); height: calc(100% - 1.5px); }
.action-border rect {
  fill: none; stroke: #fff0bc; stroke-width: 2; stroke-linecap: round;
  animation: action-border-flow 3s linear infinite;
}
.action-border.is-still { visibility: hidden; }
@keyframes action-border-flow {
  from { stroke-dashoffset: var(--flow-from); }
  to { stroke-dashoffset: var(--flow-to); }
}
@media (prefers-reduced-motion: reduce) {
  .action-border { visibility: hidden; }
}
.game-page .seat.target-eligible, .game-page .self-general.target-eligible { outline-color: #e0b869; }
.game-page .seat.target-selected, .game-page .self-general.target-selected { outline-color: #ffe6a3; box-shadow: inset 0 0 0 3px #ffdc83, 0 0 24px #e1b65888; }
.game-page .table-center { align-self: center; position: relative; padding: 16px 8px; }
.game-page .battlefield > .table-watermark {
  position: absolute; left: 50%; top: 50%; z-index: -1; transform: translate(-50%, -50%);
  color: #c0a46a12; text-shadow: 0 1px #e2c2810a; pointer-events: none;
}
.game-page .battle-log-toggle {
  position: relative; align-self: flex-end; flex: 0 0 auto; margin-top: auto; z-index: 6; min-width: 54px; min-height: 34px; padding: 6px 12px;
  border: 1px solid #c2a26699; border-radius: 9px 3px 9px 3px; color: #f2d99f;
  background: linear-gradient(145deg, #394234e8, #0e1d1eee); box-shadow: 0 3px 12px #0006, inset 0 0 0 3px #c2a2660c;
}
.game-page .battle-log-toggle:hover { background: #394335; border-color: #d5b675; }
.game-page .battle-log-toggle.is-open { color: #fff0bd; border-color: #d6b76f; background: linear-gradient(145deg, #765b2f, #382c1c); }
.game-page .deck-label { color: #b5b49b; letter-spacing: 1px; }
.game-page .current-event { max-width: 430px; margin: 0 auto; }
.game-page .current-event > .eyebrow { color: #d6b877; }
.game-page .table-center .fine-print { color: #c2b69d; }
.game-page .player-area {
  border-top: 0;
  background: transparent;
  box-shadow: none;
}
.game-page .action-zone { border-color: #b1955940; }
.game-page .action-zone > p, .game-page .card-tip { color: #cfc5ad; }
.game-page { --action-background:#172626; --action-color:#e4d4ad; --action-border:#a389565e; }
.game-page :is(.action-buttons button,.action-zone .army-controls > button,.action-zone .army-controls > summary) { color:var(--action-color); border:1px solid var(--action-border); background:var(--action-background); border-radius:5px; }
.game-page :is(.action-buttons button,.action-zone .army-controls > button,.action-zone .army-controls > summary):hover:not(:disabled) { background:#394335; border-color:#d5b675; }
.game-page .action-buttons button.primary { color: #fff0d1; background: linear-gradient(135deg, #856331, #584322); border-color: #b89554; box-shadow: inset 0 1px #ffdd8a33; }
.game-page .action-buttons :is([data-cmd="select-skill"],[data-formation="skill"])[aria-pressed="true"] { color: #ffebb3; background: #756038; border-color: #dab36e; }
.game-page .action-buttons button:disabled { opacity: .48; }
.game-page .playing-card {
  color: #283b32; border-color: #b6a478;
  background: repeating-linear-gradient(100deg, #7c613005 0 1px, transparent 1px 4px), linear-gradient(145deg, #fff6db, #ddd1ac);
  box-shadow: 0 5px 10px #0006, inset 0 0 0 3px #f7efda, inset 0 0 0 4px #b7a579;
}
.game-page .playing-card > span, .game-page .playing-card small { color: #6e6146; }
.game-page .playing-card.playable { border-color: #d6bb7d; box-shadow: 0 5px 12px #0008, inset 0 0 0 3px #f7efda, inset 0 0 0 4px #b7a579, 0 0 10px #d7bb6718; }
.game-page .playing-card.unavailable { color: #4c594d; background: linear-gradient(145deg, #babbab, #8c9587); box-shadow: 0 3px 8px #0004, inset 0 0 0 3px #abb09d, inset 0 0 0 4px #7d8772; }
.game-page .playing-card:disabled { cursor: not-allowed; transform: none; }
.game-page .playing-card.selected { color: #42320f; border-color: #ffe19a; background: linear-gradient(135deg, #fff5d6, #f0d58e); box-shadow: 0 0 0 1px #e8b64c, 0 0 24px #f6c66166, 0 8px 14px #0007; transform: translateY(-16px); }
.game-page .battle-log {
  position: fixed; z-index: 47; top: auto; right: var(--battle-log-right, max(12px, env(safe-area-inset-right))); bottom: var(--battle-log-bottom, 58px);
  box-sizing: border-box; width: min(380px, var(--battle-log-width, calc(100vw - 24px))); height: var(--battle-log-height, calc(100dvh - 86px)); min-height: 0; display: flex; flex-direction: column; color: #e9dfc8;
  border: 1px solid #b99a605f; border-radius: 14px 4px 14px 4px;
  background: linear-gradient(160deg, #1d302c, #111f20 62%, #172421); box-shadow: 0 22px 70px #020908dd, inset 0 0 0 3px #d2b5700a;
}
.game-page .battle-log h3 {
  height: auto; min-height: 36px; flex: 0 0 auto; gap: 12px; margin: 0; padding: 7px 12px;
  color: #f1dca9; border: 0; border-bottom: 1px solid #b99a6038;
  background: linear-gradient(90deg, #73562f38, transparent 72%); box-shadow: inset 3px 0 #c8a55e;
}
.game-page .battle-log-title { display: flex; flex: 0 0 auto; float: none; margin: 0; }
.game-page .battle-log-title b { color: #f1dca9; font: 14px/1.4 "Noto Sans SC", sans-serif; letter-spacing: 1px; }
.game-page .battle-log-summary {
  display: flex; justify-content: flex-end; gap: 10px; float: none; margin: 0; padding: 0;
  color: #a99b7c; font-size: 10px; font-weight: 400; line-height: 1.4; white-space: nowrap;
}
.game-page .battle-log-summary span { float: none; margin: 0; font: inherit; color: inherit; }
.game-page #log-scroll {
  height: auto; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 2px; padding: 8px 10px;
  background: radial-gradient(circle at 100% 0, #a8874520, transparent 36%); scrollbar-color: #8f7748 #101c1c;
}
.game-page #log-scroll .log-entry {
  position: relative; display: block; flex: 0 0 auto;
  margin: 0; padding: 5px 8px 5px 10px; border: 0; border-bottom: 1px solid #b99a601a; border-radius: 0;
  color: #ddd4bf; background: transparent; font-size: 11px; line-height: 1.65;
  box-shadow: none;
}
.game-page #log-scroll .log-entry::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: #8d825f;
}
.game-page #log-scroll .log-skill::before { background: #d0a657; }
.game-page #log-scroll .log-card::before { background: #6fa486; }
.game-page #log-scroll .log-draw::before { background: #77a6a0; }
.game-page #log-scroll .log-discard::before { background: #a87962; }
.game-page #log-scroll .log-danger::before { background: #bd6d57; }
.game-page #log-scroll .log-turn-heading {
  position: relative; display: flex; align-items: baseline; gap: 9px; flex: 0 0 auto;
  min-height: 30px; margin: 1px 0; padding: 6px 10px; border: 1px solid #b99a6050; border-radius: 7px 2px 7px 2px;
  color: #c6aa70; background: linear-gradient(100deg, #443820, #172725 72%); box-shadow: 0 4px 12px #030a09a0;
}
.game-page #log-scroll .log-turn-heading span { font-size: 9px; letter-spacing: .5px; }
.game-page #log-scroll .log-turn-heading strong { color: #f1cf87; font-size: 11px; }
.game-page #log-scroll .log-message { min-width: 0; color: #ddd4bf; }
.game-page #log-scroll .log-message strong { font-weight: 700; }
.game-page #log-scroll .log-hero-name { color: #f1cf87; text-shadow: 0 0 10px #d8a94b24; }
.game-page #log-scroll .log-hero-name.is-self { color: #ffe7a8; }
.game-page #log-scroll .log-skill-name { color: #d9b8e8; text-shadow: 0 0 10px #b987d629; }
.game-page #log-scroll .log-card-name { color: #98d4b0; text-shadow: 0 0 10px #62ae8129; }
.game-page .battle-log small { color: #c6ac76; }
.game-page .battle-log button { color: #e4cea0; border-color: #ac8d5577; }
@media (orientation: landscape) and (min-height: 601px) and (min-width: 600px) {
  :is(.in-battle,.in-formation) .game-page .battlefield { padding-top: 4px; }
  .game-page .seat { align-self: start; width: auto; height: clamp(178px, 24vh, 216px); max-width: min(100%, 162px); aspect-ratio: 3 / 4; }
  .battlefield .seat[data-position="1"], .battlefield .seat[data-position="4"] { margin-top: clamp(56px, calc(6vh + 16px), 70px); }
}
@media (orientation: landscape) and (max-height: 600px) and (min-width: 600px) {
  .game-page .table-center { display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 8px; max-height: 100%; padding: 0; }
  .game-page .table-center .deck-label { flex-shrink: 0; gap: 5px; margin: 0; font-size: 8px; }
  .game-page .table-center .deck-card-back { flex-basis: 13px; width: 13px; height: 18px; }
  .game-page .table-center .current-event { min-width: 0; margin: 0; }
  .game-page .table-center .current-event > .eyebrow { font-size: 9px; line-height: 1.2; }
  .game-page .battlefield::after { inset: 5px; opacity: .5; }
  .game-page .battlefield::before { inset: 8% 20%; }
  .game-page .battle-log-toggle { min-width: 44px; min-height: 28px; padding: 3px 8px; font-size: 10px; }
}
@media (orientation: landscape) and (max-height: 350px) {
  .game-page .table-center .deck-label { display: flex; }
  .game-page .battle-log h3 { min-height: 32px; padding: 5px 10px; }
  .game-page #log-scroll { gap: 5px; padding: 6px; }
}
@media (orientation: portrait), (max-width: 599px) {
  .game-page .rotate-hint { color: #e5d3ad; background: #28332e; border-color: #a88b554d; }
  .game-page .rotate-hint p { color: #c5bba3; }
  .game-page .rotate-hint button { color: #f1dfb7; background: #354034; border-color: #a88b5577; }
}

/* Only content avoids the cutout; the table and player-area backgrounds span it. */
@media (orientation: landscape) and (min-width: 600px) {
  body:is(.in-battle,.in-formation) .game-page { padding-left: 0; padding-right: 0; --battle-safe-left: env(safe-area-inset-left, 0px); --battle-safe-right: env(safe-area-inset-right, 0px); }
  :is(.in-battle,.in-formation) .game-page .battlefield { padding-left: calc(24px + var(--battle-safe-left)); padding-right: calc(24px + var(--battle-safe-right)); }
  :is(.in-battle,.in-formation) .game-page .player-area { padding-left: calc(14px + var(--battle-safe-left)); padding-right: calc(14px + var(--battle-safe-right)); }
}
@media (orientation: landscape) and (min-width: 600px) and (max-height: 600px) {
  :is(.in-battle,.in-formation) .game-page .battlefield { padding-left: calc(10px + var(--battle-safe-left)); padding-right: calc(10px + var(--battle-safe-right)); }
  :is(.in-battle,.in-formation) .game-page .player-area { padding-left: calc(8px + var(--battle-safe-left)); padding-right: calc(8px + var(--battle-safe-right)); }
}

/* The HUD floats over the table; it never reserves a toolbar row. */
:is(.in-battle,.in-formation) .game-page { position: relative; padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
.game-page .game-heading {
  position: absolute; top: max(14px, env(safe-area-inset-top)); left: calc(24px + var(--battle-safe-left, env(safe-area-inset-left, 0px)));
  right: calc(8px + var(--battle-safe-right, env(safe-area-inset-right, 0px))); z-index: 50; min-height: 0; margin: 0; padding: 0;
  display: flex; align-items: flex-start; justify-content: flex-end; pointer-events: none;
}
.game-page .game-heading h2 { display: none; }
.game-page .game-heading .eyebrow { font-size: 10px; letter-spacing: 1px; color: #d4c5a2; }
.game-page .battle-tools {
  pointer-events: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.game-page .battle-menu { position: relative; }
.game-page .battle-menu > .battle-tool { box-shadow: none; }
.game-page .battle-tools .battle-menu-panel { top: 0; right: calc(100% + 8px); }
.game-page .battle-tool {
  position: relative; display: grid; place-items: center; width: 38px; min-height: 38px; padding: 0;
  border: 1px solid #c2a26699; border-radius: 9px 3px 9px 3px;
  color: #f2d99f; background: linear-gradient(145deg, #394234f2, #0e1d1ef5);
  box-shadow: 0 3px 12px #0006, inset 0 0 0 3px #c2a2660c;
}
.game-page .battle-tool:hover, .game-page .battle-tool:focus-visible { color: #fff0bd; background: #394335; border-color: #d5b675; }
.game-page .battle-tool.is-active { color: #fff0bd; border-color: #d6b76f; background: linear-gradient(145deg, #765b2f, #382c1c); }
.game-page .battle-tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.game-page .battle-tool-label {
  position: absolute; top: calc(100% + 7px); right: 0; width: max-content; max-width: 150px; padding: 4px 7px;
  border: 1px solid #9e875b88; border-radius: 4px; background: #101d1df2; color: #f3e5c3;
  font-size: 10px; line-height: 1.2; opacity: 0; transform: translateY(-3px); pointer-events: none;
  transition: opacity .15s, transform .15s;
}
.game-page .battle-tool:hover .battle-tool-label, .game-page .battle-tool:focus-visible .battle-tool-label { opacity: 1; transform: translateY(0); }
.game-page a.battle-tool, .game-page .battle-tool.battle-leave { color: #dcb391; text-decoration: none; }
.game-page .battle-menu-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 3; width: 184px; padding: 6px;
  border: 1px solid #b99a6070; border-radius: 10px 3px 10px 3px;
  background: #101d1e; background-image: linear-gradient(155deg, #253532, #101d1e); box-shadow: 0 16px 38px #000b, inset 0 0 0 2px #d2b5700a;
}
.game-page .battle-menu-panel .battle-tool {
  width: 100%; min-height: 36px; display: flex; justify-content: flex-start; gap: 10px; padding: 6px 9px;
  border: 0; border-radius: 5px; background: transparent; box-shadow: none;
}
.game-page .battle-menu-panel .battle-tool:hover, .game-page .battle-menu-panel .battle-tool:focus-visible { background: #88704432; }
.game-page .battle-menu-panel .battle-tool svg { flex: 0 0 18px; width: 18px; height: 18px; }
.game-page .battle-menu-panel .battle-tool-label {
  position: static; width: auto; max-width: none; padding: 0; border: 0; background: transparent;
  color: inherit; font-size: 12px; opacity: 1; transform: none; transition: none;
}
.game-page .battle-menu-panel .battle-audio-control { display: block; width: 100%; }
.game-page .battle-audio-control { position: relative; display: block; }
@media (orientation: portrait), (max-width: 599px) {
  .game-page .rotate-hint { padding-top: 84px; }
  .game-page .battle-tool { width: 35px; min-height: 35px; }
  .game-page .battle-menu-panel .battle-tool { width: 100%; min-height: 36px; }
}

.audit-modal {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 18px;
  background: #081411d9; backdrop-filter: blur(6px);
}
.audit-modal-card {
  position: relative; width: min(760px, calc(100vw - 36px)); max-height: calc(100dvh - 36px); overflow: auto;
  padding: 26px 28px; border: 1px solid #c8a968; border-radius: 10px;
  background: linear-gradient(145deg, #f9f4e8, #e2e6d8); color: #263c33;
  box-shadow: 0 24px 80px #020908cc, inset 0 0 0 3px #fff9e5;
}
.audit-modal-close {
  position: absolute; top: 12px; right: 12px; width: 34px; min-height: 34px; padding: 0;
  border-radius: 50%; color: #53675d; background: #ffffff99; font-size: 23px; line-height: 1;
}
.audit-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; padding-right: 42px; }
.audit-heading h2 { margin: 4px 0 0; color: #263c33; }
.audit-help { margin: 14px 0 18px; color: #647269; font-size: 13px; line-height: 1.7; }
.audit-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.audit-list li { padding: 13px 15px; border: 1px solid #c9cbbd; border-radius: 7px; background: #fffdf6; }
.audit-record-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.audit-record-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.audit-timing { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .8rem; color: var(--muted); }
.audit-timing span { white-space: nowrap; }
.audit-log-button { min-height: 24px; padding: 2px 6px; line-height: 1.2; border-color: #b6a57d; background: #fffaf0; color: #4e5f56; font-size: 11px; white-space: nowrap; }
.audit-mode { padding: 3px 7px; border-radius: 20px; background: #dde4d7; color: #476052; font-size: 11px; white-space: nowrap; }
.audit-mode.guarded { background: #f1dfbd; color: #78531d; }
.audit-mode.fallback { background: #edd1c8; color: #813e31; }
.audit-list p { margin: 6px 0 0; font-size: 13px; }
.audit-list .audit-action { color: #243c35; font-weight: 700; }
.audit-list .audit-reason { color: #8a5d25; }
.audit-empty { padding: 34px; border: 1px dashed #b9bba9; border-radius: 8px; text-align: center; color: #66736a; }
.audit-empty p { margin-bottom: 0; }
.llm-log-modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 18px; background: #081411e8; }
.llm-log-card { position: relative; width: min(920px, calc(100vw - 36px)); max-height: calc(100dvh - 36px); overflow: auto; padding: 26px 28px; border: 1px solid #c8a968; border-radius: 10px; background: #f4f1e7; color: #263c33; box-shadow: 0 24px 80px #020908e6; }
.llm-log-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 40px 0 0; }
.llm-log-heading h2 { margin: 0; min-width: 0; white-space: nowrap; }
.llm-log-tabs { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.llm-log-tabs button { min-width: 0; min-height: 32px; padding: 4px 8px; border: 0; border-radius: 0; box-shadow: none; background: transparent; color: var(--muted); font-size: 14px; }
.llm-log-tabs button:hover { background: transparent; color: var(--ink); }
.llm-log-tabs button[aria-selected="true"], .llm-log-tabs button[aria-selected="true"]:hover { background: transparent; color: var(--gold); font-weight: 700; box-shadow: none; }
.llm-log-card > h3, .llm-log-card #llm-log-panel > h3 { margin: 18px 0 8px; font-size: 16px; }
.llm-log-sections { display: flex; flex-direction: column; gap: 28px; margin-top: 18px; }
.llm-log-card > h3 + .llm-log-sections, .llm-log-card #llm-log-panel > h3 + .llm-log-sections { margin-top: 0; }
.llm-log-sections section { min-width: 0; }
.llm-log-sections > section + section { border-top: 1px solid #bca77b55; padding-top: 24px; }
.llm-log-sections h3 { margin: 0 0 7px; font-size: 14px; }
.llm-log-sections pre { margin: 0; padding: 0; border: 0; background: transparent; color: inherit; font: 14px/1.7 "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif; white-space: pre-wrap; overflow-wrap: anywhere; }
.llm-log-sections pre.llm-log-json { padding: 12px 14px; border: 1px solid #bca77b33; border-radius: 8px; background: #0003; font: 13px/1.65 ui-monospace, "Sarasa Mono SC", "Noto Sans SC", monospace; tab-size: 2; }
@media (max-width: 599px) {
  .audit-modal { padding: 10px; }
  .audit-modal-card { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); padding: 22px 18px; }
  .audit-record-heading { align-items: flex-start; }
  .audit-record-tools { align-items: flex-end; flex-direction: column; }
  .llm-log-modal { padding: 10px; }
  .llm-log-card { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); padding: 22px 18px; }
  .llm-log-heading { gap: 8px; margin-right: 36px; }
  .llm-log-heading h2 { font-size: 18px; }
  .llm-log-tabs button { padding: 4px 4px; font-size: 13px; }
}
@media (orientation: landscape) and (max-height: 600px) and (min-width: 600px) {
  .game-page .game-heading { top: max(4px, env(safe-area-inset-top)); }
  .game-page .battle-tool { width: 30px; min-height: 30px; padding: 0; }
  .game-page .battle-menu-panel { width: 168px; }
  .game-page .battle-menu-panel .battle-tool { width: 100%; min-height: 31px; padding: 4px 7px; }
  .game-page .battle-tool svg { width: 18px; height: 18px; }
}

/* Dialogs and results share the lobby palette; card artwork keeps its own colors. */
.skill-modal-card, .audit-modal-card, .llm-log-card { background: var(--surface); color: var(--ink); border-color: var(--gold); box-shadow: 0 24px 80px #020908cc; }
.skill-modal-card h2, .audit-heading h2, .audit-list .audit-action { color: var(--ink); }
.skill-modal-card .eyebrow, .audit-list .audit-reason { color: var(--gold); }
.skill-modal-close, .audit-modal-close, .audit-log-button { background: var(--raised); color: var(--ink); border-color: var(--line); }
.audit-help, .audit-empty { color: var(--muted); }
.audit-list li { background: var(--control); border-color: var(--line); }
.audit-mode { background: var(--raised); color: var(--muted); }
.audit-mode.guarded { background: #423b29; color: var(--warning); }
.audit-mode.fallback { background: #42302b; color: var(--danger); }
.game-page .result { background: var(--surface); color: var(--ink); border-color: var(--gold); }

.game-page .seat button.role-mark {
  pointer-events: auto; z-index: 4; cursor: pointer; appearance: none;
  width: auto; min-width: 38px; min-height: 24px; margin: 0;
  font-family: inherit; line-height: 1.2; padding: 3px 5px;
}
.game-page .seat button.role-mark[data-marked="true"] { border-style: dashed; color: #ffe0a0; }
.game-page .seat button.role-mark:focus-visible { outline: 2px solid #ffe0a0; outline-offset: 2px; }

/* One scene spans the opponents, hand area and safe-area padding. */
.game-page.has-scene-background { background-repeat: no-repeat; }
.game-page.has-scene-background .table-column,
.game-page.has-scene-background .battlefield,
.game-page.has-scene-background .player-area { background: transparent; box-shadow: none; }
.game-page.has-scene-background .battlefield::before { content: none; }

/* Identity badges share one compact box. */
.game-page .seat .role,
.game-page .self-general .role,
.game-page .seat button.role-mark {
  box-sizing: border-box; width: 24px; min-width: 24px; max-width: 24px;
  height: 24px; min-height: 24px; padding: 0; margin: 0;
  font-size: 12px; line-height: 22px; text-align: center; text-align-last: center;
}
.game-page .action-zone { --action-button-width: 112px; row-gap: 6px; }
.game-page .action-zone.pressure-choice-active { top:0; padding-bottom:0; }
.game-page .action-zone.pressure-choice-active > p[role="status"] { line-height:1.35; }
@media (max-width: 760px) and (orientation: portrait) {
  .game-page .action-zone.pressure-choice-active, .game-page.ring-formation .action-zone.pressure-choice-active {
    position:fixed; z-index:40; left:12px; right:12px; top:auto;
    bottom:calc(12px + env(safe-area-inset-bottom)); width:auto; height:auto;
    padding:12px; border:1px solid #b89554; border-radius:10px;
    background:#172626f5; box-shadow:0 8px 32px #0007;
  }
  .game-page .action-zone.pressure-choice-active > p[role="status"] { text-align:left; }
  .game-page .action-zone.pressure-choice-active .action-buttons {
    display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); width:100%; gap:8px;
  }
  .game-page .action-zone.pressure-choice-active .action-buttons button { width:100%; min-height:40px; padding:8px 4px; }
  .game-page .pressure-choice-active .formation-response-prompt { grid-column:1 / -1; }
}
.game-page .action-zone.discard-payment-active .battle-log-toggle { display: none; }
.game-page .action-zone > p[role="status"] {
  min-width: 0;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
}
@media (orientation: landscape) and (min-width: 600px) {
  .game-page .action-zone > p[role="status"] {
    width: max-content;
    max-width: min(600px, calc(100vw - var(--player-card-width) - var(--battle-safe-left) - var(--battle-safe-right) - 64px));
    align-self: flex-end;
  }
  .game-page .action-zone { position: relative; top: 36px; padding-bottom: 36px; }
  .game-page .action-zone > p[role="status"] {
    position: absolute;
    right: 0;
    bottom: calc(100% + 4px);
    width: max-content;
  }
}
.game-page .action-buttons {
  width: min(100%, var(--action-button-width)); padding: 0;
  align-self: flex-end; align-items: stretch; flex-direction: column; flex-wrap: nowrap;
}
.game-page .action-buttons button,
.game-page .battle-log-toggle {
  box-sizing: border-box; width: min(100%, var(--action-button-width));
  min-width: 0; margin-left: 0; margin-right: 0; white-space: normal;
}
@media (orientation: landscape) and (max-height: 600px) {
  .game-page .action-zone { --action-button-width: 96px; }
}
@media (orientation: landscape) and (max-height: 350px) {
  .game-page .action-zone { row-gap: 4px; }
  .game-page .action-buttons { gap: 2px; margin-top: 0; }
}

.role-mark-dialog {
  width: min(360px, calc(100vw - 32px)); max-height: calc(100dvh - 24px); padding: 20px;
  border: 1px solid #b99a60; border-radius: 12px 4px 12px 4px;
  background: linear-gradient(145deg, #253532, #101d1e); color: #f1dfb7;
  box-shadow: 0 24px 80px #000b; overflow: auto;
}
.role-mark-dialog::backdrop { background: #06100db3; }
.role-mark-dialog header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.role-mark-dialog h2 { margin: 0; font-size: 17px; color: #f1dfb7; }
.role-mark-dialog p { margin: 5px 0 0; font-size: 12px; color: #b9b394; }
.role-mark-dialog .card-rule-effect { margin-top: 14px; color: #e8dec6; line-height: 1.7; }
.role-mark-dialog .card-rule-note { margin-top: 10px; font-size: 11px; line-height: 1.6; color: #b9b394; }
.role-mark-close { width: 32px; min-height: 32px; padding: 0; background: transparent; color: #d4c5a2; border: 0; font-size: 24px; }
.role-mark-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.role-mark-options button { display: grid; justify-items: center; gap: 8px; padding: 12px 2px; border: 1px solid #82754f; border-radius: 6px; background: #142622; color: #d4c5a2; }
.role-mark-options b { font-size: 25px; font-weight: normal; line-height: 1.2; }
.role-mark-options span { font-size: 12px; }
.role-mark-options button[aria-pressed="true"] { border-color: #e0bd72; background: #55462a; color: #ffe6ad; box-shadow: inset 0 0 0 1px #e0bd72; }
.role-mark-options button:hover { background: #394335; }
.role-mark-dialog button:focus-visible { outline: 2px solid #ffe0a0; outline-offset: 3px; }

/* Keep names and skills together; equipment never takes their column width. */
.game-page .seat-info, .game-page .self-info {
  position: absolute; top: auto; left: 0; right: 0; width: 100%; margin: 0;
  padding: 4px var(--card-inset) 5px; overflow: visible;
  background: transparent;
  pointer-events: none;
}
.game-page .seat-info h3, .game-page .self-heading b {
  display: block; width: 100%; min-width: 0; margin: 0; padding: 0;
  font-size: 14px; line-height: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.game-page .general-name, .game-page .self-heading {
  display: flex; align-items: center; flex-wrap: nowrap; gap: 4px; margin: 0 0 3px; padding: 0;
}
.game-page .general-name h3, .game-page .self-heading > div { flex: 1; min-width: 0; }
.game-page .self-heading > div { display: block; margin: 0; padding: 0; }
.game-page .seat, .game-page .self-general { --hand-badge-size: clamp(26px, 1.8vw, 32px); }
.game-page .hand-count {
  position: absolute; right: var(--card-inset); z-index: 4;
  display: grid; place-items: center; width: var(--hand-badge-size); height: var(--hand-badge-size);
  margin: 0; padding: 5px 1px 1px 6px;
  color: #f3e4ba; font-weight: 700; font-size: clamp(14px, 1vw, 18px); line-height: 1;
  font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none;
  filter: drop-shadow(0 1px 2px #000a);
}
.game-page .hand-count svg { position: absolute; inset: 0; width: 100%; height: 100%; fill: #172821dd; stroke: #d7bf83; stroke-width: 1.2; }
.game-page .hand-count > span { position: relative; font-size: inherit; }
/* Only the last skill or equipment row needs to leave the corner clear. */
.game-page .seat-info:not(:has(.general-status)) .seat-skills > button:last-child,
.game-page .self-info:not(:has(.general-status)) .self-skills > button:last-child { max-width: calc(100% - var(--hand-badge-size) - 3px); }
.game-page .general-status { padding-right: calc(var(--hand-badge-size) + 2px); }
.game-page .seat-info > small, .game-page .seat-info > .muted, .game-page .self-heading > div > span:not(.role):not(.health) {
  display: block; font-size: 10px; line-height: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.game-page .seat-skills, .game-page .self-skills { width: 100%; margin: 0; padding: 0; gap: 2px; min-height: 0; }
.game-page .seat-skills button, .game-page .self-skills button {
  display: block; width: fit-content; max-width: 100%; min-width: 0; min-height: 19px; padding: 1px 5px;
  border: 1px solid #c8b58b36; border-radius: 3px; background: #12251c66;
  color: #f2e7cd; font-size: 11px; line-height: 15px; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: auto;
}
.game-page .self-skills button.available { color: #ffe3a0; border-color: #e5c779a6; background: #5c492a66; box-shadow: none; }
.game-page .general-status { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.game-page .general-status .treasure-zone { position: static; width: auto; flex-direction: row; gap: 2px; }
.game-page .general-status .treasure-slot { width: 17px; height: 17px; min-height: 17px; padding: 0; justify-content: center; font-size: 10px; }
@media (orientation: landscape) and (max-height: 600px) {

  .game-page .seat-info, .game-page .self-info { padding: 3px 5px 4px; }
  .game-page .seat-info h3, .game-page .self-heading b { padding: 0; font-size: 12px; line-height: 16px; }
  .game-page .seat-skills button, .game-page .self-skills button { min-height: 17px; padding: 0 1px; line-height: 15px; }
}
@media (orientation: landscape) and (max-height: 350px) {
  .game-page .general-name { gap: 2px; }
  .game-page .general-name h3 { font-size: 11px; }
}

/* Pack the seats around the center; size portraits from both viewport axes. */
@media (orientation: landscape) and (min-width: 600px) {
  .game-page .battlefield {
    container-type: inline-size;
    --seat-gap: clamp(6px, .7vw, 14px);
    --seat-height: calc(28dvh + 16px);
    --table-side-padding: 24px;
    width: 100%;
    max-width: calc(4 * var(--seat-height) * .75 + 3 * var(--seat-gap) + 2 * var(--table-side-padding) + var(--battle-safe-left) + var(--battle-safe-right));
    justify-self: center;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    column-gap: var(--seat-gap);
  }
  .game-page .battlefield .seat {
    height: min(var(--seat-height), calc((100cqw - 3 * var(--seat-gap)) / 4 * 4 / 3));
    width: auto; max-width: 100%; aspect-ratio: 3 / 4;
  }
  /* Five-player opponents spread across the available table width. */
  .game-page[data-player-count="5"] { --five-seat-height: calc(28dvh + 16px); }
  .game-page[data-player-count="5"] .battlefield { max-width: none; --seat-height: var(--five-seat-height); }
  /* Campaign objectives use the outer column beside the centered enemies. */
  .game-page .player-area {
    --player-card-width: min(18vw, calc((clamp(170px, 28dvh, 360px) - 20px) * .75));
  }
}
@media (orientation: landscape) and (min-width: 600px) and (min-height: 601px) {
  .game-page .table-column { grid-template-rows: minmax(0, 1fr) clamp(170px, 28dvh, 360px); }
  .game-page .seat-info h3, .game-page .self-heading b { font-size: clamp(14px, 1.1vw, 24px); line-height: 1.35; }
  .game-page .seat-skills button, .game-page .self-skills button { font-size: clamp(11px, .85vw, 18px); line-height: 1.35; }
}
@media (orientation: landscape) and (min-width: 600px) and (max-height: 600px) {
  .game-page .battlefield { --table-side-padding: 10px; --seat-height: calc(30dvh + 32px); }
  .game-page .player-area {
    --player-card-width: min(18vw, calc((clamp(128px, 36dvh, 178px) - 10px) * .75));
  }
}

/* Shallow screens use five across the top and one on either edge. */
@media (orientation: landscape) and (min-width: 600px) {
  .game-page[data-player-count="8"] .battlefield {
    container-type: inline-size;
    --eight-gap: var(--seat-gap);
    --eight-arc: clamp(8px, 2dvh, 18px);
    --eight-seat-height: min(32dvh, calc((100cqw - 6 * var(--eight-gap)) / 7 * 4 / 3));
    max-width: none;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 6px var(--eight-gap);
    padding-top: 4px; padding-bottom: 4px;
  }
  .game-page[data-player-count="8"] .battlefield .seat[data-position] {
    grid-column: auto; grid-row: 1; margin-top: 0;
    height: var(--eight-seat-height); width: calc(var(--eight-seat-height) * .75);
    max-width: 100%; max-height: 100%; aspect-ratio: 3 / 4;
    align-self: start; min-width: 0; overflow: hidden;
  }
  .game-page[data-player-count="8"] .battlefield .seat[data-position="1"] { grid-column: 7; align-self: end; justify-self: end; }
  .game-page[data-player-count="8"] .battlefield .seat[data-position="2"] { grid-column: 6; margin-top: var(--eight-arc); }
  .game-page[data-player-count="8"] .battlefield .seat[data-position="3"] { grid-column: 5; margin-top: calc(var(--eight-arc) * .3); }
  .game-page[data-player-count="8"] .battlefield .seat[data-position="4"] { grid-column: 4; }
  .game-page[data-player-count="8"] .battlefield .seat[data-position="5"] { grid-column: 3; margin-top: calc(var(--eight-arc) * .3); }
  .game-page[data-player-count="8"] .battlefield .seat[data-position="6"] { grid-column: 2; margin-top: var(--eight-arc); }
  .game-page[data-player-count="8"] .battlefield .seat[data-position="7"] { grid-column: 1; align-self: end; justify-self: start; }
  /* The public-card animation uses this area's center as its table anchor. */
  .game-page[data-player-count="8"] .battlefield > .table-watermark,
  .game-page[data-player-count="8"] .battlefield::before {
    position: relative; inset: auto; transform: none;
    grid-column: 2 / 7; grid-row: 1; align-self: stretch;
    min-height: 0;
    margin-top: calc(var(--eight-seat-height) + var(--eight-arc));
  }
  .game-page[data-player-count="8"] .battlefield > .table-watermark { display: grid; place-items: center; overflow: hidden; }
  .game-page[data-player-count="8"] .battlefield .table-center {
    grid-column: 2 / 7; grid-row: 2; padding: 0;
    max-height: 96px; overflow: auto;
  }
  :is(.in-battle,.in-formation) .game-page[data-player-count="8"] .battlefield {
    padding-left: calc(14px + var(--battle-safe-left));
    padding-right: calc(14px + var(--battle-safe-right));
  }
}
/* Taller tables use three across the top and two down each side. */
@media (orientation: landscape) and (min-width: 600px) and (min-height: 601px) {
  .game-page[data-player-count="8"] {
    --ring-seat-height: min(calc((100dvh - 112px) / 3), calc((100vw - var(--battle-safe-left) - var(--battle-safe-right) - 28px - 4 * clamp(6px, .7vw, 14px)) / 5 * 4 / 3));
  }
  .game-page[data-player-count="8"] .table-column { grid-template-rows: minmax(0, 1fr) calc(var(--ring-seat-height) + 20px); }
  .game-page[data-player-count="8"] .player-area { --player-card-width: calc(var(--ring-seat-height) * .75); }
  .game-page[data-player-count="8"] .self-general { height: var(--ring-seat-height); min-height: 0; }

  .game-page[data-player-count="8"] .battlefield {
    container-type: size;
    /* Status occupies the middle columns only; flanks can use its height too. */
    --eight-seat-height: var(--ring-seat-height);
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr) auto;
  }
  .game-page[data-player-count="8"] .battlefield .seat[data-position] { margin-top: 0; }
  .game-page[data-player-count="8"] .battlefield .seat[data-position="1"] { grid-column: 5; grid-row: 1 / 3; margin-bottom: 8px; }
  .game-page[data-player-count="8"] .battlefield .seat[data-position="2"] { grid-column: 5; grid-row: 1 / 3; margin-top: clamp(24px, calc(480px - 40vw), 48px); justify-self: start; }
  .game-page[data-player-count="8"] .battlefield .seat[data-position="3"] { grid-column: 4; }
  .game-page[data-player-count="8"] .battlefield .seat[data-position="4"] { grid-column: 3; }
  .game-page[data-player-count="8"] .battlefield .seat[data-position="5"] { grid-column: 2; }
  .game-page[data-player-count="8"] .battlefield .seat[data-position="6"] { grid-column: 1; grid-row: 1 / 3; margin-top: clamp(24px, calc(480px - 40vw), 48px); justify-self: end; }
  .game-page[data-player-count="8"] .battlefield .seat[data-position="7"] { grid-column: 1; grid-row: 1 / 3; margin-bottom: 8px; }
  .game-page[data-player-count="8"] .battlefield .seat[data-position] { grid-row: 1 / 4; }
  .game-page[data-player-count="8"] .battlefield > .table-watermark,
  .game-page[data-player-count="8"] .battlefield::before {
    grid-column: 2 / 5; grid-row: 1 / 3;
    margin-top: calc(var(--eight-seat-height) + var(--eight-gap));
  }
  .game-page[data-player-count="8"] .battlefield .table-center { grid-column: 2 / 5; grid-row: 3; max-height: 80px; }
}
@media (orientation: landscape) and (min-width: 600px) and (max-height: 600px) {
  :is(.in-battle,.in-formation) .game-page[data-player-count="8"] .battlefield {
    padding-left: calc(8px + var(--battle-safe-left));
    padding-right: calc(8px + var(--battle-safe-right));
  }
  .game-page[data-player-count="8"] .battlefield { --eight-arc: 8px; row-gap: 4px; }
  .game-page[data-player-count="8"] .battlefield .table-center { max-height: 28px; }
  .game-page[data-player-count="8"] .game-heading { left: calc(10px + var(--battle-safe-left)); }
  .game-page[data-player-count="8"] .game-heading .eyebrow { font-size: clamp(7px, 1.1vw, 9px); letter-spacing: 0; white-space: nowrap; }
  body:has(.game-page[data-player-count="8"]) .card-flight { width: clamp(36px, 12dvh, 72px); }
}

/* Numeric health and compact public combat effects for rules version 3. */
.game-page .combat-health { position: absolute; bottom: var(--card-inset); right: var(--card-inset); display: flex; align-items: center; justify-content: flex-end; gap: 2px; width: auto; max-width: calc(100% - 2 * var(--card-inset)); height: 17px; margin: 0; z-index: 4; color: #8ed6ac; }
.health-number { font: 700 14px/17px sans-serif; color: #fff2d2; text-shadow: 0 1px 2px #000, 0 0 3px #000; white-space: nowrap; }
.health-emblem { flex: 0 0 14px; width: 14px; height: 17px; object-fit: contain; filter: drop-shadow(0 1px 2px #000); }
.combat-health.critical { color: #f19b7e; }
.combat-health.critical .health-number { color: #ffb49b; }
.combat-status { position: absolute; top: var(--card-inset); right: var(--card-inset); z-index: 5; display: flex; align-items: flex-end; text-align: right; flex-direction: column; gap: 3px; max-width: 65%; pointer-events: none; }
.combat-status button { pointer-events: auto; }
.combat-effects { display: contents; }
.buff-badges { display: flex; gap: 3px; min-height: 22px; padding: 2px; border: 0; background: #112921e6; color: #fff; border-radius: 4px; font-size: 10px; }
.buff-badge { display: inline-flex; align-items: center; gap: 2px; color: #e6c178; }
.buff-badge.regeneration { color: #94e0a7; }
.buff-dialog { max-height: 80dvh; overflow: auto; }
.buff-dialog article { border-top: 1px solid var(--line); padding-top: 6px; }

/* Cards are not scroll containers: action borders and delayed cards extend beyond the frame. */
.game-page[data-player-count] .battlefield .seat,
.game-page .player-area .self-general { overflow: visible; }
.game-page .judgment-zone {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  margin: 0; height: 22px; max-height: 22px; flex-wrap: nowrap; gap: 3px;
}
.game-page .judgment-zone button {
  display: inline-flex; align-items: center; gap: 3px; flex: 0 1 auto; min-width: 22px; max-width: 100%; height: 22px; min-height: 22px;
  padding: 2px 5px; font-size: 10px; line-height: 1; border: 1px solid #bca46a66; border-radius: 3px 3px 7px 3px; background: #172c24f2;
}
.game-page .judgment-zone button svg { width: 12px; height: 12px; flex: 0 0 12px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.game-page .judgment-zone button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:is(.in-battle,.in-formation) .game-page .battlefield:has(.judgment-zone) { padding-bottom: 30px; }
.game-page[data-player-count="8"] .battlefield:has(.judgment-zone) { --eight-gap: 30px; }
.game-page .self-general > .judgment-zone,
.game-page[data-player-count="5"] .seat[data-position="4"] > .judgment-zone,
.game-page[data-player-count="8"] .seat[data-position="7"] > .judgment-zone {
  top: 0; left: calc(100% + 4px); right: auto;
  width: 72px; height: auto; max-height: 100%; flex-direction: column;
}
.game-page[data-player-count="5"] .seat[data-position="1"] > .judgment-zone,
.game-page[data-player-count="8"] .seat[data-position="1"] > .judgment-zone {
  top: 0; right: calc(100% + 4px); left: auto;
  width: 72px; height: auto; max-height: 100%; flex-direction: column;
}
.game-page .judgment-zone:has(button) { scrollbar-width: thin; }
.game-page .judgment-zone button { flex-shrink: 1; }
.game-page .self-general > .judgment-zone button { flex-shrink: 0; }
.game-page .player-area:has(.self-general > .judgment-zone) { column-gap: 82px; }
@media (orientation: landscape) and (min-width: 600px) and (max-height: 600px) {
  .game-page[data-player-count="8"] .seat:is([data-position="1"], [data-position="7"]):has(.judgment-zone) { transform: translateY(40px); }
  .game-page[data-player-count="8"] .seat:is([data-position="1"], [data-position="7"]) > .judgment-zone { top: auto; bottom: 0; }
}
@media (orientation: landscape) and (min-width: 600px) and (min-height: 601px) {
  .game-page[data-player-count="8"]:has(.judgment-zone) {
    --ring-seat-height: min(calc((100dvh - 112px) / 3), calc((100vw - var(--battle-safe-left) - var(--battle-safe-right) - 28px - 4 * 82px) / 5 * 4 / 3));
  }
  .game-page[data-player-count="8"] .seat[data-position="6"] > .judgment-zone {
    top: 0; left: calc(100% + 4px); right: auto;
    width: 72px; height: auto; max-height: 100%; flex-direction: column;
  }
  .game-page[data-player-count="8"] .seat[data-position="2"] > .judgment-zone {
    top: 0; right: calc(100% + 4px); left: auto;
    width: 72px; height: auto; max-height: 100%; flex-direction: column;
  }
}

/* Keep pile counts and live activity on separate, centered lines. */
.game-page[data-player-count] .battlefield .table-center {
  position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%);
  grid-area: auto; width: max-content; max-width: 60%; min-height: 0; max-height: none;
  padding: 0; overflow: visible; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
.game-page .table-center .deck-label { position: static; display: flex; align-items: center; justify-content: center; gap: 0; margin: 0; font-size: 10px; line-height: 1.3; letter-spacing: .5px; }
.game-page .table-center .deck-card-back { display: none; }
.game-page .table-center .current-event { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px 10px; max-width: 100%; margin: 0; }
.game-page .table-center .current-event > .eyebrow { flex: 0 0 auto; font-size: 11px; line-height: 1.4; letter-spacing: .5px; }
.game-page .table-center .fine-print { margin: 0; }
/* Center the status in the open area below the top portraits. */
@media (orientation: landscape) and (min-width: 600px) {
  .game-page[data-player-count] .battlefield .table-center { top: calc(30% + var(--seat-height) * .7); }
  .game-page[data-player-count="8"] .battlefield .table-center { top: calc(30% + (var(--eight-seat-height) + var(--eight-arc)) * .7); }
}
@media (orientation: landscape) and (min-width: 600px) and (min-height: 601px) {
  .game-page[data-player-count="8"] .battlefield .table-center { top: calc(30% + (var(--eight-seat-height) + var(--eight-gap)) * .7); }
}
@media (orientation: landscape) and (max-height: 600px) {
  .game-page .battlefield .table-center { gap: 2px; }
  .game-page .table-center .deck-label { font-size: 8px; }
  .game-page .table-center .current-event > .eyebrow { font-size: 9px; }
}
@media (orientation: landscape) and (max-height: 350px) {
  .game-page .table-center .deck-label { display: flex; }
}

/* Portraits show equipment; the name opens the complete skill sheet. */
.game-page .general-details {
  position: relative; z-index: 3; display: block; max-width: 100%; min-height: 0; margin: 0; padding: 0;
  border: 0; border-radius: 2px; background: transparent; color: inherit; font: inherit; line-height: inherit;
  text-align: left; text-shadow: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: auto;
}
.game-page .general-details:hover { color: #ffe3a0; }
.game-page .general-details:focus-visible { outline: 2px solid #ffe3a0; outline-offset: 2px; }
.game-page .general-status { width: 100%; margin-top: 3px; }
.game-page .general-status .treasure-zone { position: relative; inset: auto; z-index: 3; display: flex; flex-direction: column; align-items: flex-start; width: fit-content; max-width: 100%; min-width: 0; gap: 3px; }
.game-page .general-status .treasure-slot {
  display: flex; flex: 0 0 auto; align-items: center; justify-content: flex-start; gap: 4px;
  width: fit-content; max-width: 100%; height: auto; min-height: 20px; padding: 2px 4px;
  color: #f1dfb3; border: 1px solid #bba06a70; border-radius: 3px; background: #15271fe6;
}
.game-page .general-status .treasure-slot small { flex: 0 0 auto; font-size: 9px; line-height: 1.3; color: #b7ad91; }
.game-page .general-status .treasure-slot b { min-width: 0; font-size: clamp(10px, .85vw, 16px); line-height: 1.3; }

/* Equal side columns center the hand on the table. */
@media (orientation: landscape) and (min-width: 600px) {
  .game-page .player-area { grid-template-columns: var(--player-card-width) minmax(0, 1fr) var(--player-card-width); }
}



/* Identity silhouettes stay legible in compact portrait badges. */
.role-icon { pointer-events: none; display: inline-block; width: 18px; height: 18px; vertical-align: middle; fill: currentColor; stroke: none; }
.role-mark-options .role-icon { width: 28px; height: 28px; }
.game-page :is(.seat, .self-general) .role:has(.role-icon) {
  color: #f5dfaa; background: transparent; border: 1px solid transparent; border-radius: 3px;
  box-shadow: none;
}
.game-page .role .role-icon { filter: drop-shadow(0 1px 1px #000b) drop-shadow(0 0 2px #0006); }
.game-page .seat button.role-mark[data-marked="true"] { border: 1px dashed #e4cd9366; }

.defense-badge { min-height:16px; padding:1px 4px; border:0; border-radius:3px; background:#142b38df; color:#e1eef2; font-size:10px; line-height:1.3; white-space:nowrap; }

.tapered-action-line{fill:#eddaad;stroke:none;filter:drop-shadow(0 0 2px #e8d19855)}
.action-target-glow{fill:none;stroke:#eddaad;stroke-width:1;filter:drop-shadow(0 0 3px #e8d19888);pointer-events:none}

.hand .playing-card.draw-pending { opacity: 0 !important; pointer-events: none !important; transition: none !important; }


/* Reserve a stable card row; selection prose uses the space above it. */
@media (orientation: landscape) and (min-width: 600px) {
  .game-page .hand-area { position: relative; }
  .game-page .hand { position: absolute; inset: 0; height: auto; }
  .game-page .hand .playing-card {
    width: calc(var(--player-card-width) * .68);
    min-width: calc(var(--player-card-width) * .68);
    height: 68%;
  }
  .game-page:not(.ring-formation) .action-zone {
    top: 32%;
    height: 68%;
    padding-bottom: 0;
  }
  .game-page:not(.ring-formation) .action-buttons { margin-top: 0; }
  .game-page .hand-area > .card-tip {
    /* Stay clear of the 16px selected-card lift plus a small gap. */
    position: absolute; bottom: calc(68% + 21px); left: 50%; transform: translateX(-50%);
    width: min(100%, 520px); max-height: calc(32% - 21px); margin: 0;
    overflow: auto; line-height: 1.5; overflow-wrap: anywhere;
  }
}

.game-page[data-mode="camp"] :is(.seat, .self-general) .role[data-allegiance="ally"] { color: #8cdda0; }
.game-page[data-mode="camp"] :is(.seat, .self-general) .role[data-allegiance="enemy"] { color: #f28c81; }

/* Inward battlefield corners behind public cards. */
.battle-emblem {
  display: grid;
  place-items: center;
  width: clamp(96px, 18dvh, 192px);
  aspect-ratio: 1;
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20120%20120%22%3E%3Cdefs%3E%3Cpath%20id%3D%22corner%22%20d%3D%22M18%2045V18H45L37%2023H23V37Z%22%2F%3E%3C%2Fdefs%3E%3Cg%20fill%3D%22%23b59a69%22%3E%3Cuse%20href%3D%22%23corner%22%2F%3E%3Cuse%20href%3D%22%23corner%22%20transform%3D%22rotate%2890%2060%2060%29%22%2F%3E%3Cuse%20href%3D%22%23corner%22%20transform%3D%22rotate%28180%2060%2060%29%22%2F%3E%3Cuse%20href%3D%22%23corner%22%20transform%3D%22rotate%28270%2060%2060%29%22%2F%3E%3C%2Fg%3E%3Cg%20fill%3D%22none%22%20stroke%3D%22%23b59a69%22%20stroke-width%3D%221%22%20opacity%3D%22.5%22%3E%3Cpath%20d%3D%22m29%2038%209-9m44%200%209%209m0%2044-9%209m-44%200-9-9%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
  opacity: .3;
  pointer-events: none;
  user-select: none;
}
.game-page[data-player-count] .battlefield > .table-watermark {
  position: fixed; grid-area: auto; inset: auto;
  left: 50vw; top: calc(50dvh + 24px);
  width: max-content; height: auto; min-height: 0; margin: 0; padding: 0;
  transform: translate(-50%,-50%); z-index: 0; overflow: visible;
}

.battle-emblem > span {
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: clamp(28.5px, 5.25dvh, 57px);
  font-weight: 700;
  font-synthesis: weight;
  line-height: 1;
  letter-spacing: .12em;
  text-indent: .12em;
  color: #b59a69;
  text-shadow: none;
}

/* A narrow diagonal cut across aligned lettering. */
.battle-emblem-word { display: grid; position: relative; }
.battle-emblem-word > span { grid-area: 1 / 1; }
.battle-emblem-word > span:first-child {
  clip-path: polygon(0 0, 100% 0, 100% 18%, 0 78%);
}
.battle-emblem-word > span:last-child {
  clip-path: polygon(0 88%, 100% 28%, 100% 100%, 0 100%);
}
.battle-emblem-word::after {
  content: ""; position: absolute; inset: 0 -.12em;
  background: #dbc594;
  clip-path: polygon(0 84%, 100% 22%, 100% 24%, 0 86%);
  opacity: .65;
}

.skill-modal-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem 1rem; margin: 7px 32px 12px 0; }
.skill-modal-heading h2 { margin: 0; }
.skill-modal-heading .skill-modal-stats { font-size: 1rem; }
.skill-modal-card h3 { color: var(--gold); }
.skill-modal .fine-print { margin-top: 16px; }
.skill-modal .skill-name { margin-top: 18px; }

/* Selection stays compact; long skill prose is read in the existing dialog. */
.game-page .hand-area > .skill-tip {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  width: max-content; max-width: 100%; max-height: none; overflow: visible;
  padding: 3px 9px; border: 1px solid #d9bd8355; border-radius: 6px;
  background: #172822ed; text-align: left; box-sizing: border-box;
}
.game-page .skill-tip .skill-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: clamp(11px, .9vw, 14px); }
.game-page .skill-tip button { flex: 0 0 auto; min-height: 28px; padding: 3px 5px; border: 0; background: transparent; color: var(--ink); font-size: 12px; line-height: 1.4; }

.game-page .hand-area > .selected-card-details {
  background: #172626; border-color: #a38956; color: #fff0d1;
  position: fixed; z-index: 1200; bottom: auto; transform: translateX(-50%);
  width: max-content; max-width: calc(100vw - 16px); max-height: none;
  margin: 0; padding: 4px 10px; overflow: visible; white-space: nowrap;
  font-size: 13px; line-height: 1.5;
}
.game-page .hand-area > .selected-card-details:hover { background: #394335; border-color: #d5b675; }
.game-page .hand-area > .selected-card-details:focus-visible { outline: 2px solid #ffe0a0; outline-offset: 2px; }
.game-page button.treasure-zone{padding:0;border:0;border-radius:0;background:transparent;box-shadow:none;text-align:left;cursor:pointer;pointer-events:auto}
.game-page button.treasure-zone:hover{background:transparent;transform:none}
.game-page button.treasure-zone:focus-visible{outline:2px solid var(--gold);outline-offset:3px}
.equipment-details::backdrop { background: #10211bc9; backdrop-filter: blur(5px); }
.equipment-detail-entry { margin-top: 18px; }
.equipment-detail-entry .skill-name { margin: 0 0 8px; }
.equipment-detail-entry .equipment-detail-meta,
.equipment-detail-entry .equipment-detail-flavor { color: var(--muted); font-size: .85rem; line-height: 1.65; }
.equipment-detail-entry .equipment-detail-flavor { margin-top: .5rem; }

/* Compact response entry centered above the operation area. */
.game-page .action-zone > p.response-summary[role="status"] {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; max-width: 100%; text-align: center;
}
.game-page .response-summary strong { color: #f4dc9b; font-weight: 600; }
.game-page .response-summary button {
  padding: 3px 5px; min-height: 24px; font: inherit; white-space: nowrap;
}
.game-page .action-zone > p.response-summary[role="status"] {
  width: max-content; max-width: none; white-space: nowrap;
}
.game-page .response-summary > * { flex-shrink: 0; }
@media (orientation: landscape) and (min-width: 600px) {
  .game-page .action-zone > p.response-summary[role="status"] {
    right: 50%; transform: translateX(50%);
  }
}
.game-page .action-zone > p.response-summary[role="status"] { gap: 4px; }
.game-page .response-summary button {
  padding: 0; border: 0; background: transparent; box-shadow: none;
  color: #e7c985; text-decoration: underline; text-underline-offset: 3px;
}

/* Equipment sits directly above the name; health and resources occupy the right column. */
.game-page :is(.seat,.self-general) > :is(.general-name,.self-heading){position:absolute;top:auto;left:var(--card-inset);right:calc(var(--card-inset) + var(--health-label-width, 55px) + 4px);bottom:var(--card-inset);z-index:4;margin:0;padding:0!important;pointer-events:none}
.game-page :is(.seat,.self-general) > :is(.general-name,.self-heading) :is(h3,b){display:block;margin:0;font-size:clamp(12px,1.2vw,20px);line-height:1.3;color:#fff2d2;text-shadow:0 1px 2px #000,0 0 3px #000;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.game-page :is(.seat,.self-general) > .role{top:var(--card-inset);bottom:auto;left:var(--card-inset);right:auto;padding-left:0;padding-right:0;text-align:left}
.game-page :is(.seat-info,.self-info){bottom:calc(var(--card-inset) + 3px + clamp(12px,1.2vw,20px) * 1.3);padding:0 var(--card-inset)}
.game-page :is(.seat,.self-general) > .hand-count{bottom:calc(var(--card-inset) + 21px);right:var(--card-inset)}

.game-page .combat-stats{position:absolute;left:var(--card-inset);right:auto;bottom:calc(var(--card-inset) + 4px + clamp(12px,1.2vw,20px) * 1.3);z-index:5;display:none;align-items:center;gap:5px;color:#e8e3d3;font:10px/16px sans-serif;text-shadow:0 1px 2px #000;white-space:nowrap}
.game-page .combat-stats > :is(span,button){display:inline-flex;align-items:center;gap:1px;min-width:0;min-height:16px;margin:0;padding:0;border:0;background:transparent;color:inherit;font:inherit}
.game-page .combat-stats svg{width:11px;height:11px;fill:currentColor;flex:none}
.game-page .general-status{padding-right:calc(var(--health-label-width,55px) + 4px)}

/* Reserve a readable public-card lane on shallow phone tables. */
@media (orientation: landscape) and (min-width: 600px) and (max-height: 600px) {
  .game-page .battlefield { --seat-height: 26dvh; }
  /* Four opponents leave enough room for larger portraits on five-seat tables. */
  .game-page[data-player-count="5"] { --five-seat-height: 34dvh; }
  .game-page[data-player-count="5"] .battlefield { --seat-height: var(--five-seat-height); }
  .game-page[data-player-count="8"] .battlefield {
    --eight-seat-height: min(32dvh, calc((100cqw - 6 * var(--eight-gap)) / 7 * 4 / 3));
  }
  .game-page[data-player-count] .battlefield .table-center {
    top: calc(var(--seat-height) + 8px); transform: translateX(-50%);
  }
  .game-page[data-player-count="8"] .battlefield .table-center {
    top: calc(var(--eight-seat-height) + var(--eight-arc) + 8px);
  }
}

/* Declarative pack visuals occupy only the hero border and never intercept input. */
.extension-effect{position:absolute;inset:0;width:100%;height:100%;pointer-events:none!important;z-index:2;border-radius:inherit}
.extension-resources{position:absolute;right:var(--card-inset,6px);bottom:calc(var(--card-inset,6px) + 21px);display:flex;flex-direction:column;align-items:flex-end;gap:3px;max-width:calc(100% - 12px);pointer-events:none;z-index:6}
.extension-resource{position:relative;display:inline-flex;align-items:baseline;gap:1px;overflow:hidden;box-sizing:border-box;height:19px;padding:1px 6px 4px;border:1px solid color-mix(in srgb,var(--resource-color) 38%,transparent);border-radius:7px;background:#10212cce;color:#f2f7fa;font:10px/12px sans-serif;font-variant-numeric:tabular-nums;white-space:nowrap;box-shadow:0 1px 3px #0004}
.extension-resource::before,.extension-resource::after{content:'';position:absolute;bottom:0;left:0;height:2px}
.extension-resource::before{width:100%;background:#ffffff18}
.extension-resource::after{width:var(--resource-fill);background:var(--resource-color)}
.extension-resource strong{font:inherit;font-weight:700}
.extension-resource small{font:8px/12px sans-serif;color:#c1ccd4}
.resource-spark{align-self:center;margin-right:3px;color:var(--resource-color);font-size:11px}
.extension-resource[data-full="true"]{border-color:var(--resource-color);box-shadow:0 0 5px color-mix(in srgb,var(--resource-color) 28%,transparent)}
.game-page :is(.seat,.self-general):has(> .extension-resources) > .hand-count{bottom:calc(var(--card-inset) + 24px + var(--resource-stack-height,19px))}
.game-page :is(.seat,.self-general):has(> .extension-resources) .combat-stats{bottom:calc(var(--card-inset) + 24px + var(--resource-stack-height,19px))}
.extension-preview{position:relative;width:200px;height:280px;margin:20px auto;background:linear-gradient(145deg,#272035,#11131b);border:1px solid #76617b;border-radius:8px;display:grid;place-items:center;color:#dfcceb}
.extension-preview canvas{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}
.extension-workbench .workbench-layout{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(260px,1fr);gap:20px}
.extension-workbench textarea{width:100%;font-family:ui-monospace,"Noto Sans SC","Microsoft YaHei",monospace}
@media(max-width:650px){.extension-workbench .workbench-layout{grid-template-columns:1fr}}

/* The bounded elemental choice needs room for four alternatives in both table modes. */
.game-page .action-buttons.element-choice-controls{position:fixed;inset:50% auto auto 50%;transform:translate(-50%,-50%);z-index:60;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;width:min(440px,calc(100vw - 112px));max-height:calc(100dvh - 48px);overflow:auto;padding:16px;border:1px solid #a48a4b;border-radius:12px;background:rgba(24,34,32,.98);box-shadow:0 16px 48px #0008}
.game-page .element-choice-controls>p{grid-column:1/-1;margin:0 0 2px;text-align:center;color:#eed49c;font-size:14px}
.game-page .element-choice-controls>button{min-width:0;min-height:44px;padding:8px;white-space:normal;line-height:1.4}
.game-page .action-buttons.element-choice-controls>button{width:100%;max-width:none;justify-self:stretch}
.game-page .action-buttons.element-choice-controls>p{text-align:center;margin:0 0 2px}

.game-page .battle-season { position: absolute; top: 0; left: 0; color: #e7d5aa; font-size: 12px; letter-spacing: 1px; pointer-events: none; }

.game-page .table-center .current-event:has(.battle-action-clock) { flex-direction: row; flex-wrap: wrap; }
.game-page .battle-action-clock { color: #e7d5aa; font-size: 11px; line-height: 1.4; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* A single status row frees vertical space for portrait-shaped public cards. */
@media (orientation: landscape) and (min-width: 600px) and (max-height: 600px) {
  .game-page[data-player-count] .battlefield .table-center {
    flex-direction: row; flex-wrap: wrap; gap: 2px 10px; max-width: 64%;
    top: calc(var(--seat-height) + 4px);
  }
  .game-page .table-center .deck-label { font-size: 9px; letter-spacing: 0; }
  .game-page .table-center .current-event { flex-direction: row; gap: 5px; }
  .game-page .table-center .battle-action-clock { font-size: 10px; }
  .game-page .table-center .fine-print { flex-basis: 100%; text-align: center; }
}
@media (orientation: landscape) and (min-width: 600px) and (max-height: 600px) {
  .game-page[data-player-count="8"] .battlefield .table-center {
    top: calc(var(--eight-seat-height) + var(--eight-arc) + 4px);
  }
}
@media (orientation: landscape) and (min-width: 600px) and (max-height: 350px) {
  .game-page .table-column { grid-template-rows: minmax(0, 1fr) 100px; }
  .game-page .player-area { --player-card-width: 67.5px; }
}

.army-badge{pointer-events:auto;display:block;font-size:10px;line-height:1.4;color:#ffe4a8;background:#201b14dc;padding:2px 4px;border-radius:4px;white-space:normal;max-width:150px}.army-morale.routed{color:#ff9a88}.army-morale.low{color:#ffc078}.army-rout-mark{margin-left:2px;font-size:9px;color:inherit}.army-controls{position:relative;max-width:100%;font-size:12px}.army-controls>summary{cursor:pointer;padding:6px 10px;border:1px solid #b89560;border-radius:6px;background:#292319;color:#ffe1ac}.army-options{position:absolute;bottom:calc(100% + 6px);right:0;width:max-content;max-width:min(320px,calc(100vw - 24px));max-height:45dvh;overflow:auto;box-sizing:border-box;display:flex;flex-direction:column;gap:4px;background:#191b20;border:1px solid #b89560;border-radius:8px;padding:5px;z-index:80;box-shadow:0 4px 20px #0009}.game-page .army-options button{width:100%;min-width:0;margin:0;padding:8px 10px;font-size:12px;line-height:1.4;white-space:normal;text-align:left}.army-direct>button{width:var(--action-button-width,112px);max-width:100%;margin:0;white-space:normal}.army-controls:has(+.action-buttons){margin-bottom:4px}.army-details{font-size:13px;line-height:1.6}.combat-status:has(.army-badge){flex-wrap:wrap}

/* Submission feedback does not predict rule results or remove the hand card. */
.game-page .playing-card.card-face.action-submitting { opacity: .55; translate: 0 -5px; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .game-page .playing-card.card-face.action-submitting { translate: none; } }

.game-page .action-zone > .rescue-footer { flex: 0 0 auto; overflow: visible; margin-top: 0; }

/* All battle seats reserve a permanent information strip outside the portrait. */
:is(.in-battle,.in-formation) .external-status-table { --portrait-info-gap: 4px; }

  :is(.in-battle,.in-formation) .external-status-table :is(.seat,.self-general) > .combat-status {
    top: calc(100% + 4px); bottom: auto; left: 0; right: 0;
    width: auto; max-width: none; height: 32px; max-height: 32px;
    display: flex; flex-direction: column; flex-wrap: nowrap; align-items: stretch;
    gap: 2px; pointer-events: auto; text-align: left;
  }
  :is(.in-battle,.in-formation) .external-status-table .army-badge {
    order: 0; max-width: none; padding: 1px 2px; font-size: 10px; line-height: 16px;
    white-space: nowrap; letter-spacing: 0;
  }
  :is(.in-battle,.in-formation) .external-status-table .army-upkeep { display: none; }
  :is(.in-battle,.in-formation) .external-status-table .army-supply.shortage { color: #ff9a88; font-weight: 700; }
  :is(.in-battle,.in-formation) .external-status-table .combat-effects {
    order: 1; display: flex; gap: 3px; height: 15px; min-height: 15px;
    overflow-x: auto; scrollbar-width: none; pointer-events: auto;
  }
  :is(.in-battle,.in-formation) .external-status-table .combat-effects:empty { display: none; }
  :is(.in-battle,.in-formation) .external-status-table .combat-effects > * {
    flex: 0 0 auto; margin: 0; min-height: 0; height: 15px;
    box-sizing: border-box; padding: 0 3px; font-size: 9px; line-height: 13px; white-space: nowrap;
  }
  :is(.in-battle,.in-formation) .external-status-table .seat > .judgment-zone { top: calc(100% + 40px); }
  :is(.in-battle,.in-formation) .external-status-table[data-player-count="8"] .seat:is([data-position="1"],[data-position="7"]) { margin-bottom: 38px; }
  :is(.in-battle,.in-formation) .external-status-table .self-general > .combat-status {
    top: 4px; left: calc(100% + 6px); right: auto; width: 56px;
    height: auto; max-height: calc(100% - 8px); overflow-y: auto;
  }
  :is(.in-battle,.in-formation) .external-status-table .self-general .army-badge { white-space: normal; }
  :is(.in-battle,.in-formation) .external-status-table .self-general .army-supply { display: block; }
  :is(.in-battle,.in-formation) .external-status-table .self-general .combat-effects { flex-direction: column; height: auto; overflow: visible; }
  :is(.in-battle,.in-formation) .external-status-table .hand-area { margin-left: 68px; }
  :is(.in-battle,.in-formation) .game-page.external-status-table[data-player-count] .battlefield .table-center {
    top: var(--round-row-top, 55%); max-width: 64%; height: 14px; max-height: 14px;
    flex-wrap: nowrap; gap: 6px; overflow: auto; scrollbar-width: none; white-space: nowrap;
  }

@media (orientation: landscape) and (max-height: 350px) {
  :is(.in-battle,.in-formation) .external-status-table[data-player-count="8"] .battlefield { --eight-arc: 0px; }
  :is(.in-battle,.in-formation) .external-status-table .seat > .combat-status { top: calc(100% + 2px); height: 30px; max-height: 30px; gap: 0; }
  :is(.in-battle,.in-formation) .game-page.external-status-table[data-player-count] .battlefield .table-center { height: 12px; max-height: 12px; }
}

  :is(.in-battle,.in-formation) .game-page.external-status-table[data-player-count] .battlefield .seat[data-position] { overflow: visible; }


.army-label-full { display: none; }

  :is(.in-battle,.in-formation) .external-status-table .self-general > .combat-status {
    top: 0; left: calc(100% + var(--portrait-info-gap)); width: 58px; gap: 4px;
  }
  :is(.in-battle,.in-formation) .external-status-table .self-general .army-badge {
    flex-shrink: 0; padding: 4px 5px; border-left: 1px solid #c7b58066;
    border-radius: 3px; background: #18221dcc; letter-spacing: 0;
    color: #ffe4a8; font-size: 10px; line-height: 16px;
  }
  :is(.in-battle,.in-formation) .external-status-table .self-general :is(.army-morale,.army-supply) {
    display: flex; align-items: baseline; justify-content: flex-start; gap: 0;
  }
  :is(.in-battle,.in-formation) .external-status-table .army-value { font: 700 11px/16px sans-serif; font-variant-numeric: tabular-nums; }
  :is(.in-battle,.in-formation) .external-status-table .self-general :is(.army-label-short,.army-separator) { display: none; }
  :is(.in-battle,.in-formation) .external-status-table .self-general .army-label-full { display: inline; }
  :is(.in-battle,.in-formation) .external-status-table .self-general .army-rout {
    display: block; margin-top: 3px; padding-top: 3px; border-top: 1px solid #d9968244; color: #ffb5a8;
  }


.portrait-status { display: none; }

  :is(.in-battle,.in-formation) .external-status-table :is(.seat,.self-general) > .portrait-status {
    position: absolute; top: var(--card-inset); right: var(--card-inset); z-index: 7;
    display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
    width: min(64px, calc(100% - 30px)); height: auto; pointer-events: none;
  }
  :is(.in-battle,.in-formation) .external-status-table .portrait-status > button {
    flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
    max-width: 100%; min-width: 0; min-height: 17px; height: 17px;
    margin: 0; padding: 0 2px; border: 1px solid #bda98288; border-radius: 3px;
    background: #29251cce; color: #ffe6bb; font: 9px/15px sans-serif;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: auto;
  }
  :is(.in-battle,.in-formation) .external-status-table .portrait-status > [hidden] { display: none; }
  :is(.in-battle,.in-formation) .external-status-table .combat-status > .combat-effects,
  :is(.in-battle,.in-formation) .external-status-table .army-badge .army-rout { display: none; }
  :is(.in-battle,.in-formation) .external-status-table .combat-status > .extension-resources {
    position: static; order: 1; display: flex; flex-direction: row; align-items: center;
    width: 100%; max-width: 100%; min-height: 15px; gap: 3px;
    overflow-x: auto; scrollbar-width: none; pointer-events: auto;
  }
  :is(.in-battle,.in-formation) .external-status-table .combat-status .extension-resource {
    flex: 0 0 auto; height: 15px; box-sizing: border-box; padding: 0 3px; font-size: 9px; line-height: 13px;
  }
  :is(.in-battle,.in-formation) .external-status-table .self-general .combat-status > .extension-resources {
    flex-direction: column; align-items: stretch; overflow: visible;
  }
  :is(.in-battle,.in-formation) .external-status-table :is(.seat,.self-general) > .hand-count {
    bottom: calc(var(--card-inset) + 21px);
  }



  :is(.in-battle,.in-formation) .external-status-table .seat > .combat-status {
    display: grid; grid-template-columns: max-content minmax(0, 1fr);
    align-items: start; column-gap: 2px;
  }
  :is(.in-battle,.in-formation) .external-status-table .seat .combat-status > .extension-resources {
    justify-self: end; margin-left: auto; width: max-content; max-width: 100%; min-width: 0;
  }
  :is(.in-battle,.in-formation) .external-status-table .seat .combat-status:not(:has(.army-badge)) { grid-template-columns: minmax(0, 1fr); }
  :is(.in-battle,.in-formation) .external-status-table .seat .combat-status .extension-resource { padding-inline: 1px; }
  :is(.in-battle,.in-formation) .external-status-table .seat .resource-spark { font-size: 9px; margin-right: 1px; }

@media (orientation: landscape) and (max-height: 350px) {
  :is(.in-battle,.in-formation) .external-status-table .seat .army-badge { padding-inline: 1px; }
}

/* Equipment shares a row with hand count, not the wider health label below it. */
:is(.in-battle,.in-formation) .external-status-table .general-status {
  padding-right: calc(var(--hand-badge-size) + 4px);
}

.army-stat-icon { width: 11px; height: 13px; vertical-align: -2px; color: inherit; }
.army-stat-label { margin-right: 1px; }
.army-supply > .army-separator { display: none; }
.army-supply { margin-left: 3px; }
.army-supply.shortage { color: #ff9a88; }

  :is(.in-battle,.in-formation) .external-status-table .army-stat-icon { width: 11px; height: 11px; vertical-align: -1px; }
  :is(.in-battle,.in-formation) .external-status-table .army-stat-label { margin-right: 3px; }
  :is(.in-battle,.in-formation) .external-status-table .self-general .army-supply { margin-left: 0; }

@media (orientation: landscape) and (min-height: 601px) {
  :is(.in-battle,.in-formation) .external-status-table[data-player-count="8"] .seat:is([data-position="2"],[data-position="6"]) { margin-top: 0; }
  :is(.in-battle,.in-formation) .external-status-table[data-player-count="8"] .seat:is([data-position="1"],[data-position="7"]) { margin-bottom: 32px; }
  :is(.in-battle,.in-formation) .game-page.external-status-table[data-player-count] .battlefield .table-center { height: 24px; max-height: 24px; }
}

:is(.in-battle,.in-formation) .game-page.external-status-table[data-player-count] .battlefield .table-center {
  display: flex; flex-direction: row; align-items: center; flex-wrap: nowrap;
}
:is(.in-battle,.in-formation) .external-status-table .table-center > * { margin: 0; flex-shrink: 0; }
:is(.in-battle,.in-formation) .external-status-table .table-center .current-event { flex-direction: row; }

/* Keep public resource readouts light against both bright and dark table art. */
:is(.in-battle,.in-formation) .external-status-table .army-badge {
  width: fit-content; max-width: 100%; box-sizing: border-box;
  border: 0; border-radius: 3px;
  background: linear-gradient(90deg, #14292300, #14292366 12%, #14292380 76%, #14292300);
  text-shadow: 0 1px 2px #000d;
}
:is(.in-battle,.in-formation) .external-status-table .self-general .army-badge {
  align-self: flex-start; width: fit-content; padding: 2px 4px;
  border: 0; border-radius: 3px;
  background: linear-gradient(90deg, #14292300, #14292366 12%, #14292380 76%, #14292300);
}
:is(.in-battle,.in-formation) .external-status-table .army-stat-icon {
  filter: drop-shadow(0 1px 1px #0009);
}

/* Named resource readouts share the quiet backdrop of the army information. */
:is(.in-battle,.in-formation) .external-status-table .combat-status .extension-resource {
  height: 16px; padding: 0 2px; gap: 1px; border: 0; border-radius: 3px;
  background: linear-gradient(90deg, #14292300, #14292366 12%, #14292380 76%, #14292300);
  box-shadow: none; color: #f4ebd5; text-shadow: 0 1px 2px #000d;
  font: 10px/16px sans-serif;
}
:is(.in-battle,.in-formation) .external-status-table .extension-resource::before,
:is(.in-battle,.in-formation) .external-status-table .extension-resource::after { content: none; }
:is(.in-battle,.in-formation) .external-status-table .extension-resource .resource-name {
  color: var(--resource-color); margin-right: 3px; font: inherit;
}
:is(.in-battle,.in-formation) .external-status-table .extension-resource strong {
  font: 700 11px/16px sans-serif;
}
:is(.in-battle,.in-formation) .external-status-table .extension-resource small {
  color: #c1c5b9; font: 8px/16px sans-serif;
}
@media (orientation: landscape) and (max-height: 600px) {
  :is(.in-battle,.in-formation) .external-status-table .army-value {
    font: 700 10px/16px sans-serif;
    font-variant-numeric: tabular-nums;
  }
  :is(.in-battle,.in-formation) .external-status-table .army-stat-icon {
    width: 10px; height: 10px; vertical-align: -1px;
  }
  :is(.in-battle,.in-formation) .external-status-table .combat-status .extension-resource,
  :is(.in-battle,.in-formation) .external-status-table .extension-resource .resource-name,
  :is(.in-battle,.in-formation) .external-status-table .extension-resource strong,
  :is(.in-battle,.in-formation) .external-status-table .extension-resource small {
    font-size: 10px; line-height: 16px;
  }
}
:is(.in-battle,.in-formation) .external-status-table .extension-resource[data-full="true"] strong {
  color: var(--resource-color);
}
:is(.in-battle,.in-formation) .external-status-table .extension-resource[data-full="true"] .resource-name {
  filter: brightness(1.2);
}
:is(.in-battle,.in-formation) .external-status-table .seat > .combat-status { align-items: start; align-content: start; top: calc(100% + var(--portrait-info-gap)); }
:is(.in-battle,.in-formation) .external-status-table .self-general .combat-status > .extension-resources {
  overflow-x: auto; align-items: flex-start;
}

/* Keep response consequences inside the viewport above confirm/cancel. */
.game-page .action-zone > p.response-summary[role="status"] {
  right:0;transform:none;max-width:min(420px,calc(100vw - 32px));
  justify-content:flex-end;flex-wrap:wrap;white-space:normal;text-align:right;
}
.game-page .response-summary > span:last-child { flex-shrink:1;white-space:normal; }

/* Long press inspects a card/skill without native image or text selection. */
:is([data-cmd="select-card"],[data-cmd="select-skill"],[data-formation="card"],[data-formation="skill"]){-webkit-touch-callout:none;user-select:none;-webkit-user-select:none}
:is([data-cmd="select-card"],[data-formation="card"]) img{-webkit-user-drag:none}
/* Desktop round information follows the compact public-card area above the watermark. */
@media (orientation:landscape) and (min-height:601px) {
  :is(.in-battle,.in-formation) .game-page.external-status-table[data-player-count] .battlefield .table-center {
    position:fixed;left:50vw;right:auto;
    top:calc(50dvh + 24px - clamp(80px, 8.888889dvh, 96px) - 12px);bottom:auto;
    transform:translate(-50%,-100%);width:max-content;max-width:calc(100vw - 32px);
    height:auto;max-height:none;margin:0;
  }
}

/* Card choices keep their prompt, options and submission in one bounded panel. */
.game-page .card-choice-panel { position:fixed;inset:50% auto auto 50%;transform:translate(-50%,-50%);z-index:70;box-sizing:border-box;width:min(400px,calc(100vw - 32px));max-height:calc(100dvh - 24px);display:flex;flex-direction:column;gap:14px;padding:20px;border:1px solid #a48a4b;border-radius:14px;background:rgba(20,37,34,.98);box-shadow:0 16px 48px #0009;color:#eee4cc;text-align:center; }
.game-page .card-choice-panel h2 { margin:0;font-size:20px; }
.game-page .card-choice-panel p { margin:6px 0 0;font-size:14px;line-height:1.4;white-space:normal; }
.game-page .card-choice-options { display:grid;gap:8px;overflow:auto;min-height:0; }
.game-page .card-choice-panel button { width:auto;max-width:none;min-height:44px;margin:0;padding:10px 14px;white-space:normal;font-size:15px; }
.game-page .card-choice-options button { display:flex;align-items:center;gap:12px;text-align:left;border:1px solid #68766b;background:#203c36; }
.game-page .card-choice-options img { width:42px;height:52px;object-fit:cover;border-radius:4px; }
.game-page .card-choice-options button[aria-pressed="true"] { border-color:#e3c575;background:#494b32;box-shadow:inset 0 0 0 1px #e3c575; }
.game-page .card-choice-check { margin-left:auto;color:#f0d387;visibility:hidden; }
.game-page [aria-pressed="true"] > .card-choice-check { visibility:visible; }
.game-page .card-choice-panel footer { display:flex;justify-content:flex-end;gap:10px;flex-shrink:0; }
@media(max-height:450px) { .game-page .card-choice-panel { padding:12px 16px;gap:10px; } .game-page .card-choice-panel h2 { font-size:18px; } }
.game-page .card-choice-panel header { flex-shrink:0; }
.game-page .card-choice-options { grid-auto-rows:max-content; }
.game-page .card-choice-options button { height:auto;min-height:64px; }
.game-page .card-choice-panel footer { margin:0;padding:10px 0 0;border-top:1px solid #68766b55; }
@media(max-height:450px) { .game-page .card-choice-options img { width:32px;height:40px; } .game-page .card-choice-options button { min-height:54px;padding:6px 12px; } }

.audit-token { font-size: .8rem; color: var(--muted); white-space: nowrap; }

/* Match the five-seat portraits without scaling hands or action controls. */
@media (orientation: landscape) and (min-width: 600px) {
  .game-page[data-player-count="5"] .player-area {
    --self-portrait-width: calc(var(--five-seat-height) * .75);
    grid-template-columns: var(--self-portrait-width) minmax(0, 1fr) var(--player-card-width);
    grid-template-rows: minmax(0, 1fr);
  }
  .game-page[data-player-count="5"] .self-general {
    height: var(--five-seat-height);
    min-height: 0;
    width: 100%;
    align-self: end;
  }
}


.game-page .log-originals { margin-top: 3px; font-size: 11px; color: #c6bea9; }
.game-page .log-originals summary { cursor: pointer; width: fit-content; color: #c6ac76; }
.game-page .log-originals p { margin: 3px 0; padding: 0; }
.game-page .formation-sidebar-log .log-entry,
.game-page .formation-log .log-entry { padding: 5px 8px; border-bottom: 1px solid #b99a6026; line-height: 1.65; overflow-wrap: anywhere; }

/* Army state is a compact information panel, separate from skill prose. */
.army-details { margin-top: 20px; padding: 14px 16px; border: 1px solid #a9bbb02b; border-radius: 10px; background: #a9bbb00b; }
.army-details-heading { color: var(--muted); font: 500 12px/1.5 system-ui, sans-serif; letter-spacing: .04em; }
.army-details-stats { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 10px 0 8px; }
.army-details-stats > div { display: flex; align-items: baseline; gap: 7px; }
.army-details-stats dt { font-size: 12px; color: var(--muted); }
.army-details-stats dd { margin: 0; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.army-details-stats dd span { color: var(--muted); font-size: 12px; font-weight: 400; }
.skill-modal-card .army-details p, .army-details p { margin: 0; font-size: 12px; line-height: 1.7; font-weight: 400; }
.army-details-status, .army-forecast { color: var(--muted); }
.army-details .is-warning { color: #edbc88; }
.army-forecast { margin-top: 4px; }
.army-details-notes { margin-top: 6px; }
.army-details-rules { margin-top: 10px; border-top: 1px solid #a9bbb023; padding-top: 8px; color: var(--muted); }
.army-details-rules summary { width: fit-content; cursor: pointer; font-size: 12px; line-height: 1.8; }
.army-details-rules summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.army-details-rules[open] summary { margin-bottom: 6px; }
.army-details-rules p { white-space: pre-line; }

.transfer-effects .draw-card > span { transition: none; }
.card-motion-layer.transfer-effects { z-index: 1101; }

.transfer-arrived { filter: drop-shadow(0 0 7px #efce79); }

.removed-card-back { position:absolute;inset:0;z-index:2;display:grid;place-items:center;border-radius:inherit; }
.removed-card-back[hidden] { display:none; }

/* Morale names describe the current snapshot; ordinary stable morale stays quiet. */
.army-morale-state { font:500 10px/1.3 system-ui,sans-serif; white-space:nowrap; text-shadow:0 1px 2px #000d; }
.army-morale-state.high { color:#e6c67c; }
.army-morale-state.low { color:#ffc078; }
.army-morale-state.routed { color:#ff9a88; }
:is(.in-battle,.in-formation) .external-status-table :is(.army-morale,.self-general .army-morale) {
  display: inline-flex; flex-flow: row nowrap; align-items: baseline; justify-content: flex-start; white-space: nowrap;
}
:is(.in-battle,.in-formation) .external-status-table .army-morale-state { display: inline; margin: 0 0 0 3px; }
:is(.in-battle,.in-formation) .external-status-table .army-supply { vertical-align: baseline; }
:is(.in-battle,.in-formation) .external-status-table .self-general > .combat-status { width: max-content; min-width: 58px; overflow: visible; }
.in-battle .external-status-table:not(.formation-battle) .player-area .hand-area { margin-left: 88px; }
@media (orientation: landscape) and (max-height: 600px) {
  .in-battle .external-status-table:not(.formation-battle) .player-area .hand-area { margin-left: 76px; }
}

.action-line-label-back{fill:#151b20;fill-opacity:.86;stroke:#e4c37a88;stroke-width:1;pointer-events:none}

.speech-dialog{width:min(440px,calc(100vw - 32px));max-height:calc(100dvh - 24px);overflow:auto;border:1px solid var(--gold,#baa36e);border-radius:12px;background:#172322;color:#f3ebd8;padding:18px;box-shadow:0 12px 50px #0009}
.speech-dialog::backdrop{background:#0007}
.speech-dialog header,.speech-footer{display:flex;align-items:center;justify-content:space-between;gap:12px}
.speech-dialog h2{margin:0;font-size:20px}.speech-dialog label{display:block;margin-top:12px}.speech-dialog input{display:block;width:100%;box-sizing:border-box;margin:6px 0 12px}.speech-dialog select{max-width:70%}.speech-dialog [role=status]{margin:6px 0 0;font-size:13px}.speech-dialog button{min-height:36px}.log-speech{border-left:2px solid #bda56d;padding-left:8px;color:#e5d5a7}
