:root {
  --bg: #090e11;
  --surface: #10181c;
  --surface-2: #152126;
  --surface-3: #1b292f;
  --line: #26373d;
  --line-soft: #1c2b30;
  --ink: #edf2ed;
  --muted: #91a19e;
  --faint: #62736f;
  --accent: #d7b46a;
  --accent-strong: #f2ca76;
  --accent-ink: #241b0b;
  --teal: #66b4a4;
  --red: #d97868;
  --blue: #719aca;
  --radius: 14px;
  --shadow: 0 20px 50px rgb(0 0 0 / .28);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 76% -10%, rgb(74 117 105 / .16), transparent 36rem),
    var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", Avenir, system-ui, sans-serif;
  font-size: 14px;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, [role="button"] { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip-link { position: fixed; left: 12px; top: -50px; z-index: 100; background: var(--accent); color: #111; padding: 10px; }
.skip-link:focus { top: 12px; }
.app-shell { min-height: 100vh; display: grid; grid-template: 72px minmax(0, 1fr) / 292px minmax(0, 1fr); }

.topbar {
  position: sticky; top: 0; z-index: 20; grid-column: 1 / -1;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
  min-width: 0; height: 72px; border-bottom: 1px solid var(--line); background: rgb(9 14 17 / .91); backdrop-filter: blur(16px);
}
.encounter-meta { min-width: 0; display: flex; align-items: center; gap: 10px; padding: 0 18px; }
.compact-field { min-width: 0; display: grid; gap: 2px; }
.compact-field span { color: var(--faint); font-size: 9px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.compact-field select { width: min(25vw, 290px); min-height: 32px; padding: 3px 25px 3px 0; border: 0; border-bottom: 1px solid transparent; border-radius: 0; background: transparent; color: var(--ink); font-weight: 600; }
.compact-field select:hover, .compact-field select:focus { border-color: var(--line); }
.turn-control { display: flex; align-items: center; gap: 9px; margin-left: 8px; color: var(--muted); white-space: nowrap; }
.turn-control > span { min-width: 115px; display: grid; line-height: 1.1; }
.turn-control small { color: var(--faint); font-size: 8px; font-style: normal; letter-spacing: .12em; text-transform: uppercase; }
.turn-control strong { max-width: 160px; overflow: hidden; color: var(--ink); font-size: 12px; text-overflow: ellipsis; }
.turn-control em { margin-top: 3px; color: var(--muted); font: normal 8px ui-monospace, "SFMono-Regular", monospace; }
.turn-control button { width: 27px; height: 32px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.top-actions { display: flex; gap: 8px; padding-right: 22px; }

.sidebar { grid-row: 2; min-height: calc(100vh - 72px); padding: 12px 16px 16px; border-right: 1px solid var(--line); background: rgb(13 20 23 / .75); }
.sidebar-game-switch { display: none; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
#enemyCount { color: var(--ink); }
.sidebar h2, .panel h2, dialog h2 { margin: 3px 0 0; font: 600 21px "Iowan Old Style", Baskerville, Georgia, serif; }
.eyebrow { color: var(--accent); font-size: 9px; font-weight: 700; letter-spacing: .17em; text-transform: uppercase; }
.round-stepper { display: grid; grid-template-columns: 30px minmax(0, 1fr) 30px; align-items: center; gap: 8px; margin-bottom: 8px; padding: 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.sidebar-combat-context { position: sticky; top: 72px; z-index: 12; padding: 12px 0 8px; background: var(--bg); box-shadow: 0 12px 18px rgb(0 0 0 / .34); }
.prior-banner { display: grid; gap: 8px; margin-bottom: 8px; padding: 12px; border: 1px dashed var(--accent); border-radius: 10px; background: rgb(215 180 106 / .07); }
.prior-banner[hidden], .turn-banner[hidden] { display: none; }
.prior-banner > span { display: grid; gap: 2px; text-align: center; }
.prior-banner small { color: var(--accent); font-size: 7px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.prior-banner strong { font-size: 11px; }
.prior-banner .button { width: 100%; min-height: 44px; border-color: var(--red); background: var(--red); color: #23100c; }
.prior-banner .button:hover { background: #e58a78; border-color: #e58a78; }
.sidebar-turn-control { display: grid; gap: 10px; margin-bottom: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.round-stepper > span, .sidebar-turn-control > span { min-width: 0; display: grid; text-align: center; }
.round-stepper small, .sidebar-turn-control small { color: var(--faint); font-size: 7px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.round-stepper strong, .sidebar-turn-control strong { overflow: hidden; margin-top: 2px; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.round-stepper em, .sidebar-turn-control em { margin-top: 2px; color: var(--muted); font: normal 8px ui-monospace, "SFMono-Regular", monospace; }
.round-stepper button { width: 30px; height: 31px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); }
.round-stepper button:disabled { opacity: .3; cursor: default; }
.turn-buttons { display: grid; grid-template-columns: auto 1fr; gap: 8px; }
.turn-back { min-height: 48px; padding: 10px 12px; }
.turn-next { min-height: 48px; padding: 10px 12px; font-size: 16px; }
.roster-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 16px 7px 8px; color: var(--faint); font-size: 8px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.roster-tools > span:last-child { display: flex; gap: 4px; }
.roster { display: grid; gap: 5px; }
.roster-section-label { margin: 19px 9px 7px; color: var(--faint); font-size: 8px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.roster-group { margin-bottom: 8px; }
.profile-row { width: 100%; display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 12px 10px; border: 1px solid transparent; border-radius: 10px; background: transparent; text-align: left; }
.profile-row:hover { background: var(--surface); }
.profile-row.active { border-color: var(--line); background: var(--surface-2); }
.profile-row .profile-copy { min-width: 0; display: grid; gap: 2px; }
.profile-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.profile-row small { color: var(--muted); font-size: 10px; }
.color-dot, .unit-color { border-radius: 50%; background: var(--unit-color, var(--faint)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--unit-color, var(--faint)) 18%, transparent); }
.color-dot { width: 8px; height: 8px; }
.hp-mini { color: var(--muted); font: 500 10px ui-monospace, "SFMono-Regular", monospace; }
.roster-turn-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 23px; gap: 4px; border: 1px solid transparent; border-radius: 10px; }
.roster-turn-row.active { border-color: var(--accent); background: rgb(215 180 106 / .07); }
.roster-turn-row.next::after { content: "NEXT"; position: absolute; top: -4px; right: 31px; z-index: 2; padding: 1px 4px; background: var(--teal); color: #07110f; font-size: 6px; font-weight: 800; letter-spacing: .09em; }
.roster-actor { width: 100%; min-width: 0; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 10px 7px 10px 9px; border: 0; border-radius: 9px; background: transparent; text-align: left; }
.roster-actor:hover { background: var(--surface-2); }
.roster-marker { position: relative; width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); font: 800 10px ui-monospace, "SFMono-Regular", monospace; }
.roster-marker.enemy.has-color { border: 0; background: var(--unit-color); color: transparent; box-shadow: 0 0 0 3px color-mix(in srgb, var(--unit-color) 17%, transparent); }
.roster-marker.enemy.has-thumbnail { border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--surface); color: transparent; box-shadow: 0 0 0 2px rgb(0 0 0 / .22); }
.roster-marker.enemy.has-thumbnail img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.roster-marker.enemy.has-thumbnail.has-color::after { content: ""; position: absolute; z-index: 2; top: -4px; right: -4px; width: 12px; height: 12px; border: 2px solid #0b1114; border-radius: 50%; background: var(--unit-color); box-shadow: 0 0 0 1px rgb(255 255 255 / .3), 0 2px 5px rgb(0 0 0 / .65); }
.roster-turn-row.defeated { border-color: rgb(255 77 87 / .58); }
.roster-turn-row.defeated::before { content: ""; position: absolute; z-index: 4; inset: 2px; border-radius: 7px; pointer-events: none; background: linear-gradient(to bottom right, transparent calc(50% - 1.5px), #ff3542 calc(50% - 1.5px), #ff3542 calc(50% + 1.5px), transparent calc(50% + 1.5px)), linear-gradient(to top right, transparent calc(50% - 1.5px), #ff3542 calc(50% - 1.5px), #ff3542 calc(50% + 1.5px), transparent calc(50% + 1.5px)); filter: drop-shadow(0 1px 1px #180709); }
.roster-turn-row.defeated .roster-actor { opacity: .64; }
.roster-turn-row.defeated .order-buttons { opacity: .5; }
.roster-marker.player { border-color: #52605d; background: #1d292c; color: #b8c3c0; }
.roster-copy { min-width: 0; display: grid; gap: 2px; }
.roster-copy strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.roster-copy small { overflow: hidden; color: var(--faint); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.status-row { display: block; margin-top: 4px; }
.status-count { display: inline-flex; align-items: center; padding: 2px 5px; border-radius: 99px; background: #e3d02c; color: #1d1a05; font-size: 7px; font-weight: 900; letter-spacing: .03em; text-transform: uppercase; }
.roster-resources { display: grid; gap: 3px; margin-top: 5px; }
.mini-res { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 6px; font-size: 8px; }
.mini-res i { color: var(--resource-color); font-style: normal; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.mini-bar { display: block; height: 4px; overflow: hidden; border-radius: 99px; background: var(--line-soft); }
.mini-bar u { display: block; height: 100%; background: var(--resource-color); transform: scaleX(var(--fill, .05)); transform-origin: left; text-decoration: none; }
.mini-res em { min-width: 32px; display: grid; justify-items: end; color: var(--ink); font-style: normal; font-family: ui-monospace, "SFMono-Regular", monospace; text-align: right; }
.mini-delta { margin-top: 1px; font: 700 7px ui-monospace, "SFMono-Regular", monospace; }
.mini-delta.loss { color: var(--red); }
.mini-delta.gain { color: var(--teal); }
.turn-banner { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.turn-banner[data-kind="player"] { border-color: var(--teal); background: rgb(102 180 164 / .08); }
.turn-banner[data-kind="enemy"] { border-color: var(--line); }
.turn-kind { padding: 4px 8px; border-radius: 99px; font-size: 8px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.turn-kind.player { background: var(--teal); color: #07110f; }
.turn-kind.enemy { background: var(--surface-3); color: var(--accent-strong); }
.turn-who { display: grid; gap: 2px; }
.turn-who strong { font-size: 14px; }
.turn-who small { color: var(--muted); font-size: 10px; }
.form-section-title { grid-column: 1 / -1; margin: 6px 0 -2px; color: var(--accent); font-size: 9px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.form-section-head { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0 -2px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.form-section-head > span { color: var(--accent); font-size: 9px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.include-picker { display: flex; align-items: center; gap: 6px; margin: 0; }
.include-picker > span { color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.include-picker select { width: auto; min-height: 32px; padding: 5px 8px; font-size: 11px; }
.roster-score { display: grid; justify-items: end; gap: 1px; color: var(--accent); font: 600 14px ui-monospace, "SFMono-Regular", monospace; }
.roster-score small { color: var(--faint); font: 600 6px "Avenir Next", Avenir, sans-serif; letter-spacing: .08em; text-transform: uppercase; }
.order-buttons { display: grid; align-content: center; gap: 2px; padding-right: 3px; }
.order-buttons button { width: 20px; height: 18px; padding: 0; border: 1px solid var(--line-soft); border-radius: 4px; background: transparent; color: var(--faint); font-size: 8px; }
.order-buttons button:hover { border-color: var(--line); color: var(--ink); }
.color-field { min-width: 0; }
.color-picker { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; padding: 7px; border: 1px solid var(--line); border-radius: 8px; background: #0c1316; }
.color-choice { position: relative; aspect-ratio: 1; min-width: 0; padding: 0; border: 1px solid color-mix(in srgb, var(--choice-color, var(--line)) 70%, var(--line)); border-radius: 6px; background: var(--choice-color); color: #8b9692; }
.color-choice.no-color { border-style: dashed; background: repeating-linear-gradient(135deg, #172124 0 4px, #0c1316 4px 8px); font-size: 16px; line-height: 1; }
.color-choice.selected { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: 0 0 0 1px #0c1316; }
.color-choice.selected::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; color: #07110f; font-size: 13px; font-weight: 900; text-shadow: 0 1px 0 rgb(255 255 255 / .45); }
.color-choice.no-color.selected::after { color: var(--accent); text-shadow: none; }
.status-section { margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--line-soft); }
.status-list { display: grid; gap: 6px; margin-top: 7px; }
.status-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 9px; border: 1px solid rgb(227 208 44 / .48); border-radius: 7px; background: rgb(227 208 44 / .08); }
.status-item > span { min-width: 0; display: grid; gap: 2px; }
.status-item strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.status-item small { color: var(--accent-strong); font-size: 8px; }
.status-item button { flex: 0 0 auto; padding: 4px 6px; border: 1px solid var(--line); border-radius: 5px; background: transparent; color: var(--ink); font-size: 8px; }
.status-empty { margin-top: 7px; padding: 10px; }
.profile-image-field { display: grid; grid-template-columns: minmax(0, 1fr) 92px; gap: 12px; align-items: start; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.profile-image-field > div:first-child { display: grid; gap: 4px; }
.profile-image-field small { color: var(--muted); font-size: 9px; line-height: 1.45; }
.profile-image-crop { position: relative; grid-column: 2; grid-row: 1 / span 2; width: 92px; aspect-ratio: 1; overflow: hidden; display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 8px; background: var(--bg); color: var(--faint); font-size: 8px; }
.profile-image-crop img { width: 100%; height: 100%; object-fit: cover; }
.profile-image-controls { grid-column: 1; display: grid; grid-template-columns: auto repeat(3, minmax(0, 1fr)); gap: 8px; align-items: end; }
.profile-image-controls label { display: grid; gap: 4px; color: var(--muted); font-size: 8px; }
.profile-image-controls input[type="range"] { width: 100%; accent-color: var(--accent); }
.file-picker { position: relative; display: inline-grid !important; place-items: center; min-height: 30px; padding: 0 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink) !important; cursor: pointer; font-weight: 700 !important; }
.file-picker input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.damage-defense-field { display: grid; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.damage-defense-field > div:first-child { display: grid; gap: 4px; }
.damage-defense-field > div:first-child small { color: var(--muted); font-size: 9px; line-height: 1.45; }
.damage-defense-grid { display: grid; grid-template-columns: minmax(105px, 1fr) 90px minmax(120px, 1fr); align-items: center; gap: 6px 8px; max-height: 320px; overflow: auto; padding: 8px; border: 1px solid var(--line-soft); border-radius: 8px; background: var(--bg); }
.damage-defense-grid > strong { position: sticky; top: -8px; z-index: 1; padding: 6px 0; background: var(--bg); color: var(--faint); font-size: 8px; letter-spacing: .08em; text-transform: uppercase; }
.damage-defense-grid > span { font-size: 10px; }
.damage-defense-grid > span small { color: var(--faint); font-size: 8px; }
.damage-defense-grid input, .damage-defense-grid select { min-height: 31px; padding: 5px 7px; font-size: 10px; }
.roster-turn-row.pending { border-style: dashed; opacity: .62; }
.sidebar-footer { position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-top: 20px; background: linear-gradient(transparent, var(--bg) 28%); }
.sidebar-footer .sidebar-add-roster { grid-column: 1 / -1; }

.main-panel { grid-column: 2; min-width: 0; padding: 30px clamp(20px, 3vw, 46px) 60px; overflow: visible; }
.empty-state { min-height: calc(100vh - 180px); max-width: 620px; margin: auto; text-align: center; align-content: center; }
.empty-state h1 { margin: 10px 0; font: 700 clamp(38px, 6vw, 68px)/.95 "Iowan Old Style", Baskerville, Georgia, serif; }
.empty-state p:not(.eyebrow) { max-width: 500px; margin: 18px auto 24px; color: var(--muted); font-size: 16px; line-height: 1.7; }
.empty-sigil { width: 72px; height: 72px; margin: 0 auto 20px; display: grid; place-items: center; border: 1px dashed var(--accent); border-radius: 50%; color: var(--accent); font: 600 30px "Iowan Old Style", Baskerville, Georgia, serif; }
.unit-header { position: sticky; top: 72px; z-index: 15; display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 0 -12px 24px; padding: 14px 12px; border-bottom: 1px solid var(--line); background: rgb(9 14 17 / .94); backdrop-filter: blur(16px); }
.unit-identity { min-width: 0; display: flex; align-items: center; gap: 15px; }
.unit-color { flex: 0 0 auto; width: 15px; height: 48px; border-radius: 5px; }
.identity-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.identity-line h1 { overflow: hidden; margin: 0; text-overflow: ellipsis; white-space: nowrap; font: 700 clamp(28px, 4vw, 43px)/1 "Iowan Old Style", Baskerville, Georgia, serif; }
.class-badge { flex: 0 0 auto; padding: 5px 10px; border-radius: 99px; font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.class-badge[data-class="grunt"] { background: rgb(102 180 164 / .16); color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }
.class-badge[data-class="heroic"] { background: rgb(215 180 106 / .14); color: var(--accent-strong); box-shadow: inset 0 0 0 1px var(--accent); }
.class-badge[data-class="boss"] { background: rgb(217 120 104 / .16); color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.roster-copy strong { display: flex; align-items: center; gap: 6px; min-width: 0; }
.class-tag { flex: 0 0 auto; padding: 2px 6px; border-radius: 99px; font-size: 7px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.class-tag[data-class="grunt"] { background: rgb(102 180 164 / .16); color: var(--teal); }
.class-tag[data-class="heroic"] { background: rgb(215 180 106 / .14); color: var(--accent-strong); }
.class-tag[data-class="boss"] { background: rgb(217 120 104 / .16); color: var(--red); }
.class-tag[data-class="player"] { background: #1d292c; color: #b8c3c0; }
.roster-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity-meta { display: flex; align-items: center; gap: 7px; margin-top: 7px; color: var(--muted); font-size: 11px; }
.view-switcher { display: flex; gap: 3px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.view-switcher button { padding: 7px 14px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 700; }
.view-switcher button[aria-selected="true"] { background: var(--surface-3); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }

.resource-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.resource-card { position: relative; min-width: 0; min-height: 112px; overflow: hidden; padding: 15px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, var(--surface-2), var(--surface)); }
.resource-card::after { content: ""; position: absolute; inset: auto 0 0; height: 3px; background: var(--resource-color); opacity: .8; transform: scaleX(var(--fill, .05)); transform-origin: left; transition: transform .25s; }
.resource-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.resource-top button { border: 0; background: none; color: var(--faint); font-size: 14px; }
.resource-value { display: flex; align-items: baseline; gap: 7px; margin-top: 10px; }
.resource-value strong { font: 500 clamp(22px, 3vw, 31px) ui-monospace, "SFMono-Regular", monospace; }
.resource-value span { color: var(--muted); font: 400 11px ui-monospace, "SFMono-Regular", monospace; }
.resource-change { font: 700 13px ui-monospace, "SFMono-Regular", monospace; }
.resource-change.loss { color: var(--red); }
.resource-change.gain { color: var(--teal); }
.resource-card small { display: block; margin-top: 6px; color: var(--faint); font-size: 10px; }
.resource-card .resource-observation { color: var(--accent-strong); font: 600 9px ui-monospace, "SFMono-Regular", monospace; }

.track-grid, .intel-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(270px, .7fr); gap: 12px; align-items: start; }
.panel { min-width: 0; padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); background: rgb(16 24 28 / .9); box-shadow: 0 12px 32px rgb(0 0 0 / .08); }
.panel-heading { margin-bottom: 17px; }
.keyboard-hint, .legend { color: var(--faint); font-size: 10px; }
.quick-panel, .timeline-panel, .stats-panel, .evidence-panel { grid-column: 1; }
.suggestions-panel, .loadout-panel, .derived-panel { grid-column: 2; }
.suggestions-panel, .derived-panel { grid-row: span 1; }
.estimator-panel { grid-column: 1 / -1; }
.player-statline { margin-top: 3px; color: var(--teal); font: 600 8px ui-monospace, "SFMono-Regular", monospace; }
.cloud-controls { display: flex; align-items: center; gap: 6px; }
.cloud-status { max-width: 140px; overflow: hidden; padding: 4px 7px; border: 1px solid var(--line); border-radius: 99px; color: var(--faint); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.cloud-status.online { border-color: rgb(102 180 164 / .5); color: var(--teal); }
.cloud-status.error { border-color: rgb(217 120 104 / .5); color: var(--red); }
.estimator-controls { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 10px; }
.estimator-controls label { min-width: 0; }
.estimator-controls label > span { display: block; margin: 0 0 6px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.estimator-result { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 8px; margin-top: 14px; }
.estimator-result > div { padding: 12px; border: 1px solid var(--line-soft); border-radius: 8px; background: #0d1518; }
.estimator-result small { display: block; color: var(--faint); font-size: 8px; letter-spacing: .08em; text-transform: uppercase; }
.estimator-result strong { display: block; margin-top: 7px; color: var(--accent-strong); font: 600 19px ui-monospace, "SFMono-Regular", monospace; }
.estimator-result > p { grid-column: 1 / -1; margin: 2px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.estimator-empty { padding: 14px; border: 1px dashed var(--line); border-radius: 8px; color: var(--faint) !important; text-align: center; }
.segmented { display: flex; overflow-x: auto; gap: 2px; padding-bottom: 14px; }
.segmented button { padding: 7px 10px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 11px; white-space: nowrap; }
.segmented button:first-child { border-radius: 7px 0 0 7px; }
.segmented button:last-child { border-radius: 0 7px 7px 0; }
.segmented button.active { border-color: color-mix(in srgb, var(--accent) 58%, var(--line)); background: rgb(215 180 106 / .09); color: var(--accent-strong); }
.event-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.attack-modifiers { min-width: 0; margin: 0; padding: 0; border: 0; }
.attack-modifiers legend { margin: 0 0 6px; padding: 0; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.attack-modifiers > div { display: flex; flex-wrap: wrap; gap: 5px; min-height: 39px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: #0c1316; }
.attack-modifiers .modifier-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 5px; border: 1px solid var(--line-soft); border-radius: 5px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.attack-modifiers .modifier-chip input { width: 12px; min-height: 12px; margin: 0; accent-color: var(--accent); }
.attack-modifiers .modifier-chip:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 65%, var(--line)); background: rgb(215 180 106 / .1); color: var(--accent-strong); }
.attack-modifiers .pinpoint-value { display: flex; align-items: center; gap: 5px; min-width: 100%; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.attack-modifiers .pinpoint-value input { width: 72px; min-height: 28px; padding: 5px 7px; font-size: 11px; letter-spacing: normal; text-transform: none; }
.damage-types-field { grid-column: 1 / -1; min-width: 0; margin: 0; padding: 0; border: 0; }
.damage-types-field legend { margin: 0 0 6px; padding: 0; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.damage-type-group { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 7px; align-items: start; padding: 5px 6px; border: 1px solid var(--line-soft); border-bottom: 0; background: #0c1316; }
.damage-type-group:first-of-type { border-radius: 8px 8px 0 0; }
.damage-type-group:last-child { border-bottom: 1px solid var(--line-soft); border-radius: 0 0 8px 8px; }
.damage-type-group > small { padding-top: 4px; color: var(--faint); font-size: 8px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.damage-type-group > span { display: flex; flex-wrap: wrap; gap: 5px; }
.damage-types-field .modifier-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 5px; border: 1px solid var(--line-soft); border-radius: 5px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.damage-types-field .modifier-chip input { width: 12px; min-height: 12px; margin: 0; accent-color: var(--red); }
.damage-types-field .modifier-chip:has(input:checked) { border-color: color-mix(in srgb, var(--red) 68%, var(--line)); background: rgb(217 120 104 / .11); color: #f09a89; }
.quick-log-footer { display: flex; align-items: end; gap: 10px; margin-top: 11px; }
.grow { flex: 1; }
.field-label, .field > span { display: block; margin: 0 0 6px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
input, select, textarea { width: 100%; min-height: 39px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #0c1316; color: var(--ink); }
textarea { min-height: 86px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #53635f; }
.check-field { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.check-field input { width: 15px; min-height: 15px; accent-color: var(--accent); }

.suggestion { margin-bottom: 9px; padding: 11px 12px; border: 1px solid var(--line-soft); border-left: 2px solid var(--accent); border-radius: 8px; background: #0d1518; }
.suggestion-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.suggestion strong { font-size: 12px; }
.confidence { color: var(--teal); font: 500 9px ui-monospace, "SFMono-Regular", monospace; text-transform: uppercase; }
.suggestion p { margin: 7px 0 9px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.suggestion button { padding: 4px 7px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-2); color: var(--accent); font-size: 9px; font-weight: 700; }
.muted-empty { padding: 18px 10px; color: var(--faint); text-align: center; font-size: 11px; line-height: 1.55; }

.timeline { position: relative; }
.timeline::before { content: ""; position: absolute; top: 5px; bottom: 5px; left: 58px; width: 1px; background: var(--line); }
.timeline-item { position: relative; display: grid; grid-template-columns: 47px 16px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 8px 0; }
.timeline-round { color: var(--faint); font: 500 9px ui-monospace, "SFMono-Regular", monospace; text-align: right; text-transform: uppercase; }
.timeline-dot { z-index: 1; width: 9px; height: 9px; margin-top: 2px; border: 2px solid var(--surface); border-radius: 50%; background: var(--event-color, var(--faint)); box-shadow: 0 0 0 1px var(--event-color, var(--faint)); }
.timeline-copy strong { display: block; font-size: 11px; }
.timeline-copy p { margin: 4px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.timeline-resource { font-weight: 800; }
.timeline-resource[data-resource="hp"] { color: var(--red); }
.timeline-resource[data-resource="thp"] { color: #b884d8; }
.timeline-resource[data-resource="rp"] { color: var(--teal); }
.timeline-resource[data-resource="mp"] { color: var(--blue); }
.timeline-resource[data-resource="ap"] { color: var(--accent-strong); }
.timeline-delete { opacity: 0; border: 0; background: transparent; color: var(--faint); }
.timeline-item:hover .timeline-delete { opacity: 1; }
.loadout-list { display: grid; gap: 8px; }
.loadout-card { padding: 11px; border: 1px solid var(--line-soft); border-radius: 8px; background: #0d1518; }
.loadout-card button { width: 100%; padding: 0; border: 0; background: transparent; text-align: left; }
.loadout-name { display: flex; justify-content: space-between; gap: 8px; }
.loadout-name strong { font-size: 11px; }
.costs { display: flex; gap: 4px; }
.cost { padding: 2px 5px; border-radius: 4px; background: var(--surface-3); color: var(--accent); font: 500 8px ui-monospace, "SFMono-Regular", monospace; }
.loadout-card p { margin: 8px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.tag-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.tag { padding: 2px 6px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: 8px; text-transform: uppercase; }

.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat-card { padding: 14px; border: 1px solid var(--line-soft); border-radius: 10px; background: #0d1518; }
.stat-card button { width: 100%; padding: 0; border: 0; background: none; text-align: left; }
.stat-card-header { display: flex; justify-content: space-between; align-items: center; }
.stat-card-header span:first-child { font: 700 10px "Avenir Next", Avenir, sans-serif; letter-spacing: .1em; text-transform: uppercase; }
.knowledge-dot { width: 6px; height: 6px; border-radius: 50%; }
.knowledge-dot.exact, .legend i.exact { background: var(--teal); }
.knowledge-dot.bounded, .legend i.bounded { background: var(--accent); }
.knowledge-dot.unknown, .legend i.unknown { background: var(--faint); }
.stat-number { margin-top: 12px; font: 500 25px ui-monospace, "SFMono-Regular", monospace; }
.stat-number small { color: var(--faint); font-size: 11px; }
.stat-card p { min-height: 30px; margin: 7px 0 0; color: var(--muted); font-size: 9px; line-height: 1.4; }
.legend { display: flex; align-items: center; gap: 5px; }
.legend i { display: inline-block; width: 5px; height: 5px; margin-left: 5px; border-radius: 50%; }
.derived-panel { grid-column: 1 / -1; }
.derived-grid { display: grid; width: 100%; }
.derived-table-header { display: grid; grid-template-columns: minmax(130px, 1fr) minmax(180px, 1.7fr) minmax(120px, .8fr); gap: 14px; padding: 0 10px 8px; border-bottom: 1px solid var(--line); color: var(--faint); font-size: 8px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.derived-row { width: 100%; display: grid; grid-template-columns: minmax(130px, 1fr) minmax(180px, 1.7fr) minmax(120px, .8fr); gap: 14px; align-items: center; padding: 11px 10px; border: 0; border-bottom: 1px solid var(--line-soft); border-radius: 0; background: transparent; color: var(--ink); text-align: left; }
.derived-row:hover { background: var(--surface-2); }
.derived-row:last-child { border: 0; }
.derived-name { font-size: 11px; font-weight: 700; }
.derived-row small { display: block; min-width: 0; color: var(--faint); font: 400 8px ui-monospace, "SFMono-Regular", monospace; overflow-wrap: anywhere; }
.derived-value { text-align: right; font: 500 14px ui-monospace, "SFMono-Regular", monospace; }
.derived-value em { display: block; margin-top: 3px; color: var(--accent); font: normal 8px "Avenir Next", Avenir, sans-serif; }
.evidence-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.evidence-item:last-child { border: 0; }
.evidence-item strong { font-size: 11px; }
.evidence-item p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.item-meta { display: block; margin-bottom: 5px; color: var(--faint); font: 500 8px ui-monospace, "SFMono-Regular", monospace; text-transform: uppercase; }
.item-edit { align-self: center; border: 0; background: transparent; color: var(--faint); font-size: 11px; }

.dossier { max-width: 960px; margin: 0 auto; padding: clamp(24px, 5vw, 58px); border: 1px solid #55472e; background: #e8e1d1; color: #1d2524; box-shadow: var(--shadow); }
.dossier-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; padding-bottom: 24px; border-bottom: 2px solid #292f2d; }
.dossier .eyebrow { color: #765f2e; }
.dossier h2 { margin: 5px 0 7px; font: 700 clamp(35px, 6vw, 59px)/.95 "Iowan Old Style", Baskerville, Georgia, serif; }
.dossier-header p { margin: 0; color: #59615e; }
.dossier-stamp { align-self: start; padding: 10px 14px; border: 2px solid #826b38; color: #826b38; font: 600 10px ui-monospace, "SFMono-Regular", monospace; text-transform: uppercase; transform: rotate(2deg); }
.dossier-portrait { width: min(100%, 620px); margin: 24px auto 0; padding: 8px; border: 1px solid #bcb4a3; background: #f2ecdf; }
.dossier-portrait img { display: block; width: 100%; max-height: 680px; object-fit: contain; background: #d6cfbf; }
.dossier-portrait figcaption { margin-top: 7px; color: #666d69; font-size: 9px; font-style: italic; text-align: center; }
.dossier-section { padding: 23px 0; border-bottom: 1px solid #bcb4a3; }
.dossier-source { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid #bcb4a3; color: #666d69; font-size: 9px; }
.dossier-source strong { color: #765f2e; }
.preserve-lines { white-space: pre-line; }
.dossier-section h3 { margin: 0 0 14px; font: 700 20px "Iowan Old Style", Baskerville, Georgia, serif; }
.dossier-stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.dossier-stat { padding: 12px; border: 1px solid #bcb4a3; }
.dossier-stat span { display: block; color: #666d69; font-size: 8px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.dossier-stat strong { display: block; margin-top: 8px; font: 600 22px ui-monospace, "SFMono-Regular", monospace; }
.dossier-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.dossier-list { margin: 0; padding: 0; list-style: none; }
.dossier-list li { padding: 9px 0; border-bottom: 1px solid #cbc4b5; font-size: 11px; line-height: 1.5; }
.dossier-list strong { display: block; }
.dossier-footer { padding-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #68706d; font-size: 9px; }

.button { min-height: 38px; padding: 8px 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font-size: 11px; font-weight: 700; }
.button:hover { border-color: #3b5057; background: var(--surface-3); }
.button.primary { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.button.primary:hover { background: var(--accent-strong); }
.button.ghost, .button.subtle { background: transparent; color: var(--muted); }
.button.subtle { padding: 7px; font-size: 10px; }
.button.danger { color: var(--red); }
.tiny-button, .text-button { padding: 4px 7px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--muted); font-size: 9px; }
.text-button { padding: 0; border: 0; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.mobile-only { display: none; }

dialog { width: min(620px, calc(100vw - 32px)); max-height: min(820px, calc(100vh - 32px)); overflow: auto; padding: 0; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); color: var(--ink); box-shadow: 0 30px 90px #000; }
dialog::backdrop { background: rgb(0 0 0 / .68); backdrop-filter: blur(5px); }
.dialog-heading { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: start; padding: 20px 22px; border-bottom: 1px solid var(--line); background: var(--surface); }
.dialog-body { display: grid; gap: 14px; padding: 22px; }
.dialog-actions { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 15px 22px; border-top: 1px solid var(--line); background: var(--surface); }
.spacer { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid[hidden] { display: none; }
.monster-results { grid-column: 1 / -1; display: grid; gap: 4px; max-height: 190px; overflow: auto; }
.monster-results button { padding: 8px 10px; border: 1px solid var(--line-soft); border-radius: 8px; background: #0c1316; color: var(--ink); text-align: left; font-size: 12px; }
.monster-results button:hover { border-color: var(--accent); }
.monster-results button strong { display: block; }
.monster-results button small { display: block; margin-top: 2px; color: var(--faint); font-size: 10px; }
.monster-empty { padding: 6px 2px; color: var(--faint); font-size: 11px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { margin: 4px 0 -3px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--accent); font-size: 9px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.form-help { margin: -5px 0 0; color: var(--faint); font-size: 10px; line-height: 1.45; }
.inline-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.color-input { min-height: 39px; padding: 3px; }
.toast-region { position: fixed; z-index: 80; right: 18px; bottom: 18px; display: grid; gap: 7px; }
.toast { max-width: 330px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-3); box-shadow: var(--shadow); color: var(--ink); font-size: 11px; animation: toast-in .2s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 240px minmax(0, 1fr); }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; }
  .track-grid, .intel-grid { grid-template-columns: 1fr; }
  .quick-panel, .timeline-panel, .stats-panel, .evidence-panel, .suggestions-panel, .loadout-panel, .derived-panel { grid-column: 1; }
  .resource-strip { grid-template-columns: repeat(2, 1fr); }
  .top-actions .button span { display: none; }
  .turn-control > span { min-width: 90px; }
  .turn-control strong { max-width: 100px; }
  .estimator-controls, .estimator-result { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .app-shell { display: block; }
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; height: 62px; padding: 0 10px; }
  .mobile-only { display: block; }
  .encounter-meta { display: none; }
  .top-actions { padding: 0; }
  .top-actions .ghost { display: none; }
  .cloud-status { display: none; }
  .cloud-controls .button { padding: 7px 9px; }
  .sidebar { position: fixed; z-index: 40; inset: 62px auto 0 0; width: min(88vw, 310px); min-height: auto; transform: translateX(-101%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .sidebar-game-switch { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
  .sidebar-game-switch label { min-width: 0; }
  .sidebar-game-switch label span { display: block; margin-bottom: 5px; color: var(--faint); font-size: 8px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
  .sidebar-game-switch select { min-height: 35px; }
  .main-panel { padding: 21px 14px 50px; }
  .unit-header { align-items: stretch; flex-direction: column; }
  .view-switcher { align-self: stretch; }
  .view-switcher button { flex: 1; }
  .resource-strip { grid-template-columns: 1fr 1fr; }
  .resource-card { min-height: 96px; padding: 13px; }
  .event-fields, .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: 1; }
  .damage-defense-grid { grid-template-columns: minmax(92px, 1fr) 64px minmax(105px, 1fr); }
  .damage-type-group { grid-template-columns: 44px minmax(0, 1fr); }
  .quick-log-footer { align-items: stretch; flex-direction: column; }
  .quick-log-footer .button { width: 100%; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .derived-table-header { display: none; }
  .derived-row { grid-template-columns: minmax(105px, 1fr) minmax(90px, auto); }
  .derived-row > small { display: none; }
  .dossier { padding: 24px 18px; }
  .dossier-header, .dossier-columns { grid-template-columns: 1fr; }
  .dossier-stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dossier-stamp { justify-self: start; }
  .estimator-controls, .estimator-result { grid-template-columns: 1fr; }
}
