:root {
  color-scheme: dark;
  --bg: #10130f;
  --panel: #191d17;
  --panel-2: #22271f;
  --text: #eef2e8;
  --muted: #aeb7a7;
  --line: #32392e;
  --accent: #d7b35f;
  --accent-2: #74b3c7;
  --danger: #d47768;
  --ok: #8cc77a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

[hidden] {
  display: none !important;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 6px 12px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 15px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 5vw, 48px);
}

h2 {
  font-size: 18px;
}

.status-pill,
button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
}

.status-pill {
  padding: 10px 14px;
  color: var(--muted);
  min-width: 160px;
  text-align: center;
}

.control-band,
.setup-guide,
.workspace,
.stats-band,
.summary-grid article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.setup-guide {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 28px;
  margin-bottom: 16px;
  padding: 28px;
  position: relative;
  overflow: hidden;
}

.setup-guide[hidden] {
  display: none;
}

.setup-guide::before {
  content: "";
  position: absolute;
  inset: 0;
  border-top: 3px solid var(--accent);
  pointer-events: none;
}

.setup-copy {
  position: relative;
  z-index: 1;
}

.setup-kicker {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.setup-guide h2 {
  max-width: 720px;
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1.08;
}

.setup-guide p {
  max-width: 780px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.setup-steps {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 14px;
}

.setup-steps li {
  position: relative;
  min-height: 34px;
  padding-left: 46px;
  min-width: 0;
}

.setup-steps li::before {
  counter-increment: setup-step;
  content: counter(setup-step);
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #171309;
  font-weight: 800;
}

.setup-steps {
  counter-reset: setup-step;
}

.setup-steps strong,
.setup-steps span {
  display: block;
}

.setup-steps strong {
  color: var(--text);
  line-height: 1.2;
}

.setup-steps span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.control-band {
  display: grid;
  grid-template-columns: minmax(280px, 640px) 1fr;
  gap: 18px;
  padding: 18px;
}

.control-band.setup-mode {
  grid-template-columns: 1fr;
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 20px 34px;
}

.control-band.setup-mode .file-panel {
  justify-content: center;
}

.control-band.setup-mode .date-field,
.control-band.setup-mode .primary-button {
  min-height: 48px;
}

.file-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.fallback-control {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.fallback-control small {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

button {
  min-height: 42px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

.primary-button {
  background: var(--accent);
  color: #171309;
  border-color: var(--accent);
  font-weight: 700;
}

.active-toggle {
  border-color: var(--ok);
  background: #1f2d1d;
}

.date-field {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
}

.date-field span {
  font-size: 13px;
  white-space: nowrap;
}

.date-field input {
  width: 136px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  color-scheme: dark;
  cursor: pointer;
}

.progress-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.progress-track {
  height: 10px;
  background: #0c0e0b;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}

#progressBar {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 160ms ease;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.summary-grid article {
  padding: 16px;
}

.summary-head,
.death-head {
  min-height: 30px;
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 0;
}

.death-head {
  justify-content: space-between;
  gap: 8px;
}

.summary-grid strong {
  display: block;
  font-size: 28px;
  min-height: 34px;
  overflow-wrap: anywhere;
}

.death-character {
  min-height: 28px;
  width: min(118px, 58%);
  display: flex;
  align-items: center;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.death-character input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
}

.stats-band {
  margin-bottom: 16px;
  overflow: hidden;
}

.section-head.compact {
  height: auto;
  min-height: 54px;
  padding-block: 12px;
}

.stats-toggle {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  text-align: left;
}

.stats-toggle:hover {
  border-color: var(--line);
  background: var(--panel-2);
}

.location-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: 86px;
  gap: 1px;
  background: var(--line);
  border-top: 1px solid var(--line);
  max-height: 174px;
  overflow: hidden;
}

.stats-band.expanded .location-stats {
  max-height: none;
}

.stat-row {
  min-width: 0;
  min-height: 86px;
  background: var(--panel);
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 10px;
  align-items: start;
  border: 0;
  color: inherit;
  cursor: pointer;
}

.stat-row:hover,
.stat-row:focus-visible {
  background: var(--panel-2);
  outline: 0;
}

.stat-row.selected {
  box-shadow: inset 0 0 0 1px var(--accent);
}

.stat-row strong,
.stat-row small {
  display: block;
}

.stat-row strong {
  margin-bottom: 7px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-metrics {
  min-width: 56px;
  text-align: right;
}

.stat-metrics b {
  display: block;
  font-size: 24px;
  line-height: 1;
  color: var(--accent);
}

.stat-metrics small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}

.empty-stat {
  grid-column: 1 / -1;
  margin: 0;
  padding: 24px;
  color: var(--muted);
  background: var(--panel);
  text-align: center;
}

.workspace {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 560px;
  overflow: hidden;
}

.filters {
  padding: 14px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter {
  justify-content: flex-start;
  width: 100%;
}

.filter.active {
  border-color: var(--accent);
  background: #2c2a1d;
}

#searchBox {
  margin-top: 8px;
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c0e0b;
  color: var(--text);
  padding: 0 12px;
}

.table-area {
  min-width: 0;
}

.section-head {
  height: 62px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.section-head span {
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
  max-height: 640px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  z-index: 1;
}

td strong,
td small {
  display: block;
}

td small {
  margin-top: 4px;
  color: var(--muted);
}

.death-count {
  color: var(--danger);
}

.type {
  display: inline-flex;
  min-width: 82px;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  color: #111;
  background: var(--muted);
}

.type-map {
  background: var(--ok);
}

.type-anomaly {
  background: #b99cff;
}

.type-citadel {
  background: #8fb6ff;
}

.type-expedition {
  background: #c7a07a;
}

.type-hideout,
.type-town {
  background: var(--accent-2);
}

.type-boss {
  background: var(--danger);
}

.type-special {
  background: var(--accent);
}

.empty {
  height: 220px;
  text-align: center;
  color: var(--muted);
  vertical-align: middle;
}

.load-more {
  text-align: center;
  color: var(--muted);
  background: #12150f;
}

@media (max-width: 860px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .setup-guide,
  .control-band,
  .workspace {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .location-stats {
    grid-template-columns: 1fr;
  }

  .workspace {
    display: block;
  }

  .filters {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  #searchBox {
    grid-column: 1 / -1;
  }

  .section-head {
    align-items: flex-start;
    height: auto;
    padding: 14px;
    flex-direction: column;
  }
}
