:root {
  --walnut: #2b1d12; --walnut2: #3b2819; --paper: #efe6d0; --paper2: #e5d9bd; --ink: #2a2118; --muted: #7a6a55;
  --brass: #c9a24a; --brass2: #e8c66a; --us: #2e4a86; --cs: #8b2a22; --rule: #b9a47e; --bad: #9b2a1f; --warn: #9a6a10;
  --left: 300px; --right: 244px; --top: 52px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--walnut); color: var(--ink); font: 13px/1.4 Georgia, 'Times New Roman', serif; overflow: hidden; }
button { font: inherit; }
#top { height: var(--top); overflow: hidden; display: flex; align-items: center; gap: 14px; padding: 0 12px; background: linear-gradient(#3b2819, #24180f); color: #f1e4c4; border-bottom: 2px solid var(--brass); }
.brand { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: .5px; font-variant: small-caps; color: #f6e8c4; }
.ver { font-size: 11px; color: var(--walnut); background: var(--brass); border-radius: 3px; padding: 1px 5px; font-family: Georgia, serif; }
.sub { font-style: italic; color: #d9c69c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.clock { margin-left: auto; white-space: nowrap; }
.clock .muted { color: #b8a57f; }
.side-pill { padding: 4px 10px; border-radius: 12px; font-weight: bold; white-space: nowrap; border: 1px solid #0006; }
.side-pill.US { background: var(--us); color: #fff; }
.side-pill.CS { background: #9a978c; color: #1b1a16; }
.drawer-toggle { display: none; background: var(--walnut2); color: #f1e4c4; border: 1px solid var(--brass); border-radius: 4px; padding: 5px 9px; cursor: pointer; }
#main { position: absolute; top: calc(var(--top) + 2px); left: 0; right: 0; bottom: 0; overflow: hidden; display: grid; grid-template-columns: var(--left) 1fr var(--right); }
.panel { background: var(--paper); overflow-y: auto; overflow-x: hidden; border-right: 1px solid var(--rule); padding: 8px 10px 16px; }
#right { border-right: 0; border-left: 1px solid var(--rule); }
.panel section { margin-bottom: 12px; }
.panel h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--walnut2); margin: 4px 0 6px; padding-bottom: 3px; border-bottom: 1px solid var(--rule); font-weight: normal; }
.muted { color: var(--muted); } .small { font-size: 11.5px; } .bad { color: var(--bad); } .warn { color: var(--warn); }
#mapwrap { position: relative; overflow: hidden; background: #b9a988; touch-action: none; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
#tip { position: absolute; pointer-events: none; background: #f7efdcee; border: 1px solid var(--walnut2); border-radius: 4px; padding: 5px 8px; max-width: 240px; box-shadow: 0 2px 8px #0005; font-size: 12px; }
#tip[hidden] { display: none; }
#banner { position: absolute; top: 14px; left: 50%; transform: translate(-50%, -20px); background: #24180fe6; color: #f6e8c4; padding: 8px 18px; border: 1px solid var(--brass); border-radius: 4px; opacity: 0; transition: all .35s; pointer-events: none; font-size: 15px; white-space: nowrap; }
#banner.on { opacity: 1; transform: translate(-50%, 0); }
button { background: #f8f0dc; border: 1px solid #9c8762; border-radius: 4px; padding: 6px 7px; cursor: pointer; color: var(--ink); }
button:hover:not(:disabled) { background: #fff7e3; border-color: var(--walnut2); }
button:disabled { opacity: .45; cursor: default; }
button.on { background: #f3d58a; border-color: var(--warn); }
button.big { width: 100%; padding: 10px; font-size: 15px; background: linear-gradient(#4a321f, #2b1d12); color: #f6e8c4; border: 1px solid var(--brass); }
button.big:hover:not(:disabled) { background: linear-gradient(#5a3d26, #33231a); }
kbd { font: 10px monospace; color: var(--muted); border: 1px solid #c8b58f; border-radius: 3px; padding: 0 3px; float: right; margin-top: 2px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.grid2 button { text-align: left; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 6px; margin-top: 7px; font-size: 12px; }
.opts label.wide { grid-column: 1 / -1; }
.opts label { cursor: pointer; }
select { font: inherit; background: #fbf5e6; border: 1px solid #9c8762; border-radius: 3px; }
/* selected card */
.selhead { display: flex; gap: 9px; align-items: center; margin-bottom: 6px; }
.selhead .nm { font-weight: bold; font-size: 14px; }
.chain { font-size: 11.5px; color: var(--muted); font-style: italic; }
.ctr { width: 44px; height: 38px; flex: none; border: 2px solid #111; border-top-width: 6px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 1px; font-size: 12px; }
.ctr.US { background: var(--us); color: #f4f1e6; border-color: #16284d; border-top-color: #0f1c38; }
.ctr.CS { background: #8d8c83; color: #1c1b18; border-color: #3e3d38; border-top-color: #7a1f1a; }
.ctr.rout { background: #b14a3a; color: #fff; }
.ctr.horses { background: #7a5230; font-size: 20px; justify-content: center; }
.sym { display: block; width: 26px; height: 12px; border: 1.5px solid currentColor; position: relative; margin-bottom: 2px; }
.sym.inf { background: linear-gradient(to top right, transparent 46%, currentColor 48%, currentColor 52%, transparent 54%), linear-gradient(to bottom right, transparent 46%, currentColor 48%, currentColor 52%, transparent 54%); }
.sym.cav { background: linear-gradient(to top right, transparent 46%, currentColor 48%, currentColor 52%, transparent 54%); }
.sym.art::after { content: ''; position: absolute; left: 50%; top: 50%; width: 5px; height: 5px; margin: -2.5px; border-radius: 50%; background: currentColor; }
.ldr { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 3px solid; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 9px; line-height: 1; }
.ldr.US { background: #dfe6f5; border-color: var(--us); color: var(--us); }
.ldr.CS { background: #efe9dc; border-color: #8d8c83; color: var(--cs); }
.ldr b { font-size: 13px; }
table.kv { width: 100%; border-collapse: collapse; font-size: 12px; }
table.kv th { text-align: left; font-weight: normal; color: var(--muted); padding: 1px 6px 1px 0; vertical-align: top; white-space: nowrap; width: 1%; }
table.kv td { padding: 1px 0; }
.also { margin-top: 5px; font-size: 12px; }
.also a { color: var(--us); }
/* casualty return: the ruled slip */
.slip { background: #fbf6e8; border: 1px solid #b9a47e; box-shadow: inset 0 0 0 3px #fbf6e8, inset 0 0 0 4px #d8c69f; padding: 7px 9px; }
.slip .sh { font-variant: small-caps; letter-spacing: 1px; color: var(--walnut2); border-bottom: 1px double #b9a47e; margin-bottom: 4px; }
.slip .who { font-size: 12.5px; margin-bottom: 4px; }
.sd { display: inline-block; font-size: 9.5px; font-weight: bold; padding: 0 3px; border-radius: 2px; margin-right: 3px; vertical-align: 1px; }
.sd.US { background: var(--us); color: #fff; } .sd.CS { background: #9a978c; color: #1b1a16; }
table.ruled { width: 100%; border-collapse: collapse; font-size: 12px; }
table.ruled td { border-bottom: 1px solid #e3d6b8; padding: 2px 0; background-image: linear-gradient(to right, transparent 0, transparent 100%); }
table.ruled td.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 6px; }
table.ruled tr.sum td { border-top: 1px solid #b9a47e; font-style: italic; }
table.ruled tr.tot td { border-top: 2px solid var(--walnut2); border-bottom: 0; font-weight: bold; font-size: 13px; }
.die { display: inline-block; width: 17px; height: 17px; line-height: 15px; text-align: center; border: 1px solid #5a4630; border-radius: 3px; background: #fffdf6; font-weight: bold; font-size: 11px; margin: 0 1px; }
.morale, .slsub, .out { font-size: 12px; margin-top: 5px; color: var(--ink); }
.out { font-weight: bold; }
ul.ev { margin: 5px 0 0 16px; padding: 0; font-size: 12px; }
/* brigade return */
.bdehead { margin-bottom: 4px; }
.gauge { position: relative; height: 18px; background: #e3d6b8; border: 1px solid #b9a47e; margin: 4px 0 6px; }
.gauge .fill { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(#c05a40, #9b2a1f); }
.gauge .mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--walnut); }
.gauge span { position: absolute; left: 6px; top: 1px; font-size: 11px; color: #1b130b; text-shadow: 0 0 3px #f5ecd6; }
table.roster { width: 100%; border-collapse: collapse; font-size: 12px; }
table.roster tr { cursor: pointer; } table.roster tr:hover td { background: #f7eed8; } table.roster tr.cur td { background: #f3dc9e; }
table.roster td { padding: 1px 3px; }
.bar { height: 7px; background: #e3d6b8; min-width: 60px; } .bar div { height: 100%; background: #6f8458; }
td.st { width: 14px; font-weight: bold; text-align: center; } td.st.dis { color: var(--warn); } td.st.rout, td.st.gone { color: var(--bad); }
.farm { font-style: italic; } .obj { color: var(--cs); }
#log { font-size: 11.5px; max-height: 260px; overflow-y: auto; }
#log .l { padding: 1px 0; border-bottom: 1px dotted #d8c9a6; }
#log .t { color: var(--muted); font-size: 10.5px; }
#log .h { font-weight: bold; } #log .lead { color: var(--cs); font-weight: bold; } #log .wreck { color: var(--bad); } #log .cap { color: #6b3c80; } #log .obj { color: var(--us); font-weight: bold; } #log .arr { color: #3a6a2a; }
.vpline { font-size: 16px; }
ul.objs { list-style: none; margin: 5px 0; padding: 0; font-size: 12px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; border: 1px solid #0005; }
.dot.US { background: var(--us); } .dot.CS { background: var(--cs); } .dot.none { background: #e8dcc0; }
/* modal sheets */
#modal { position: fixed; inset: 0; background: #140c06b3; display: flex; align-items: flex-start; justify-content: center; z-index: 50; overflow-y: auto; padding: 24px 12px; }
#modal[hidden] { display: none; }
.sheet { background: var(--paper); max-width: 860px; width: 100%; border: 2px solid var(--brass); box-shadow: 0 10px 40px #000a; padding: 18px 22px; }
.title h1 { font-variant: small-caps; margin: 0; font-size: 34px; letter-spacing: 1px; color: var(--walnut); }
.title .ver { font-size: 13px; vertical-align: middle; }
.epi { font-style: italic; color: var(--muted); margin: 2px 0 8px; }
.lede { margin: 0 0 12px; }
.scs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sc { display: flex; gap: 8px; border: 1px solid var(--rule); padding: 8px; cursor: pointer; background: #f8f0dc; }
.sc:has(input:checked) { border-color: var(--walnut2); background: #fff7e3; box-shadow: 0 0 0 2px var(--brass); }
.scn { font-weight: bold; font-size: 14px; } .scsub { font-style: italic; color: var(--muted); font-size: 12px; } .scb { font-size: 12px; margin-top: 3px; }
.size { font-weight: normal; font-size: 10.5px; background: var(--walnut2); color: #f1e4c4; padding: 0 5px; border-radius: 3px; vertical-align: 2px; }
.cmdrow { margin: 12px 0; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.btnrow button.big { width: auto; padding: 10px 22px; }
.rules p { margin: 6px 0; }
.end .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.end h2 { font-variant: small-caps; font-size: 26px; margin: 0; }
.end h3 { font-size: 14px; }
.threat { color: var(--bad); font-weight: bold; }
.course { margin: 10px 0 4px; } .course h3 { margin: 6px 0 2px; } .course svg { width: 100%; height: auto; display: block; background: #fbf6e8; border: 1px solid var(--rule); }
.course .key { font-size: 11.5px; } .course .key i { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin: 0 4px 0 10px; }
/* narrower screens */
@media (max-width: 1150px) { :root { --left: 262px; --right: 214px; } .sub { display: none; } }
@media (max-width: 860px) {
  :root { --top: 48px; }
  .drawer-toggle { display: inline-block; }
  .brand h1 { font-size: 16px; }
  .clock .muted, .clock b { display: none; }
  #main { grid-template-columns: 1fr; }
  #mapwrap { grid-column: 1; }
  .panel { position: absolute; top: 0; bottom: 0; z-index: 20; width: min(310px, 86vw); box-shadow: 0 0 24px #000a; transition: transform .25s; }
  #left { left: 0; transform: translateX(-105%); }
  #right { right: 0; transform: translateX(105%); }
  body.show-left #left { transform: none; }
  body.show-right #right { transform: none; }
  .scs, .end .cols { grid-template-columns: 1fr; }
  .title h1 { font-size: 26px; }
}
@media (max-width: 520px) { .side-pill, .clock { display: none; } .drawer-toggle .t { display: none; } .brand h1 { font-size: 15px; } #top { gap: 8px; padding: 0 8px; } .drawer-toggle:last-child { margin-left: auto; } }
@media (prefers-reduced-motion: reduce) { .panel, #banner { transition: none; } }

#mini { width: 100%; max-width: 220px; margin: 0 auto; display: block; border: 1px solid var(--rule); cursor: pointer; background: #d4cd9f; touch-action: none; }
.opts.one { grid-template-columns: 1fr; max-height: 150px; overflow-y: auto; }

#delegBox summary { cursor: pointer; list-style: none; }
#delegBox summary::-webkit-details-marker { display: none; }
#delegBox summary h2::after { content: ' ▸'; }
#delegBox[open] summary h2::after { content: ' ▾'; }
@media (max-height: 860px) and (min-width: 861px) {
  .panel section { margin-bottom: 7px; }
  .panel h2 { margin: 2px 0 4px; }
  #right button { padding: 4px 6px; }
  button.big { padding: 7px; font-size: 14px; }
  .opts { margin-top: 4px; gap: 1px 6px; }
}

button.wide { width: 100%; margin-top: 5px; }
.coord { font-variant: small-caps; color: var(--muted); font-size: 11.5px; }
#opt_volume { width: 70px; vertical-align: middle; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible, canvas:focus-visible { outline: 2px solid #c9a24a; outline-offset: 2px; }
.hdrbtn { background: var(--walnut2); color: #f1e4c4; border: 1px solid var(--brass); border-radius: 4px; padding: 3px 8px; font-size: 16px; line-height: 1; }
.hdrbtn:hover:not(:disabled) { background: #4a321f; color: #fff; }
