:root {
  --paper: #f3efe5;
  --paper-deep: #e6dece;
  --surface: #fffdf7;
  --ink: #17211f;
  --muted: #6e756e;
  --line: #cfc7b8;
  --red: #d94f45;
  --red-dark: #9f302c;
  --blue: #246e9d;
  --blue-dark: #174863;
  --gold: #e5ae42;
  --green: #296f58;
  --shadow: 0 18px 48px rgba(31, 38, 34, 0.12);
  --radius: 24px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 0%, rgba(229, 174, 66, 0.14), transparent 30rem),
    radial-gradient(circle at 90% 100%, rgba(36, 110, 157, 0.11), transparent 34rem),
    var(--paper);
}

button { font: inherit; }
button:focus-visible { outline: 3px solid rgba(229, 174, 66, 0.75); outline-offset: 3px; }

.loading-screen {
  min-height: 100vh;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
}

.loading-mark {
  font-weight: 900;
  letter-spacing: 0.38em;
  color: var(--ink);
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0.2rem; font-size: clamp(1.3rem, 2.4vw, 2rem); line-height: 1; }
h2 { font-size: 1rem; }

.brand-lockup { display: flex; align-items: center; gap: 0.8rem; }
.brand-seal {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: white;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: inset 0 0 0 5px rgba(255,255,255,0.12);
}
.brand-seal i { margin: 0 -1px; font-style: normal; }

.phase-pill,
.turn-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 34px;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,0.58);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.turn-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.is-red { color: var(--red-dark); }
.is-blue { color: var(--blue-dark); }

.board-svg {
  display: block;
  width: 100%;
  max-height: min(69vh, 710px);
  overflow: visible;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.cell polygon {
  fill: rgba(255, 253, 247, 0.9);
  stroke: #bdb4a4;
  stroke-width: 2;
  transition: transform 140ms ease, fill 140ms ease, stroke 140ms ease, opacity 140ms ease;
  transform-box: fill-box;
  transform-origin: center;
}

.cell.empty text.number { fill: #7e8179; font-size: 14px; font-weight: 700; }
.cell.empty.illegal { opacity: 0.36; cursor: help; }
.cell.empty.legal { cursor: pointer; }
.cell.empty.legal polygon { fill: #fffdf8; stroke: #8f998e; }
.cell.empty.legal:hover polygon {
  fill: #fff4ce;
  stroke: var(--gold);
  stroke-width: 4;
  transform: scale(1.055);
}

.cell .piece-disc { stroke: rgba(255,255,255,0.86); stroke-width: 4; filter: drop-shadow(0 4px 4px rgba(23,33,31,0.18)); }
.cell .piece-disc.red { fill: var(--red); }
.cell .piece-disc.blue { fill: var(--blue); }
.cell .piece-kind { fill: white; font-size: 22px; font-weight: 950; text-anchor: middle; dominant-baseline: central; }
.cell .effect-badge { fill: var(--ink); }
.cell .effect-badge.conversion { fill: var(--green); }
.cell .effect-badge.sacrifice { fill: var(--red-dark); }
.cell .effect-text { fill: white; font-size: 8px; font-weight: 900; text-anchor: middle; dominant-baseline: central; }
.cell .liberty-badge { fill: rgba(23, 33, 31, 0.86); stroke: white; stroke-width: 1.5; }
.cell .liberty-badge.danger { fill: #f4bd45; }
.cell .liberty-text { fill: white; font-size: 9px; font-weight: 950; text-anchor: middle; dominant-baseline: central; }
.cell .liberty-badge.danger + .liberty-text { fill: var(--ink); }
.cell .sacrifice-badge { fill: #fff3bd; stroke: var(--red-dark); stroke-width: 1.5; }
.cell .sacrifice-text { fill: var(--red-dark); font-size: 7px; font-weight: 950; text-anchor: middle; dominant-baseline: central; }
.cell.sacrifice-preview-point polygon { fill: #ffe8d5; stroke: var(--red-dark); stroke-width: 4; stroke-dasharray: 6 3; }
.cell.sacrifice-staged polygon { fill: #fff0da; stroke: var(--red-dark); stroke-width: 5; }
.cell.sacrifice-staged .piece-disc,
.cell.sacrifice-staged .piece-kind,
.cell.sacrifice-staged .sacrifice-badge,
.cell.sacrifice-staged .sacrifice-text {
  transform-box: fill-box;
  transform-origin: center;
  animation: sacrifice-arrive 550ms ease-in-out both;
}
.board-svg.large-board .cell.empty text.number { font-size: 11px; }
.board-svg.large-board .cell .piece-kind { font-size: 17px; }
.board-svg.large-board .cell .liberty-text { font-size: 7.5px; }
.board-svg.large-board .cell polygon { stroke-width: 1.6; }
.cell.atari polygon { stroke: var(--gold); stroke-width: 4; }
.cell.capture-preview .piece-disc { stroke: #fff3bd; stroke-width: 7; filter: drop-shadow(0 0 9px rgba(229,174,66,.85)); }
.cell.capture-preview polygon { fill: #fff1bd; stroke: var(--gold); stroke-width: 5; }
.cell.conversion-preview .piece-disc { stroke: #d9fff1; stroke-width: 7; filter: drop-shadow(0 0 10px rgba(41,111,88,.8)); }
.cell.conversion-preview polygon { fill: #def5e9; stroke: var(--green); stroke-width: 5; stroke-dasharray: 5 3; }

.piece-picker { display: grid; gap: 0.55rem; }
.effect-legend { margin: 0; color: var(--muted); font-size: 0.67rem; line-height: 1.35; }
.effect-legend strong { color: var(--ink); }
.piece-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.55rem; }
.piece-button {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.72rem 0.65rem;
  background: rgba(255,255,255,0.7);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}
.piece-button:hover:not(:disabled) { transform: translateY(-2px); border-color: #978d7c; }
.piece-button.selected { background: var(--ink); color: white; border-color: var(--ink); }
.piece-button:disabled { opacity: 0.35; cursor: not-allowed; }
.piece-button.cooling {
  border-style: dashed;
  background: rgba(229, 174, 66, 0.13);
}
.piece-button.cooling:disabled { opacity: 0.58; }
.piece-button strong { display: block; font-size: 1.05rem; }
.piece-button small { display: block; margin-top: 0.2rem; opacity: 0.65; font-size: 0.7rem; }
.piece-icon { display: block; margin-bottom: 0.15rem; font-size: 1.35rem; line-height: 1; }
.piece-count {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  min-width: 24px;
  height: 24px;
  padding: 0 0.45rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--paper-deep);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 900;
}
.piece-button.selected .piece-count { background: white; }

.button-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.action-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 38px;
  padding: 0.55rem 0.9rem;
  background: rgba(255,255,255,0.74);
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
}
.action-button:hover:not(:disabled) { border-color: var(--ink); }
.action-button:disabled { opacity: 0.35; cursor: not-allowed; }
.action-button.danger { color: var(--red-dark); }
.action-button.primary { background: var(--ink); color: white; border-color: var(--ink); }
.action-button.pass { border-color: var(--green); color: var(--green); }
.action-button.pass.primary { background: var(--green); color: white; }

.score-pair { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 0.8rem; }
.score-side { display: flex; align-items: baseline; gap: 0.5rem; }
.score-side.blue { justify-content: flex-end; text-align: right; }
.score-number { font-size: clamp(2rem, 5vw, 4.4rem); line-height: 0.9; font-weight: 950; letter-spacing: -0.07em; }
.score-side.red .score-number { color: var(--red-dark); }
.score-side.blue .score-number { color: var(--blue-dark); }
.score-label { color: var(--muted); font-size: 0.72rem; font-weight: 800; }
.versus { color: #aaa292; font-size: 0.7rem; font-weight: 900; letter-spacing: 0.16em; }

.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.55rem; }
.metric {
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 0.68rem;
  background: rgba(255,255,255,0.48);
}
.metric span { display: block; color: var(--muted); font-size: 0.68rem; }
.metric strong { display: block; margin-top: 0.2rem; font-size: 1.1rem; }

.capture-line { display: grid; grid-template-columns: 1fr auto auto; gap: 0.45rem; align-items: baseline; padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.capture-line:last-child { border-bottom: 0; }
.capture-name { font-size: 0.78rem; font-weight: 850; }
.capture-line strong { font-size: 1.35rem; }
.capture-line small { color: var(--muted); }

.history-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.history-list li { position: relative; padding-left: 1rem; color: var(--muted); font-size: 0.76rem; line-height: 1.35; }
.history-list li::before { content: ""; position: absolute; left: 0; top: 0.48em; width: 5px; height: 5px; border-radius: 50%; background: var(--gold); }
.status-message { margin: 0; color: var(--green); font-size: 0.8rem; font-weight: 750; line-height: 1.4; }
.search-status { margin: -0.15rem 0 0; color: var(--muted); font-size: 0.68rem; line-height: 1.35; }

/* Variant A — board-first arena */
.arena { min-height: 100vh; padding: 1.2rem clamp(1rem, 3vw, 2.8rem) 7rem; display: grid; grid-template-rows: auto 1fr auto; gap: 1rem; }
.arena-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; max-width: 1400px; width: 100%; margin: 0 auto; }
.arena-meta { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; }
.arena-stage { position: relative; display: grid; place-items: center; min-height: 0; }
.arena-board { width: min(100%, 790px); }
.arena-score {
  position: absolute;
  top: 0.4rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  width: min(82%, 470px);
  padding: 0.75rem 1.2rem;
  border: 1px solid rgba(207,199,184,0.8);
  border-radius: 22px;
  background: rgba(255,253,247,0.88);
  box-shadow: 0 12px 32px rgba(31,38,34,0.08);
  backdrop-filter: blur(14px);
}
.arena-score .score-number { font-size: 2rem; }
.arena-tray {
  width: min(100%, 900px);
  margin: 0 auto;
  padding: 0.9rem;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 0.85rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255,253,247,0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.arena-actions { display: grid; gap: 0.65rem; }
.arena-events { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 0.75rem; }

/* Variant B — three-column strategy desk */
.strategy-desk { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(430px, 1fr) 292px; gap: 1rem; padding: 1rem 1rem 6.5rem; }
.desk-panel {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255,253,247,0.76);
  box-shadow: 0 9px 30px rgba(31,38,34,0.07);
}
.control-tower, .intel-panel { padding: 1rem; display: flex; flex-direction: column; gap: 1.1rem; min-height: calc(100vh - 7.5rem); }
.map-panel { min-height: calc(100vh - 7.5rem); display: grid; grid-template-rows: auto 1fr auto; padding: 0.9rem; }
.map-header { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; padding: 0.35rem 0.5rem; }
.map-board { min-height: 0; display: grid; place-items: center; }
.map-footer { display: flex; justify-content: space-between; gap: 0.8rem; padding: 0.5rem; color: var(--muted); font-size: 0.75rem; }
.control-tower .piece-buttons { grid-template-columns: 1fr; }
.control-tower .piece-button { padding: 0.85rem; }
.intel-section { border-top: 1px solid var(--line); padding-top: 0.9rem; }
.intel-section:first-of-type { border-top: 0; padding-top: 0; }
.intel-panel .score-number { font-size: 2.35rem; }
.intel-panel .history-list { max-height: 240px; overflow: auto; }

/* Variant C — analytical command table */
.analysis-table { min-height: 100vh; padding: 1rem clamp(1rem, 3vw, 3rem) 7rem; }
.analysis-header {
  max-width: 1380px;
  margin: 0 auto 1rem;
  display: grid;
  grid-template-columns: 1fr minmax(340px, 0.9fr) 1fr;
  align-items: center;
  gap: 1.2rem;
}
.analysis-header .score-pair { padding: 0.8rem 1.1rem; border-radius: 20px; background: var(--ink); color: white; }
.analysis-header .score-number { color: white !important; font-size: 2.35rem; }
.analysis-header .score-label, .analysis-header .versus { color: rgba(255,255,255,0.58); }
.analysis-turn { text-align: right; }
.analysis-grid { max-width: 1380px; margin: 0 auto; display: grid; grid-template-columns: minmax(500px, 1.35fr) minmax(330px, 0.65fr); gap: 1rem; }
.analysis-board {
  position: relative;
  min-height: calc(100vh - 12rem);
  display: grid;
  place-items: center;
  padding: 1rem;
  border-radius: 30px;
  background: #ded6c7;
  box-shadow: inset 0 0 0 1px #c8bdab;
}
.analysis-board::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px dashed rgba(23,33,31,0.18);
  border-radius: 22px;
  pointer-events: none;
}
.analysis-rail { display: grid; align-content: start; gap: 0.85rem; }
.analysis-card { border: 1px solid var(--line); border-radius: 20px; padding: 0.95rem; background: rgba(255,253,247,0.82); }
.analysis-card h2 { margin-bottom: 0.7rem; }
.analysis-card .piece-buttons { grid-template-columns: repeat(3, 1fr); }
.analysis-card .piece-button { text-align: center; padding-top: 1.8rem; }
.analysis-card .piece-count { left: 50%; right: auto; transform: translateX(-50%); top: 0.35rem; }
.territory-bar { height: 11px; display: flex; overflow: hidden; border-radius: 999px; background: var(--paper-deep); }
.territory-bar span { min-width: 3px; }
.territory-red { background: var(--red); }
.territory-contested { background: var(--gold); }
.territory-blue { background: var(--blue); }
.territory-neutral { background: #bbb3a4; }

.game-over-banner {
  border: 2px solid var(--ink);
  border-radius: 18px;
  padding: 0.85rem 1rem;
  background: #fff3bd;
  box-shadow: 7px 7px 0 var(--ink);
}
.game-over-banner strong { display: block; font-size: 1.25rem; }
.game-over-banner p { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.8rem; }

/* Mobile-first UI prototype: three genuinely different phone layouts. */
body.mobile-layout {
  overflow-x: hidden;
  background: #101816;
}
body.mobile-layout #app {
  width: min(100%, 440px);
  min-height: 100svh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 0 70px rgba(0,0,0,.48);
}
.mobile-game {
  position: relative;
  min-width: 0;
  width: min(100%, 440px);
  min-height: 100svh;
  margin: 0 auto;
  background: var(--paper);
  color: var(--ink);
}
.mobile-board-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, rgba(229,174,66,.16), transparent 45%),
    #e7dfd1;
}
.mobile-board-toolbar {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: 0 .65rem;
  border-bottom: 1px solid rgba(23,33,31,.12);
  background: rgba(255,253,247,.84);
  color: var(--muted);
  font-size: .62rem;
  font-weight: 780;
  backdrop-filter: blur(12px);
}
.zoom-control { display: flex; align-items: center; gap: .2rem; flex: 0 0 auto; }
.zoom-control button {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: var(--ink);
  color: white;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 900;
}
.zoom-control strong { width: 39px; text-align: center; color: var(--ink); font-size: .62rem; }
.mobile-board-scroll {
  position: relative;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.mobile-board-scroll::-webkit-scrollbar { display: none; }
.mobile-board-scroll .board-svg {
  width: var(--mobile-board-width);
  max-width: none;
  max-height: none;
  height: auto;
  margin: 0;
}
.mobile-score-strip {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  align-items: center;
  gap: .55rem;
}
.mobile-score { min-width: 0; display: flex; align-items: baseline; gap: .22rem; font-size: .66rem; font-weight: 850; }
.mobile-score i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.mobile-score strong { font-size: 1.35rem; line-height: 1; }
.mobile-score.red { color: var(--red-dark); }
.mobile-score.blue { color: var(--blue-dark); }
.mobile-score.blue { justify-content: flex-end; }
.mobile-turn-copy { min-width: 0; text-align: center; }
.mobile-turn-copy strong, .mobile-turn-copy small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mobile-turn-copy strong { font-size: .72rem; }
.mobile-turn-copy small { margin-top: .1rem; color: var(--muted); font-size: .58rem; }
.mobile-piece-controls { min-width: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem; }
.mobile-piece {
  position: relative;
  min-width: 0;
  min-height: 62px;
  display: grid;
  place-items: center;
  gap: .05rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.72);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(23,33,31,.06);
}
.mobile-piece span { font-size: 1.55rem; line-height: 1; }
.mobile-piece small { font-size: .62rem; font-weight: 850; }
.mobile-piece.selected { border: 2px solid var(--ink); background: var(--ink); color: white; box-shadow: 0 7px 20px rgba(23,33,31,.22); }
.mobile-piece.cooling { border-style: dashed; background: #eee7d9; opacity: .54; }
.mobile-piece:disabled { cursor: not-allowed; }
.mobile-utilities { min-width: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .4rem; }
.mobile-utilities button {
  min-width: 44px;
  min-height: 48px;
  display: grid;
  place-items: center;
  gap: 0;
  border: 0;
  border-radius: 14px;
  background: rgba(23,33,31,.07);
  color: var(--ink);
  cursor: pointer;
}
.mobile-utilities button span { font-size: 1rem; line-height: 1; }
.mobile-utilities button small { font-size: .56rem; font-weight: 800; }
.mobile-utilities button:disabled { opacity: .25; cursor: default; }
.mobile-utilities button.danger { color: var(--red-dark); }
.mobile-live-message {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .55rem .7rem;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255,253,247,.9);
  color: var(--muted);
  font-size: .66rem;
  font-weight: 760;
  box-shadow: 0 7px 20px rgba(23,33,31,.08);
}
.mobile-live-message i { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; }
.mobile-live-message i.red { background: var(--red); }
.mobile-live-message i.blue { background: var(--blue); }
.mobile-live-message span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* A — one-screen thumb arena: board first, commands anchored at the bottom. */
.mobile-arena-v2 {
  height: 100svh;
  display: grid;
  grid-template-columns: minmax(0,1fr);
  grid-template-rows: auto minmax(0,1fr) auto auto;
  overflow: hidden;
}
.mobile-arena-v2 > * { min-width: 0; }
.mobile-app-bar {
  min-height: 105px;
  display: grid;
  align-content: end;
  gap: .55rem;
  padding: calc(env(safe-area-inset-top, 0px) + 48px) .8rem .65rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255,253,247,.95);
}
.mobile-wordmark { display: flex; align-items: baseline; justify-content: space-between; }
.mobile-wordmark span { font-size: .75rem; font-weight: 950; letter-spacing: .18em; }
.mobile-wordmark small { color: var(--muted); font-size: .58rem; }
.mobile-arena-board { min-height: 0; }
.mobile-arena-board .mobile-board-stage { height: 100%; }
.mobile-arena-board .mobile-board-scroll { height: calc(100% - 36px); }
.mobile-arena-message { padding: .45rem .65rem 0; background: var(--surface); }
.mobile-arena-message .game-over-banner { margin-bottom: .5rem; }
.mobile-thumb-dock {
  display: grid;
  grid-template-columns: minmax(0,1.5fr) minmax(0,.9fr);
  gap: .55rem;
  align-items: center;
  padding: .55rem .65rem calc(env(safe-area-inset-bottom, 0px) + .65rem);
  border-top: 1px solid var(--line);
  background: rgba(255,253,247,.98);
  box-shadow: 0 -14px 32px rgba(23,33,31,.1);
}
.mobile-thumb-dock .mobile-piece { min-height: 66px; }
.mobile-thumb-dock .mobile-utilities { grid-template-columns: repeat(2, 1fr); }
.mobile-thumb-dock .mobile-utilities button { min-height: 31px; }

/* B — scrollable tactical sheet: information is readable, controls stay sticky. */
.mobile-scroll-v2 { min-height: 100svh; min-width: 0; padding-bottom: calc(158px + env(safe-area-inset-bottom, 0px)); }
.mobile-scroll-header {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 101px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: .6rem;
  padding: calc(env(safe-area-inset-top, 0px) + 53px) .8rem .7rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255,253,247,.94);
  backdrop-filter: blur(14px);
}
.mobile-scroll-header strong { font-size: 1rem; }
.mobile-scroll-header .eyebrow { margin: 0 0 .15rem; font-size: .52rem; }
.mobile-phase { padding: .35rem .55rem; border-radius: 999px; background: var(--ink); color: white; font-size: .58rem; font-weight: 850; }
.mobile-scroll-v2 > .mobile-score-strip { padding: .7rem .8rem; border-bottom: 1px solid var(--line); background: #ece5d8; }
.mobile-scroll-content { display: grid; gap: .65rem; padding: .65rem; }
.mobile-scroll-content .board-card { height: min(55svh, 520px); border: 1px solid var(--line); border-radius: 20px; }
.mobile-scroll-content .board-card .mobile-board-scroll { height: calc(100% - 36px); }
.mobile-intel { overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,253,247,.75); }
.mobile-intel summary { display: flex; justify-content: space-between; gap: .4rem; padding: .8rem; cursor: pointer; font-size: .72rem; font-weight: 900; }
.mobile-intel summary span { color: var(--muted); font-size: .6rem; }
.mobile-intel .metric-grid, .mobile-intel .history-list { padding: 0 .75rem .75rem; }
.mobile-command-sheet {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 0;
  width: min(100%, 440px);
  display: grid;
  grid-template-columns: minmax(0,1.35fr) minmax(0,.8fr);
  gap: .45rem .55rem;
  padding: .55rem .65rem calc(env(safe-area-inset-bottom, 0px) + .65rem);
  border-top: 1px solid var(--line);
  background: rgba(255,253,247,.98);
  box-shadow: 0 -16px 40px rgba(23,33,31,.15);
  transform: translateX(-50%);
}
.command-label { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: .65rem; }
.command-label span { color: var(--muted); }
.mobile-command-sheet .mobile-piece { min-height: 62px; }
.mobile-command-sheet .mobile-utilities { grid-template-columns: repeat(2,1fr); }
.mobile-command-sheet .mobile-utilities button { min-height: 30px; }

/* C — focus mode: nearly all board, with a game HUD floating above it. */
.mobile-focus-v2 { height: 100svh; overflow: hidden; background: #d8d0c1; }
.focus-board-layer, .focus-board-layer .mobile-board-stage { position: absolute; inset: 0; }
.focus-board-layer .mobile-board-scroll { height: 100%; padding: 90px 56px 112px 0; }
.focus-board-layer .mobile-board-toolbar {
  position: absolute;
  z-index: 8;
  top: calc(env(safe-area-inset-top, 0px) + 99px);
  left: .65rem;
  right: .65rem;
  border: 1px solid rgba(23,33,31,.13);
  border-radius: 12px;
  box-shadow: 0 5px 18px rgba(23,33,31,.08);
}
.focus-hud {
  position: absolute;
  z-index: 10;
  top: 0;
  left: 0;
  right: 0;
  min-height: 96px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: .65rem;
  padding: calc(env(safe-area-inset-top, 0px) + 49px) .7rem .7rem;
  background: linear-gradient(#17211ff2, #17211fdc);
  color: white;
  box-shadow: 0 10px 30px rgba(23,33,31,.2);
}
.focus-rank { display: flex; align-items: center; gap: .4rem; }
.focus-rank > span { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: #ffe39b; color: var(--ink); font-weight: 950; }
.focus-rank small, .focus-rank strong, .focus-turn small, .focus-turn strong { display: block; }
.focus-rank small, .focus-turn small { color: rgba(255,255,255,.58); font-size: .5rem; }
.focus-rank strong, .focus-turn strong { font-size: .7rem; }
.focus-score { display: flex; gap: .4rem; align-items: center; font-size: 1.2rem; }
.focus-score .red { color: #ff8277; }
.focus-score .blue { color: #70b9eb; }
.focus-turn { text-align: right; }
.focus-piece-rail { position: absolute; z-index: 12; right: .55rem; top: 50%; transform: translateY(-42%); }
.mobile-piece-controls.vertical { display: flex; flex-direction: column; }
.mobile-piece-controls.vertical .mobile-piece { width: 58px; min-height: 58px; border-radius: 50%; background: rgba(255,253,247,.92); backdrop-filter: blur(12px); }
.mobile-piece-controls.vertical .mobile-piece.selected { background: var(--ink); }
.focus-message { position: absolute; z-index: 11; left: .65rem; right: 4.6rem; bottom: calc(env(safe-area-inset-bottom, 0px) + 67px); }
.focus-actions {
  position: absolute;
  z-index: 12;
  left: .65rem;
  right: .65rem;
  bottom: calc(env(safe-area-inset-bottom, 0px) + .55rem);
  padding: .25rem;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 17px;
  background: rgba(23,33,31,.9);
  backdrop-filter: blur(14px);
}
.focus-actions .mobile-utilities button { min-height: 44px; background: rgba(255,255,255,.08); color: white; }
.mobile-focus-v2 > .game-over-banner { position: absolute; z-index: 20; top: 145px; left: 1rem; right: 1rem; }

/* D — War of Crests: premium heraldic mobile command table. */
body.war-theme {
  --war-iron: #10161b;
  --war-panel: #18242b;
  --war-parchment: #e9d7b0;
  --war-hex: #f6e8c8;
  --war-gold: #c89b3c;
  --war-gold-bright: #e2bc64;
  --war-red: #b83b3b;
  --war-blue: #2f6f9f;
  background: #090d10;
}
body.war-theme #app { background: var(--war-iron); }
.war-crest {
  height: 100svh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--war-iron);
  color: #f7edda;
  font-family: "Noto Sans Thai", "Tahoma", sans-serif;
}
.war-banner {
  position: relative;
  z-index: 10;
  min-height: 112px;
  display: grid;
  grid-template-columns: 1fr minmax(124px, 1.25fr) 1fr;
  align-items: end;
  gap: .35rem;
  padding: calc(env(safe-area-inset-top, 0px) + 48px) .7rem .68rem;
  border-bottom: 2px solid #725626;
  background:
    linear-gradient(90deg, rgba(184,59,59,.2), transparent 28%, transparent 72%, rgba(47,111,159,.22)),
    linear-gradient(#1b2931, #0f171c);
  box-shadow: 0 8px 24px rgba(0,0,0,.44);
}
.war-banner::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: -4px;
  height: 5px;
  border-radius: 50%;
  background: var(--war-gold);
  box-shadow: 0 0 12px rgba(226,188,100,.45);
}
.war-score { display: grid; line-height: 1; }
.war-score small { font-size: .43rem; font-weight: 900; letter-spacing: .09em; }
.war-score strong { margin-top: .15rem; font-family: Georgia, serif; font-size: 1.75rem; color: #fff7e5; font-variant-numeric: tabular-nums; }
.war-score span { margin-top: .15rem; color: #a99f8c; font-size: .51rem; font-weight: 700; }
.war-score.crimson small { color: #ef8079; }
.war-score.azure { text-align: right; }
.war-score.azure small { color: #74b6e4; }
.war-turn-sigil { min-width: 0; display: grid; place-items: center; text-align: center; }
.war-turn-sigil i {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  margin-top: -5px;
  border: 1px solid var(--war-gold);
  border-radius: 50%;
  background: #261f14;
  color: var(--war-gold-bright);
  box-shadow: 0 0 0 3px rgba(200,155,60,.12);
  font-family: Georgia, serif;
  font-size: .9rem;
  font-style: normal;
}
.war-turn-sigil strong { margin-top: .25rem; overflow: hidden; color: #f4d99b; font-family: "Noto Serif Thai", Georgia, serif; font-size: .72rem; white-space: nowrap; text-overflow: ellipsis; }
.war-turn-sigil small { color: #a99f8c; font-size: .49rem; }
.war-crest.ai-thinking .war-turn-sigil i { animation: war-thinking 1.1s ease-in-out infinite; }
.war-battlefield { min-height: 0; overflow: hidden; background: var(--war-parchment); }
.war-map { height: 100%; background: var(--war-parchment); }
.war-map-toolbar {
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 .7rem;
  border-bottom: 1px solid rgba(78,57,27,.35);
  background: linear-gradient(90deg, #d3bd8d, #ead9b5 50%, #d3bd8d);
  color: #49371d;
  box-shadow: inset 0 -1px rgba(255,255,255,.42);
  font-family: "Noto Serif Thai", Georgia, serif;
  font-size: .6rem;
  font-weight: 800;
}
.war-map-toolbar b { color: #7a2d2e; }
.war-map-toolbar button {
  min-width: 48px;
  min-height: 28px;
  border: 1px solid rgba(63,48,28,.3);
  border-radius: 999px;
  background: rgba(255,248,226,.6);
  color: #49371d;
  cursor: pointer;
  font-weight: 900;
}
.war-map-toolbar button small { font-size: .48rem; }
.war-map .mobile-board-scroll { height: calc(100% - 34px); background:
  radial-gradient(circle at 22% 18%, rgba(121,83,36,.08) 0 1px, transparent 1.5px),
  radial-gradient(circle at 70% 75%, rgba(121,83,36,.06) 0 1px, transparent 1.5px),
  linear-gradient(112deg, rgba(255,255,255,.15), transparent 35%),
  var(--war-parchment);
  background-size: 37px 41px, 53px 47px, auto, auto;
}
.war-theme .cell polygon { fill: rgba(246,232,200,.76); stroke: #8d7753; }
.war-theme .cell.empty.legal polygon { fill: rgba(255,246,219,.9); stroke: #927438; }
.war-theme .cell.empty.legal:hover polygon { fill: #fff0bc; stroke: var(--war-gold); }
.war-theme .cell.empty text.number { fill: #7b6a4f; }
.war-theme .cell .piece-disc { stroke: #e9d49f; stroke-width: 3; filter: drop-shadow(0 3px 3px rgba(29,19,8,.38)); }
.war-theme .cell .piece-disc.red { fill: var(--war-red); }
.war-theme .cell .piece-disc.blue { fill: var(--war-blue); stroke-dasharray: 5 2; }
.unit-icon, .unit-symbol { overflow: visible; }
.unit-fill { fill: currentColor; }
.unit-cut { fill: #243039; }
.unit-stroke { fill: none; stroke: currentColor; stroke-width: 2.7; stroke-linecap: round; stroke-linejoin: round; }
.war-theme .piece-kind { color: #fff3d9; fill: #fff3d9; }
.war-theme .piece-kind .unit-fill { fill: #fff3d9; }
.war-theme .piece-kind .unit-cut { fill: #273037; }
.war-theme .piece-kind .unit-stroke { stroke: #fff3d9; }
.war-live-message {
  position: absolute;
  z-index: 12;
  left: .7rem;
  right: .7rem;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 204px);
  min-height: 35px;
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .4rem .65rem;
  border: 1px solid rgba(226,188,100,.52);
  border-radius: 10px;
  background: rgba(16,22,27,.9);
  color: #d8ceb9;
  box-shadow: 0 7px 20px rgba(0,0,0,.34);
  backdrop-filter: blur(10px);
  font-size: .57rem;
  font-weight: 700;
}
.war-live-message i { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; }
.war-live-message i.red { background: #e35b56; }
.war-live-message i.blue { background: #60a5d5; }
.war-live-message span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.war-command-dock {
  position: relative;
  z-index: 14;
  display: grid;
  gap: .38rem;
  padding: .45rem .65rem calc(env(safe-area-inset-bottom, 0px) + .55rem);
  border-top: 2px solid #725626;
  background: linear-gradient(#1d2a31, #0d1418);
  box-shadow: 0 -12px 30px rgba(0,0,0,.38);
}
.war-advantage-bar { min-width: 0; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .28rem; }
.war-advantage-bar span {
  min-width: 0;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .18rem;
  padding: .18rem .2rem;
  border: 1px solid rgba(200,155,60,.3);
  border-radius: 7px;
  background: rgba(200,155,60,.07);
  color: #b9c3c2;
  font-size: .48rem;
  white-space: nowrap;
}
.war-advantage-bar b { color: #f1dcaa; font-size: .5rem; }
.war-advantage-bar em { color: #ff9f72; font-size: .46rem; font-style: normal; font-weight: 950; }
.war-dock-heading { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.war-dock-heading span, .war-dock-heading b, .war-dock-heading small { display: block; }
.war-dock-heading b { color: #f2dfb2; font-family: "Noto Serif Thai", Georgia, serif; font-size: .65rem; }
.war-dock-heading small { margin-top: .05rem; color: #9eaaad; font-size: .48rem; }
.war-dock-heading em { color: var(--war-gold-bright); font-family: "Noto Serif Thai", Georgia, serif; font-size: .56rem; font-style: normal; white-space: nowrap; }
.war-unit-controls { min-width: 0; display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: .42rem; }
.war-unit-card {
  position: relative;
  min-width: 0;
  min-height: 62px;
  display: grid;
  grid-template-columns: 35px minmax(0,1fr);
  align-items: center;
  gap: .32rem;
  padding: .28rem .35rem;
  border: 1px solid #3d4b50;
  border-radius: 12px;
  background: #202d33;
  color: #e9dfca;
  cursor: pointer;
  text-align: left;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}
.war-unit-card.selected { transform: translateY(-4px); border-color: var(--war-gold-bright); background: #29383e; box-shadow: 0 0 0 2px rgba(226,188,100,.14), 0 7px 16px rgba(0,0,0,.35); }
.war-unit-card.cooling { opacity: .5; filter: grayscale(.6); }
.war-unit-medallion { width: 34px; height: 34px; display: grid; place-items: center; border: 2px solid #9f7c38; border-radius: 50%; background: #172126; color: #f2dfb2; }
.war-unit-medallion .unit-icon { width: 22px; height: 22px; }
.war-unit-copy { min-width: 0; }
.war-unit-copy strong, .war-unit-copy small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.war-unit-copy strong { font-family: "Noto Serif Thai", Georgia, serif; font-size: .61rem; }
.war-unit-copy small { margin-top: .12rem; color: #aeb9b9; font-size: .5rem; }
.war-commands { display: grid; grid-template-columns: repeat(3,1fr); gap: .38rem; }
.war-commands button { min-height: 31px; border: 1px solid #344349; border-radius: 9px; background: rgba(255,255,255,.04); color: #bcc6c6; cursor: pointer; font-size: .55rem; font-weight: 800; }
.war-commands button:disabled { opacity: .28; cursor: default; }
.war-crest > .game-over-banner { position: absolute; z-index: 30; top: 130px; left: .8rem; right: .8rem; color: #202321; }
.war-theme .busy::after { display: none; }
.war-theme .prototype-switcher { border: 1px solid rgba(226,188,100,.52); background: rgba(9,14,17,.92); color: #f1dcaa; }
@keyframes war-thinking {
  0%, 100% { box-shadow: 0 0 0 3px rgba(200,155,60,.1), 0 0 0 rgba(226,188,100,0); }
  50% { box-shadow: 0 0 0 3px rgba(200,155,60,.22), 0 0 18px rgba(226,188,100,.7); }
}

/* v0.14 — Premium Modern Tabletop, tuned for iPhone 13 Pro (390×844). */
body.war-theme {
  --war-iron: #182321;
  --war-panel: #182321;
  --war-parchment: #efe9de;
  --war-hex: #fbf8f0;
  --war-gold: #e2a93b;
  --war-gold-bright: #f0c65a;
  --war-red: #b8343d;
  --war-blue: #1e6b9f;
  background: #101715;
}
body.war-theme #app, body.war-theme .mobile-game { width: min(100%, 390px); }
.war-crest { grid-template-rows: auto minmax(0,1fr) auto; background: #efe9de; font-family: "Noto Sans Thai", Tahoma, sans-serif; }
.war-banner {
  min-height: 103px;
  grid-template-columns: 78px minmax(0,1fr) 78px;
  gap: 8px;
  padding: max(48px, env(safe-area-inset-top, 0px)) 12px 7px;
  border-bottom: 1px solid #3b4945;
  background: #182321;
  box-shadow: 0 4px 12px rgba(18,28,25,.2);
}
.war-banner::after { display: none; }
.war-score { display: grid; grid-template-columns: minmax(0,1fr) auto; grid-template-rows: 16px 16px; align-items: center; column-gap: 4px; }
.war-score small { grid-column: 1; grid-row: 1; color: #d9d5c9; font-size: 12px; font-weight: 800; letter-spacing: 0; }
.war-score span { grid-column: 1; grid-row: 2; margin: 0; color: #9aa5a0; font-size: 12px; font-weight: 700; }
.war-score strong { grid-column: 2; grid-row: 1 / 3; margin: 0; color: #fff8e8; font-family: inherit; font-size: 28px; line-height: 32px; }
.war-score.crimson small { color: #ff9298; }
.war-score.azure { text-align: left; }
.war-score.azure small { color: #83c5ed; }
.war-turn-sigil { align-self: center; }
.war-turn-sigil i { width: 9px; height: 9px; margin: 0 0 3px; border: 0; background: #e2a93b; box-shadow: none; }
.war-turn-sigil strong { margin: 0; color: #fff8e8; font-family: inherit; font-size: 16px; line-height: 20px; }
.war-turn-sigil small { color: #aeb8b3; font-size: 12px; line-height: 16px; }
.war-crest.ai-thinking .war-turn-sigil i { animation: tabletop-thinking 1.1s ease-in-out infinite; }
.war-battlefield, .war-map { background: #efe9de; }
.war-map-toolbar {
  height: 48px;
  padding: 0 8px 0 12px;
  border-bottom: 1px solid #c8c1b6;
  background: rgba(251,248,240,.97);
  color: #68716d;
  box-shadow: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 750;
}
.war-camera-controls { display: grid; grid-template-columns: repeat(3,44px); gap: 2px; }
.war-camera-controls button, .war-map-toolbar .war-camera-controls button {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #202a28;
  font-size: 20px;
}
.war-map .mobile-board-scroll {
  height: calc(100% - 48px);
  background:
    radial-gradient(circle at 28% 22%, rgba(74,81,76,.035) 0 1px, transparent 1.4px),
    #efe9de;
  background-size: 41px 43px, auto;
}
.war-theme .cell polygon { fill: #fbf8f0; stroke: #aaa398; }
.war-theme .cell.empty.legal polygon { fill: #fffdf7; stroke: #8f9893; }
.war-theme .cell.empty.legal:hover polygon { fill: #fff7dc; stroke: #e2a93b; }
.war-theme .cell.empty text.number { fill: #777f7b; }
.war-theme .cell .piece-disc { stroke: #fff8e8; stroke-width: 3; filter: drop-shadow(0 2px 2px rgba(32,42,40,.28)); }
.war-theme .cell .piece-disc.red { fill: #b8343d; stroke-dasharray: none; }
.war-theme .cell .piece-disc.blue { fill: #1e6b9f; stroke-dasharray: 5 2; }
.gesture-icon, .gesture-symbol { overflow: visible; color: currentColor; }
.gesture-fill { fill: currentColor; }
.gesture-cut { fill: #24312e; opacity: .72; }
.war-theme .piece-kind { color: #fff8e8; fill: #fff8e8; }
.war-theme .piece-kind .gesture-fill { fill: #fff8e8; }
.war-theme .piece-kind .gesture-cut { fill: #253330; }
.war-theme .board-svg.large-board .cell.empty text.number { font-size: 14px; }
.war-theme .board-svg.large-board .cell .liberty-text { font-size: 14px; }
.war-theme .cell .effect-text { font-size: 13px; }
.war-theme .cell:not(.atari) .liberty-badge,
.war-theme .cell:not(.atari) .liberty-text { display: none; }
.war-live-message {
  left: 12px;
  right: 12px;
  bottom: calc(max(34px, env(safe-area-inset-bottom, 0px)) + 196px);
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 12px;
  background: rgba(24,35,33,.94);
  color: #f1eee5;
  font-size: 14px;
  font-weight: 700;
}
.war-command-dock {
  gap: 8px;
  padding: 8px 12px max(4px, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #33423e;
  background: #182321;
  box-shadow: 0 -6px 18px rgba(23,34,31,.24);
}
.war-advantage-bar { height: 44px; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 4px; }
.war-advantage-bar span {
  min-height: 44px;
  display: grid;
  place-content: center;
  gap: 1px;
  padding: 2px 3px;
  border: 1px solid #42504c;
  border-radius: 9px;
  background: #202d2a;
  color: #d9ddd9;
  font-size: 12px;
  line-height: 14px;
  white-space: nowrap;
}
.war-advantage-bar span.selected { border: 2px solid #e2a93b; background: #2d3935; box-shadow: 0 0 0 1px rgba(226,169,59,.18); }
.war-advantage-bar b, .war-advantage-bar em { display: flex; align-items: center; justify-content: center; gap: 3px; color: #fff8e8; font-size: 12px; line-height: 14px; font-style: normal; font-weight: 800; }
.war-advantage-bar em { color: #c4ccc8; font-weight: 700; }
.war-advantage-bar .gesture-icon { width: 14px; height: 14px; flex: 0 0 14px; }
.war-unit-controls { height: 76px; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; }
.war-unit-card {
  min-height: 76px;
  grid-template-columns: 30px minmax(0,1fr);
  gap: 4px;
  padding: 6px;
  border: 2px solid #3b4945;
  border-radius: 12px;
  background: #202d2a;
  color: #fff8e8;
  box-shadow: none;
}
.war-unit-card.selected { transform: none; border: 3px solid #e2a93b; background: #2b3834; box-shadow: 0 0 0 1px rgba(226,169,59,.18); }
.war-unit-card.selected::after { content: "✓"; position: absolute; top: 3px; right: 5px; color: #f0c65a; font-size: 13px; font-weight: 950; }
.war-unit-card.cooling {
  opacity: 1;
  filter: grayscale(.28);
  border-style: dashed;
  background: repeating-linear-gradient(135deg, #202d2a 0 7px, #2b3734 7px 12px);
}
.war-unit-medallion { width: 30px; height: 36px; border: 0; border-radius: 9px; background: #111a18; color: #fff8e8; }
.war-unit-medallion .gesture-icon { width: 28px; height: 28px; }
.war-unit-copy strong { font-family: inherit; font-size: 15px; line-height: 20px; }
.war-unit-copy small { margin: 1px 0 0; color: #c0c8c4; font-size: 12px; line-height: 16px; }
.war-unit-copy strong, .war-unit-copy small { overflow: visible; text-overflow: clip; }
.war-commands { height: 44px; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; }
.war-commands button { min-height: 44px; border: 1px solid #42504c; border-radius: 10px; background: #202d2a; color: #f4f0e6; font-size: 15px; line-height: 20px; font-weight: 800; }
.war-commands button:disabled { opacity: .42; }
.war-crest > .game-over-banner { top: 112px; }
body.war-theme .prototype-switcher { grid-template-columns: 44px minmax(148px,auto) 44px; min-height: 50px; border-color: rgba(255,255,255,.15); background: rgba(24,35,33,.96); color: #fff8e8; }
body.war-theme .prototype-switcher button { width: 44px; height: 44px; }
body.war-theme .prototype-switcher span { font-size: 12px; }
@keyframes tabletop-thinking { 0%,100% { opacity:.45; transform:scale(.8); } 50% { opacity:1; transform:scale(1.25); } }

body.mobile-layout .prototype-switcher {
  top: max(8px, env(safe-area-inset-top, 0px));
  bottom: auto;
  grid-template-columns: 34px minmax(112px, auto) 34px;
  padding: 3px;
  box-shadow: 0 8px 24px rgba(0,0,0,.28);
}
body.mobile-layout .prototype-switcher button { width: 31px; height: 31px; }
body.mobile-layout .prototype-switcher span { padding: 0 .45rem; font-size: .62rem; }
body.mobile-layout .toast { top: calc(env(safe-area-inset-top, 0px) + 50px); width: min(90vw, 390px); }

/* Forced phone preview (?mobile=1) uses the real mobile tutorial at desktop widths too. */
body.mobile-layout .onboarding-dialog { width: min(440px, 96vw); min-height: min(720px, calc(100vh - 1rem)); border-radius: 24px; }
body.mobile-layout .onboarding-content.lesson-step { grid-template-columns: 1fr; gap: .35rem; padding: .8rem 1rem .45rem; }
body.mobile-layout .lesson-copy h2, body.mobile-layout .rank-intro h2 { font-size: 1.65rem; }
body.mobile-layout .lesson-copy > p:last-child { line-height: 1.45; font-size: .78rem; }
body.mobile-layout .lesson-visual { min-height: 230px; }
body.mobile-layout .tutorial-board { max-height: 230px; }
body.mobile-layout .rank-intro { grid-template-columns: 1fr; gap: .35rem; }
body.mobile-layout .rank-grid { grid-template-columns: 1fr; }
body.mobile-layout .rank-card { min-height: 82px; grid-template-columns: 42px 1fr auto; padding: .65rem; }
body.mobile-layout .rank-sigil { width: 40px; height: 40px; font-size: 1.35rem; }
body.mobile-layout .onboarding-content.rank-step { overflow: auto; }

/* v0.11 onboarding — three rule beats, then an AI-rank lobby. */
.onboarding-backdrop {
  position: fixed;
  z-index: 200;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(17, 28, 26, 0.74);
  backdrop-filter: blur(9px);
}
.onboarding-dialog {
  width: min(900px, 96vw);
  min-height: min(590px, calc(100vh - 2rem));
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.32);
  border-radius: 30px;
  background: var(--surface);
  box-shadow: 0 34px 90px rgba(0,0,0,.42);
}
.onboarding-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.4rem .9rem;
  border-bottom: 1px solid var(--line);
}
.onboarding-header strong { font-size: 1.05rem; }
.onboarding-header span { color: var(--muted); font-size: .75rem; font-weight: 850; }
.onboarding-progress { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; padding: .72rem 1.4rem 0; }
.onboarding-progress i { height: 5px; border-radius: 999px; background: var(--paper-deep); transition: background 220ms ease, transform 220ms ease; }
.onboarding-progress i.active { background: var(--gold); transform: scaleY(1.25); }
.onboarding-content.lesson-step {
  display: grid;
  grid-template-columns: minmax(260px, .88fr) minmax(360px, 1.12fr);
  align-items: center;
  gap: 1.5rem;
  padding: 1.3rem 2.1rem 1rem;
}
.lesson-copy { align-self: center; }
.onboarding-kicker { margin: 0 0 .45rem; color: var(--green); font-size: .72rem; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.lesson-copy h2, .rank-intro h2 { margin: 0 0 .75rem; font-size: clamp(1.7rem, 3.2vw, 2.7rem); line-height: 1.05; letter-spacing: -.04em; }
.lesson-copy > p:last-child, .rank-intro > p:last-child { color: var(--muted); line-height: 1.7; }
.lesson-visual {
  min-height: 330px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 26px;
  background:
    radial-gradient(circle at 50% 35%, rgba(229,174,66,.16), transparent 45%),
    var(--paper);
}
.tutorial-board { width: min(100%, 410px); max-height: 320px; overflow: visible; }
.tutorial-stone polygon { fill: #fffdf8; stroke: #bcb3a4; stroke-width: 2; }
.tutorial-stone circle { stroke: rgba(255,255,255,.92); stroke-width: 4; filter: drop-shadow(0 4px 4px rgba(23,33,31,.2)); }
.tutorial-stone.red circle { fill: var(--red); }
.tutorial-stone.blue circle { fill: var(--blue); }
.tutorial-stone > text:not(.tutorial-badge) { fill: white; font-size: 20px; font-weight: 950; text-anchor: middle; dominant-baseline: central; }
.tutorial-stone .tutorial-unit { color: white; }
.tutorial-stone .tutorial-unit .unit-fill { fill: white; }
.tutorial-stone .tutorial-unit .unit-cut { fill: #273037; }
.tutorial-stone .tutorial-unit .unit-stroke { stroke: white; }
.tutorial-stone .tutorial-badge { fill: white; stroke: var(--ink); stroke-width: 4px; paint-order: stroke; font-size: 8px; font-weight: 950; text-anchor: middle; }
.tutorial-stone.doomed circle { animation: doomed-pulse 1.45s ease-in-out infinite; }
.surround-ring { fill: none; stroke: var(--red); stroke-width: 4; stroke-dasharray: 8 5; animation: ring-march 2s linear infinite; }
.connection-line, .pinch-line { fill: none; stroke: var(--green); stroke-width: 12; stroke-linecap: round; opacity: .5; }
.liberty-dot { fill: #82b99f; stroke: white; stroke-width: 3; filter: drop-shadow(0 2px 2px rgba(41,111,88,.25)); }
.tutorial-caption { fill: var(--muted); font-size: 10px; font-weight: 850; text-anchor: middle; }
.rps-arrow { fill: var(--ink); font-size: 15px; font-weight: 950; text-anchor: middle; }
.war-matchups .matchup-row > text:not(.matchup-names) { fill: #8b3b2d; font-size: 11px; font-weight: 950; text-anchor: middle; }
.war-matchups .matchup-names { fill: #51432e; font-size: 8px; font-weight: 850; text-anchor: middle; }
.pinch-flip .tutorial-stone circle { transform-box: fill-box; transform-origin: center; animation: tutorial-color-flip 2.4s ease-in-out infinite; }
.pinch-flip .tutorial-stone > text:not(.tutorial-badge) { transform-box: fill-box; transform-origin: center; animation: tutorial-icon-flip 2.4s ease-in-out infinite; }
.new-stone { animation: tutorial-new-stone 2.4s ease-out infinite; }

.onboarding-content.rank-step { padding: 1.15rem 1.6rem 1.25rem; }
.rank-intro { display: grid; grid-template-columns: 1fr 1.2fr; column-gap: 1.5rem; align-items: end; margin-bottom: 1rem; }
.rank-intro .onboarding-kicker { grid-column: 1 / -1; }
.rank-intro h2, .rank-intro p { margin-bottom: 0; }
.rank-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
.rank-card {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: .85rem;
  align-items: center;
  min-height: 112px;
  padding: .85rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(243,239,229,.48);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}
.rank-card:hover { transform: translateY(-2px); border-color: #978d7c; }
.rank-card.selected { border: 2px solid var(--green); background: #e8f3ed; box-shadow: 0 8px 24px rgba(41,111,88,.13); }
.rank-sigil { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: #ffe39b; font-size: 1.8rem; }
.rank-copy strong, .rank-copy em, .rank-copy small { display: block; }
.rank-copy strong { font-size: 1.05rem; }
.rank-copy em { color: var(--green); font-size: .74rem; font-style: normal; font-weight: 850; }
.rank-copy small { margin-top: .25rem; color: var(--muted); font-size: .68rem; line-height: 1.35; }
.rank-depth { color: var(--muted); font-size: .65rem; font-weight: 850; line-height: 1.45; text-align: right; }
.onboarding-actions { display: flex; justify-content: space-between; gap: .75rem; padding: 1rem 1.4rem 1.2rem; border-top: 1px solid var(--line); }
.tutorial-button { min-height: 45px; padding: .7rem 1.15rem; border: 1px solid var(--line); border-radius: 999px; background: white; color: var(--ink); cursor: pointer; font-weight: 850; }
.tutorial-button:disabled { opacity: .3; cursor: default; }
.tutorial-button.next, .tutorial-button.start { min-width: 150px; border-color: var(--ink); background: var(--ink); color: white; }
.tutorial-button.start { min-width: 230px; background: var(--green); border-color: var(--green); }

body.war-theme .onboarding-backdrop { background: rgba(6,10,12,.86); }
body.war-theme .onboarding-dialog {
  border-color: rgba(200,155,60,.54);
  background: #eadab7;
  color: #202321;
  box-shadow: 0 30px 90px rgba(0,0,0,.68), inset 0 0 0 4px rgba(96,68,29,.08);
}
body.war-theme .onboarding-header { border-bottom-color: rgba(89,66,32,.28); background: linear-gradient(90deg, #162229, #0e171b); color: #f3dfb3; }
body.war-theme .onboarding-header .eyebrow, body.war-theme .onboarding-header span { color: #a99f8c; }
body.war-theme .onboarding-progress i { background: rgba(86,66,36,.22); }
body.war-theme .onboarding-progress i.active { background: var(--war-gold); }
body.war-theme .onboarding-kicker { color: #7b4f22; }
body.war-theme .lesson-copy h2, body.war-theme .rank-intro h2 { font-family: "Noto Serif Thai", Georgia, serif; }
body.war-theme .lesson-copy > p:last-child, body.war-theme .rank-intro > p:last-child { color: #675b48; }
body.war-theme .lesson-visual { border-color: rgba(89,66,32,.3); background: radial-gradient(circle at 50% 40%, rgba(200,155,60,.2), transparent 50%), #e2ce9f; }
body.war-theme .tutorial-stone polygon { fill: #f4e5c1; stroke: #8c7653; }
body.war-theme .tutorial-stone.red circle { fill: var(--war-red); }
body.war-theme .tutorial-stone.blue circle { fill: var(--war-blue); }
body.war-theme .tutorial-caption { fill: #675b48; }
body.war-theme .rps-arrow { fill: #382c1c; font-size: 12px; }
body.war-theme .onboarding-actions { border-top-color: rgba(89,66,32,.28); }
body.war-theme .tutorial-button { border-color: rgba(89,66,32,.32); background: rgba(255,248,227,.58); color: #382c1c; }
body.war-theme .tutorial-button.next, body.war-theme .tutorial-button.start { border-color: var(--war-gold); background: #152127; color: #f3dfb3; }
body.war-theme .rank-card { border-color: rgba(89,66,32,.3); background: rgba(255,248,227,.32); color: #202321; }
body.war-theme .rank-card.selected { border-color: var(--war-gold); background: rgba(200,155,60,.16); }
body.war-theme .rank-sigil { background: #152127; color: var(--war-gold-bright); }
body.war-theme .rank-copy em { color: #7b4f22; }

/* Modern tabletop onboarding overrides the discarded medieval treatment. */
body.war-theme .onboarding-dialog {
  width: min(374px, calc(100vw - 16px));
  min-height: min(760px, calc(100dvh - 16px));
  border: 1px solid #46534f;
  border-radius: 24px;
  background: #fbf8f0;
  color: #202a28;
  box-shadow: 0 28px 80px rgba(0,0,0,.58);
}
body.war-theme .onboarding-header { border-color: #394742; background: #182321; color: #fff8e8; }
body.war-theme .onboarding-header .eyebrow, body.war-theme .onboarding-header span { color: #aeb8b3; font-size: 12px; }
body.war-theme .onboarding-header strong { font-size: 16px; }
body.war-theme .onboarding-progress i { background: #d6d1c7; }
body.war-theme .onboarding-progress i.active { background: #e2a93b; }
body.war-theme .onboarding-kicker { color: #5e6864; font-size: 12px; letter-spacing: .04em; }
body.war-theme .lesson-copy h2, body.war-theme .rank-intro h2 { font-family: "Noto Sans Thai", Tahoma, sans-serif; }
body.war-theme .lesson-copy > p:last-child, body.war-theme .rank-intro > p:last-child { color: #59635f; font-size: 14px; line-height: 1.55; }
body.war-theme .lesson-visual { border-color: #c9c3b8; background: #efe9de; }
body.war-theme .tutorial-stone polygon { fill: #fbf8f0; stroke: #aaa398; }
body.war-theme .tutorial-stone.red circle { fill: #b8343d; }
body.war-theme .tutorial-stone.blue circle { fill: #1e6b9f; stroke-dasharray: 5 2; }
body.war-theme .tutorial-caption { fill: #59635f; font-size: 11px; }
body.war-theme .rps-arrow { fill: #202a28; font-size: 13px; }
body.war-theme .war-matchups .matchup-row > text:not(.matchup-names) { fill: #8d3038; font-size: 12px; }
body.war-theme .war-matchups .matchup-names { fill: #202a28; font-size: 11px; }
body.war-theme .onboarding-actions { border-color: #d0c9bd; }
body.war-theme .tutorial-button { min-height: 44px; border-color: #bbb5aa; background: #fffdf7; color: #202a28; font-size: 15px; }
body.war-theme .tutorial-button.next, body.war-theme .tutorial-button.start { border-color: #182321; background: #182321; color: #fff8e8; }
body.war-theme .rank-card { min-height: 88px; border-color: #c9c3b8; background: #f4f0e8; color: #202a28; }
body.war-theme .rank-card.selected { border-color: #e2a93b; background: #fff4d6; }
body.war-theme .rank-sigil { background: #182321; color: #fff8e8; }
body.war-theme .rank-copy strong { font-size: 15px; }
body.war-theme .rank-copy em, body.war-theme .rank-copy small, body.war-theme .rank-depth { color: #59635f; font-size: 12px; }
body.mobile-layout.war-theme .prototype-switcher { display: none; }

@keyframes ring-march { to { stroke-dashoffset: -26; } }
@keyframes doomed-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes tutorial-color-flip {
  0%, 36% { fill: var(--blue); transform: scaleX(1); }
  48% { fill: var(--blue); transform: scaleX(.05); }
  49% { fill: var(--red); transform: scaleX(.05); }
  62%, 88% { fill: var(--red); transform: scaleX(1); }
  100% { fill: var(--blue); transform: scaleX(1); }
}
@keyframes tutorial-icon-flip { 0%, 36%, 62%, 100% { transform: scaleX(1); } 48%, 49% { transform: scaleX(.05); } }
@keyframes tutorial-new-stone { 0%, 22% { opacity: 0; } 36%, 100% { opacity: 1; } }

.prototype-switcher {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 42px minmax(160px, auto) 42px;
  align-items: center;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 999px;
  padding: 5px;
  background: rgba(23,33,31,0.95);
  color: white;
  box-shadow: 0 16px 40px rgba(23,33,31,0.3);
  backdrop-filter: blur(14px);
}
.prototype-switcher button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: rgba(255,255,255,0.1); color: white; cursor: pointer; font-weight: 900; }
.prototype-switcher button:hover { background: rgba(255,255,255,0.22); }
.prototype-switcher span { padding: 0 0.75rem; text-align: center; font-size: 0.75rem; font-weight: 850; }

.toast {
  position: fixed;
  z-index: 120;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(90vw, 520px);
  padding: 0.75rem 1rem;
  border-radius: 13px;
  background: var(--red-dark);
  color: white;
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  font-weight: 750;
}

.busy::after {
  content: "AI กำลังคิด…";
  position: fixed;
  z-index: 90;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(243,239,229,0.55);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
  backdrop-filter: blur(2px);
}

.cell.just-placed .piece-disc,
.cell.just-placed .piece-kind,
.cell.just-placed .liberty-badge,
.cell.just-placed .liberty-text {
  transform-box: fill-box;
  transform-origin: center;
  animation: piece-arrive 520ms cubic-bezier(.2, .9, .25, 1.25) both;
}

.cell.just-captured polygon {
  animation: capture-pulse 900ms ease-out both;
}

.cell.just-converted polygon {
  animation: conversion-pulse 720ms ease-out both;
}

.cell.just-converted .piece-disc,
.cell.just-converted .piece-kind {
  transform-box: fill-box;
  transform-origin: center;
}

.cell.just-converted.from-red .piece-disc { animation: convert-red-to-blue 720ms ease-in-out both; }
.cell.just-converted.from-blue .piece-disc { animation: convert-blue-to-red 720ms ease-in-out both; }
.cell.just-converted .piece-kind { animation: conversion-flip 720ms ease-in-out both; }

@keyframes piece-arrive {
  0% { opacity: 0; transform: scale(.18); }
  65% { opacity: 1; transform: scale(1.14); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes capture-pulse {
  0% { fill: #fff3bd; stroke: var(--red-dark); stroke-width: 8; filter: drop-shadow(0 0 12px rgba(217,79,69,.8)); }
  100% { stroke-width: 1.5; filter: none; }
}

@keyframes conversion-pulse {
  0% { fill: #dff6eb; stroke: var(--green); stroke-width: 7; filter: drop-shadow(0 0 12px rgba(41,111,88,.8)); }
  100% { stroke-width: 1.5; filter: none; }
}

@keyframes convert-red-to-blue {
  0%, 42% { fill: var(--red); transform: scaleX(1); }
  50% { fill: var(--red); transform: scaleX(.06); }
  51% { fill: var(--blue); transform: scaleX(.06); }
  100% { fill: var(--blue); transform: scaleX(1); }
}

@keyframes convert-blue-to-red {
  0%, 42% { fill: var(--blue); transform: scaleX(1); }
  50% { fill: var(--blue); transform: scaleX(.06); }
  51% { fill: var(--red); transform: scaleX(.06); }
  100% { fill: var(--red); transform: scaleX(1); }
}

@keyframes conversion-flip {
  0%, 42% { transform: scaleX(1); }
  50% { transform: scaleX(.06); }
  100% { transform: scaleX(1); }
}

@keyframes sacrifice-arrive {
  0% { opacity: 0; transform: scale(.25); }
  35% { opacity: 1; transform: scale(1.08); }
  78% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(.45); }
}

@media (prefers-reduced-motion: reduce) {
  .cell.just-placed .piece-disc,
  .cell.just-placed .piece-kind,
  .cell.just-placed .liberty-badge,
  .cell.just-placed .liberty-text,
  .cell.just-captured polygon { animation-duration: 1ms; }
  .cell.just-converted polygon,
  .cell.just-converted .piece-disc,
  .cell.just-converted .piece-kind { animation-duration: 1ms; }
  .cell.sacrifice-staged .piece-disc,
  .cell.sacrifice-staged .piece-kind,
  .cell.sacrifice-staged .sacrifice-badge,
  .cell.sacrifice-staged .sacrifice-text { animation-duration: 1ms; }
  .tutorial-stone.doomed circle,
  .surround-ring,
  .pinch-flip .tutorial-stone circle,
  .pinch-flip .tutorial-stone > text,
  .new-stone { animation-duration: 1ms; }
}

@media (max-width: 1050px) {
  .strategy-desk { grid-template-columns: 220px 1fr; }
  .intel-panel { grid-column: 1 / -1; min-height: auto; display: grid; grid-template-columns: repeat(3, 1fr); }
  .analysis-grid { grid-template-columns: 1fr; }
  .analysis-board { min-height: 58vh; }
  .analysis-rail { grid-template-columns: repeat(2, 1fr); }
  .analysis-rail > :last-child { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .onboarding-backdrop { padding: .45rem; }
  .onboarding-dialog { min-height: calc(100vh - .9rem); border-radius: 22px; }
  .onboarding-content.lesson-step { grid-template-columns: 1fr; gap: .5rem; padding: 1rem 1.1rem .5rem; }
  .lesson-copy h2, .rank-intro h2 { font-size: 1.65rem; }
  .lesson-copy > p:last-child { line-height: 1.5; font-size: .82rem; }
  .lesson-visual { min-height: 230px; }
  .tutorial-board { max-height: 235px; }
  .rank-intro { grid-template-columns: 1fr; gap: .45rem; }
  .rank-grid { grid-template-columns: 1fr; }
  .rank-card { min-height: 86px; grid-template-columns: 44px 1fr auto; }
  .rank-sigil { width: 42px; height: 42px; font-size: 1.4rem; }
  .onboarding-content.rank-step { overflow: auto; }
  .arena { padding: 0.8rem 0.65rem 6.5rem; }
  .arena-top { align-items: flex-start; }
  .arena-top .brand-seal { display: none; }
  .arena-meta { max-width: 150px; }
  .arena-score { position: static; transform: none; width: 100%; margin-bottom: -0.7rem; }
  .arena-stage { align-content: start; }
  .arena-tray { grid-template-columns: 1fr; padding: 0.7rem; }
  .board-svg { max-height: none; }
  .strategy-desk { display: flex; flex-direction: column; padding: 0.65rem 0.65rem 6.5rem; }
  .control-tower, .map-panel, .intel-panel { min-height: auto; }
  .control-tower .piece-buttons { grid-template-columns: repeat(3, 1fr); }
  .intel-panel { display: flex; }
  .map-panel { order: -1; }
  .analysis-table { padding: 0.75rem 0.65rem 6.5rem; }
  .analysis-header { grid-template-columns: 1fr; gap: 0.7rem; }
  .analysis-turn { text-align: left; }
  .analysis-rail { grid-template-columns: 1fr; }
  .analysis-rail > :last-child { grid-column: auto; }
  .analysis-board { min-height: auto; padding: 0.2rem; }
  .brand-lockup h1 { font-size: 1.15rem; }
  .prototype-switcher { bottom: 10px; }
}

/* v0.15 — approved fantasy tabletop direction, generated environment art + live SVG board. */
body.war-theme {
  --arena-ink: #0b3c45;
  --arena-ink-deep: #062a33;
  --arena-gold: #f2c75c;
  --arena-ivory: #fff7dc;
  --arena-red: #db4039;
  --arena-blue: #1477bd;
  background: #073c55;
}

body.war-theme #app,
body.war-theme .mobile-game {
  width: min(100%, 430px);
  min-height: 100svh;
}

.war-crest {
  height: 100svh;
  min-height: 620px;
  grid-template-rows: 88px minmax(0, 1fr) auto;
  isolation: isolate;
  overflow: hidden;
  background:
    linear-gradient(to bottom, rgba(6, 63, 80, .04), rgba(6, 53, 62, .1)),
    url("assets/fantasy-arena.webp") center / cover no-repeat;
  color: #123b3e;
}

.war-banner {
  z-index: 20;
  min-height: 76px;
  margin: max(8px, env(safe-area-inset-top, 0px)) 8px 0;
  padding: 8px 11px;
  grid-template-columns: 88px minmax(0, 1fr) 88px;
  gap: 5px;
  border: 1px solid rgba(255, 241, 185, .78);
  border-radius: 22px;
  background:
    linear-gradient(90deg, rgba(163, 39, 38, .94), rgba(13, 59, 66, .94) 40%, rgba(13, 59, 66, .94) 60%, rgba(16, 90, 145, .95));
  box-shadow: inset 0 1px rgba(255,255,255,.4), inset 0 -2px rgba(0,0,0,.18), 0 9px 24px rgba(4, 40, 48, .32);
  backdrop-filter: blur(14px) saturate(1.2);
}

.war-score { grid-template-rows: 18px 18px; }
.war-score small { color: #fff2d0; font-size: 11px; text-shadow: 0 1px rgba(0,0,0,.25); }
.war-score span { color: rgba(255,247,220,.78); font-size: 10px; }
.war-score strong { color: white; font-size: 30px; line-height: 36px; text-shadow: 0 2px 2px rgba(0,0,0,.32); }
.war-score.crimson small,
.war-score.azure small { color: #fff4d8; }
.war-turn-sigil strong { color: var(--arena-ivory); font-size: 15px; text-shadow: 0 2px rgba(0,0,0,.28); }
.war-turn-sigil small { color: rgba(255,247,220,.74); font-size: 10px; }
.war-turn-sigil i {
  width: 14px;
  height: 14px;
  margin-bottom: 3px;
  border: 3px solid rgba(255,255,255,.8);
  background: var(--arena-gold);
  box-shadow: 0 0 0 3px rgba(242,199,92,.22), 0 0 14px rgba(255,219,116,.55);
}

.war-battlefield,
.war-map,
.war-map .mobile-board-scroll {
  background: transparent;
}

.war-battlefield { position: relative; overflow: hidden; }
.war-map { position: relative; height: 100%; }
.war-map-toolbar {
  position: absolute;
  z-index: 9;
  top: 6px;
  left: 50%;
  width: calc(100% - 22px);
  height: 42px;
  transform: translateX(-50%);
  padding: 0 5px 0 13px;
  border: 1px solid rgba(255,247,220,.84);
  border-radius: 15px;
  background: rgba(8, 63, 69, .82);
  color: rgba(255,247,220,.92);
  box-shadow: 0 6px 16px rgba(4,45,54,.2), inset 0 1px rgba(255,255,255,.16);
  backdrop-filter: blur(12px);
  font-size: 11px;
}
.war-camera-controls { grid-template-columns: repeat(3, 38px); gap: 1px; }
.war-camera-controls button,
.war-map-toolbar .war-camera-controls button {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  border: 0;
  border-radius: 11px;
  background: rgba(255,255,255,.1);
  color: var(--arena-ivory);
  font-size: 20px;
}
.war-map .mobile-board-scroll {
  height: 100%;
  padding: 30px 0 12px;
  filter: drop-shadow(0 15px 14px rgba(5, 50, 46, .24));
}

.war-theme .cell polygon {
  fill: url(#hex-face);
  stroke: #a99870;
  stroke-width: 2;
  filter: drop-shadow(0 2px 1px rgba(67, 52, 24, .22));
}
.war-theme .cell.empty.legal polygon { fill: url(#hex-face); stroke: #d7b652; stroke-width: 2.4; }
.war-theme .cell.empty.legal:hover polygon { fill: #fff7c8; stroke: #f3bd35; }
.war-theme .cell.empty text.number { fill: #8e8064; font-size: 11px; font-weight: 850; opacity: .78; }
.war-theme .cell .piece-disc { stroke: #ffe29a; stroke-width: 3.5; filter: drop-shadow(0 4px 3px rgba(38,25,5,.4)); }
.war-theme .cell .piece-disc.red { fill: url(#red-piece); stroke-dasharray: none; }
.war-theme .cell .piece-disc.blue { fill: url(#blue-piece); stroke-dasharray: none; }
.war-theme .piece-kind .gesture-fill { fill: #fff0c8; }
.war-theme .piece-kind .gesture-cut { fill: rgba(75, 40, 22, .8); }
.war-theme .cell.atari .piece-disc { stroke: #fff3a8; stroke-width: 5; filter: drop-shadow(0 0 8px #ff9c3b); }
.war-theme .cell .liberty-badge { fill: rgba(29, 49, 40, .88); }
.war-theme .cell .liberty-text { fill: #fff5d8; }

.war-live-message {
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 199px);
  min-height: 34px;
  padding: 6px 11px;
  border: 1px solid rgba(255,247,220,.88);
  border-radius: 999px;
  background: rgba(7, 58, 63, .86);
  color: #fff7dc;
  box-shadow: 0 6px 18px rgba(4, 40, 46, .28);
  backdrop-filter: blur(12px);
  font-size: 11px;
}
.war-live-message i { box-shadow: 0 0 0 3px rgba(255,255,255,.14); }

.war-command-dock {
  z-index: 18;
  gap: 5px;
  padding: 6px 9px calc(env(safe-area-inset-bottom, 0px) + 7px);
  border: 1px solid rgba(255,244,198,.92);
  border-bottom: 0;
  border-radius: 27px 27px 0 0;
  background:
    radial-gradient(circle at 50% 0, rgba(255,255,255,.92), transparent 44%),
    linear-gradient(#f8e9bf, #dcc48f);
  box-shadow: inset 0 2px rgba(255,255,255,.9), 0 -12px 28px rgba(5, 43, 46, .3);
}

.war-advantage-bar {
  height: 34px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}
.war-advantage-bar span {
  min-width: 0;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 3px 5px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 10px;
  background: #0d5057;
  color: #fff4ce;
  box-shadow: inset 0 1px rgba(255,255,255,.13);
}
.war-advantage-bar span.selected {
  border: 2px solid #f3bf3d;
  background: #096574;
  box-shadow: 0 0 0 2px rgba(242,183,55,.15);
}
.war-advantage-bar b { color: #ffd96e; font-size: 11px; line-height: 1; }
.war-advantage-bar .gesture-icon { width: 19px; height: 19px; flex: 0 0 19px; }

.war-unit-controls {
  height: 86px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}
.war-unit-card {
  min-width: 0;
  min-height: 86px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 2px;
  border: 0;
  border-radius: 17px;
  background: transparent;
  color: #153f3d;
  text-align: center;
  overflow: visible;
}
.war-unit-card.selected {
  transform: translateY(-2px);
  border: 0;
  background: rgba(255,255,255,.26);
  box-shadow: none;
}
.war-unit-card.selected::after {
  content: "";
  top: 4px;
  right: calc(50% - 34px);
  width: 10px;
  height: 10px;
  border: 2px solid #fff4c9;
  border-radius: 50%;
  background: #f4bc35;
  box-shadow: 0 2px 5px rgba(59,43,3,.35);
}
.war-unit-medallion {
  width: 58px;
  height: 58px;
  border: 4px solid #f1c65b;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 24%, #32a6b7, #08707c 62%, #05434b);
  color: #fff0c7;
  box-shadow: inset 0 2px 3px rgba(255,255,255,.38), inset 0 -5px 8px rgba(0,0,0,.22), 0 5px 8px rgba(70,48,4,.3);
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.human-red .war-unit-medallion { background: radial-gradient(circle at 34% 24%, #ff766b, #d93f39 62%, #8f2420); }
.human-blue .war-unit-medallion { background: radial-gradient(circle at 34% 24%, #45b1ef, #1478bb 62%, #0a487b); }
.war-unit-card.selected .war-unit-medallion {
  transform: scale(1.08);
  border-color: #ffda69;
  box-shadow: inset 0 2px 3px rgba(255,255,255,.45), inset 0 -5px 8px rgba(0,0,0,.22), 0 0 0 3px rgba(255,244,191,.82), 0 5px 12px rgba(69,45,0,.38);
}
.war-unit-medallion .gesture-icon { width: 39px; height: 39px; }
.war-unit-copy strong { color: #153c3b; font-size: 13px; line-height: 17px; text-shadow: 0 1px rgba(255,255,255,.7); }
.war-unit-copy small { display: none; }
.war-unit-card.cooling { opacity: .48; filter: grayscale(.7); }
.war-unit-card.cooling .war-unit-copy small { display: block; color: #7f443a; font-size: 10px; }

.war-commands {
  height: 46px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}
.war-commands button {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 2px solid #d4a743;
  border-radius: 15px;
  background: linear-gradient(#11717a, #084c54);
  color: #fff5d8;
  box-shadow: inset 0 1px rgba(255,255,255,.22), 0 3px 5px rgba(79,51,4,.24);
  font-size: 12px;
}
.war-commands button b { font-size: 19px; line-height: 1; }
.war-commands button span { font-weight: 850; }
.war-commands button:disabled { opacity: .45; filter: grayscale(.45); }

.war-crest > .game-over-banner {
  top: 104px;
  left: 18px;
  right: 18px;
  border: 2px solid #edbd4f;
  border-radius: 22px;
  background: rgba(255,247,220,.95);
  box-shadow: 0 14px 32px rgba(4,42,46,.35);
}

body.war-theme .onboarding-backdrop {
  padding: max(10px, env(safe-area-inset-top, 0px)) 8px max(10px, env(safe-area-inset-bottom, 0px));
  background:
    linear-gradient(rgba(4,45,56,.56), rgba(4,45,56,.72)),
    url("assets/fantasy-arena.webp") center / cover no-repeat;
}
body.war-theme .onboarding-dialog {
  min-height: min(824px, calc(100svh - 18px));
  border: 2px solid rgba(255,237,175,.95);
  border-radius: 28px;
  background: rgba(255,248,224,.96);
  box-shadow: 0 22px 70px rgba(2,34,42,.48), inset 0 1px white;
  overflow: hidden;
}
body.war-theme .onboarding-header {
  border-bottom: 1px solid rgba(255,235,170,.5);
  background: linear-gradient(100deg, #0b535b, #087184);
  color: #fff4d2;
}
body.war-theme .onboarding-header .eyebrow,
body.war-theme .onboarding-header span { color: rgba(255,245,217,.78); }
body.war-theme .onboarding-progress i.active { background: #e8b541; }
body.war-theme .lesson-copy h2,
body.war-theme .rank-intro h2 { color: #0d3e42; font-family: inherit; }
body.war-theme .onboarding-kicker { color: #b54a35; }
body.war-theme .lesson-copy > p:last-child,
body.war-theme .rank-intro > p:last-child { color: #536966; }
body.war-theme .lesson-visual {
  border: 1px solid #d5b768;
  border-radius: 22px;
  background: linear-gradient(rgba(255,252,235,.9), rgba(222,202,153,.72));
  box-shadow: inset 0 2px rgba(255,255,255,.75);
}
body.war-theme .tutorial-button {
  min-height: 48px;
  border: 1px solid #c6a65e;
  border-radius: 15px;
  background: rgba(255,255,255,.48);
  color: #17494b;
}
body.war-theme .tutorial-button.next,
body.war-theme .tutorial-button.start {
  border: 2px solid #d4a743;
  background: linear-gradient(#11717a, #084c54);
  color: #fff6da;
}
body.war-theme .rank-card {
  border: 1px solid #ccb066;
  border-radius: 17px;
  background: rgba(255,255,255,.42);
  color: #173e3f;
}
body.war-theme .rank-card.selected { border: 3px solid #e3ad35; background: #fff3c7; }
body.war-theme .rank-sigil { background: #0b5c65; color: #ffe390; }

@keyframes arena-selected {
  0%, 100% { transform: scale(1.08); }
  50% { transform: scale(1.12); }
}

@media (max-height: 700px) {
  .war-crest { grid-template-rows: 74px minmax(0, 1fr) auto; }
  .war-banner { min-height: 66px; margin-top: 5px; padding-block: 5px; }
  .war-advantage-bar { height: 30px; }
  .war-advantage-bar span { min-height: 30px; }
  .war-unit-controls, .war-unit-card { height: 76px; min-height: 76px; }
  .war-unit-medallion { width: 50px; height: 50px; }
  .war-unit-medallion .gesture-icon { width: 34px; height: 34px; }
  .war-commands, .war-commands button { height: 42px; min-height: 42px; }
  .war-live-message { bottom: calc(env(safe-area-inset-bottom, 0px) + 179px); }
}

/* v0.18 — ImageGen UI skin. CSS only positions live data and hit areas over the generated art. */
body.war-theme { background: #083247; }
body.war-theme #app,
body.war-theme .mobile-game { width: min(100%, 390px); }

.war-crest {
  position: relative;
  display: block;
  width: min(100%,390px);
  height: min(100svh,844px);
  min-height: 620px;
  overflow: hidden;
  background: url("assets/fantasy-ui-skin-v2.webp") center / 100% 100% no-repeat;
  box-shadow: 0 0 70px rgba(0,0,0,.5);
}

.war-banner {
  position: absolute;
  z-index: 20;
  top: 3.25%;
  left: 2.7%;
  right: 2.7%;
  width: auto;
  height: 6.7%;
  min-height: 0;
  margin: 0;
  padding: 4px 10px;
  grid-template-columns: 30% 40% 30%;
  gap: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}
.war-score .score-crest,
.war-score .score-copy em { display: none; }
.war-score { gap: 4px; }
.war-score.crimson { justify-content: flex-end; padding-right: 6px; }
.war-score.azure { justify-content: flex-start; padding-left: 6px; }
.war-score .score-copy small {
  color: rgba(255,248,219,.9);
  font-size: 11px;
  text-shadow: 0 2px 2px rgba(0,0,0,.5);
}
.war-score strong {
  color: #fff8dc;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 35px;
  line-height: 38px;
  text-shadow: 0 3px 2px rgba(62,24,4,.64), 0 0 4px rgba(255,238,170,.45);
}
.war-turn-sigil i { display: none; }
.war-turn-sigil strong {
  color: #fff2c6;
  font-size: 19px;
  line-height: 22px;
  text-shadow: 0 2px 2px rgba(0,0,0,.62), 0 0 5px rgba(255,220,123,.34);
}
.war-turn-sigil small {
  color: rgba(255,244,211,.82);
  font-size: 11px;
  line-height: 13px;
  text-shadow: 0 1px rgba(0,0,0,.55);
}

.war-battlefield {
  position: absolute;
  z-index: 6;
  top: 12.65%;
  left: 2.4%;
  right: 2.4%;
  width: auto;
  height: 54.4%;
  overflow: hidden;
  clip-path: polygon(23% 0,77% 0,94% 7%,100% 23%,94% 42%,100% 66%,92% 86%,77% 100%,23% 100%,8% 86%,0 66%,6% 42%,0 23%,6% 7%);
  background: transparent;
  filter: none;
}
.arena-shell,
.arena-shell .war-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  clip-path: none;
  background: transparent;
  box-shadow: none;
  filter: none;
}
.arena-frame { display: none; }
.arena-shell .mobile-board-scroll,
.war-map .mobile-board-scroll {
  height: 100%;
  padding: 0;
  background: transparent;
  filter: none;
}

.war-theme .cell .hex-shadow { fill: rgba(62,42,16,.2); transform: translateY(2px); }
.war-theme .cell .hex-face {
  fill: rgba(255,247,215,.22);
  stroke: rgba(117,91,46,.72);
  stroke-width: 2.2;
  filter: none;
}
.war-theme .cell .hex-engrave {
  fill: none;
  stroke: rgba(255,248,211,.65);
  stroke-width: 1.2;
}
.war-theme .cell.empty.legal .hex-face { fill: rgba(255,248,218,.18); stroke: rgba(126,98,49,.72); }
.war-theme .cell.empty.legal:hover .hex-face { fill: rgba(255,230,126,.38); stroke: #ffd969; }

.war-live-message {
  position: absolute;
  z-index: 17;
  top: 65.15%;
  bottom: auto;
  left: 15%;
  right: 15%;
  min-height: 25px;
  padding: 3px 9px;
  border: 1px solid rgba(255,224,135,.7);
  border-radius: 999px;
  background: rgba(5,57,67,.78);
  color: #fff0c2;
  box-shadow: 0 3px 8px rgba(0,37,45,.28);
  font-size: 10px;
  backdrop-filter: blur(5px);
}

.war-command-dock {
  position: absolute;
  z-index: 18;
  top: 68.7%;
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  height: auto;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}
.war-command-dock::before,
.war-command-dock::after { display: none; }

.war-advantage-bar {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 8.9%;
  right: 8.9%;
  width: auto;
  height: 16.3%;
  margin: 0;
  padding: 2px 4px;
  gap: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.war-advantage-bar span,
.war-advantage-bar span.selected {
  min-height: 100%;
  gap: 4px;
  padding: 0 3px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.war-advantage-bar span + span { border: 0; }
.war-advantage-bar b {
  color: #ffe08b;
  font-size: 12px;
  text-shadow: 0 2px 2px rgba(0,0,0,.5);
}
.war-advantage-bar .gesture-icon {
  width: 23px;
  height: 23px;
  color: #fff0c8;
  filter: drop-shadow(0 2px 1px rgba(0,0,0,.48));
}

.war-unit-controls {
  position: absolute;
  z-index: 3;
  top: 19.5%;
  left: 3.7%;
  right: 3.7%;
  width: auto;
  height: 52%;
  gap: 2.5%;
}
.war-unit-card,
.war-unit-card.selected {
  height: 100%;
  min-height: 0;
  padding: 0;
  gap: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transform: none;
}
.war-unit-card.selected::after {
  top: 0;
  right: calc(50% - 48px);
  width: 13px;
  height: 13px;
  border: 2px solid #fff6c7;
  background: #ffd45a;
}
.war-unit-medallion {
  width: 86px;
  height: 86px;
  margin-top: 2px;
  border: 0;
  border-radius: 50%;
  background: transparent !important;
  color: #fff0c8;
  box-shadow: none;
}
.war-unit-card.selected .war-unit-medallion {
  transform: translateY(-3px);
  border: 0;
  box-shadow: 0 0 0 4px rgba(255,247,197,.88), 0 0 0 9px rgba(255,201,56,.55), 0 7px 12px rgba(69,41,0,.35);
}
.war-unit-medallion .gesture-icon {
  width: 57px;
  height: 57px;
  filter: drop-shadow(0 3px 2px rgba(37,21,8,.5));
}
.war-unit-copy {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 0;
  margin: 0;
}
.war-unit-copy strong {
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff3c9;
  box-shadow: none;
  font-size: 14px;
  line-height: 19px;
  text-shadow: 0 2px 2px rgba(0,0,0,.65);
}
.war-unit-card.cooling {
  opacity: 1;
  filter: grayscale(.58) brightness(.7);
}
.war-unit-card.cooling .war-unit-medallion::after {
  inset: 31px -3px auto;
  padding: 3px 1px;
  border: 1px solid #efd27d;
  background: rgba(38,48,44,.9);
  color: #fff1c7;
  font-size: 10px;
}

.war-commands {
  position: absolute;
  z-index: 3;
  top: 73.5%;
  left: 8.5%;
  right: 8.5%;
  width: auto;
  height: 26.5%;
  gap: 8%;
}
.war-commands button {
  height: 100%;
  min-height: 0;
  padding: 0 0 2px;
  gap: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  color: #fff2c9;
}
.war-commands button b {
  width: 48px;
  height: 42px;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #fff0c0;
  font-size: 28px;
  text-shadow: 0 3px 2px rgba(0,0,0,.48);
}
.war-commands button span {
  color: #fff0c6;
  font-size: 12px;
  line-height: 15px;
  text-shadow: 0 2px 2px rgba(0,0,0,.68);
}
.war-commands button:disabled { opacity: .45; filter: grayscale(.65); }

.war-crest > .game-over-banner {
  top: 13%;
  left: 14%;
  right: 14%;
  border: 2px solid #efc45f;
  background: rgba(255,243,202,.96);
}

@media (max-height: 700px) {
  .war-crest { height: 100svh; min-height: 0; }
  .war-score strong { font-size: 31px; }
  .war-turn-sigil strong { font-size: 16px; }
  .war-unit-medallion { width: 72px; height: 72px; }
  .war-unit-medallion .gesture-icon { width: 47px; height: 47px; }
  .war-unit-copy strong { font-size: 12px; }
  .war-commands button span { font-size: 10px; }
}

/* v0.17 — structural fidelity rebuild: arena silhouette, layered materials and foreground altar. */
.war-crest { grid-template-rows: 96px minmax(0, 1fr) 258px; }

.war-banner {
  min-height: 88px;
  margin: max(5px, env(safe-area-inset-top, 0px)) 6px 0;
  grid-template-columns: 112px minmax(0,1fr) 112px;
  padding: 8px 10px;
  border: 2px solid #f1cf78;
  border-radius: 25px;
  background:
    linear-gradient(90deg, rgba(169,35,35,.98), rgba(38,54,54,.96) 39%, rgba(38,54,54,.96) 61%, rgba(13,91,157,.98));
  box-shadow:
    inset 0 2px rgba(255,255,255,.34),
    inset 0 -5px rgba(4,30,38,.24),
    0 0 0 2px rgba(70,48,13,.28),
    0 9px 18px rgba(3,38,47,.34);
}
.war-score { gap: 5px; }
.war-score .score-crest {
  width: 32px;
  height: 39px;
  flex-basis: 32px;
  background: linear-gradient(#f8d46d, #b7781d);
  color: #fff3bd;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.4));
  outline: 0;
  box-shadow: inset 0 0 0 2px rgba(255,246,189,.65);
  font-size: 18px;
}
.war-score .score-copy small { font-size: 12px; }
.war-score .score-copy em { font-size: 10px; }
.war-score strong { font-size: 37px; line-height: 40px; }
.war-turn-sigil i {
  width: 17px;
  height: 17px;
  border-color: #fff0ae;
  box-shadow: 0 0 0 4px rgba(244,193,62,.2), 0 0 18px rgba(255,217,101,.72);
}
.war-turn-sigil strong { font-size: 19px; line-height: 22px; }
.war-turn-sigil small { font-size: 11px; line-height: 14px; }

.war-battlefield { overflow: visible; }
.arena-shell {
  position: relative;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 13px 12px rgba(4,45,49,.32));
}
.arena-shell .war-map {
  position: absolute;
  z-index: 1;
  inset: 8px 5px 6px;
  clip-path: polygon(15% 1%, 85% 1%, 99% 14%, 99% 86%, 85% 99%, 15% 99%, 1% 86%, 1% 14%);
  background: rgba(218,196,146,.95);
  box-shadow: inset 0 0 28px rgba(70,52,24,.48);
}
.arena-shell .mobile-board-scroll { background: rgba(225,207,164,.74); }
.arena-frame {
  position: absolute;
  z-index: 5;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.arena-wall-shadow {
  fill: none;
  stroke: rgba(41,31,17,.6);
  stroke-width: 26;
  filter: url(#arena-shadow);
}
.arena-wall {
  fill: none;
  stroke: url(#arena-wall);
  stroke-width: 20;
  stroke-linejoin: bevel;
}
.arena-wall-light {
  fill: none;
  stroke: rgba(255,244,199,.72);
  stroke-width: 3;
  stroke-linejoin: bevel;
}
.arena-waterfall {
  fill: none;
  stroke: url(#arena-water);
  stroke-width: 15;
  stroke-linecap: round;
  opacity: .88;
  filter: drop-shadow(0 2px 4px rgba(7,80,115,.38));
}
.arena-tower rect { fill: url(#arena-wall); stroke: #614b2a; stroke-width: 2; }
.arena-tower ellipse { fill: url(#tower-cap); stroke: #f2d17a; stroke-width: 2; }
.arena-tower .tower-ring { fill: #157ea2; stroke: #7ce9ff; stroke-width: 2; }
.arena-tower .tower-crystal { fill: #43d8f2; stroke: #d4fbff; stroke-width: 1.5; filter: drop-shadow(0 0 5px #2ac9ee); }
.arena-foliage circle { fill: #3a792f; }
.arena-foliage circle:nth-child(2) { fill: #6aa943; }
.arena-foliage circle:nth-child(3) { fill: #255f2b; }
.arena-foliage .flower { fill: #f59ac4; stroke: #fff0bc; stroke-width: 1; }

.war-theme .cell .hex-shadow {
  fill: rgba(57,43,20,.56);
  stroke: none;
  filter: none;
}
.war-theme .cell .hex-face {
  fill: url(#hex-face);
  stroke: #927947;
  stroke-width: 2.4;
  filter: drop-shadow(0 1px 1px rgba(255,255,255,.5));
}
.war-theme .cell .hex-engrave {
  fill: none;
  stroke: rgba(255,252,224,.7);
  stroke-width: 1.4;
  filter: none;
}
.war-theme .cell.empty.legal .hex-face { fill: url(#hex-face); stroke: #9d824b; stroke-width: 2.4; }
.war-theme .cell.empty.legal:hover .hex-face { fill: #fff0a6; stroke: #ffc737; stroke-width: 4; }
.war-theme .cell.empty.legal:hover .hex-engrave { stroke: #fff7cd; stroke-width: 2; }

.war-theme .piece-shadow { fill: rgba(42,27,10,.42); filter: blur(1px); }
.war-theme .piece-base { fill: #3b2a18; stroke: #17110b; stroke-width: 1.5; }
.war-theme .piece-rim { fill: #d9a842; stroke: #fff0a2; stroke-width: 2.2; }
.war-theme .piece-disc { stroke: rgba(255,242,188,.62); stroke-width: 1.5; filter: none; }
.war-theme .piece-shine { fill: rgba(255,255,255,.32); pointer-events: none; }
.war-theme .piece-kind .gesture-fill { fill: #fff0c7; filter: drop-shadow(0 1px 1px rgba(76,37,13,.58)); }
.war-theme .piece-kind .gesture-cut { fill: rgba(104,57,24,.68); }
.war-theme .cell.atari .piece-rim { stroke: #fff086; stroke-width: 4; filter: drop-shadow(0 0 7px #ff8137); }

.cell.just-placed .piece-shadow,
.cell.just-placed .piece-base,
.cell.just-placed .piece-rim,
.cell.just-placed .piece-shine {
  transform-box: fill-box;
  transform-origin: center;
  animation: piece-arrive 520ms cubic-bezier(.2,.9,.25,1.25) both;
}
.cell.just-converted .piece-rim,
.cell.just-converted .piece-base,
.cell.just-converted .piece-shine {
  transform-box: fill-box;
  transform-origin: center;
  animation: conversion-flip 720ms ease-in-out both;
}

.war-live-message {
  z-index: 17;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 261px);
  min-height: 33px;
  font-size: 12px;
  border-width: 2px;
}

.war-command-dock {
  height: 258px;
  grid-template-rows: 47px 118px 80px;
  gap: 4px;
  padding: 0 8px calc(env(safe-area-inset-bottom,0px) + 5px);
  background: transparent;
}
.war-command-dock::before { display: none; }
.war-command-dock::after {
  content: "";
  position: absolute;
  z-index: 1;
  left: 1px;
  right: 1px;
  top: 39px;
  bottom: -16px;
  clip-path: polygon(8% 7%, 15% 0, 85% 0, 92% 7%, 100% 14%, 100% 100%, 0 100%, 0 14%);
  border-radius: 24px 24px 0 0;
  background:
    radial-gradient(circle at 5% 12%, #578332 0 4%, transparent 9%),
    radial-gradient(circle at 95% 13%, #3d762f 0 4%, transparent 10%),
    radial-gradient(circle at 11% 19%, #ed91b4 0 1.5%, transparent 4%),
    radial-gradient(circle at 89% 18%, #f2a1c2 0 1.5%, transparent 4%),
    repeating-radial-gradient(circle at 50% 90%, transparent 0 34px, rgba(139,105,52,.12) 35px 37px),
    linear-gradient(155deg, #fff1bd, #d4b571 76%, #9a753d);
  box-shadow:
    inset 0 4px 3px rgba(255,255,255,.7),
    inset 0 -9px 14px rgba(87,57,17,.23),
    0 -11px 24px rgba(5,43,47,.34);
  pointer-events: none;
}
.war-advantage-bar,
.war-unit-controls,
.war-commands { z-index: 3; }

.war-advantage-bar {
  width: calc(100% - 8px);
  height: 47px;
  padding: 4px;
  border: 2px solid #e4b34b;
  border-radius: 20px;
  background: linear-gradient(#126878, #073e4a);
  box-shadow: inset 0 2px rgba(255,255,255,.15), 0 6px 12px rgba(3,39,46,.3);
}
.war-advantage-bar span,
.war-advantage-bar span.selected { min-height: 35px; }
.war-advantage-bar b { font-size: 13px; }
.war-advantage-bar .gesture-icon { width: 24px; height: 24px; }

.war-unit-controls,
.war-unit-card,
.war-unit-card.selected { height: 118px; min-height: 118px; }
.war-unit-card { padding-top: 0; }
.war-unit-medallion {
  width: 88px;
  height: 88px;
  border: 6px solid #e8b844;
  box-shadow:
    inset 0 4px 5px rgba(255,255,255,.42),
    inset 0 -9px 13px rgba(0,0,0,.28),
    0 0 0 3px #fff0ac,
    0 9px 12px rgba(68,42,3,.34);
}
.war-unit-card.selected .war-unit-medallion {
  transform: translateY(-4px) scale(1.06);
  box-shadow:
    inset 0 4px 5px rgba(255,255,255,.5),
    inset 0 -9px 13px rgba(0,0,0,.25),
    0 0 0 4px #fff6c7,
    0 0 0 10px rgba(255,204,66,.5),
    0 11px 15px rgba(63,40,2,.42);
}
.war-unit-card.selected::after { right: calc(50% - 47px); }
.war-unit-medallion .gesture-icon { width: 56px; height: 56px; }
.war-unit-copy { margin-top: -7px; }
.war-unit-copy strong {
  min-width: 88px;
  padding: 4px 12px 3px;
  border: 2px solid #d1a441;
  font-size: 15px;
  line-height: 18px;
}
.war-unit-card.cooling {
  opacity: 1;
  filter: grayscale(.55) saturate(.45);
}
.war-unit-card.cooling .war-unit-medallion::after {
  content: "พัก 1 ตา";
  position: absolute;
  inset: 24px -5px auto;
  padding: 4px 2px;
  border: 1px solid #e8c66e;
  border-radius: 999px;
  background: rgba(46,54,47,.9);
  color: #fff3c8;
  font-size: 11px;
  font-weight: 900;
}

.war-commands,
.war-commands button { height: 80px; min-height: 80px; }
.war-commands button { gap: 3px; }
.war-commands button b {
  width: 58px;
  height: 58px;
  border-width: 4px;
  font-size: 27px;
}
.war-commands button span { font-size: 13px; line-height: 16px; font-weight: 900; }

@media (max-width: 360px) {
  .war-banner { grid-template-columns: 101px minmax(0,1fr) 101px; }
  .war-score .score-copy em { display: none; }
  .war-score strong { font-size: 33px; }
  .war-turn-sigil strong { font-size: 17px; }
}

@media (max-height: 700px) {
  .war-crest { grid-template-rows: 82px minmax(0,1fr) 222px; }
  .war-banner { min-height: 74px; }
  .war-command-dock { height: 222px; grid-template-rows: 40px 102px 72px; }
  .war-advantage-bar { height: 40px; }
  .war-unit-controls, .war-unit-card, .war-unit-card.selected { height: 102px; min-height: 102px; }
  .war-unit-medallion { width: 76px; height: 76px; }
  .war-unit-medallion .gesture-icon { width: 48px; height: 48px; }
  .war-commands, .war-commands button { height: 72px; min-height: 72px; }
  .war-commands button b { width: 52px; height: 52px; }
  .war-live-message { bottom: calc(env(safe-area-inset-bottom,0px) + 225px); }
}

/* v0.16 — element-for-element composition pass from the approved ImageGen concept. */
.war-crest {
  grid-template-rows: 92px minmax(0, 1fr) 234px;
}

.war-banner {
  min-height: 80px;
  grid-template-columns: 106px minmax(0, 1fr) 106px;
  gap: 4px;
  padding: 7px 9px;
  border-radius: 24px;
}
.war-score {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
}
.war-score.azure { justify-content: flex-end; }
.war-score .score-crest {
  width: 25px;
  height: 31px;
  flex: 0 0 25px;
  display: grid;
  place-items: center;
  clip-path: polygon(50% 0, 91% 20%, 84% 72%, 50% 100%, 16% 72%, 9% 20%);
  background: rgba(255, 224, 118, .15);
  color: #ffe27c;
  filter: drop-shadow(0 1px rgba(0,0,0,.3));
  font-size: 15px;
  font-style: normal;
  outline: 1px solid #ffe27c;
}
.war-score .score-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}
.war-score .score-copy small,
.war-score .score-copy em {
  display: block;
  overflow: hidden;
  color: #fff4d7;
  font-style: normal;
  font-weight: 850;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.war-score .score-copy small { font-size: 11px; }
.war-score .score-copy em { color: rgba(255,244,215,.7); font-size: 8px; }
.war-score strong {
  flex: 0 0 auto;
  color: #fff8e4;
  font-size: 30px;
  line-height: 34px;
}
.war-score.azure .score-copy { text-align: right; }
.war-turn-sigil strong { font-size: 16px; line-height: 19px; }
.war-turn-sigil small { font-size: 9px; line-height: 12px; }

.war-map-toolbar { display: none; }
.war-map .mobile-board-scroll {
  height: 100%;
  padding: 0;
}
.war-map .board-svg { margin: 0; }

.war-theme .cell.empty text.number,
.war-theme .cell .effect-badge,
.war-theme .cell .effect-text,
.war-theme .cell .liberty-badge,
.war-theme .cell .liberty-text { opacity: 0; pointer-events: none; }
.war-theme .cell polygon { stroke-width: 2.25; }
.war-theme .cell.empty.legal polygon { stroke: #bca35e; stroke-width: 2.25; }
.war-theme .cell.empty.legal:hover polygon { stroke: #ffd55a; stroke-width: 3.5; }

.war-live-message {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 237px);
  left: 22px;
  right: 22px;
  min-height: 30px;
  padding: 4px 10px;
  font-size: 10px;
  opacity: .94;
}

.war-command-dock {
  height: 234px;
  align-content: end;
  grid-template-rows: 39px 108px 69px;
  gap: 5px;
  padding: 0 9px calc(env(safe-area-inset-bottom, 0px) + 4px);
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(to bottom, transparent 0, rgba(255,242,203,.08) 20%, rgba(255,239,194,.36) 48%, rgba(219,191,132,.58) 100%);
  box-shadow: none;
  overflow: visible;
  isolation: isolate;
}
.war-command-dock::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 50%;
  bottom: -176px;
  width: 430px;
  height: 430px;
  transform: translateX(-50%);
  border: 1px solid rgba(137,100,41,.2);
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle, transparent 0 34px, rgba(154,115,55,.11) 35px 37px),
    radial-gradient(circle, rgba(255,248,219,.58), rgba(229,205,154,.32) 68%, transparent 69%);
  pointer-events: none;
}
.war-advantage-bar,
.war-unit-controls,
.war-commands { position: relative; z-index: 2; }

.war-advantage-bar {
  width: calc(100% - 14px);
  height: 39px;
  margin: 0 auto;
  gap: 4px;
  padding: 3px;
  border: 1px solid #e8b94d;
  border-radius: 17px;
  background: rgba(7, 59, 66, .95);
  box-shadow: inset 0 1px rgba(255,255,255,.16), 0 5px 12px rgba(4,44,48,.24);
}
.war-advantage-bar span,
.war-advantage-bar span.selected {
  min-height: 31px;
  padding: 2px 4px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  box-shadow: none;
}
.war-advantage-bar span + span { border-left: 1px solid rgba(255,223,134,.26); border-radius: 0 12px 12px 0; }
.war-advantage-bar span.selected { background: rgba(255,217,99,.14); }
.war-advantage-bar b { font-size: 11px; }
.war-advantage-bar .gesture-icon { width: 20px; height: 20px; }

.war-unit-controls {
  height: 108px;
  gap: 4px;
}
.war-unit-card,
.war-unit-card.selected {
  min-height: 108px;
  height: 108px;
  gap: 1px;
  padding: 2px 1px 0;
  transform: none;
  background: transparent;
  z-index: 1;
}
.war-unit-card.selected::after {
  top: 1px;
  right: calc(50% - 42px);
  width: 12px;
  height: 12px;
}
.war-unit-medallion {
  position: relative;
  z-index: 1;
  width: 82px;
  height: 82px;
  border-width: 5px;
  box-shadow: inset 0 3px 4px rgba(255,255,255,.4), inset 0 -8px 11px rgba(0,0,0,.22), 0 7px 10px rgba(75,48,4,.3);
}
.war-unit-card.selected .war-unit-medallion {
  transform: translateY(-2px) scale(1.04);
  box-shadow: inset 0 3px 4px rgba(255,255,255,.45), inset 0 -8px 11px rgba(0,0,0,.22), 0 0 0 4px rgba(255,248,207,.88), 0 7px 13px rgba(69,45,0,.4);
}
.war-unit-medallion .gesture-icon { width: 51px; height: 51px; }
.war-unit-copy { margin-top: -6px; z-index: 2; }
.war-unit-copy strong {
  min-width: 74px;
  padding: 3px 10px 2px;
  border: 1px solid #c4983d;
  border-radius: 999px;
  background: #0a5b55;
  color: #fff5d7;
  box-shadow: inset 0 1px rgba(255,255,255,.18), 0 2px 4px rgba(72,44,4,.2);
  font-size: 12px;
  line-height: 15px;
  text-shadow: 0 1px rgba(0,0,0,.25);
}
.war-unit-card.cooling { opacity: .55; }
.war-unit-card.cooling .war-unit-copy small { display: none; }

.war-commands {
  height: 69px;
  gap: 7px;
}
.war-commands button {
  min-height: 69px;
  height: 69px;
  flex-direction: column;
  gap: 1px;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: #123f3f;
  box-shadow: none;
}
.war-commands button b {
  width: 49px;
  height: 49px;
  display: grid;
  place-items: center;
  border: 3px solid #d9aa46;
  border-radius: 50%;
  background: linear-gradient(#12808a, #07545c);
  color: #fff2ca;
  box-shadow: inset 0 2px rgba(255,255,255,.23), 0 4px 7px rgba(67,43,4,.3);
  font-size: 24px;
}
.war-commands button span {
  color: #143e3d;
  font-size: 10px;
  line-height: 14px;
  text-shadow: 0 1px rgba(255,255,255,.7);
}
.war-commands button:disabled { opacity: .42; }

@media (max-width: 360px) {
  .war-banner { grid-template-columns: 92px minmax(0,1fr) 92px; }
  .war-score .score-copy em { display: none; }
  .war-unit-medallion { width: 74px; height: 74px; }
  .war-unit-medallion .gesture-icon { width: 46px; height: 46px; }
}

@media (max-height: 700px) {
  .war-crest { grid-template-rows: 78px minmax(0,1fr) 204px; }
  .war-banner { min-height: 68px; }
  .war-command-dock { height: 204px; grid-template-rows: 34px 94px 64px; }
  .war-advantage-bar { height: 34px; }
  .war-unit-controls, .war-unit-card, .war-unit-card.selected { height: 94px; min-height: 94px; }
  .war-unit-medallion { width: 68px; height: 68px; }
  .war-unit-medallion .gesture-icon { width: 43px; height: 43px; }
  .war-commands, .war-commands button { height: 64px; min-height: 64px; }
  .war-commands button b { width: 44px; height: 44px; }
  .war-live-message { bottom: calc(env(safe-area-inset-bottom, 0px) + 207px); }
}
