:root {
  --bg: #0b0c0f;
  --deep: #08090b;
  --panel: #131519;
  --raise: #1a1d23;
  --line: #24272f;
  --text: #e4e4e7;
  --muted: #8c909b;
  --gold: #cfa53b;
  --hit: #e0533f;
  --spec: #47b868;
  --radius-s: 4px;
  --radius-m: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 "Barlow Semi Condensed", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 { font-family: "Marcellus", Georgia, serif; font-weight: 400; margin: 0; }
h1 { font-size: 1.9rem; color: var(--gold); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; color: var(--muted); margin: 20px 0 8px; }

button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* header */
.top {
  display: grid;
  grid-template-columns: minmax(240px, 340px) 1fr;
  gap: 16px 32px;
  align-items: end;
  padding: 24px 24px 20px;
  background: var(--deep);
  border-bottom: 1px solid var(--line);
}
.brand p { margin: 6px 0 0; color: var(--muted); max-width: 46ch; }

.stats { display: flex; flex-wrap: wrap; gap: 10px 14px; }
.stats label { display: flex; flex-direction: column; gap: 3px; font-size: 0.85rem; color: var(--muted); }
.stats input, .stats select {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 6px 8px;
  color: var(--text);
  font-size: 1rem;
}
.stats input { width: 84px; }
.stats .field { display: flex; flex-direction: column; gap: 3px; font-size: 0.85rem; color: var(--muted); }
.field-label { display: flex; align-items: center; gap: 5px; }

.info { position: relative; display: inline-flex; }
.info-btn {
  width: 15px;
  height: 15px;
  padding: 0;
  border: 1px solid var(--muted);
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font: 600 10px/13px Georgia, serif;
  font-style: italic;
  cursor: help;
}
.info-btn:hover, .info-btn:focus-visible { border-color: var(--gold); color: var(--gold); }
.tip {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 220px;
  padding: 7px 10px;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.35;
  z-index: 10;
  visibility: hidden;
  opacity: 0;
  transition: opacity 120ms;
}
.info:hover .tip, .info-btn:focus + .tip { visibility: visible; opacity: 1; }

/* layout */
.layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 24px;
  padding: 24px;
  align-items: start;
}

/* weapons */
.armory { position: sticky; top: 16px; }
.legend { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.9rem; margin: 6px 0 12px; }
.sw { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
.sw.hit { background: var(--hit); }
.sw.spec { background: var(--spec); margin-left: 10px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 6px; }

.tile {
  display: grid;
  grid-template-columns: 32px 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  text-align: left;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--hit);
  border-radius: var(--radius-s);
  cursor: pointer;
}
.tile.spec { border-left-color: var(--spec); }
.tile:hover { background: var(--raise); }
.tile:active { transform: translateY(1px); }
.tile:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.tile img { grid-row: span 2; width: 32px; height: 32px; object-fit: contain; filter: drop-shadow(1px 1px 0 #000); }
.tile .name { font-size: 0.85rem; color: var(--muted); line-height: 1.15; }
.tile .max { font-size: 1.5rem; font-weight: 700; line-height: 1.1; color: var(--hit); }
.tile.spec .max { color: var(--spec); }
.tile .meta { grid-column: 1 / -1; font-size: 0.8rem; color: var(--muted); margin-top: 4px; }

/* warden */
.warden { padding: 16px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); margin-bottom: 18px; }
.warden-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
#wardenText { font-size: 1.1rem; }
.warden-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.note { margin: 0; color: var(--muted); font-size: 0.9rem; }

.plan-actions { display: flex; gap: 8px; }
.plan-actions button {
  background: var(--raise);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-s);
  padding: 5px 12px;
  cursor: pointer;
  font-size: 0.9rem;
}
.plan-actions .quiet { color: var(--muted); }
.plan-actions button:disabled { opacity: 0.4; cursor: default; }

.bar { height: 10px; background: #26161a; border-radius: 99px; overflow: hidden; }
.bar.big { height: 16px; }
.bar .fill { height: 100%; background: linear-gradient(90deg, #9c2f2a, var(--hit)); transition: width 200ms ease; }

/* downs */
.down {
  padding: 14px 18px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  margin-bottom: 14px;
  background: var(--panel);
}
.down.current { border-color: var(--gold); box-shadow: inset 3px 0 0 var(--gold); }
.down:last-child { animation: open 220ms ease-out; }
@keyframes open { from { opacity: 0; transform: translateY(-4px); } }

.down-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.down-head h3 { margin: 0; color: var(--text); font-size: 1.15rem; }
.down-head .window { color: var(--muted); font-size: 0.95rem; }

.track { position: relative; margin-top: 12px; }
.ruler, .strip { display: grid; grid-template-columns: repeat(var(--cols), 1fr); }
.strip { min-height: 54px; background: var(--deep); border-radius: var(--radius-s); position: relative; }
.ruler span { font-size: 0.7rem; color: var(--muted); border-left: 1px solid #4a4f5c; padding: 2px 0 0 3px; height: 16px; white-space: nowrap; min-width: 0; }
.strip .limit { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--gold); pointer-events: none; }

.blk {
  grid-row: 1;
  margin: 3px 1px;
  border: 0;
  border-radius: 3px;
  background: var(--hit);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  min-width: 0;
  position: relative;
  z-index: 1;
}
.blk.spec, .blk.spec b { background: var(--spec); color: #06210e; }
.blk:hover { filter: brightness(1.12); }
.blk img { width: 22px; height: 22px; object-fit: contain; flex: none; filter: drop-shadow(1px 1px 0 #000); }
.blk b { font-size: 1rem; white-space: nowrap; }

.down-foot { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.down-foot .bar { flex: 1; min-width: 160px; }
.down-foot .left { color: var(--muted); font-size: 0.9rem; }
.down-foot .dealt { font-weight: 600; }

@media (max-width: 900px) {
  .top, .layout { grid-template-columns: 1fr; padding: 16px; }
  .armory { position: static; }
  .blk img { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bar .fill { transition: none; }
  .down:last-child { animation: none; }
}
