/* Ratmancer Damage Calculator: cogitator theme, matched to the Throne Ledger. */
:root {
  --bg: #0a0c0d;
  --panel: #12171a;
  --panel2: #0d1113;
  --line: #3a2f19;
  --line2: #241d10;
  --amber: #ffb000;
  --amber-dim: #d8a338;
  --gold: #d4af37;
  --green: #3ddc6a;
  --red: #ff4d4d;
  --text: #e8d9b5;
  --muted: #a8915f;
  --faint: #7d6c49;
}

html body {
  font-family: "Share Tech Mono", ui-monospace, monospace;
  background-color: var(--bg);
  color: var(--text);
  background-image:
    radial-gradient(ellipse 70% 45% at 50% -8%, rgba(255, 176, 0, .10), transparent 70%),
    radial-gradient(rgba(40, 32, 12, .38) 1px, transparent 0);
  background-size: 100% 100%, 22px 22px;
  background-attachment: fixed, scroll;
}
html body .font-serif, .rm-cinzel { font-family: "Cinzel", serif !important; letter-spacing: .04em; }
html body .font-sans { font-family: "Share Tech Mono", ui-monospace, monospace; }

/* Warm the stock greys so everything reads as amber phosphor. */
html body .text-gray-100, html body .text-gray-200 { color: #e8d9b5; }
html body .text-gray-300 { color: #d6c39a; }
html body .text-gray-400 { color: #b9a274; }
html body .text-gray-500 { color: var(--muted); }
html body .text-gray-600 { color: var(--faint); }

::selection { background: rgba(255, 176, 0, .35); color: #fff; }
* { scrollbar-color: #3a2f19 #0a0c0d; }

/* ── inputs ─────────────────────────────────────────────────────── */
.rm-input {
  min-width: 0;
  background: rgba(6, 8, 9, .88);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.rm-input:hover { border-color: #57451f; }
.rm-input:focus { border-color: var(--amber); box-shadow: 0 0 0 1px rgba(255, 176, 0, .25), 0 0 14px -4px rgba(255, 176, 0, .7); }
.rm-input.bad { border-color: #b8312f; box-shadow: 0 0 10px -4px #ff4d4d; }
select.rm-input option, select.rm-input optgroup { background: #0d1113; color: var(--text); }
input[type="number"].rm-input { font-variant-numeric: tabular-nums; }
input[type="checkbox"] { accent-color: var(--amber); }

.rm-label { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--amber-dim); }

/* ── buttons ────────────────────────────────────────────────────── */
.rm-btn {
  font-family: inherit;
  font-size: 12px;
  letter-spacing: .04em;
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: #191f22;
  color: var(--text);
  cursor: pointer;
  transition: .12s;
  white-space: nowrap;
}
.rm-btn:hover:not(:disabled) { background: #232a2e; border-color: var(--amber-dim); color: var(--amber); }
.rm-btn:disabled { opacity: .4; cursor: not-allowed; }
.rm-btn.primary { background: var(--amber); color: #120d00; border-color: var(--amber); font-weight: bold; box-shadow: 0 0 14px -3px rgba(255, 176, 0, .6); }
.rm-btn.primary:hover:not(:disabled) { background: #ffc333; color: #120d00; }
.rm-btn.on { background: #2a2113; color: var(--amber); border-color: var(--amber); box-shadow: 0 0 12px -3px rgba(255, 176, 0, .55); }
.rm-btn.dashed { border-style: dashed; background: transparent; color: var(--muted); }
.rm-btn.dashed:hover { color: var(--amber); }
.rm-btn.gold { border-color: rgba(212, 175, 55, .55); color: #f0d78a; background: rgba(212, 175, 55, .06); }
.rm-btn.sm { padding: 3px 8px; font-size: 11px; }

.rm-seg { display: flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.rm-seg button { font-family: inherit; font-size: 12px; padding: 6px 11px; background: #12171a; color: var(--muted); border: 0; cursor: pointer; transition: .12s; }
.rm-seg button + button { border-left: 1px solid var(--line); }
.rm-seg button:hover { color: var(--amber); }
.rm-seg button.on { background: #2a2113; color: var(--amber); box-shadow: inset 0 -2px 0 var(--amber); text-shadow: 0 0 8px rgba(255, 176, 0, .55); }

.rm-pill {
  font-family: inherit;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 3px 9px;
  border-radius: 99px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(0, 0, 0, .35);
  cursor: pointer;
  transition: .12s;
  white-space: nowrap;
}
.rm-pill:hover { border-color: var(--amber-dim); color: var(--text); }
.rm-pill.on { color: var(--amber); border-color: var(--amber); background: rgba(255, 176, 0, .12); text-shadow: 0 0 6px rgba(255, 176, 0, .6); box-shadow: 0 0 10px -4px rgba(255, 176, 0, .7); }

.rm-tag {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 2px 7px;
  border-radius: 99px;
  border: 1px solid var(--fc, var(--amber));
  color: var(--fc, var(--amber));
  background: rgba(0, 0, 0, .4);
  white-space: nowrap;
}

.rm-icon-btn {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: .12s;
}
.rm-icon-btn:hover { color: var(--amber); border-color: var(--line); background: rgba(255, 176, 0, .06); }
.rm-icon-btn.danger:hover { color: #ff7b7b; border-color: #6b2020; background: rgba(255, 77, 77, .08); }

/* ── panels with ledger-style headers ───────────────────────────── */
.rm-panel {
  position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, .018), transparent 120px), var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .55), 0 18px 40px -26px #000, inset 0 1px 0 rgba(255, 176, 0, .07);
}
.rm-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px 10px;
  background: linear-gradient(90deg, rgba(255, 176, 0, .17), rgba(255, 176, 0, .05) 45%, transparent 85%);
  border-bottom: 1px solid rgba(255, 176, 0, .28);
}
.rm-head::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 4px;
  background: repeating-linear-gradient(135deg, var(--hc, var(--amber)) 0 9px, transparent 9px 18px);
  opacity: .5;
}
.rm-head::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 46px;
  height: 6px;
  transform: translateY(-50%);
  background: radial-gradient(circle, rgba(255, 176, 0, .35) 1.5px, transparent 2px) 0 0 / 11px 6px repeat-x;
  pointer-events: none;
}
.rm-head.click { cursor: pointer; }
.rm-head.click:hover { background: linear-gradient(90deg, rgba(255, 176, 0, .22), rgba(255, 176, 0, .07) 45%, transparent 85%); }
.rm-head h2 {
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--gold);
  line-height: 1.2;
  text-shadow: 0 0 14px rgba(212, 175, 55, .4);
}
.rm-head .rm-sub { font-size: 11px; color: var(--muted); margin-top: 2px; letter-spacing: .02em; }
.rm-head .rm-right { margin-left: auto; padding-right: 58px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.rm-body { padding: 14px; }

.rm-glyph {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 32% 28%, #2a2113 0%, #0a0d10 75%);
  border: 1px solid rgba(255, 176, 0, .55);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .5), 0 0 12px -3px rgba(255, 176, 0, .7);
}
.rm-glyph i, .rm-sigil i, .rm-mask {
  display: block;
  background-color: var(--fc, var(--amber));
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.rm-glyph i { width: 58%; height: 58%; }

.rm-chev { display: inline-block; width: 14px; color: var(--amber-dim); transition: transform .15s; text-align: center; }

/* ── sigils ─────────────────────────────────────────────────────── */
.rm-sigil {
  --sz: 38px;
  position: relative;
  flex: 0 0 auto;
  width: var(--sz);
  height: var(--sz);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 32% 28%, #1b2026 0%, #0a0d10 72%);
  border: 1px solid var(--fc);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, .55), 0 0 14px -2px var(--fc), inset 0 0 12px -4px var(--fc);
}
.rm-sigil::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .07); pointer-events: none; }
.rm-sigil i { width: 62%; height: 62%; filter: drop-shadow(0 0 4px rgba(0, 0, 0, .8)); }
.rm-sigil.sm { --sz: 20px; box-shadow: 0 0 0 2px rgba(0, 0, 0, .5), 0 0 8px -3px var(--fc); }
.rm-sigil.sm::after { inset: 2px; }
.rm-sigil.pick { cursor: pointer; transition: box-shadow .15s, transform .15s; }
.rm-sigil.pick:hover { transform: scale(1.06); box-shadow: 0 0 0 3px rgba(0, 0, 0, .55), 0 0 22px 0 var(--fc), inset 0 0 14px -3px var(--fc); }
.rm-sigil select { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

/* ── unit cards with faction watermark ──────────────────────────── */
.rm-unit {
  --fc: var(--gold);
  position: relative;
  isolation: isolate;
  border-radius: 8px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--fc);
  overflow: hidden;
  background:
    radial-gradient(130% 85% at 100% 0%, color-mix(in srgb, var(--fc) 15%, transparent), transparent 62%),
    linear-gradient(135deg, rgba(255, 255, 255, .025), transparent 55%),
    var(--panel);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .5), 0 0 30px -18px var(--fc), inset 0 1px 0 rgba(255, 255, 255, .03);
}
.rm-unit::before {
  content: "";
  position: absolute;
  right: -36px;
  top: -18px;
  width: 270px;
  height: 270px;
  background-color: var(--fc);
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
  opacity: .085;
  transform: rotate(-10deg);
  pointer-events: none;
  z-index: -1;
}
.rm-unit-head {
  position: relative;
  padding: 11px 12px 10px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--fc) 20%, transparent), transparent 75%);
  border-bottom: 1px solid color-mix(in srgb, var(--fc) 35%, transparent);
}
.rm-unit-head::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: repeating-linear-gradient(135deg, var(--fc) 0 7px, transparent 7px 14px);
  opacity: .45;
}
.rm-unit-name {
  font-family: "Cinzel", serif !important;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .05em;
  color: var(--fc);
  background: transparent;
  border-color: transparent;
  text-shadow: 0 0 14px color-mix(in srgb, var(--fc) 45%, transparent);
}
.rm-unit-name:hover { border-color: var(--line); }
.rm-faction-name { font-size: 10px; text-transform: uppercase; letter-spacing: .16em; color: color-mix(in srgb, var(--fc) 70%, #d8a338); }
.rm-attached { margin-left: 18px; }
@media (min-width: 640px) { .rm-attached { margin-left: 30px; } }

.rm-weapon {
  position: relative;
  border-radius: 6px;
  border: 1px solid var(--line2);
  background: rgba(8, 10, 11, .74);
  padding: 10px;
  transition: border-color .15s;
}
.rm-weapon:hover { border-color: var(--line); }
.rm-weapon.off { opacity: .45; }
.rm-weapon.alt { border-color: color-mix(in srgb, var(--fc) 40%, var(--line2)); }

.rm-group {
  --fc: var(--gold);
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--fc) 45%, var(--line));
  background: linear-gradient(180deg, color-mix(in srgb, var(--fc) 8%, transparent), transparent 80px), rgba(10, 12, 13, .6);
  box-shadow: 0 0 34px -22px var(--fc);
}
.rm-group-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; text-align: left; cursor: pointer; }
.rm-group-head:hover { background: rgba(255, 255, 255, .02); }

/* ── stock target cards ─────────────────────────────────────────── */
.rm-card {
  --fc: var(--gold);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: 6px;
  border: 1px solid var(--line2);
  background: linear-gradient(135deg, rgba(255, 255, 255, .025), transparent 60%), var(--panel2);
  transition: .15s;
}
.rm-card:hover { border-color: var(--line); }
.rm-card.custom { border-color: color-mix(in srgb, var(--fc) 40%, var(--line)); border-left: 3px solid var(--fc); }
.rm-card.wm::before {
  content: "";
  position: absolute;
  right: -14px;
  bottom: -14px;
  width: 92px;
  height: 92px;
  background-color: var(--fc);
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
  opacity: .1;
  pointer-events: none;
  z-index: -1;
}
.rm-card.custom.wm::before { width: 170px; height: 170px; right: -20px; bottom: auto; top: -20px; opacity: .08; transform: rotate(-10deg); }

/* ── header ─────────────────────────────────────────────────────── */
.rm-top { border-bottom: 1px solid var(--line); background: linear-gradient(180deg, rgba(255, 176, 0, .06), transparent); position: relative; }
.rm-top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: linear-gradient(90deg, transparent, rgba(255, 176, 0, .55), transparent); }
.rm-brand { font-family: "Cinzel", serif; font-weight: 700; color: var(--gold); letter-spacing: .1em; text-transform: uppercase; line-height: 1.1; text-shadow: 0 0 18px rgba(212, 175, 55, .45); }
.rm-brand em { font-style: normal; color: var(--amber); }
.rm-tagline { font-size: 11px; color: var(--amber-dim); letter-spacing: .16em; text-transform: uppercase; }
.rm-ratsigil { --fc: #ffb000; --sz: 54px; font-size: 26px; }

.rm-nav { position: sticky; top: 0; z-index: 20; background: rgba(10, 12, 13, .92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }

.rm-footer { color: var(--faint); }
.rm-footer a { color: var(--amber-dim); text-decoration: underline; }

/* ── flanking ornament, desktop only ────────────────────────────── */
.rm-flank { position: fixed; top: 0; bottom: 0; width: clamp(70px, 6vw, 110px); pointer-events: none; z-index: 0; display: none; overflow: hidden; user-select: none; }
.rm-flank.l { left: 0; }
.rm-flank.r { right: 0; }
@media (min-width: 1500px) { .rm-flank { display: block; } }
.rm-flank .rail { position: absolute; top: 0; bottom: 0; width: 14px; background: linear-gradient(180deg, transparent, rgba(58, 47, 25, .85) 12%, rgba(58, 47, 25, .85) 88%, transparent); border-left: 1px solid rgba(255, 176, 0, .12); border-right: 1px solid rgba(0, 0, 0, .5); }
.rm-flank.l .rail { right: 18px; }
.rm-flank.r .rail { left: 18px; }
.rm-flank .rivets { position: absolute; top: 6%; bottom: 6%; width: 14px; background-image: radial-gradient(circle at 50% 6px, rgba(255, 176, 0, .3) 1.6px, transparent 2.2px); background-size: 14px 34px; background-repeat: repeat-y; }
.rm-flank.l .rivets { right: 18px; }
.rm-flank.r .rivets { left: 18px; }
.rm-flank .cog { position: absolute; left: 50%; transform: translateX(-50%); width: 50px; height: 50px; opacity: .17; --fc: var(--amber); }
.rm-flank .cog.top { top: 34px; }
.rm-flank .cog.bot { bottom: 34px; }
.rm-flank .litany { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(180deg); writing-mode: vertical-rl; font-family: "Cinzel", serif; font-size: 11px; letter-spacing: .42em; color: var(--amber); opacity: .2; white-space: nowrap; text-transform: uppercase; }
.rm-flank.r .litany { transform: translate(-50%, -50%) rotate(0deg); }
.rm-app { position: relative; z-index: 1; }

/* ── cogitator screen effects (toggle) ──────────────────────────── */
.rm-crt { position: fixed; inset: 0; pointer-events: none; z-index: 9999; display: none; }
body.crt-on .rm-crt { display: block; }
.rm-crt .lines { position: absolute; inset: 0; background: repeating-linear-gradient(180deg, rgba(0, 0, 0, .13) 0, rgba(0, 0, 0, .13) 1px, transparent 1px, transparent 3px); animation: rm-drift 9s linear infinite; }
.rm-crt .bloom { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 42%, rgba(255, 176, 0, .05) 0%, rgba(255, 176, 0, .02) 38%, transparent 68%); }
.rm-crt .vig { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(0, 0, 0, .2) 84%, rgba(0, 0, 0, .38) 100%); }
@keyframes rm-drift { from { background-position-y: 0; } to { background-position-y: 3px; } }
@media (prefers-reduced-motion: reduce) { .rm-crt .lines { animation: none; } }

body.crt-on .rm-brand { text-shadow: 0 0 10px rgba(212, 175, 55, .6), 0 0 26px rgba(255, 176, 0, .25); }
body.crt-on .rm-head h2 { text-shadow: 0 0 10px rgba(255, 176, 0, .45); }
body.crt-on .rm-glow-num { text-shadow: 0 0 10px rgba(255, 176, 0, .45); }
body.crt-on .rm-pill.on, body.crt-on .rm-tag { text-shadow: 0 0 6px currentColor; }
body.crt-on .rm-flank .litany { text-shadow: 0 0 10px rgba(255, 176, 0, .4); }

/* ── misc ───────────────────────────────────────────────────────── */
.rm-num { font-variant-numeric: tabular-nums; }
.rm-glow-num { color: #ffd166; }
.rm-divider { height: 1px; background: linear-gradient(90deg, transparent, var(--line), transparent); }
.rm-modal { background: rgba(0, 0, 0, .82); backdrop-filter: blur(2px); }
.rm-modal-box { border: 1px solid var(--amber-dim); box-shadow: 0 0 60px -20px rgba(255, 176, 0, .5), 0 30px 60px -20px #000; }

@keyframes rm-flicker { 0%, 100% { opacity: 1; } 92% { opacity: 1; } 93% { opacity: .82; } 94% { opacity: 1; } 97% { opacity: .9; } }
body.crt-on .rm-brand { animation: rm-flicker 7s infinite; }
@media (prefers-reduced-motion: reduce) { body.crt-on .rm-brand { animation: none; } }

/* ── unit buffs strip ───────────────────────────────────────────── */
.rm-buffs {
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: rgba(8, 10, 11, .55);
  transition: border-color .15s, box-shadow .15s;
}
.rm-buffs.active {
  border-style: solid;
  border-color: rgba(255, 176, 0, .45);
  background: linear-gradient(90deg, rgba(255, 176, 0, .09), rgba(8, 10, 11, .6) 60%);
  box-shadow: 0 0 16px -8px rgba(255, 176, 0, .7);
}
.rm-buffs-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 6px 10px;
  text-align: left;
  cursor: pointer;
  background: transparent;
  border: 0;
  font-family: inherit;
  color: inherit;
}
.rm-buffs-head:hover .rm-label { color: var(--amber); }
