:root {
  color-scheme: light;
  --ink: #193a43;
  --brand: #155164;
  --muted: #48646c;
  --edge: #cbdcde;
  --ice: #edf5f5;
  --paper: #fff;
  --width: 78rem;
  --gutter: clamp(12px, 2.5vw, 28px);
  font: 16px/1.5 'Atkinson Hyperlegible Next','Source Sans 3','PingFang SC','Microsoft YaHei',sans-serif;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: #eaf1f1;
}
* { box-sizing: border-box; }
body, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
button, input, select { color: inherit; font: inherit; }
button, select { cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
:where(a, button, select, input):focus-visible { outline: 3px solid #277a8d; outline-offset: 2px; }
.hint, small { color: var(--muted); font-size: .85rem; }

/* Page identity and jump links. Both destinations remain reachable on a small screen. */
.bear-page .site-header {
  max-width: var(--width); margin: 0 auto; padding: 16px var(--gutter);
  grid-template-columns: minmax(0, 1fr) auto; gap: 8px;
  border-bottom: 1px solid #b5cacc;
}
.bear-page .page-title { display: flex; align-items: center; gap: 12px; font-size: clamp(1.3rem, 2.3vw, 1.85rem); font-weight: 720; }
.bear-page .page-title::before {
  content: ''; flex: none; width: 46px; height: 46px; border-radius: 12px;
  background: #d4e7ec url('./bear-art/trap.webp') center / 320% auto no-repeat;
  box-shadow: inset 0 0 0 1px #b6cfd3;
}
.bear-page .site-home { color: var(--muted); }
.bear-jumps {
  position: sticky; top: 0; z-index: 3; display: flex; justify-content: center; gap: 1.5rem;
  padding-inline: var(--gutter); background: #f6faf9; border-bottom: 1px solid var(--edge);
}
.bear-jumps a { padding: 11px 8px; min-height: 44px; color: var(--brand); font-size: .9rem; font-weight: 650; text-decoration: none; }
.bear-jumps a[aria-current=location] { box-shadow: inset 0 -3px var(--brand); }
.bear-jumps a:hover, .bear-jumps a:focus-visible { text-decoration: underline; text-underline-offset: 4px; }
main {
  max-width: var(--width); margin: auto; padding: 14px max(var(--gutter),env(safe-area-inset-right)) 32px max(var(--gutter),env(safe-area-inset-left));
  display: grid; align-items: start; gap: 16px;
}
main > section {
  min-width: 0; scroll-margin-top: 54px; padding: clamp(14px, 2vw, 24px);
  background: var(--paper); border: 1px solid var(--edge); border-radius: 14px;
}
h2 { font-size: 1.25rem; line-height: 1.4; }
h3 { font-size: 1rem; }
.force-config > .hint { margin-top: 4px; }
.imports { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); align-items: start; gap: 6px; margin: 12px 0 16px; }
.imports button, .section-heading button { min-height: 44px; border: 1px solid var(--edge); border-radius: 7px; background: #fff; }
.imports button { width: 100%; padding: 0 2px; font-size: .9rem; white-space: nowrap; }
.imports .import-action { background: #eaf4f4; border-color: #a8c6cc; }
.imports small:not(:empty) { display: block; margin-top: 4px; }
.army-stock { background: #f4f8f8; border-radius: 8px; padding: 0 10px; }
.troop-row { display: grid; grid-template-columns: 34px max-content minmax(0,1fr); align-items: center; gap: 8px; min-height: 52px; font-weight: 650; }
.troop-row + .troop-row, .buff-row + .buff-row { border-top: 1px solid var(--edge); }
.troop-row img { width: 32px; height: 36px; object-fit: contain; }
.force-config input[type=number] {
  justify-self: end; width: 100%; min-width: 0; max-width: 12rem; height: 44px;
  padding: 0 9px; background: #fff; border: 1px solid #b3c9cd; border-radius: 6px;
  text-align: right; font-size: 1rem; font-weight: 630; appearance: textfield; -moz-appearance: textfield;
}
.force-config input::-webkit-inner-spin-button, .force-config input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.march-capacity { margin-top: 16px; }
.cap-base { display: grid; grid-template-columns: 1fr minmax(6rem, 43%); align-items: center; gap: 8px; font-weight: 650; }
.buffs { margin: 10px 0; border-top: 1px solid var(--edge); }
.buff-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 8px; padding: 6px 0; }
.buff-title { display: grid; gap: 1px; font-size: .9rem; font-weight: 600; }
.buff-title strong { color: var(--brand); font-size: .8rem; }
.buff-picker { position: relative; }
.buff-picker::after { content: ''; position: absolute; right: .8rem; top: 48%; width: 6px; height: 6px; border: solid var(--brand); border-width: 0 1.5px 1.5px 0; transform: translateY(-50%) rotate(45deg); pointer-events: none; }
.buff-picker select { appearance: none; min-height: 44px; padding: 0 1.9rem 0 .7rem; border: 1px solid #b3c9cd; border-radius: 7px; background: #f6fafa; color: var(--brand); font-size: 1rem; font-weight: 600; }
.capacity-total { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; background: #174554; color: white; padding: 10px 13px; border-radius: 7px; }
.capacity-total span { font-size: .9rem; }
.capacity-total b { font-size: 1.3rem; line-height: 1.25; }

/* The number is the value to enter in-game; the ratio is secondary. */
.plan-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.own-mode-switch { position: relative; flex: 1 0 12rem; max-width: 18rem; min-height: 44px; background: #e5efef; border-radius: 8px; }
.own-mode-labels { position: absolute; inset: 3px; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); pointer-events: none; }
.own-mode-labels span { display: grid; place-items: center; border-radius: 6px; color: var(--muted); font-size: .88rem; font-weight: 650; }
.own-mode-labels .is-selected { background: var(--brand); color: white; }
#own-mode { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; appearance: none; -webkit-appearance: none; opacity: 0; cursor: pointer; touch-action: pan-y; }
#own-mode::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 50%; height: 44px; }
#own-mode::-moz-range-thumb { width: 50%; height: 44px; border: 0; }
.own-mode-switch:has(:focus-visible) { outline: 3px solid #277a8d; outline-offset: 2px; }
#plan-message:not(:empty) { padding: 10px 12px; margin-top: 14px; border-left: 3px solid #ae8248; background: #faf5eb; color: #654c2f; border-radius: 2px; font-size: .9rem; }
#teams { display: grid; gap: 10px; margin: 16px 0 0; padding: 0; list-style: none; }
.march { min-width: 0; border: 1px solid var(--edge); border-radius: 9px; overflow: hidden; }
.march-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 3px 8px; padding: 7px 10px; background: #eef5f5; }
.march-title { display: flex; align-items: center; gap: 6px; line-height: 1.3; }
.march-title img { height: 30px; width: 27px; object-fit: contain; }
.march-title .team-no { font-size: .85rem; color: var(--muted); font-weight: 550; }
.march[data-role=driver] { border-color: #d6c8ab; }
.march[data-role=driver] .march-head { background: #f6f0e4; }
.march-head small { white-space: nowrap; font-size: .8rem; }
.march-body { padding: 8px 10px 10px; }
.soldier-line { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; }
.soldier-line > div { min-width: 0; }
.soldier-line small { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 4px; font-size: .77rem; }
.soldier-line strong { display: block; font-size: clamp(.94rem, 3.7vw, 1.12rem); line-height: 1.35; letter-spacing: -.025em; }
.troop-stats { width: 100%; margin-top: 18px; border-collapse: collapse; }
.troop-stats th, .troop-stats td { text-align: center; padding: 7px 6px; }
.troop-stats td:nth-child(3) { white-space: nowrap; }
.troop-stats thead { background: #eff5f5; color: var(--muted); font-size: .85rem; }
.troop-stats tbody tr { border-bottom: 1px solid var(--edge); }
.troop-stats tfoot { color: var(--brand); font-weight: 700; border-top: 2px solid #9ab9bf; }
.troop-stats th[scope=row] { white-space: nowrap; }

.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.section-heading button { padding-inline: 12px; }
#sample-dialog { width: min(42rem,calc(100% - 24px)); height: min(90dvh,52rem); margin: auto; padding: 16px; border: 0; border-radius: 14px; background: var(--paper); color: var(--ink); }
#sample-dialog[open] { display: grid; grid-template-rows: auto minmax(0,1fr) auto; gap: 12px; overflow: hidden; }
.sample-images { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; min-height: 0; }
.sample-images img { width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; }
:root:has(#sample-dialog[open]) { overflow: hidden; }
@media (max-width: 24rem) {
  main { padding-inline: 8px; }
  main > section { padding: 12px; }
  .bear-page .site-header { padding-block: 10px; }
  .own-mode-switch { flex-basis: 10rem; }
  .troop-stats { font-size: .875rem; }
  .troop-stats th, .troop-stats td { padding-inline: 3px; }
}
@media (min-width: 40rem) and (max-width: 59.99rem) {
  #teams { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (min-width: 60rem) {
  .bear-jumps { display: none; }
  main { grid-template-columns: minmax(19rem,.85fr) minmax(0,1.65fr); gap: 20px; padding-top: 20px; }
  .force-config { position: sticky; top: 12px; }
  main > section { scroll-margin-top: 12px; }
}
@media (min-width: 72rem) {
  #teams { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-height: 46rem) { .force-config { position: static; } }
@media (forced-colors: active) {
  .buff-picker select { appearance: auto; }
  .buff-picker::after { display: none; }
  .own-mode-labels .is-selected { border: 2px solid Highlight; }
}
