/* Kingshot Tools — shared styles, built on the Web Design system:
   neutral grays, black primary, one orange highlight (#FF5722), Inter, thin borders. */
@font-face{font-family:"Inter";font-style:normal;font-weight:400 900;font-display:swap;src:url(inter-latin.woff2) format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}

/* ---- tokens ---- */
:root,[data-theme="light"]{
  --bg:#fafafa; --card:#ffffff; --raised:#f4f4f5;
  --text:#09090b; --muted:#63636b; --line:#e4e4e7;
  --accent:#ff5722; --accent-bg:#fff3ee; --accent-fg:#ffffff; --accent-ink:#d84315;
  --second:#2563eb; --second-bg:#eff6ff;
  --primary:#09090b; --primary-fg:#fafafa;
  --ok:#15803d; --ok-bg:#f0fdf4;
  --warn:#b45309; --warn-bg:#fffbeb;
  --danger:#c81e1e; --danger-bg:#fef2f2;
  --shadow-card:0 1px 2px rgba(9,9,11,.04);
  --shadow-hover:0 4px 12px -4px rgba(9,9,11,.08);
  --shadow-popover:0 12px 32px -8px rgba(9,9,11,.16);
}
[data-theme="dark"]{
  --bg:#0a0a0a; --card:#111113; --raised:#1c1c1f;
  --text:#fafafa; --muted:#a1a1aa; --line:#27272a;
  --accent:#ff5722; --accent-bg:#2a140c; --accent-fg:#0a0a0a; --accent-ink:#ff5722;
  --second:#60a5fa; --second-bg:#0f1d33;
  --primary:#fafafa; --primary-fg:#09090b;
  --ok:#4ade80; --ok-bg:#0c2417;
  --warn:#fbbf24; --warn-bg:#271c06;
  --danger:#f87171; --danger-bg:#2a1010;
  --shadow-card:none; --shadow-hover:none;
  --shadow-popover:0 12px 32px -8px rgba(0,0,0,.7);
}
:root{
  --space-1:4px; --space-2:8px; --space-3:12px; --space-4:16px; --space-5:24px; --space-6:28px; --space-7:80px;
  --radius:10px; --radius-sm:6px; --radius-xs:4px; --radius-pill:999px;
  --page-max:1080px; --tile-min:260px;
  --font-sans:Inter,system-ui,-apple-system,"Segoe UI",sans-serif;
  --font-mono:ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  /* troop colors: infantry = blue partner, cavalry = orange highlight, archery = green */
  --inf:var(--second); --cav:var(--accent); --arc:var(--ok);
}

/* ---- base ---- */
*,*::before,*::after{box-sizing:border-box}
html{color-scheme:light;background:var(--bg);-webkit-font-smoothing:antialiased}
[data-theme="dark"]{color-scheme:dark}
body{margin:0;background:var(--bg);color:var(--text);font:14px/1.55 var(--font-sans);font-variant-numeric:tabular-nums}
a{color:var(--accent-ink);text-underline-offset:3px}
h1{font-size:24px;font-weight:600;letter-spacing:-.02em;line-height:1.25;margin:0 0 6px;text-wrap:balance}
h2{font-size:16px;font-weight:600;letter-spacing:-.01em;line-height:1.4;margin:0}
.dek{color:var(--muted);margin:0;font-size:14px;max-width:64ch}
.sr,.vhide{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}

/* ---- page shell ---- */
.wrap{max-width:560px;margin:0 auto;padding:0 var(--space-5) var(--space-7);display:flex;flex-direction:column;gap:var(--space-4)}
.wrap>.head{margin-bottom:var(--space-3)}
.tl-bar{position:sticky;top:0;z-index:50;display:flex;align-items:center;justify-content:space-between;gap:var(--space-3);padding:6px 0;background:var(--bg)}
.tl-back{display:inline-flex;align-items:center;gap:6px;padding:10px 0;min-height:44px;font-weight:500;font-size:13px;color:var(--muted);text-decoration:none;transition:color .15s}
.tl-back:hover{color:var(--text)}

/* ---- theme switcher ---- */
.theme-switch{display:inline-flex;gap:2px;padding:3px;background:var(--card);border:1px solid var(--line);border-radius:var(--radius-sm)}
.theme-switch button{display:grid;place-items:center;width:38px;height:34px;padding:0;border:0;border-radius:var(--radius-xs);background:none;color:var(--muted)}
.theme-switch button:hover,.theme-switch button[aria-pressed="true"]{color:var(--text);background:var(--raised)}
.theme-switch svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}

/* ---- controls ---- */
input,select,textarea{font:inherit;font-variant-numeric:tabular-nums;color:var(--text);background:var(--card);border:1px solid var(--line);border-radius:var(--radius-sm);padding:8px 10px;max-width:100%;transition:border-color .15s,box-shadow .15s}
input:focus,select:focus,textarea:focus{outline:none;border-color:var(--text);box-shadow:0 0 0 3px var(--accent-bg);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 35%,transparent)}
input.bad{border-color:var(--danger)}
input.bad:focus{box-shadow:0 0 0 3px var(--danger-bg)}
input[type=number]{-moz-appearance:textfield}
input::-webkit-outer-spin-button,input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}
::placeholder{color:var(--muted);opacity:.8}
select{cursor:pointer}
button{font:inherit;font-size:13px;font-weight:500;cursor:pointer;padding:7px 14px;color:var(--text);background:var(--card);border:1px solid var(--line);border-radius:var(--radius-sm);transition:background .15s,border-color .15s,color .15s}
button:hover{background:var(--raised)}
button:focus-visible,a:focus-visible,[tabindex]:focus-visible{outline:2px solid var(--text);outline-offset:2px}
button:disabled,button[disabled]{opacity:.45;cursor:not-allowed}
button:disabled:hover{background:var(--card)}
button,a,input,select,label{touch-action:manipulation}

/* ---- calculator card ---- */
.cal,.ask{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow-card);padding:var(--space-5);display:flex;flex-direction:column;gap:14px}
.calhead{display:flex;align-items:baseline;justify-content:space-between;gap:4px 12px;flex-wrap:wrap}
.hint{font-size:12.5px;color:var(--muted)}
.calhead .hint{text-align:right}
.hint b{color:var(--text);font-weight:600}
.frow{display:flex;gap:var(--space-3);align-items:flex-end}
.f{display:block;flex:1 1 0;min-width:0}
.f span{display:block;font-size:13px;font-weight:500;color:var(--text);margin-bottom:6px;line-height:1.3}
.f input{width:100%;text-align:center}
.f.inf span::before,.f.cav span::before{content:"";display:inline-block;width:8px;height:8px;border-radius:2px;margin-right:6px;vertical-align:1px}
.f.inf span::before{background:var(--inf)}
.f.cav span::before{background:var(--cav)}
.derived{font-size:12.5px;color:var(--muted);display:flex;flex-wrap:wrap;gap:4px 12px}
.derived b{color:var(--text);font-weight:600}

/* ---- notices ---- */
.est,.good{border-radius:var(--radius-sm);padding:10px 14px;font-size:13px;color:var(--text);border:1px solid}
.est{background:var(--warn-bg);border-color:var(--warn-bg)}
.est strong{color:var(--warn)}
.good{background:var(--ok-bg);border-color:var(--ok-bg)}
.good strong{color:var(--ok)}

/* ---- big input (ask) ---- */
.ask{gap:10px}
.ask>label{font-size:13px;font-weight:500;color:var(--text)}
.ask>input{width:100%;font-size:clamp(28px,9vw,36px);font-weight:600;letter-spacing:-.02em;line-height:1.15;text-align:center;padding:8px 10px}
.pick{display:flex;align-items:center;gap:var(--space-2)}
.pick select{flex:1;min-width:0;font-weight:500}
.pick .step{flex:none;width:40px;height:38px;padding:0;font-size:17px;line-height:1}

/* ---- answer ---- */
.answer{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow-card);padding:20px var(--space-5);display:flex;flex-direction:column;gap:2px;text-align:center}
.answer .cap{font-size:12px;font-weight:500;color:var(--muted)}
.answer .val{font-weight:600;font-size:clamp(36px,12vw,52px);line-height:1.1;letter-spacing:-.03em;color:var(--accent);margin:2px 0}
.answer .unit{font-size:13px;font-weight:500;color:var(--text)}
.answer .why{font-size:12.5px;color:var(--muted);margin-top:6px}

/* ---- bar + legend ---- */
.bar{display:flex;height:8px;border-radius:var(--radius-pill);overflow:hidden;background:var(--raised)}
.bar i{display:block;transition:flex-basis .18s ease-out}
#barInf{background:var(--inf)}
#barCav{background:var(--cav)}
.legend{display:flex;flex-wrap:wrap;gap:4px 14px;font-size:12.5px;color:var(--muted)}
.legend b{color:var(--text);font-weight:600}
.legend .k{display:inline-block;width:8px;height:8px;border-radius:2px;margin-right:6px}

/* ---- table ---- */
.tablewrap{overflow-x:auto;border:1px solid var(--line);border-radius:var(--radius);background:var(--card);box-shadow:var(--shadow-card)}
table{width:100%;border-collapse:collapse}
th,td{font-size:13px;text-align:right;padding:9px 14px;white-space:nowrap;border-bottom:1px solid var(--line)}
th{font-size:12px;font-weight:500;color:var(--muted)}
td:first-child,th:first-child{text-align:left}
tbody tr:last-child td{border-bottom:0}
tbody tr:hover td{background:var(--raised)}
tbody tr.hi td{color:var(--accent-ink);font-weight:600;background:var(--accent-bg)}
tbody tr.rest td{color:var(--warn);font-weight:600;background:var(--warn-bg)}
tbody td.z{color:var(--muted);opacity:.6}

/* ---- footer ---- */
footer{font-size:12.5px;line-height:1.55;color:var(--muted);border-top:1px solid var(--line);padding-top:var(--space-4);margin-top:var(--space-2)}
footer b{color:var(--text);font-weight:600}
footer ul{margin:6px 0 0;padding-left:18px}

/* ---- tool tiles (home page) ---- */
.tool-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(var(--tile-min),1fr));gap:var(--space-3)}
a.tool{display:block;background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:18px 20px;color:inherit;text-decoration:none;box-shadow:var(--shadow-card);transition:border-color .15s,box-shadow .15s}
a.tool:hover{border-color:var(--muted);box-shadow:var(--shadow-hover)}
a.tool b{display:block;font-size:14px;font-weight:600;margin-bottom:4px;color:var(--text)}
a.tool span{display:block;color:var(--muted);font-size:13px}

@media (max-width:600px){
  .wrap{padding-left:var(--space-4);padding-right:var(--space-4)}
  .cal,.ask{padding:var(--space-4)}
  input,select,textarea{font-size:16px}
  th,td{padding-left:10px;padding-right:10px}
}

/* ---- page transitions: cross-fade with a 6px rise ---- */
@view-transition{navigation:auto}
::view-transition-old(root){animation:page-out .16s ease-in both}
::view-transition-new(root){animation:page-in .22s cubic-bezier(.2,.7,.2,1) both}
@keyframes page-out{to{opacity:0}}
@keyframes page-in{from{opacity:0;transform:translateY(6px)}}
@supports not (view-transition-name:none){body{animation:page-in .22s cubic-bezier(.2,.7,.2,1) both}}
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{transition:none!important}
  ::view-transition-old(root),::view-transition-new(root),body{animation:none!important}
}
