:root {
  --bg: #0e0e10; --panel: #17171b; --panel2: #1f1f25; --line: #2c2c34;
  --ink: #e8e8ea; --dim: #9a9aa4; --accent: #b9924a; --accent2: #6d8bbd; --good: #3c5a3c;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
header { text-align: center; padding: 22px 16px 6px; }
h1 { margin: 0 0 4px; font-size: 26px; }
.sub { margin: 0 auto; max-width: 760px; color: var(--dim); font-size: 13px; }

.controls {
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: center;
  padding: 18px 16px; max-width: 1100px; margin: 0 auto;
}
.controls label, .controls .field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--dim); min-width: 220px; }
.controls label.grow, .controls .field.grow { flex: 1 1 360px; }
.lbl { font-size: 12px; color: var(--dim); }
.toggles { display: flex; justify-content: center; gap: 18px; padding: 0 16px 10px; }
.toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--dim); cursor: pointer; }
.toggle input { accent-color: var(--accent2); cursor: pointer; }
select {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px; font-size: 14px;
}
select:disabled { opacity: .5; }

.sheet { max-width: 1000px; margin: 0 auto 60px; padding: 0 16px; display: flex; flex-direction: column; gap: 22px; }
.groupHead { margin: 10px 0 -6px; padding-bottom: 6px; border-bottom: 2px solid var(--accent2); font-size: 20px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.card > h2 {
  margin: 0; padding: 12px 16px; font-size: 20px; letter-spacing: .03em;
  background: #26262e; border-bottom: 1px solid var(--line);
}
.card .meta { padding: 6px 16px; color: var(--dim); font-size: 13px; display: flex; flex-wrap: wrap; gap: 16px; }
.card .meta b { color: var(--ink); }

.stats { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px; }
.stat { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; width: 64px; text-align: center; padding: 6px 4px; }
.stat .v { font-size: 18px; font-weight: 600; }
.stat .k { font-size: 9px; color: var(--dim); line-height: 1.15; margin-top: 2px; }
.modelName { padding: 2px 16px; color: var(--accent); font-weight: 600; font-size: 13px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 16px; border-top: 1px solid var(--line); }
thead th { background: #2a2a32; color: var(--accent2); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; border-top: none; }
.sectionTitle { padding: 12px 16px 2px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent2); }

.rules { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; padding: 12px 16px; }
.rule { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.rule .rh { background: var(--good); padding: 6px 10px; font-weight: 600; font-size: 13px; }
.rule .rh[data-rule] { cursor: pointer; }
.spellNum { display: inline-block; min-width: 1.4em; text-align: center; padding: 0 5px; margin-right: 4px; border-radius: 4px; background: rgba(255,255,255,.12); font-size: 11px; }
.rule.rolled { outline: 2px solid var(--accent2); }
.rule.rolled .rh { background: var(--accent2); color: #0b0d12; }
.rule .rb { padding: 8px 10px; font-size: 12.5px; color: #d7d7db; white-space: pre-wrap; }

.opts { padding: 8px 16px 14px; }
.optGroup { margin: 8px 0; }
.optGroup .gh { color: var(--accent); font-weight: 600; font-size: 13px; }
.optGroup .gh .choose { color: var(--dim); font-weight: 400; font-size: 12px; }
.choiceRow { display: flex; flex-wrap: wrap; gap: 6px; margin: 5px 0 0; }
.opt { background: var(--panel2); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; font-size: 12.5px; cursor: pointer; }
.opt:hover { border-color: var(--accent); }
.opt.on { background: var(--accent); border-color: var(--accent); color: #18120a; font-weight: 600; }
.opt.on .pts { color: #18120a; }
.pts { color: var(--accent); }

/* weapon filter chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 16px 2px; }
.chip { background: var(--accent2); color: #0c1320; border: 1px solid var(--accent2); border-radius: 999px; padding: 4px 11px; font-size: 12.5px; cursor: pointer; font-weight: 600; }
.chip:not(.on) { background: var(--panel2); color: var(--dim); border-color: var(--line); font-weight: 400; }
.chip.ghost { background: transparent; color: var(--accent2); border-color: var(--accent2); font-weight: 400; float: right; }
.hint { color: var(--dim); font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 11px; }
.hint.pad { display: block; padding: 8px 16px; }

/* stat legend (full names, compact) */
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 2px 16px 4px; color: var(--dim); font-size: 11px; }
.legend b { color: var(--accent2); }

.tally { font-size: 12px; color: var(--accent); font-weight: 500; margin-left: 8px; vertical-align: middle; }
.x { float: right; background: transparent; border: none; color: var(--dim); font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px; }
.x:hover { color: #e87; }

.kw { padding: 10px 16px 16px; color: var(--dim); font-size: 12.5px; }
.kw b { color: var(--ink); }
.tags { display: inline-flex; flex-wrap: wrap; gap: 5px; }
.tag { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; color: #c8c8d0; font-size: 11.5px; }
.empty { color: var(--dim); text-align: center; padding: 40px; }

/* inline rule cross-links + modal */
.ruleref { background: none; border: none; color: var(--accent2); font: inherit; padding: 0; cursor: pointer; border-bottom: 1px dotted var(--accent2); }
.ruleref:hover { color: #9fb6da; }
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .62); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal[hidden] { display: none; }
.modalCard { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; max-width: 560px; max-height: 80vh; overflow: auto; position: relative; }
.modalCard h2 { margin: 0; padding: 14px 40px 14px 18px; font-size: 19px; background: #26262e; border-bottom: 1px solid var(--line); }
.modalText { padding: 14px 18px; font-size: 14px; white-space: pre-wrap; }
.modalClose { position: absolute; top: 8px; right: 12px; background: none; border: none; color: var(--dim); font-size: 24px; line-height: 1; cursor: pointer; }
.modalClose:hover { color: var(--ink); }

/* report button + anonymous feedback form */
.reportBtn { margin-top: 10px; background: var(--panel2); color: var(--accent2); border: 1px solid var(--accent2); border-radius: 8px; padding: 5px 14px; font-size: 13px; cursor: pointer; }
.reportBtn:hover { background: var(--accent2); color: #0c1320; }
.fbCard { max-width: 540px; padding-bottom: 16px; }
.fbForm { display: flex; flex-direction: column; gap: 10px; padding: 14px 18px 0; }
.fbForm > label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--dim); }
.fbForm input, .fbForm select, .fbForm textarea { background: var(--panel2); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 14px; }
.fbForm textarea { resize: vertical; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.fbActions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.fbActions .hint { margin-right: auto; }
.fbActions button { background: var(--accent2); color: #0c1320; border: none; border-radius: 8px; padding: 8px 18px; font-weight: 600; cursor: pointer; }
.fbActions button:disabled { opacity: .6; cursor: default; }

/* unit search combobox (ageofindex-style): pills live inside the input, which grows as they wrap */
.combo { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; min-height: 40px; position: relative; }
.combo:focus-within { border-color: var(--accent2); }
.cChips { display: contents; }
.cInput { flex: 1 1 90px; min-width: 90px; background: transparent; border: none; color: var(--ink); font-size: 14px; outline: none; padding: 4px 2px; }
.cInput:disabled { cursor: not-allowed; }
.cMenu { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; max-height: 280px; overflow: auto; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }
.cMenu[hidden] { display: none; }
.comboItem { padding: 8px 12px; font-size: 14px; cursor: pointer; }
.comboItem:hover { background: var(--panel2); color: var(--accent); }
.comboNone { padding: 8px 12px; font-size: 13px; color: var(--dim); }
.uchip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel2); border: 1px solid var(--accent2); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 13px; }
.uchip button { background: #33333c; border: none; color: var(--dim); border-radius: 999px; width: 18px; height: 18px; line-height: 1; cursor: pointer; font-size: 14px; }
.uchip button:hover { color: #e87; }
.cClear { background: transparent; color: var(--dim); border: 1px dashed var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.cClear:hover { color: #e87; border-color: #e87; }

/* auto-update banner */
#updateBanner { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--accent2); color: #0c1320; padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,.4); z-index: 60; }
#updateBanner button { margin-left: 10px; background: #0c1320; color: #fff; border: none; border-radius: 7px; padding: 5px 12px; cursor: pointer; font-weight: 600; }
