:root {
  --bg: #141311;
  --bg-2: #1c1a18;
  --ink: #f2eee8;
  --muted: #9a948c;
  --faint: #6f6a64;
  --line: #2b2824;
  --tile: #f3f0ea;
  --accent: #c4a574;
  --accent-ink: #1a1612;
  --danger: #c47a6a;
  --radius: 10px;
  --font: "IBM Plex Sans", "Helvetica Neue", sans-serif;
  --display: "Newsreader", "Iowan Old Style", serif;
  --bar-h: 4.4rem;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; }
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
body { overflow: hidden; }

.app {
  height: 100dvh;
  height: 100svh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 1.25rem;
  padding: 0.55rem 1.25rem 0.4rem;
  border-bottom: 1px solid var(--line);
  min-height: 0;
}
.eyebrow {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 500;
}
.top h1 {
  font-family: var(--display);
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.vibe {
  flex: 1 1 14rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
  max-width: 36rem;
}

.stage {
  min-height: 0;
  display: grid;
  grid-template-rows: 1.15fr 2.2fr 2.2fr 1.15fr;
  gap: 0.3rem 0.75rem;
  padding: 0.35rem 1rem 0.2rem;
  width: min(42rem, 100%);
  margin: 0 auto;
}

.row {
  min-width: 0;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 0.75rem;
}
.row-tops .slot { flex: 1 1 0; max-width: 16rem; }

.slot {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  outline: none;
  height: 100%;
}
.slot:focus-visible .tile {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tile {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  width: auto;
  height: auto;
  aspect-ratio: 4 / 5;
  max-height: 100%;
  background: var(--tile);
  border-radius: var(--radius);
  overflow: hidden;
  align-self: center;
}
.tile img {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  object-position: center;
  transition: opacity 0.18s ease;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}
.tile img.swap { opacity: 0; }

.nav, .lock {
  position: absolute;
  z-index: 2;
  border: 0;
  background: rgba(20, 19, 17, 0.08);
  color: #2a2723;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.nav {
  top: 50%;
  transform: translateY(-50%);
  width: 1.7rem;
  height: 2.4rem;
  font-size: 1.35rem;
  line-height: 1;
  border-radius: 4px;
  opacity: 0.45;
}
.nav.prev { left: 0.15rem; }
.nav.next { right: 0.15rem; }
.row-hat .nav, .row-shoes .nav {
  width: 1.15rem;
  height: 1.6rem;
  font-size: 1.05rem;
  background: rgba(20, 19, 17, 0.04);
}
.tile:hover .nav, .slot:focus-within .nav, .nav:focus-visible { opacity: 1; background: rgba(20,19,17,0.16); }
.lock {
  top: 0.3rem;
  right: 0.3rem;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  opacity: 0.5;
  background: rgba(243, 240, 234, 0.7);
}
.lock:hover, .lock:focus-visible, .lock[aria-pressed="true"] { opacity: 1; }
.lock[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.lock svg {
  width: 0.85rem;
  height: 0.85rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.lock[aria-pressed="false"] .shackle {
  transform: translate(3px, -2px) rotate(18deg);
  transform-origin: 16px 8px;
}

.cap {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  align-items: baseline;
  padding: 0.2rem 0.05rem 0;
  color: var(--ink);
  text-decoration: none;
  font-size: clamp(0.64rem, 0.85vw, 0.75rem);
  line-height: 1.25;
  min-height: 1.55rem;
  max-height: 2.3rem;
  width: 100%;
  flex: 0 0 auto;
}
.cap:hover .cap-name { text-decoration: underline; text-underline-offset: 2px; }
.cap-name {
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: var(--ink);
}
.cap-price {
  flex: 0 0 auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.cap-price strong { color: var(--ink); font-weight: 500; }
.cap-price s { color: var(--faint); text-decoration: line-through; margin-left: 0.25rem; }

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.5rem 1.25rem 0.55rem;
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.bar-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.bar-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.35rem 1rem; }
.total {
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.total-label { font-family: var(--font); font-size: 0.72rem; color: var(--muted); font-weight: 400; margin-left: 0.2rem; }
.asof { font-size: 0.68rem; color: var(--faint); max-width: 28rem; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink);
  font: 500 0.82rem/1 var(--font);
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover, .btn:focus-visible { border-color: var(--muted); background: #24211e; }
.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 600;
}
.btn.primary:hover, .btn.primary:focus-visible { filter: brightness(1.06); }
.btn.icon {
  width: 2rem;
  height: 2rem;
  padding: 0;
  font-size: 1.2rem;
}

.shop {
  width: min(26rem, calc(100vw - 2rem));
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-2);
  color: var(--ink);
  padding: 1rem 1.1rem 1.15rem;
  box-shadow: none;
}
.shop::backdrop { background: rgba(8, 7, 6, 0.62); }
.shop-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.shop h2 { font-family: var(--display); font-size: 1.25rem; font-weight: 600; }
.shop-sub { color: var(--muted); font-size: 0.8rem; margin: 0.2rem 0 0.8rem; }
.shop ul { list-style: none; display: flex; flex-direction: column; gap: 0.55rem; }
.shop li a {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.86rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.5rem;
}
.shop li a:hover { color: var(--accent); }
.shop-total { margin-top: 0.8rem; font-family: var(--display); font-size: 1.15rem; }

@media (max-width: 640px) {
  body { overflow: hidden; }
  .top { padding: 0.4rem 0.7rem 0.25rem; }
  .stage { padding: 0.25rem 0.55rem 0.1rem; gap: 0.22rem 0.45rem; width: 100%; }
  .row-tops { gap: 0.4rem; }
  .row-tops .slot { max-width: none; }
  .nav { opacity: 0.7; width: 1.35rem; height: 2rem; font-size: 1.2rem; }
  .bar { padding: 0.4rem 0.7rem 0.45rem; }
  .vibe { display: none; }
  .asof { max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-height: 700px) {
  .top { padding-top: 0.35rem; padding-bottom: 0.25rem; }
  .top h1 { font-size: 1.15rem; }
  .cap { min-height: 1.45rem; }
}
