:root {
  --bg: #edf0f6;
  --bg-2: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --border: #d7dfeb;
  --text: #18253b;
  --muted: #607189;
  --accent: #4f7cff;
  --accent-2: #7d5cff;
  --success: #19b36b;
  --warning: #d98b0f;
  --danger: #dd4256;
  --danger-soft: #fff0f2;
  --shadow: 0 14px 34px rgba(27, 39, 64, 0.08);
  --radius: 24px;
  --radius-sm: 16px;
  --team: #e8f8ef;
  --box: #e9f1ff;
  --dead: #fff0f2;
  --released: #fff4df;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(79, 124, 255, 0.08), transparent 22%),
    radial-gradient(circle at top right, rgba(125, 92, 255, 0.07), transparent 24%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
}

img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.3rem, 1.6vw, 1.7rem); }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

.app-shell {
  width: min(1500px, calc(100% - 28px));
  margin: 14px auto 26px;
}

.dashboard-shell {
  display: grid;
  gap: 16px;
}

.sidebar-column,
.dashboard-main,
.players-list,
.rules-list,
.button-grid,
.stats-grid,
.encounter-tools,
.encounters-list,
.encounter-players-grid,
.badges-grid,
.milestones-list,
.form-grid,
.auth-grid,
.hero-stats,
.death-counters,
.content-strip,
.summary-strip {
  display: grid;
  gap: 14px;
}

.sidebar-column { align-content: start; }
.dashboard-main { min-width: 0; }

.card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.sidebar-card { background: rgba(255, 255, 255, 0.95); }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
}

.sidebar-brand-icon {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: #6b78a0;
  margin-bottom: 6px;
}

.muted { color: var(--muted); }
.tiny { font-size: 0.83rem; }
.hidden { display: none !important; }
.wrap-row { flex-wrap: wrap; }
.no-margin { margin-bottom: 0; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.compact-head { align-items: center; }
.progress-subhead { margin-top: 18px; }

.badge-soft {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #eef2ff;
  border: 1px solid #dbe4ff;
  color: #32425f;
}

.form-grid,
.auth-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.form-grid .full-span { grid-column: 1 / -1; }
.align-end { align-items: end; }

label {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-size: 0.95rem;
}

input, select, textarea {
  width: 100%;
  border: 1px solid #d6dfeb;
  background: #fbfcff;
  color: var(--text);
  border-radius: 16px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(79, 124, 255, 0.74);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(79, 124, 255, 0.12);
}

textarea { resize: vertical; min-height: 96px; }

button,
.file-label {
  border: none;
  border-radius: 16px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #ffffff;
  font-weight: 700;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease, filter 140ms ease;
  text-align: center;
  box-shadow: 0 10px 24px rgba(79, 124, 255, 0.18);
}

button:hover,
.file-label:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.ghost-btn {
  background: #f5f7fc;
  color: var(--text);
  border: 1px solid #d7dfeb;
  box-shadow: none;
}

.danger {
  background: linear-gradient(135deg, #f56579, #dd4256);
}

.small-btn { padding: 10px 12px; font-size: 0.84rem; }

.button-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.button-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.compact-grid { gap: 10px; }

.info-banner {
  display: none;
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: #fff5e6;
  color: #8d5b00;
  border: 1px solid #f5d9a1;
}

.info-banner.show { display: block; }
.cloud-controls { margin-top: 14px; }

.quick-readme-card {
  padding: 14px 18px;
}

.readme-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #f5f7fc;
  color: var(--text);
  border: 1px solid #d7dfeb;
  box-shadow: none;
}

.readme-toggle-hint {
  color: var(--muted);
  font-weight: 700;
}

.readme-panel {
  margin-top: 14px;
}

.readme-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.readme-grid article {
  background: #f8faff;
  border: 1px solid #dbe4f0;
  border-radius: 18px;
  padding: 14px;
}

.readme-grid h3 {
  margin-bottom: 8px;
}

.readme-grid p {
  color: var(--muted);
  line-height: 1.5;
}


.banner-card {
  position: relative;
  overflow: hidden;
  min-height: 180px;
  padding: 0;
}

.banner-media,
.banner-overlay,
.banner-content {
  position: absolute;
  inset: 0;
}

.banner-media {
  background: url('assets/banner.jpg') center right / cover no-repeat;
}

.banner-overlay {
  background: linear-gradient(90deg, rgba(255,255,255,0.92) 0%, rgba(255,255,255,0.76) 34%, rgba(255,255,255,0.16) 100%);
}

.banner-content {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 24px;
}

.banner-title {
  font-size: clamp(1.8rem, 2.4vw, 2.6rem);
  margin-bottom: 10px;
}

.banner-subtitle {
  max-width: 640px;
  color: #344158;
  line-height: 1.45;
}

.banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.summary-strip {
  grid-template-columns: minmax(270px, 0.9fr) minmax(0, 1.7fr);
}

.summary-card {
  min-width: 0;
}

.death-counters { grid-template-columns: 1fr; }

.death-counter-card {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid #d9e1ec;
  background: var(--surface-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.death-counter-card.has-deaths {
  background: var(--danger-soft);
  border-color: #f3c3ca;
}

.death-counter-main {
  display: grid;
  gap: 4px;
}

.death-counter-label {
  display: inline-block;
}

.death-counter-clicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.death-stepper-btn {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  line-height: 1;
}

.death-counter-total {
  min-width: 54px;
  text-align: center;
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text);
}

.edition-headline-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin: 12px 0 14px;
}

.next-cap-pill strong { color: var(--accent-2); }

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.stats-grid-compact { gap: 10px; }

.stat-card {
  border-radius: 18px;
  border: 1px solid #dde4ef;
  background: #f8faff;
  padding: 14px;
}

.stat-card span { color: var(--muted); font-size: 0.85rem; }
.stat-card strong { font-size: 1.38rem; display: block; margin-top: 6px; }
.stat-card-muted { background: #fbfbfd; }

.content-strip {
  grid-template-columns: minmax(0, 1.75fr) minmax(260px, 0.72fr);
  align-items: start;
}

.encounters-panel,
.progress-panel,
.add-panel { min-width: 0; }

.encounter-tools {
  width: min(100%, 360px);
  grid-template-columns: 1fr;
}

.players-list { grid-template-columns: 1fr; }
.player-card,
.mon-form-card,
.encounter-card,
.empty-state,
.milestone-row,
.rule-chip {
  border-radius: 18px;
  border: 1px solid #dde4ef;
  background: #f9fbff;
}

.player-card,
.mon-form-card,
.encounter-card {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.player-card-head,
.mon-form-head,
.encounter-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.rules-list { grid-template-columns: 1fr; }

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  background: #f9fbff;
  border: 1px solid #dde4ef;
}

.checkbox-inline input {
  width: 18px;
  height: 18px;
  padding: 0;
  margin: 0;
}

.special-encounter-wrap {
  justify-content: center;
  height: 100%;
}

.milestone-row {
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.milestone-row.done {
  background: #ecfbf3;
  border-color: #bee8ce;
}

.badges-grid {
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
}

.badge-card {
  width: 100%;
  padding: 14px 12px;
  border-radius: 18px;
  background: #f9fbff;
  border: 1px solid #dde4ef;
  color: var(--text);
  box-shadow: none;
}

.badge-card.earned {
  background: linear-gradient(180deg, rgba(79, 124, 255, 0.12), rgba(125, 92, 255, 0.09));
  border-color: #cbd8ff;
}

.badge-card svg {
  width: 72px;
  height: 72px;
  margin: 0 auto 8px;
}

.badge-name {
  display: block;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
}

.badge-meta {
  display: block;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.encounter-players-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.encounter-form .warning-text {
  min-height: 1.2em;
  color: var(--warning);
  margin: 0;
}

.encounters-list { grid-template-columns: 1fr; }

.encounter-card.dead {
  border-color: #f3c3ca;
  background: #fff7f8;
}

.location-chip {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 999px;
  background: #edf3ff;
  color: #33445f;
}

.encounter-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.encounter-body {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.mon-card {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 12px;
  padding: 12px;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid #e1e8f2;
}

.mon-sprite {
  width: 78px;
  height: 78px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: #f3f7ff;
}

.mon-sprite img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  image-rendering: pixelated;
}

.mon-info h3 {
  font-size: 1rem;
  margin: 4px 0 4px;
}

.encounter-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.compact-meta {
  align-items: center;
  gap: 6px;
}

.encounter-notes {
  color: #3f4c63;
  line-height: 1.5;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 11px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.status-pill-inline {
  padding: 4px 8px;
  font-size: 0.74rem;
  line-height: 1.1;
}

.status-pill.team { background: var(--team); border-color: #bde8cf; }
.status-pill.box { background: var(--box); border-color: #cadeff; }
.status-pill.dead { background: var(--dead); border-color: #f3c3ca; }
.status-pill.freigelassen { background: var(--released); border-color: #efd8a2; }

.quick-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.status-quick-btn {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  box-shadow: none;
}

.status-quick-btn.team { background: #e8f8ef; color: #0f7342; border: 1px solid #bde8cf; }
.status-quick-btn.box { background: #e9f1ff; color: #2354a9; border: 1px solid #cadeff; }
.status-quick-btn.dead { background: #fff0f2; color: #b12439; border: 1px solid #f3c3ca; }

.empty-state {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.file-label { display: grid; place-items: center; }

@media (min-width: 1080px) {
  .dashboard-shell {
    grid-template-columns: 300px minmax(0, 1fr);
    align-items: start;
  }

  .sidebar-column {
    position: sticky;
    top: 14px;
  }

  .encounter-tools {
    grid-template-columns: 1fr 170px;
    width: auto;
  }
}

@media (max-width: 1079px) {
  .summary-strip,
  .content-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 16px, 100%);
    margin: 8px auto 22px;
  }

  .card { padding: 15px; border-radius: 20px; }
  .button-row { flex-direction: column; align-items: stretch; }
  .banner-content { padding: 18px; flex-direction: column; }
  .banner-card { min-height: 210px; }
  .banner-overlay { background: linear-gradient(180deg, rgba(255,255,255,0.94) 0%, rgba(255,255,255,0.82) 46%, rgba(255,255,255,0.25) 100%); }
  .mon-card { grid-template-columns: 66px 1fr; }
  .mon-sprite, .mon-sprite img { width: 60px; height: 60px; }
  .death-counter-card { flex-direction: column; align-items: flex-start; }
  .death-counter-clicker { width: 100%; justify-content: flex-start; }
  .edition-headline-row { align-items: flex-start; }
}


.theme-toggle-btn {
  min-width: 0;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
}

body[data-theme='dark'] {
  --bg: #0f172a;
  --bg-2: #111827;
  --surface: rgba(17, 24, 39, 0.92);
  --surface-2: #172036;
  --border: #2b3855;
  --text: #e8eefc;
  --muted: #a1afc8;
  --accent: #7aa2ff;
  --accent-2: #9a7cff;
  --success: #2fd08d;
  --warning: #f0b24b;
  --danger: #ff6f88;
  --danger-soft: #3a1d28;
  --team: #133425;
  --box: #142944;
  --dead: #341a23;
  --released: #3a3020;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
  background:
    radial-gradient(circle at top left, rgba(122, 162, 255, 0.16), transparent 24%),
    radial-gradient(circle at top right, rgba(154, 124, 255, 0.12), transparent 26%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
}

body[data-theme='dark'] .card,
body[data-theme='dark'] .sidebar-card {
  background: rgba(17, 24, 39, 0.9);
  border-color: var(--border);
}

body[data-theme='dark'] .eyebrow,
body[data-theme='dark'] .banner-subtitle,
body[data-theme='dark'] .encounter-notes,
body[data-theme='dark'] .sync-note {
  color: var(--muted);
}

body[data-theme='dark'] input,
body[data-theme='dark'] select,
body[data-theme='dark'] textarea {
  background: #0f172a;
  border-color: #30415f;
  color: var(--text);
}

body[data-theme='dark'] input:focus,
body[data-theme='dark'] select:focus,
body[data-theme='dark'] textarea:focus {
  background: #111b2f;
  border-color: rgba(122, 162, 255, 0.8);
  box-shadow: 0 0 0 4px rgba(122, 162, 255, 0.16);
}

body[data-theme='dark'] .ghost-btn,
body[data-theme='dark'] .readme-toggle {
  background: #172036;
  color: var(--text);
  border-color: #31405d;
}

body[data-theme='dark'] .badge-soft,
body[data-theme='dark'] .location-chip {
  background: #172036;
  color: var(--text);
  border-color: #31405d;
}

body[data-theme='dark'] .readme-grid article,
body[data-theme='dark'] .player-card,
body[data-theme='dark'] .mon-form-card,
body[data-theme='dark'] .encounter-card,
body[data-theme='dark'] .empty-state,
body[data-theme='dark'] .milestone-row,
body[data-theme='dark'] .rule-chip,
body[data-theme='dark'] .checkbox-inline,
body[data-theme='dark'] .badge-card,
body[data-theme='dark'] .stat-card,
body[data-theme='dark'] .death-counter-card,
body[data-theme='dark'] .mon-card {
  background: #172036;
  border-color: #31405d;
}

body[data-theme='dark'] .readme-grid article p,
body[data-theme='dark'] .stat-card span,
body[data-theme='dark'] .badge-meta,
body[data-theme='dark'] .encounter-meta,
body[data-theme='dark'] .readme-toggle-hint,
body[data-theme='dark'] .death-counter-label,
body[data-theme='dark'] .death-counter-main .tiny,
body[data-theme='dark'] .milestone-main .tiny {
  color: var(--muted);
}

body[data-theme='dark'] .badge-card.earned {
  background: linear-gradient(180deg, rgba(122, 162, 255, 0.2), rgba(154, 124, 255, 0.18));
  border-color: #50638c;
}

body[data-theme='dark'] .milestone-row.done {
  background: #133425;
  border-color: #285940;
}

body[data-theme='dark'] .death-counter-card.has-deaths,
body[data-theme='dark'] .encounter-card.dead {
  background: #2a1721;
  border-color: #6e3444;
}

body[data-theme='dark'] .mon-sprite {
  background: #10192c;
}

body[data-theme='dark'] .status-quick-btn.team {
  background: #163825;
  color: #8ce8b6;
  border-color: #285940;
}

body[data-theme='dark'] .status-quick-btn.box {
  background: #162943;
  color: #93b7ff;
  border-color: #304c73;
}

body[data-theme='dark'] .status-quick-btn.dead {
  background: #341a23;
  color: #ff9fb0;
  border-color: #6e3444;
}

body[data-theme='dark'] .status-pill.team { background: #163825; border-color: #285940; color: #8ce8b6; }
body[data-theme='dark'] .status-pill.box { background: #162943; border-color: #304c73; color: #93b7ff; }
body[data-theme='dark'] .status-pill.dead { background: #341a23; border-color: #6e3444; color: #ff9fb0; }
body[data-theme='dark'] .status-pill.freigelassen { background: #3a3020; border-color: #675531; color: #ffd587; }

body[data-theme='dark'] .banner-overlay {
  background: linear-gradient(90deg, rgba(10,13,21,0.86) 0%, rgba(10,13,21,0.58) 34%, rgba(10,13,21,0.14) 100%);
}

body[data-theme='dark'] .next-cap-pill strong,
body[data-theme='dark'] .death-counter-total {
  color: #c8d7ff;
}

body[data-theme='dark'] .special-encounter-wrap,
body[data-theme='dark'] .file-label {
  color: var(--text);
}

@media (max-width: 720px) {
  body[data-theme='dark'] .banner-overlay {
    background: linear-gradient(180deg, rgba(10,13,21,0.9) 0%, rgba(10,13,21,0.72) 46%, rgba(10,13,21,0.24) 100%);
  }
}
