:root {
  --bg: #0f1115;
  --panel: #151923;
  --text: #e6e6e6;
  --muted: #9aa4b2;
  --accent: #6ea8fe;
  --good: #7ce38b;
  --warn: #ffce6b;
  --danger: #f97a7a;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; padding: 24px;
  font: 14px/1.45 system-ui, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, #1a2133 0%, var(--bg) 40%);
  color: var(--text);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}

h1 { margin: 0 0 8px; font-size: 20px; }
.sub { color: var(--muted); margin-bottom: 16px; }

.grid { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 1000px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: linear-gradient(180deg, #181e2a 0%, var(--panel) 100%);
  border: 1px solid #242c3d; border-radius: 12px; padding: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.wrap { flex-wrap: wrap; }
.gap8 { gap: 8px; }
.space-between { justify-content: space-between; }

textarea {
  width: 100%; min-height: 240px; resize: vertical;
  background: #0e121a; color: var(--text);
  border: 1px solid #263147; border-radius: 10px; padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.note { color: var(--muted); font-size: 12px; margin: 6px 0 0; }

/* ---------- Buttons ---------- */
.btn {
  background: var(--accent); color: #0a0f1a; font-weight: 600;
  border: 0; padding: 10px 14px; border-radius: 10px; cursor: pointer;
}
.btn.secondary { background: #2a3550; color: var(--text); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Summary fields ---------- */
.field {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
  padding: 8px 0; border-bottom: 1px dashed #2a3550;
}
.field:last-child { border-bottom: 0; }
.k { color: var(--muted); }
.v { font-weight: 700; }
.big { font-size: 22px; font-weight: 800; }
.good { color: var(--good); }
.warn { color: var(--warn); }
.danger { color: var(--danger); }

/* ---------- Details / tables ---------- */
details { margin-top: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 6px 0; border-bottom: 1px solid #232b3d; }
th { text-align: left; color: var(--muted); font-weight: 600; }

code.inline {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  background: #0e121a; padding: 2px 6px; border-radius: 6px; border: 1px solid #222a3a;
}

/* ---------- Options blocks ---------- */
.options {
  margin-top: 14px;
  border: 1px solid #263147;
  border-radius: 10px;
  padding: 10px;
}
.options legend { padding: 0 6px; color: var(--muted); }

/* Default option row = checkbox + content (two columns: 20px / 1fr) */
.opt {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 2px;
  border-top: 1px dashed #263147;
}
.opt:first-of-type { border-top: 0; }

/* Two-column layout for rows WITHOUT a checkbox (prevents overlap) */
.opt.grid-2 {
  grid-template-columns: 1fr 1fr;  /* override the 20px column */
  gap: 16px;
  padding-left: 2px;              /* balance spacing since no checkbox */
}
@media (max-width: 900px) {
  .opt.grid-2 { grid-template-columns: 1fr; }
}

.opt.no-checkbox { padding-left: 2px; } /* optional helper */

.opt-title { font-weight: 700; margin-bottom: 4px; }
.opt-desc  { color: var(--muted); font-size: 12px; line-height: 1.35; }

/* Inputs inside option headers */
.num {
  width: 84px; margin-left: 8px;
  background: #0e121a; border: 1px solid #263147; color: var(--text);
  padding: 4px 6px; border-radius: 8px;
}
select {
  background: #0e121a; border: 1px solid #263147; color: var(--text);
  padding: 6px 8px; border-radius: 8px; margin-left: 8px;
}

/* Resist / Pen rows: keep labels tidy, no wrap between name+input */
.row.wrap.gap8 label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
  white-space: nowrap;
}
.row.wrap.gap8 .num { width: 72px; }

/* ---------- Pills (element tags) ---------- */
.pill { padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.e-fire { background: #40241e; color: #ff9f7c; }
.e-cold { background: #1f2d3d; color: #7cc6ff; }
.e-light { background: #2b2a17; color: #ffe87c; }
.e-chaos { background: #2b1f29; color: #e47cff; }
.e-phys { background: #2a2a2a; color: #cfcfcf; }

/* ---------- History ---------- */
.history { display: grid; gap: 8px; margin-top: 8px; }
.hist-item {
  background: #0e121a; border: 1px solid #263147; border-radius: 8px; padding: 8px;
  cursor: pointer; transition: border-color .15s ease, transform .05s ease;
}
.hist-item:hover { border-color: #38507a; }
.hist-title { font-weight: 700; }
.hist-meta { color: var(--muted); font-size: 12px; }

/* ---------- States ---------- */
.disabledish { opacity: .55; pointer-events: none; }

/* ---------- Footer ---------- */
footer { margin-top: 24px; color: var(--muted); }

/* ---------- Extra small screens ---------- */
@media (max-width: 520px) {
  .num { width: 72px; }
  textarea { min-height: 200px; }
  .big { font-size: 20px; }
}