:root {
  color-scheme: dark;
  --bg: #151610;
  --panel: #202117;
  --panel-2: #292b1f;
  --line: #4e5139;
  --line-soft: #383a2a;
  --text: #f0eedf;
  --muted: #aaa68f;
  --accent: #b9bd80;
  --accent-2: #d5d0aa;
  --danger: #d08070;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select,
input {
  font: inherit;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 68px;
  padding: 0 28px;
  background: #1a1b13;
  color: var(--text);
  border-top: 8px solid #2b2630;
  border-bottom: 1px solid var(--line-soft);
}

.site-brand,
.site-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-brand .mark {
  width: 30px;
  height: 30px;
  border-color: #687044;
}

.site-brand strong {
  font-size: 20px;
}

.site-nav {
  margin: 0 auto;
}

.nav-tab {
  min-height: 38px;
  padding: 8px 16px;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

.nav-tab:hover,
.nav-tab.active {
  color: var(--text);
  border-color: var(--accent);
  background: #2a2c1f;
}

.app {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 320px;
  min-height: calc(100vh - 68px);
}

.sidebar,
.stats {
  padding: 18px;
  background: #1a1b13;
  border-color: var(--line-soft);
}

.sidebar {
  border-right: 1px solid var(--line-soft);
}

.stats {
  border-left: 1px solid var(--line-soft);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.mark {
  width: 34px;
  height: 34px;
  border: 2px solid var(--accent);
  background:
    linear-gradient(90deg, transparent 45%, #12130d 45% 55%, transparent 55%),
    repeating-linear-gradient(0deg, #7b7a50 0 5px, #333420 5px 8px);
  image-rendering: pixelated;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 19px;
}

h2 {
  font-size: 15px;
  margin-bottom: 10px;
}

.brand p,
.crumb,
.stat-meta,
.hint {
  color: var(--muted);
}

.panel {
  padding: 12px;
  margin-bottom: 14px;
  border: 1px solid var(--line-soft);
  background: var(--panel);
  border-radius: 6px;
}

.hidden {
  display: none;
}

.button-list {
  display: grid;
  gap: 8px;
}

button,
select,
input {
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
}

button {
  min-height: 36px;
  padding: 8px 10px;
  cursor: pointer;
}

button:hover,
button.active {
  border-color: var(--accent);
  background: #343624;
}

select {
  width: 100%;
  min-height: 36px;
  padding: 8px;
}

input {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
}

.workspace {
  min-width: 0;
  padding: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 14px;
}

.topbar h2 {
  margin: 2px 0 0;
  font-size: 21px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

#resetButton {
  color: #ffe2da;
  border-color: #74473f;
}

#adminStatus {
  color: var(--muted);
}

.icon-button {
  width: 38px;
  min-height: 36px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.sprite-card {
  border: 1px solid var(--line-soft);
  background: #0d0e0a;
  border-radius: 6px;
  overflow: hidden;
}

.sprite-wrap {
  position: relative;
  overflow: auto;
  max-height: calc(100vh - 154px);
}

#sprite {
  display: block;
  width: 100%;
  min-width: 780px;
  height: auto;
  image-rendering: pixelated;
  cursor: crosshair;
}

.hover-band {
  position: absolute;
  left: 0;
  right: 0;
  display: none;
  border: 2px solid #ffdf6b;
  background: rgba(255, 223, 107, 0.08);
  pointer-events: none;
}

.stat-item {
  display: grid;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}

.stat-item:last-child {
  border-bottom: 0;
}

.stat-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.bar {
  height: 10px;
  border: 1px solid #4b4d35;
  background: #11120d;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.admin-view {
  min-height: calc(100vh - 68px);
  padding: 24px;
}

.admin-card {
  max-width: 720px;
  padding: 18px;
  border: 1px solid var(--line-soft);
  background: var(--panel);
  border-radius: 6px;
}

.admin-card h2 {
  font-size: 22px;
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(180px, 240px) auto auto;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}

@media (max-width: 1050px) {
  .app {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .stats {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line-soft);
  }
}

@media (max-width: 720px) {
  .site-header,
  .site-nav {
    align-items: stretch;
    flex-direction: column;
  }

  .site-header {
    padding: 12px 16px;
  }

  .app {
    display: block;
  }

  .admin-row {
    grid-template-columns: 1fr;
  }

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

  #sprite {
    min-width: 620px;
  }
}
