:root {
  --bg: #0f1115;
  --card: #171a21;
  --card2: #1e222b;
  --border: #2a2f3a;
  --text: #e6e8ee;
  --muted: #8b93a5;
  --accent: #f0b232;
  --accent2: #4f8cff;
  --kill: #3ecf8e;
  --wipe: #e5534b;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--card); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand p { margin: 0; color: var(--muted); font-size: 12px; }
.logo { font-size: 28px; }

main { max-width: 1400px; margin: 0 auto; padding: 20px 24px 40px; display: flex; flex-direction: column; gap: 16px; }
footer { text-align: center; padding: 10px 16px 30px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.row-between.wrap { flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

/* Formularer */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent2); }
label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
label input, label select { color: var(--text); }
.setup-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 8px; }
.setup-form label { flex-direction: column; align-items: flex-start; gap: 4px; }
.setup-form input { min-width: 260px; }
.add-row { display: flex; gap: 10px; align-items: stretch; }
.add-row textarea { flex: 1; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.btn { background: var(--card2); border: 1px solid var(--border); border-radius: 6px; padding: 8px 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: #1a1200; border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: default; }
.msg { color: var(--muted); }
.msg.error { color: var(--wipe); }
.msg.ok { color: var(--kill); }
.controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 7px 12px; cursor: pointer; color: var(--muted); }
.seg button.active { background: var(--card2); color: var(--text); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 12px; }
.progress { flex-basis: 100%; height: 6px; background: var(--card2); border-radius: 3px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--accent2); transition: width .2s; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: var(--card2); border: 1px solid var(--border); border-radius: 999px; padding: 5px 6px 5px 12px; }
.chip .t { font-weight: 600; }
.chip .m { color: var(--muted); font-size: 12px; }
.chip button { background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 999px; }
.chip button:hover { background: var(--border); color: var(--text); }

/* Fliser */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tile .v { font-size: 22px; font-weight: 700; }
.tile .l { color: var(--muted); font-size: 12px; }

.chart-wrap { position: relative; height: 300px; }
.chart-wrap.short { height: 220px; }

/* Tabeller */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 9px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; position: sticky; top: 0; background: var(--card); }
td.num, th.num { text-align: right; }
tr.kill td.result { color: var(--kill); font-weight: 600; }
tr.wipe td.result { color: var(--wipe); }
tr.wipe td.result.late { color: #f0b232; }
tr.wipe td.result.close { color: #ff8a3d; }
.pulls tbody tr:hover { background: var(--card2); }
.pulls td.num.pct { min-width: 5em; }
.pulls .bar { display: inline-block; height: 8px; background: var(--wipe); border-radius: 4px; vertical-align: middle; margin-right: 6px; opacity: .8; }

.matrix th.player, .matrix td.player { position: sticky; left: 0; background: var(--card); z-index: 1; min-width: 160px; }
.matrix th.player { z-index: 2; }
.matrix th.pull { cursor: pointer; text-align: right; }
.matrix th.pull:hover { color: var(--text); }
.matrix th.pull.kill { color: var(--kill); }
.matrix td.cell { text-align: right; color: var(--text); }
.matrix td.cell.none { color: var(--muted); opacity: .6; }
.matrix td.cell.death { background: rgba(229, 83, 75, .25); color: #ffb3ae; }
.matrix td.avg { text-align: right; font-weight: 700; border-left: 1px solid var(--border); }
.matrix .spec { color: var(--muted); font-size: 11px; margin-left: 6px; }
.matrix tr.role-sep td { border-top: 2px solid var(--border); }
.player .cls { font-weight: 600; }

.simple td:first-child { width: 60%; }

.deathlist { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 6px 16px; }
.deathlist li { display: flex; gap: 10px; align-items: baseline; }
.deathlist .t { color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; min-width: 4.5em; }
.deathlist .a { color: var(--muted); }

@media (max-width: 700px) {
  .top { padding: 12px 16px; }
  main { padding: 14px 12px 30px; }
  .add-row { flex-direction: column; }
}

/* Boss-faner */
.bosstabs { display: flex; flex-wrap: wrap; gap: 8px; }
.bosstabs button { background: var(--card2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 2px; min-width: 150px; }
.bosstabs button:hover { border-color: var(--muted); }
.bosstabs button.active { border-color: var(--accent); background: rgba(240, 178, 50, .1); }
.bosstabs .n { font-weight: 600; }
.bosstabs .m { color: var(--muted); font-size: 12px; }
.bosstabs .m .k { color: var(--kill); }
.badge { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 999px; background: var(--border); color: var(--text); margin-left: 6px; vertical-align: middle; text-transform: uppercase; letter-spacing: .04em; }
.badge.d5 { background: #5a2d82; } .badge.d4 { background: #3a4f8a; } .badge.d3 { background: #2d6b4f; } .badge.d10 { background: #7a4a1f; }

/* Visnings-faner */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.tabs button { background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 10px 14px; cursor: pointer; font-weight: 600; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.tab { display: flex; flex-direction: column; gap: 16px; }
.btn.small { padding: 4px 10px; font-size: 12px; }

/* Abilities */
.abilities td:first-child { width: auto; }
.abil { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.abil img { width: 20px; height: 20px; border-radius: 4px; border: 1px solid var(--border); }
.abil:hover { text-decoration: underline; }
tr.excluded td { opacity: .45; }
tr.selected td { background: rgba(79, 140, 255, .12); }
.abilities .share { display: inline-block; height: 8px; background: var(--accent2); border-radius: 4px; vertical-align: middle; margin-right: 6px; opacity: .8; }
.pchips { display: flex; flex-wrap: wrap; gap: 4px; }
.pchip { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--card2); border: 1px solid var(--border); white-space: nowrap; }
.pchip b { font-weight: 700; }
.matrix.compact th, .matrix.compact td { padding: 4px 7px; font-size: 12px; }
.matrix.compact th.player, .matrix.compact td.player { min-width: 120px; }
.matrix.compact th.abil-h { max-width: 90px; white-space: normal; text-align: center; font-size: 11px; vertical-align: bottom; }
.matrix.compact td.cnt { text-align: center; }
.matrix.compact td.cnt.zero { color: var(--muted); opacity: .4; }
.phase { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }

/* Avoidable damage */
.matrix tr.total td { border-top: 2px solid var(--border); font-weight: 700; }
.matrix td.cell.bad { color: #ffb3ae; }
.abilities .src { color: var(--muted); font-size: 11px; margin-left: 6px; }

/* Skade pr. mål */
.matrix.compact th.tgt-h { cursor: pointer; }
.matrix.compact th.tgt-h:hover { color: var(--text); }
.matrix.compact th.tgt-h.boss { color: var(--accent); }
.matrix.compact th.tgt-h.selected { color: var(--text); border-bottom: 2px solid var(--accent); }
.matrix.compact td.cnt.hl { background: rgba(240, 178, 50, .12); }

/* Sortering */
main table thead th { cursor: pointer; user-select: none; }
main table thead th.sort-asc::after { content: ' ▲'; font-size: 9px; color: var(--accent); }
main table thead th.sort-desc::after { content: ' ▼'; font-size: 9px; color: var(--accent); }
.hact { color: var(--muted); text-decoration: none; font-size: 11px; cursor: pointer; }
.hact:hover { color: var(--wipe); text-decoration: none; }
.hname { color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; cursor: pointer; }
.hname:hover { color: var(--accent2); }

/* Taktik-guide */
.guide h3 { font-size: 15px; margin: 18px 0 8px; color: var(--accent); }
.guide h3:first-of-type { margin-top: 6px; }
.guide ul { margin: 0 0 10px; padding-left: 20px; }
.guide li { margin: 4px 0; }
.guide table { margin-bottom: 8px; }
.guide td, .guide th { white-space: normal; vertical-align: top; }
.guide td:first-child { white-space: nowrap; }
.guide td:nth-child(2) { color: var(--muted); white-space: nowrap; }

.guide .badge { margin-left: 4px; }
#guideBoss { max-width: 220px; }
