:root {
  --bg: #100e0c;
  --panel: #1b1612;
  --ink: #f4eee4;
  --muted: #b5a696;
  --gold: #e4b75a;
  --line: #3c3229;
  --danger: #e07a5f;
  --good: #b7c96a;
  --sheet: #221c17;
  color-scheme: dark;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
}

body {
  overscroll-behavior: none;
}

button, input { font: inherit; color: inherit; }

#app {
  position: relative;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(226, 183, 87, 0.08), transparent 50%),
    var(--bg);
  padding-top: env(safe-area-inset-top);
}

header {
  flex: 0 0 auto;
  padding: 8px 12px 6px;
  display: grid;
  gap: 8px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}

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

h1 {
  margin: 0;
  font-family: Palatino, "Palatino Linotype", Georgia, serif;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
}

.meters {
  display: flex;
  gap: 8px;
}

.meter {
  margin: 0;
  min-width: 76px;
  padding: 6px 8px 5px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.meter span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.meter strong {
  display: block;
  margin-top: 1px;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.transport {
  display: grid;
  grid-template-columns: 1.3fr repeat(3, 1fr);
  gap: 6px;
}

.transport button,
#action,
#sheet-go,
.tool {
  border: 1px solid var(--line);
  background: #2a231c;
  border-radius: 12px;
  min-height: 48px;
  padding: 8px 10px;
  touch-action: manipulation;
}

.transport button {
  font-size: 16px;
  font-weight: 650;
}

.transport button[aria-pressed="true"] {
  background: #3d3428;
  border-color: var(--gold);
  color: var(--gold);
}

button:active { transform: translateY(1px); }

#stage {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  margin: 0 8px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #4a3d31;
  box-shadow: inset 0 0 0 3px #2a231c;
  background: #17140f;
}

#board {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#ribbon {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(16, 14, 12, 0.82);
  border: 1px solid var(--gold);
  color: var(--gold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 12px;
}

#inspector {
  flex: 0 0 auto;
  padding: 8px 12px 4px;
  display: grid;
  gap: 8px;
}

#status {
  margin: 0;
  min-height: 2.6em;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.3;
}

#aim {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

#aim[hidden] { display: none; }

#aim button {
  min-height: 48px;
  border: 1px solid var(--line);
  background: #2a231c;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  touch-action: manipulation;
}

#aim button[aria-pressed="true"] {
  border-color: var(--gold);
  color: var(--gold);
  background: #3d3428;
}

#action {
  width: 100%;
  background: #3f4a28;
  border-color: #6d7b3e;
  color: #f3f6df;
  font-size: 17px;
  font-weight: 650;
}

#action[hidden] { display: none; }

#action:disabled {
  background: #2a261f;
  color: var(--muted);
  border-color: var(--line);
}

#shop {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 12px calc(10px + env(safe-area-inset-bottom));
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
}

.tool {
  flex: 0 0 88px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  text-align: left;
  min-height: 78px;
  padding: 8px;
}

.tool[aria-pressed="true"] {
  border-color: var(--gold);
  background: #3a3126;
}

.tool.broke { opacity: 0.55; }

.swatch {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--swatch, #c4843a);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.35);
}

.tool-name { font-size: 14px; font-weight: 700; }
.tool-cost { color: var(--gold); font-size: 13px; font-variant-numeric: tabular-nums; }

#overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: flex-end;
  background: linear-gradient(to bottom, rgba(16, 14, 12, 0.02), rgba(16, 14, 12, 0.78) 48%, #100e0c 70%);
}

#overlay[hidden] { display: none; }

.sheet {
  width: 100%;
  padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
}

.sheet h2 {
  margin: 4px 0 8px;
  font-family: Palatino, "Palatino Linotype", Georgia, serif;
  font-size: 32px;
  line-height: 1.05;
  font-weight: 600;
}

.sheet p {
  margin: 0 0 14px;
  color: #ddd4c6;
  font-size: 16px;
  line-height: 1.35;
}

#sheet-go {
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 14px;
  background: var(--gold);
  color: #241c10;
  font-size: 18px;
  font-weight: 750;
}

@media (min-width: 800px) {
  body { background: #0b0a09; }
  #app { border-left: 1px solid #2a241e; border-right: 1px solid #2a241e; }
}
