:root {
  --bg: #100d0a;
  --panel: #211c15;
  --panel-deep: #17130f;
  --line: #5b4f3b;
  --line-dark: #090705;
  --text: #dccfb8;
  --muted: #b8a98b;
  --gold: #c9b06a;
  --green: #43d66f;
  --red: #d4564f;
  --blue: #76a9e0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  overflow-x: hidden;
}

button,
select,
input,
textarea {
  font: inherit;
}

.app-shell {
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 18px 12px 32px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 3rem, 3.3rem);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 1.22rem;
}

.top-actions,
.backup-actions,
.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-title {
  justify-content: space-between;
  margin-bottom: 12px;
}

.icon-btn,
.small-btn,
.wide-btn,
.tab,
.select {
  min-height: 38px;
  border: 1px solid var(--line);
  background: #2b241a;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
}

.icon-btn {
  width: 40px;
  font-size: 1.2rem;
}

.small-btn,
.wide-btn,
.tab,
.select {
  padding: 8px 12px;
}

.wide-btn {
  width: 100%;
}

.primary,
.tab.active {
  background: #5b461c;
  border-color: var(--gold);
  color: #fff1c7;
}

.danger {
  border-color: #8b3933;
  color: #ffd0cb;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 8px 0 12px;
}

.stat,
.panel,
.toast {
  border: 1px solid var(--line-dark);
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
}

.stat {
  min-height: 76px;
  padding: 12px;
  border-radius: 8px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 1.8rem;
  line-height: 1;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.tab-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.layout-two {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 12px;
}

.panel {
  border-radius: 8px;
  padding: 14px;
}

.active-panel {
  min-height: 330px;
}

.card-list,
.log-list,
.slayer-grid,
.skills-grid {
  display: grid;
  gap: 10px;
}

.card-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card,
.skill-row,
.slayer-card,
.empty-state {
  border: 1px solid var(--line);
  background: var(--panel-deep);
  border-radius: 8px;
  padding: 12px;
}

.card {
  min-height: 148px;
}

.card h3,
.slayer-card h3 {
  margin: 0 0 6px;
  font-size: 1.08rem;
}

.card p,
.backup-panel p,
.empty-state {
  color: var(--muted);
  line-height: 1.35;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #211910;
  font-size: 0.8rem;
}

.badge.good {
  color: #c7ffd7;
  border-color: #3f8f51;
}

.badge.warn {
  color: #ffe0a6;
  border-color: #a77a2a;
}

.badge.bad {
  color: #ffd0cb;
  border-color: #8b3933;
}

.skills-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  max-width: 720px;
  margin: 0 auto;
  padding: 6px;
  border: 2px solid #77684d;
  border-radius: 4px;
  background: #2a261f;
  box-shadow: inset 0 0 0 2px #12100c;
}

.skill-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 6px 8px;
  border: 1px solid #6b5d43;
  border-radius: 2px;
  background: linear-gradient(#332f27, #24211b);
  box-shadow: inset 1px 1px #494235, inset -1px -1px #14120f;
}

.skill-row img,
.slayer-card img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.slayer-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.slayer-head {
  display: flex;
  gap: 10px;
  align-items: center;
}

.slayer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.log-list {
  max-height: 68vh;
  overflow: auto;
}

.log-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.history-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--panel-deep);
  border-radius: 8px;
  padding: 10px 12px;
}

.history-item img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.skill-row img {
  width: 38px;
  height: 38px;
  image-rendering: pixelated;
}

.skill-details {
  min-width: 0;
}

.skill-details strong,
.skill-details span {
  display: block;
}

.skill-details strong {
  overflow: hidden;
  color: #f1dfb2;
  font-size: 0.96rem;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-details span {
  margin-top: 4px;
  color: #ffe45c;
  font-size: 0.86rem;
  text-shadow: 1px 1px #000;
}

.skill-row.unrestricted {
  filter: grayscale(1);
  opacity: 0.48;
}

.skill-row.unrestricted .skill-details span {
  color: #c7c1b4;
}

.skill-fallback {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #c8b98f;
  font-family: Georgia, serif;
  font-size: 1rem;
  font-weight: bold;
  text-shadow: 1px 1px #000;
}

.skill-help {
  max-width: 720px;
  margin: -2px auto 12px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.history-item strong,
.history-item span {
  display: block;
}

.history-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.85rem;
}

.log-item h3 {
  margin: 0 0 4px;
}

.backup-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 14px 0;
}

textarea {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f0c09;
  color: var(--text);
  padding: 10px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.86rem;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(360px, calc(100% - 32px));
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.site-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.82rem;
}

.site-footer a {
  color: var(--gold);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 900px) {
  .stats-grid,
  .layout-two,
  .slayer-grid,
  .card-list,
  .backup-actions {
    grid-template-columns: 1fr;
  }

  .skills-grid {
    gap: 3px;
    padding: 4px;
  }

  .skill-row {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 5px;
    min-height: 52px;
    padding: 5px;
  }

  .skill-row img,
  .skill-fallback {
    width: 28px;
    height: 28px;
  }

  .skill-fallback {
    font-size: 1.2rem;
  }

  .skill-details strong {
    font-size: 0.78rem;
  }

  .skill-details span {
    font-size: 0.76rem;
  }

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

  .top-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .icon-btn {
    width: auto;
    min-width: 0;
  }

  .panel-title {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: flex-start;
  }

  .panel-title .small-btn,
  .panel-title .select {
    max-width: 100%;
  }
}
