:root {
  --ink: #172018;
  --muted: #5d6259;
  --paper: #e8e1cc;
  --paper-deep: #cfc4a6;
  --green: #1d4434;
  --green-dark: #10291f;
  --yellow: #f4df18;
  --purple: #ad42a8;
  --red: #a7352b;
  --cyan: #159fc8;
  --shadow: 0 18px 45px rgba(12, 20, 14, 0.32);
}

* { box-sizing: border-box; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
html, body { margin: 0; min-height: 100%; background: #101813; color: var(--ink); }
body { font-family: "Arial Narrow", "Roboto Condensed", Arial, sans-serif; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.setup-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(260px, .48fr) minmax(760px, 1.52fr);
  background: #ddd4bd;
}
.hero-art {
  min-height: 100vh;
  background: linear-gradient(90deg, transparent 72%, #ddd4bd 100%), url("public/assets/cover.png") center / cover no-repeat;
  filter: saturate(.78) contrast(1.04);
}
.setup-content {
  padding: 36px clamp(32px, 4vw, 68px) 50px;
  width: 100%;
  max-width: 1240px;
  align-self: center;
}
.game-logo { width: 180px; height: 140px; object-fit: contain; display: block; margin: -18px 0 -12px; }
.eyebrow, .rail-label { color: #596459; font-weight: 900; font-size: 11px; letter-spacing: .22em; margin: 0 0 7px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-family: Georgia, serif; font-size: clamp(42px, 5vw, 68px); margin-bottom: 10px; letter-spacing: -.04em; }
.intro { max-width: 640px; color: #4f554e; font-size: 17px; line-height: 1.5; margin-bottom: 24px; }
.scenario-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.scenario-card-wrap { position: relative; min-width: 0; }
.scenario-card {
  width: 100%;
  text-align: left;
  border: 1px solid #9d987f;
  background: rgba(255,255,255,.28);
  padding: 14px 15px;
  min-height: 114px;
  color: var(--ink);
  position: relative;
  transition: .18s ease;
}
.scenario-delete { position: absolute; z-index: 2; right: 7px; bottom: 7px; width: 25px; height: 25px; display: grid; place-items: center; border: 1px solid rgba(115,30,25,.55); border-radius: 50%; background: rgba(236,229,210,.92); color: #76241f; font-size: 17px; font-weight: 900; line-height: 1; }
.scenario-delete:hover { background: #8b2e28; color: #fff; }
.scenario-card.active + .scenario-delete { border-color: rgba(255,255,255,.55); background: rgba(18,42,31,.9); color: #fff; }
.scenario-card:hover { background: rgba(255,255,255,.48); transform: translateY(-1px); }
.scenario-card.active { background: var(--green); border-color: var(--green); color: #f5f0df; box-shadow: 0 8px 18px rgba(23,52,39,.22); }
.scenario-card .number { font-weight: 900; font-size: 10px; letter-spacing: .18em; opacity: .62; }
.scenario-card h3 { font-family: Georgia, serif; font-size: 18px; margin: 6px 0 5px; }
.scenario-card p { margin: 0; font-size: 12px; line-height: 1.35; opacity: .78; }
.scenario-card .tag { position: absolute; top: 11px; right: 11px; font-size: 9px; text-transform: uppercase; letter-spacing: .12em; }
.scenario-card .imported-badge { display: inline-block; margin-top: 8px; padding: 3px 5px; background: rgba(21,159,200,.16); color: #245765; font-size: 8px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.scenario-card.active .imported-badge { background: rgba(255,255,255,.16); color: #d7f7ff; }
.scenario-import { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px 20px; align-items: center; margin: 14px 0 4px; padding: 14px 15px; border: 1px dashed #968f78; background: rgba(255,255,255,.18); }
.scenario-import h2 { margin: 0; font: 700 18px Georgia, serif; }
.scenario-import p { margin: 5px 0 0; max-width: 680px; color: #5d6259; font-size: 11px; line-height: 1.4; }
.scenario-import-actions { display: grid; grid-template-columns: auto auto; align-items: center; gap: 7px; }
.scenario-import-actions .primary, .scenario-import-actions .secondary { padding: 9px 12px; box-shadow: none; font-size: 9px; text-align: center; }
.scenario-import-actions .text-button { grid-column: 1 / -1; justify-self: end; padding: 3px 0; font-size: 10px; }
.scenario-import-actions .text-button:disabled { opacity: .35; cursor: not-allowed; }
.file-button { cursor: pointer; }
.scenario-import .scenario-import-status { grid-column: 1 / -1; min-height: 15px; margin: 0; color: #31583e; font-weight: 800; }
.scenario-import .scenario-import-status.error { color: #84352e; }
.setup-options { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 22px 0; }
.option-label { display: block; font-size: 10px; font-weight: 900; letter-spacing: .18em; color: #596459; margin-bottom: 7px; text-transform: uppercase; }
.segmented { display: flex; border: 1px solid #918b76; }
.segmented button { flex: 1; padding: 9px 10px; border: 0; background: transparent; color: var(--ink); }
.segmented button + button { border-left: 1px solid #918b76; }
.segmented button.active { background: #2a392f; color: #fff; }
.primary, .secondary, .header-button, .icon-button {
  border: 0;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.primary { background: #e3ce18; color: #151b13; padding: 11px 16px; box-shadow: 0 4px 0 #9a8a12; }
.primary:hover { background: #f3df28; }
.primary:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.primary.large { width: 100%; padding: 15px; font-size: 14px; }
.secondary { background: transparent; border: 1px solid #736e5f; padding: 10px 14px; color: inherit; }
.text-button { background: none; border: 0; color: #4b594f; padding: 12px 0; text-decoration: underline; }
.danger { color: #882b25; }
.force-builder { border-top: 1px solid #a29a82; padding-top: 17px; margin: 8px 0 20px; }
.builder-heading { display: flex; align-items: start; justify-content: space-between; gap: 15px; }
.builder-heading h2 { margin: 0; font: 700 23px Georgia, serif; }
.builder-heading .text-button { padding: 2px 0; font-size: 11px; }
.builder-intro { color: #5c6159; font-size: 12px; margin: 7px 0 11px; }
.squad-builder { display: grid; grid-template-columns: 1fr; gap: 12px; }
.builder-squad { border: 1px solid #948c75; background: rgba(255,255,255,.3); padding: 18px; min-width: 0; box-shadow: 0 4px 10px rgba(67,57,35,.08); }
.builder-squad-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.builder-squad-head > div:first-child { display: flex; align-items: baseline; gap: 10px; }
.builder-squad-head strong { font: 700 24px Georgia, serif; }
.builder-count { color: #64675e; font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.builder-type { display: flex; border: 1px solid #928a74; }
.builder-type button { border: 0; min-height: 42px; padding: 9px 16px; background: transparent; font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; }
.builder-type button + button { border-left: 1px solid #928a74; }
.builder-type button.active { background: #26382d; color: #fff; }
.builder-type button:disabled { opacity: .32; cursor: not-allowed; }
.builder-squad-body { display: grid; grid-template-columns: 1fr; gap: 18px; align-items: start; }
.builder-section-label { display: block; margin-bottom: 8px; color: #67695f; font-size: 10px; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.builder-selection { display: grid; grid-template-columns: repeat(3, minmax(190px,1fr)); gap: 12px; min-height: 148px; }
.selected-role { display: grid; grid-template-columns: 112px minmax(0,1fr); align-items: center; padding: 0; border: 1px solid #847d69; background: #d8d1bd; position: relative; min-width: 0; min-height: 142px; text-align: left; overflow: hidden; }
.selected-role img { width: 112px; height: 100%; min-height: 142px; object-fit: cover; object-position: center 28%; display: block; }
.selected-role span { display: flex; flex-direction: column; gap: 5px; padding: 13px 12px; font-size: 14px; font-weight: 900; line-height: 1.2; }
.selected-role span strong { color: #677064; font-size: 11px; font-family: inherit; }
.selected-role span small { margin-top: 8px; color: #6c6b60; font-size: 10px; font-weight: 400; }
.selected-role:not(:disabled):hover { border-color: #8b2e28; box-shadow: inset 0 0 0 2px rgba(139,46,40,.15); }
.selected-role:not(:disabled)::after { content: "×"; position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border-radius: 50%; background: rgba(115,30,25,.92); color: #fff; display: grid; place-items: center; font-size: 16px; }
.builder-pool { display: grid; grid-template-columns: repeat(3, minmax(160px,1fr)); gap: 10px; }
.builder-pool button { min-height: 68px; display: grid; grid-template-columns: 54px minmax(0,1fr) 26px; align-items: center; gap: 10px; border: 1px solid #8c846f; background: #ece5d2; padding: 7px; font-size: 11px; text-align: left; }
.builder-pool button:hover:not(:disabled) { border-color: #405548; background: #f4eedc; box-shadow: 0 2px 5px rgba(52,46,31,.14); }
.builder-pool button img { width: 54px; height: 54px; object-fit: cover; object-position: center 28%; }
.builder-pool button span { min-width: 0; }
.builder-pool button strong { display: block; overflow: hidden; text-overflow: ellipsis; }
.builder-pool button small { display: block; margin-top: 4px; color: #6c6b60; font-size: 9px; font-weight: 400; }
.builder-pool button b { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #26382d; color: #fff; font-size: 18px; }
.builder-pool button:disabled { opacity: .3; cursor: not-allowed; }
.fixed-squad-note { grid-column: 1 / -1; min-height: 90px; margin: 0; padding: 17px; border: 1px dashed #9b927b; display: flex; flex-direction: column; justify-content: center; color: #5d6259; font-size: 11px; line-height: 1.45; }
.fixed-squad-note strong { margin-bottom: 5px; color: #26382d; font: 700 15px Georgia, serif; }
.force-validation { min-height: 16px; margin: 8px 0 0; color: #84352e; font-size: 11px; font-weight: 800; }

.game-screen { min-height: 100vh; background: #17271d; color: #f3ecda; }
.game-header { min-height: 76px; display: grid; grid-template-columns: 78px minmax(170px,.75fr) minmax(300px,1.25fr) auto auto auto; align-items: center; gap: 14px; padding: 5px 18px; background: #0e1913; border-bottom: 1px solid rgba(255,255,255,.13); }
.game-header > img { width: 72px; height: 64px; object-fit: contain; }
.mission-heading span { display: block; font-size: 9px; color: #a5af9f; letter-spacing: .2em; font-weight: 800; }
.mission-heading h2 { font: 700 20px Georgia, serif; margin: 3px 0 0; }
.turn-status { display: flex; align-items: stretch; border: 1px solid #4b594e; }
.turn-status div { min-width: 74px; text-align: center; padding: 7px 12px; }
.turn-status div + div { border-left: 1px solid #4b594e; }
.turn-status span { display: block; font-size: 8px; letter-spacing: .16em; color: #97a296; }
.turn-status strong { font-size: 17px; color: #f3df24; }
.icon-button { border-radius: 50%; width: 36px; height: 36px; background: #2b3a30; color: #f7f2df; font-size: 18px; }
.header-button { background: transparent; border: 1px solid #526155; color: #f7f2df; padding: 10px 13px; font-size: 10px; }

.table-shell { display: grid; grid-template-columns: minmax(230px, 285px) minmax(600px, 1fr) minmax(250px, 310px); min-height: calc(100vh - 76px); }
.left-rail, .right-rail { padding: 16px; background: #1a2d21; overflow-y: auto; max-height: calc(100vh - 76px); }
.left-rail { border-right: 1px solid rgba(255,255,255,.1); }
.right-rail { border-left: 1px solid rgba(255,255,255,.1); }
.paper-panel { background: var(--paper); color: var(--ink); padding: 14px; border: 1px solid #a79d83; box-shadow: 0 4px 12px rgba(0,0,0,.18); margin-bottom: 13px; background-image: linear-gradient(rgba(255,255,255,.07), rgba(255,255,255,.07)), repeating-linear-gradient(0deg, transparent, transparent 4px, rgba(74,63,35,.025) 5px); }
.paper-panel h3 { font: 700 17px Georgia, serif; margin-bottom: 7px; }
.briefing p:not(.rail-label), .orders > p { font-size: 12px; line-height: 1.45; color: #4b5048; }
.objective-status { border-top: 1px solid #b8ae93; padding-top: 9px; font-size: 11px; font-weight: 800; line-height: 1.45; }
.objective-status div { display: flex; justify-content: space-between; margin-top: 5px; }
.objective-status strong { color: #77312b; }
.orders-heading, .panel-title-row { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.orders-heading span, .panel-title-row > span { font-size: 10px; font-weight: 800; color: #777466; }
.orders button { width: 100%; margin-top: 6px; font-size: 10px; }
.veteran-controls { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; margin: 8px 0 4px; }
.veteran-controls button { margin: 0; border: 1px solid #6f6755; background: #f2ecd9; padding: 7px 5px; font-weight: 900; color: #24281f; }
.veteran-controls button.active { background: #243a2d; color: #fff; }
.event-panel { border-top: 1px solid #455649; padding-top: 10px; }
.event-heading { display: flex; justify-content: space-between; color: #aeb6aa; font-size: 9px; letter-spacing: .15em; font-weight: 900; }
.event-heading button { background: none; border: 0; color: #aeb6aa; font-size: 9px; }
#event-log { list-style: none; padding: 0; margin: 9px 0; color: #d8dacd; font-size: 10px; line-height: 1.45; max-height: 260px; overflow-y: auto; }
#event-log li { padding: 6px 0 6px 32px; border-bottom: 1px solid rgba(255,255,255,.07); position: relative; }
#event-log time { position: absolute; left: 0; color: #7f8f82; }
.header-feedback { min-width: 0; padding: 0 14px; border-left: 1px solid #455649; border-right: 1px solid #455649; position: relative; }
.feedback-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 3px; }
.feedback-heading h3 { margin: 0; color: #aeb8ac; font-size: 9px; letter-spacing: .14em; text-transform: uppercase; }
#feedback-count { min-width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: #e3ce18; color: #172018; font-size: 9px; font-weight: 900; }
#feedback-form { display: grid; grid-template-columns: minmax(120px,1fr) auto; gap: 6px; align-items: stretch; }
#feedback-input { width: 100%; min-width: 0; height: 31px; border: 1px solid #667369; background: #f1ead7; color: #172018; padding: 6px 9px; font-size: 11px; }
#feedback-form .primary { min-height: 31px; padding: 6px 10px; box-shadow: none; font-size: 8px; }
.feedback-status { min-height: 10px; margin: 2px 0 0; color: #eddb46; font-size: 8px; line-height: 1.2; }
.feedback-preview { display: none; }

.board-stage { min-width: 0; padding: 12px 16px 9px; display: flex; flex-direction: column; align-items: center; background: radial-gradient(circle at center, #34503a 0, #223a29 52%, #14261b 100%); position: relative; }
.board-stage::before { content: ""; position: absolute; inset: 0; opacity: .08; background-image: repeating-linear-gradient(23deg, transparent 0 6px, #fff 7px, transparent 8px); pointer-events: none; }
.opponent-strip { width: min(100%, 980px); height: 45px; display: flex; align-items: center; justify-content: space-between; z-index: 1; }
.enemy-label { font-size: 10px; letter-spacing: .14em; color: #d2d9cf; }
.enemy-label strong { margin-left: 7px; color: #d78fd2; }
.purple-dot { width: 10px; height: 10px; display: inline-block; border-radius: 50%; background: var(--purple); margin-right: 6px; }
.enemy-squads { display: flex; gap: 7px; }
.enemy-chip { display: flex; align-items: center; gap: 5px; border: 1px solid #657268; padding: 4px 7px; font-size: 9px; color: #cbd2c8; }
.enemy-chip.eliminated { opacity: .35; text-decoration: line-through; }
.enemy-chip .mini-health { display: flex; gap: 2px; }
.mini-health i { width: 5px; height: 5px; background: #ad42a8; display: block; }

.board-wrap { position: relative; width: min(100%, 980px); aspect-ratio: 1488 / 1168; overflow: hidden; background: #159fc8; box-shadow: 0 22px 45px rgba(0,0,0,.42); z-index: 1; user-select: none; }
.map-label-layer { position: absolute; inset: 0; z-index: 2; pointer-events: none; color: #050b0c; font-family: Arial, sans-serif; font-weight: 900; }
.map-label-layer span { position: absolute; display: grid; place-items: center; transform: translate(-50%,-50%); }
.map-label-layer .column-label { top: 2.6%; font-size: clamp(11px,1.75vw,27px); }
.map-label-layer .row-label { left: 2.7%; font-size: clamp(11px,1.65vw,25px); }
.hex-layer, .token-layer { position: absolute; inset: 0; }
.hex-layer { z-index: 3; }
.token-layer { z-index: 4; pointer-events: none; }
.hex-hit {
  position: absolute;
  width: 12%;
  aspect-ratio: 184 / 170;
  transform: translate(-50%, -50%);
  border: 0;
  padding: 0;
  background-color: transparent;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  clip-path: polygon(22% 2%,78% 2%,100% 50%,78% 98%,22% 98%,0 50%);
  transition: .12s ease;
}
.hex-hit::before { content: ""; position: absolute; inset: 0; z-index: 1; background: transparent; pointer-events: none; transition: .12s ease; }
.hex-hit:hover::before { background: rgba(255,255,255,.14); }
.hex-hit.reachable { outline: none; filter: drop-shadow(0 0 6px #ffe91d); }
.hex-hit.reachable::before { background: rgba(241,225,36,.33); }
.hex-hit.deployable { outline: none; filter: drop-shadow(0 0 7px #ffe91d); }
.hex-hit.deployable::before { background: rgba(241,225,36,.42); }
.hex-hit.targetable { filter: drop-shadow(0 0 5px #ff6d5d); }
.hex-hit.targetable::before { background: rgba(175,47,39,.26); }
.hex-hit.mortar-target::after { content: attr(data-range); position: absolute; inset: 32%; z-index: 2; display: grid; place-items: center; border-radius: 50%; background: rgba(24,31,23,.9); color: #fff3a4; font-size: clamp(8px,.8vw,12px); font-weight: 900; }
.hex-hit.selected::before { background: rgba(255,255,255,.27); }
.hex-hit.scouted { filter: drop-shadow(0 0 4px #d475cf); }
.hex-hit.scouted::before { background: rgba(167,66,162,.3); }
.hex-hit.scenario-zone::before { box-shadow: inset 0 0 0 2px rgba(237,200,55,.48); }
.hex-hit:focus-visible { outline: 3px solid #fff; outline-offset: -3px; }
.board-token { position: absolute; transform: translate(-50%, -50%); display: grid; place-items: center; filter: drop-shadow(0 3px 3px rgba(0,0,0,.55)); }
.squad-token { width: 4.4%; aspect-ratio: 1; border-radius: 50%; border: 3px solid #3b3310; background: var(--yellow); color: #18180f; font-family: Georgia, serif; font-size: clamp(11px, 1.3vw, 20px); font-weight: 900; box-shadow: inset 0 0 0 3px rgba(255,255,255,.34); }
.squad-token.selected { transform: translate(-50%, -50%) scale(1.2); box-shadow: 0 0 0 4px #fff, inset 0 0 0 3px rgba(255,255,255,.34); }
.contact-token { width: 3.9%; aspect-ratio: 1; border-radius: 50%; background: var(--purple); border: 3px solid #4d174b; color: #fff; font-weight: 900; }
.contact-token.attack-selectable { pointer-events: auto; cursor: crosshair; box-shadow: 0 0 0 4px rgba(255,255,255,.92), 0 0 0 7px #d54037; transition: transform .12s ease; }
.contact-token.attack-selectable:hover { transform: translate(-50%, -50%) scale(1.18); }
.contact-token.target-squad::after { content: "TARGET"; position: absolute; top: 105%; font-size: 7px; padding: 2px 4px; background: #641f5f; }
.hq-token { width: 6%; aspect-ratio: 1.24; border-radius: 7px; background: url(public/assets/hq.png) center / cover; overflow: hidden; color: #fff; font-family: Georgia, serif; font-weight: 900; box-shadow: inset 0 0 0 2px rgba(255,255,255,.48); }
.hq-token.player-hq { border: 3px solid #e1da00; }
.hq-token.ai-hq { border: 3px solid #8b2786; }
.hq-token span { position: absolute; left: 8%; bottom: -8%; font-size: clamp(13px,1.65vw,25px); text-shadow: 0 1px 3px #000; }
.hq-token i { position: absolute; right: 4%; top: -9%; color: #e8df00; font-size: clamp(10px,1.15vw,18px); font-style: normal; text-shadow: 0 1px 2px #000; }
.hq-token.ai-hq i { color: #b73caf; }
.hq-token.selected { box-shadow: 0 0 0 4px #fff, inset 0 0 0 2px rgba(255,255,255,.48); }
.mission-token { width: 5.1%; aspect-ratio: 1; border-radius: 50%; background: rgba(238,229,191,.9); border: 3px solid #5f5540; color: #392f21; font-size: clamp(10px,1.2vw,18px); }
.search-location-token { width: 3%; aspect-ratio: 1; border-radius: 50%; background: #f4e229; border: 2px solid #443c08; color: #18180f; font-size: clamp(9px,1vw,15px); font-weight: 900; box-shadow: inset 0 0 0 2px rgba(255,255,255,.42); }
.search-location-token.village-icon { width: 4.8%; background: #f4e9bc; border-color: #5b5031; font-size: clamp(15px,1.8vw,27px); }
.bomb-token { width: 3.5%; aspect-ratio: 1; border-radius: 50%; background: #f1d728; border: 2px solid #403707; color: #111; font-size: clamp(9px,1vw,15px); }
.suppressed-marker { width: 5%; color: #e33e2f; font-size: clamp(16px,2vw,30px); font-weight: 900; text-shadow: 0 2px 1px #fff; }
.casualty-token { width: 3.1%; aspect-ratio: 1; background: #a72e27; border: 2px solid #571511; color: #fff; font-size: clamp(8px,.9vw,13px); font-weight: 900; transform: translate(32%, 28%) rotate(8deg); }
.dice-toast { position: absolute; top: 50%; left: 50%; z-index: 8; transform: translate(-50%,-50%) rotate(-2deg); background: #eee6cf; border: 3px solid #18241a; color: #172018; min-width: 190px; padding: 16px 20px; text-align: center; box-shadow: var(--shadow); font-family: Georgia, serif; }
.dice-toast strong { display: block; font-size: 38px; margin-top: 5px; }
.legend { width: min(100%,980px); display: flex; gap: 16px; padding: 9px 2px 0; color: #bfc8bd; font-size: 9px; z-index: 1; }
.legend-token { width: 10px; height: 10px; display: inline-block; margin-right: 4px; border-radius: 50%; vertical-align: -1px; }
.legend-token.yellow { background: var(--yellow); }.legend-token.purple { background: var(--purple); }.legend-token.hq { border: 2px solid #d6c900; border-radius: 2px; background: #596748; }.legend-token.target { border: 2px solid #d9cda8; }.legend-token.search { background: #f4e229; border: 2px solid #443c08; }.legend-token.bomb { background: #f1d728; }.legend-token.casualty { background: #a72e27; border-radius: 1px; }

.player-squads { display: grid; gap: 8px; }
.squad-card { border: 1px solid #817a68; background: rgba(255,255,255,.32); }
.squad-card.selected { border-color: #806f00; box-shadow: 0 0 0 2px #d5bd12; }
.squad-card.disabled { opacity: .58; }
.squad-top { display: flex; align-items: center; justify-content: space-between; padding: 7px 8px; background: #25382c; color: #f6f0de; }
.squad-top button { padding: 0; border: 0; background: none; color: inherit; font-weight: 900; font-family: Georgia, serif; }
.squad-top span { font-size: 9px; opacity: .72; }
.role-list { display: grid; grid-template-columns: repeat(3,1fr); gap: 5px; padding: 7px; }
.role-card { min-width: 0; border: 1px solid #77715f; background: #d7d1bc; padding: 0; text-align: left; position: relative; }
.role-card.active { box-shadow: 0 0 0 2px #d5bd12; }
.role-card.dead { filter: grayscale(1); opacity: .4; }
.role-card img { width: 100%; aspect-ratio: 1.35; object-fit: cover; object-position: center 28%; display: block; }
.role-card strong { display: block; padding: 4px 4px 2px; font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.health { display: flex; gap: 2px; padding: 0 4px 4px; }
.health i { width: 9px; height: 5px; border: 1px solid #776d54; background: #f1ecda; }
.health i.hit { background: #b23229; }
.action-bar { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 7px 7px; }
.action-button { border: 1px solid #685f4e; padding: 5px 6px; background: #ede6d2; color: #24281f; font-size: 8px; font-weight: 900; }
.action-button:hover { background: #f4de22; }
.action-button.scenario-action { background:#253f31;color:#fff6c7;border-color:#d8bd42; }
.action-button.scenario-action:hover { background:#365d47; }
.veteran-hand { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.veteran-card { border: 2px solid #0d4059; min-height: 112px; padding: 0; color: #fff; position: relative; overflow: hidden; text-align: left; background: #23352a center / cover; }
.veteran-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 35%, rgba(4,18,13,.95) 78%); }
.veteran-card span { position: absolute; z-index: 1; left: 7px; right: 7px; bottom: 7px; font-size: 9px; font-weight: 900; text-shadow: 0 1px 2px #000; }
.veteran-card small { display: block; margin-top: 3px; font-size: 7px; font-weight: 400; line-height: 1.25; color: #e3e5dd; }
.veteran-card.used { opacity: .35; }
.veteran-card.active { border-color: #f1d923; box-shadow: 0 0 0 3px rgba(241,217,35,.55); }

dialog { border: 1px solid #928872; background: #e8e1cc; color: var(--ink); box-shadow: 0 22px 70px rgba(0,0,0,.6); padding: 30px; max-width: min(760px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(4,10,6,.76); backdrop-filter: blur(3px); }
.dialog-close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 28px; }
dialog h2 { font: 700 29px Georgia, serif; }
.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px 24px; }
.rules-grid section { border-top: 1px solid #a89f88; padding-top: 9px; }
.rules-grid h3 { margin-bottom: 5px; font: 700 15px Georgia, serif; }
.rules-grid p, .rules-note { font-size: 12px; line-height: 1.5; color: #55594f; }
.range-reference table { width: 100%; border-collapse: collapse; font-size: 10px; }
.range-reference th, .range-reference td { border-bottom: 1px solid #b9b099; padding: 3px 5px; text-align: left; }
.range-reference th { background: #26392d; color: #f5efdc; }
.rules-note { margin: 18px 0 0; font-style: italic; }
.combat-dialog { width: min(510px, calc(100vw - 32px)); text-align: center; }
.combat-dialog p { color: #55594f; line-height: 1.5; }
.combat-dialog .primary { min-width: 190px; margin-top: 14px; }
.scenario-info-dialog { width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; }
.scenario-info-dialog > p:not(.eyebrow) { color: #4f534b; font-size: 14px; line-height: 1.65; }
.scenario-info-rules { margin-top: 20px; padding: 15px 18px; border: 1px solid #aaa087; background: #f4eedc; }
.scenario-info-rules h3 { margin-bottom: 8px; font: 700 16px Georgia, serif; }
.scenario-info-rules ul { margin: 0; padding-left: 20px; font-size: 12px; line-height: 1.55; }
.veteran-confirm-art { width: 180px; aspect-ratio: 2.5 / 3.5; margin: 12px auto 16px; border: 2px solid #514b3f; border-radius: 8px; background-position: center; background-size: cover; box-shadow: 5px 7px 0 #9d947c; }
.combat-result { width: 74px; height: 74px; margin: 16px auto 6px; display: grid; place-items: center; border: 3px solid #26392d; background: #f5efdc; font: 700 38px Georgia, serif; box-shadow: 4px 4px 0 #9d947c; }
.combat-result.hidden { display: none; }
.setup-roll-result { margin: 16px 0 6px; display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.setup-roll-result.hidden { display: none; }
.setup-roll-result span { min-width: 86px; padding: 10px 14px; border: 2px solid #26392d; background: #f5efdc; box-shadow: 3px 3px 0 #9d947c; }
.setup-roll-result strong { display: block; font: 700 31px Georgia, serif; }
.setup-roll-result small { display: block; margin-top: 3px; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.counter-role-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.counter-role-options.hidden { display: none; }
.counter-role-options button { border: 1px solid #746c59; background: #d8d0b9; padding: 10px 6px; font-size: 10px; font-weight: 900; }
.counter-role-options button:hover { background: #ead722; }
.counter-role-options small { display: block; margin-top: 3px; font-weight: 400; }
.history-dialog { min-width: min(650px, calc(100vw - 32px)); }
.history-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; padding: 10px 0; border-top: 1px solid #aaa18b; font-size: 12px; }
.history-row strong { font-family: Georgia, serif; }
.history-row span { color: #655f53; }
.result-dialog { width: min(600px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; }
.result-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin: 18px 0; }
.result-stats div { border-top: 1px solid #a59b83; padding-top: 6px; font-size: 10px; color: #6c685d; }
.result-stats strong { display: block; font-size: 19px; color: var(--ink); }
.result-dialog label { display: block; font-weight: 800; font-size: 11px; margin: 13px 0 6px; }
.rating { display: flex; gap: 6px; }
.rating button { width: 35px; height: 35px; border: 1px solid #817968; background: transparent; }
.rating button.active { background: #d9c51c; }
textarea { width: 100%; resize: vertical; border: 1px solid #938a74; background: #f5f0df; padding: 10px; }
.dialog-actions { display: flex; gap: 10px; margin-top: 15px; }
.result-feedback { margin-top: 18px; padding-top: 13px; border-top: 2px solid #857d69; }
.result-feedback-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.result-feedback-heading h3 { margin: 0; font: 700 17px Georgia, serif; }
.result-feedback-heading span { color: #696458; font-size: 10px; font-weight: 900; }
#result-feedback-list { margin: 10px 0 0; padding: 0; list-style: none; max-height: 190px; overflow-y: auto; }
#result-feedback-list li { padding: 8px 0; border-top: 1px solid #b8af98; }
#result-feedback-list li:first-child { border-top: 0; }
#result-feedback-list span { color: #6b665a; font-size: 9px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; }
#result-feedback-list p { margin: 3px 0 0; font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
#result-feedback-list .empty-feedback { color: #696458; font-size: 11px; font-style: italic; }
.feedback-copy-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.feedback-copy-actions button { font-size: 9px; }
.copy-feedback-status { min-height: 14px; margin: 6px 0 0; color: #31583e; font-size: 10px; font-weight: 800; }

@media (max-width: 1150px) {
  .setup-screen { grid-template-columns: minmax(250px,.55fr) minmax(650px,1.45fr); }
  .builder-selection { grid-template-columns: repeat(3,minmax(150px,1fr)); }
  .selected-role { grid-template-columns: 92px minmax(0,1fr); }
  .selected-role img { width: 92px; }
  .table-shell { grid-template-columns: 230px minmax(570px,1fr); }
  .right-rail { grid-column: 1 / -1; max-height: none; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; border-left: 0; border-top: 1px solid rgba(255,255,255,.1); }
}
@media (max-width: 840px) {
  .setup-screen { grid-template-columns: 1fr; }
  .hero-art { min-height: 38vh; background: linear-gradient(0deg, #ddd4bd 0, transparent 40%), url("public/assets/cover.png") center 42% / cover no-repeat; }
  .setup-content { padding-top: 0; }
  .game-header { grid-template-columns: 70px 1fr auto; height: auto; min-height: 72px; padding: 6px 12px; }
  .header-feedback { order: 3; grid-column: 1 / -1; width: 100%; padding: 7px 0; border: 0; border-top: 1px solid #455649; }
  .turn-status { order: 4; grid-column: 1 / -1; width: 100%; margin-bottom: 6px; }
  .turn-status div { flex: 1; }
  .header-button { display: none; }
  .table-shell { display: flex; flex-direction: column; }
  .left-rail, .right-rail { max-height: none; }
  .left-rail { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .event-panel { grid-column: 1 / -1; }
  .board-stage { order: -1; padding: 8px; overflow-x: auto; align-items: flex-start; }
  .board-wrap, .opponent-strip, .legend { width: 760px; }
  .right-rail { display: block; }
}
@media (max-width: 600px) {
  .scenario-list, .setup-options, .rules-grid, .left-rail, .squad-builder { grid-template-columns: 1fr; }
  .setup-content { padding-left: 20px; padding-right: 20px; }
  .hero-art { min-height: 31vh; }
  .builder-heading, .builder-squad-head { align-items: stretch; flex-direction: column; }
  .builder-squad-head > div:first-child { justify-content: space-between; }
  .builder-type button { flex: 1; }
  .builder-selection { grid-template-columns: 1fr; }
  .selected-role { min-height: 82px; }
  .selected-role img { min-height: 82px; height: 82px; }
  .builder-pool { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .left-rail { display: block; }
  .result-stats { grid-template-columns: 1fr 1fr; }
  #feedback-form, .feedback-copy-actions { grid-template-columns: 1fr; }
  .scenario-import { grid-template-columns: 1fr; }
  .scenario-import-actions { grid-template-columns: 1fr; }
  .scenario-import-actions .text-button { grid-column: 1; justify-self: start; }
}
