:root {
  --bg: #12131a;
  --bg-raised: #1c1e28;
  --bg-edge: #2a2d3a;
  --fg: #e6e8f0;
  --fg-muted: #9aa0b4;
  --accent: #7fd1c1;
  --armour: #d6b26a;
  --over: #e08a7a;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.4 system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body.sheet-is-open {
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

h1 {
  font-size: 1.25rem;
  margin: 0;
}

h2 {
  font-size: 1.1rem;
  margin: 0;
}

h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  margin: 1rem 0 0.35rem;
}

.loading {
  padding: 1.5rem;
  color: var(--fg-muted);
}

.picker {
  padding: 1.25rem 1rem 2rem;
  max-width: 46rem;
  margin: 0 auto;
}

.picker-list {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.picker-card {
  width: 100%;
  min-height: 3.5rem;
  padding: 0.9rem 1rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  text-align: left;
  background: var(--bg-raised);
  border: 1px solid var(--bg-edge);
  border-radius: 0.75rem;
}

.picker-card:active {
  transform: scale(0.99);
}

.picker-name {
  font-weight: 600;
}

.picker-marker {
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.character {
  padding: 0.75rem 0.75rem calc(4.5rem + env(safe-area-inset-bottom));
  max-width: 46rem;
  margin: 0 auto;
}

.character-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 0.5rem;
}

.back {
  color: var(--accent);
  padding: 0.5rem 0.25rem;
}

.done {
  margin-left: auto;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: var(--fg-muted);
  background: var(--bg-raised);
  border: 1px solid var(--bg-edge);
  border-radius: 999px;
}

.done-set {
  color: var(--accent);
  border-color: var(--accent);
}

.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--bg-edge);
  margin-bottom: 0.75rem;
}

.tab {
  flex: 1;
  min-height: 2.75rem;
  color: var(--fg-muted);
}

.tab-current {
  color: var(--fg);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.tab:disabled {
  opacity: 0.4;
  cursor: default;
}

.body-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.3rem;
}

.slot {
  min-height: 3.25rem;
  padding: 0.35rem 0.15rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  background: var(--bg-raised);
  border: 1px solid var(--bg-edge);
  border-radius: 0.5rem;
}

.slot-armoured {
  border-color: var(--armour);
}

.slot-name {
  font-size: 0.68rem;
  line-height: 1.1;
  text-align: center;
  color: var(--fg-muted);
}

.slot-dr {
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.slot-armoured .slot-dr {
  color: var(--armour);
}

.pin {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.6rem 0.75rem calc(0.6rem + env(safe-area-inset-bottom));
  background: var(--bg-raised);
  border-top: 1px solid var(--bg-edge);
}

.pin-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.pin-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
}

.pin-value {
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pin-field-over .pin-value,
.pin-field-over .pin-label {
  color: var(--over);
}

.shop {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.shop-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.15rem 0.6rem;
  padding: 0.5rem 0.6rem;
  background: var(--bg-raised);
  border: 1px solid var(--bg-edge);
  border-radius: 0.5rem;
}

.shop-row-carted {
  border-color: var(--accent);
}

.shop-name {
  font-size: 0.95rem;
}

.shop-price {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--fg-muted);
  text-align: right;
}

.shop-controls {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
}

.shop-controls button {
  min-height: 2.25rem;
  min-width: 2.5rem;
  padding: 0 0.6rem;
  border: 1px solid var(--bg-edge);
  border-radius: 0.4rem;
  color: var(--accent);
}

.shop-quantity {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  min-width: 1.5rem;
  text-align: center;
}

.shop-quality {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.shop-tier {
  min-height: 2.25rem;
  padding: 0 0.7rem;
  border: 1px solid var(--bg-edge);
  border-radius: 0.4rem;
  color: var(--fg-muted);
  font-size: 0.85rem;
}

.shop-tier-chosen {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.shop-caption {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.sheet-root {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border-top-left-radius: 1rem;
  border-top-right-radius: 1rem;
  animation: sheet-rise 180ms ease-out;
}

@keyframes sheet-rise {
  from {
    transform: translateY(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sheet-panel {
    animation: none;
  }
}

.sheet-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--bg-edge);
}

.sheet-dismiss {
  min-width: 2.75rem;
  min-height: 2.75rem;
  color: var(--fg-muted);
}

.sheet-content {
  overflow-y: auto;
  padding: 0.5rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
}

.detail-headline {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin: 0.75rem 0 0;
}

.detail-inherent,
.detail-roll {
  color: var(--fg-muted);
  font-size: 0.85rem;
}

.detail-caveats,
.detail-layers,
.detail-notes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.detail-layers li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.detail-layer-dr {
  color: var(--fg-muted);
  white-space: nowrap;
}

.detail-notes li {
  color: var(--fg-muted);
  font-size: 0.85rem;
}

@media (min-width: 40rem) {
  .character {
    padding-top: 1.5rem;
  }

  .body-grid {
    gap: 0.5rem;
  }

  .slot {
    min-height: 4.25rem;
  }

  .slot-name {
    font-size: 0.8rem;
  }

  .slot-dr {
    font-size: 1.05rem;
  }

  .pin {
    justify-content: center;
    gap: 2.5rem;
  }

  .pin-field {
    flex: 0 0 auto;
  }

  .sheet-panel {
    left: 50%;
    transform: translateX(-50%);
    width: min(36rem, 100%);
    animation-name: sheet-rise-wide;
  }
}

@keyframes sheet-rise-wide {
  from {
    transform: translate(-50%, 100%);
  }
}
