:root {
  --lime: #d6ff3f;
  --pink: #ff3d8a;
  --ice: #9af6ff;
  --ink: #f6f5f1;
  --dim: #a7a79e;
  --bg: #07080b;
  --panel: rgba(8, 9, 12, 0.9);
  --line: rgba(214, 255, 63, 0.38);
  --safe-t: env(safe-area-inset-top);
  --safe-b: env(safe-area-inset-bottom);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: Outfit, system-ui, sans-serif; }
body { overflow: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

#view { position: fixed; inset: 0; z-index: 0; }
#view canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#labels { position: fixed; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }

.tag {
  position: absolute; left: 0; top: 0;
  display: flex; flex-direction: column; align-items: center;
  transform: translate(-50%, -100%);
}
.tag b, .tag small, .tag .say {
  background: rgba(7, 8, 11, 0.82);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  line-height: 1.2;
  white-space: nowrap;
}
.tag b { font-size: 12px; letter-spacing: 0.14em; }
.tag small { margin-top: 3px; color: var(--lime); letter-spacing: 0.12em; font-size: 10px; text-transform: uppercase; }
.tag .say {
  margin-top: 4px; border-radius: 10px; max-width: 180px; white-space: normal;
  text-align: center; font-size: 12px; color: var(--ink); border-color: rgba(255, 61, 138, 0.55);
}

header {
  position: fixed; z-index: 5; left: 0; right: 0; top: 0;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-t)) 12px 8px;
  background: linear-gradient(#07080bf2, #07080b00);
  pointer-events: none;
}
header > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand strong {
  font-family: Anton, sans-serif; font-size: 32px; letter-spacing: 0.08em; font-weight: 400; line-height: 0.85;
}
.brand small { display: block; margin-top: 2px; color: var(--lime); letter-spacing: 0.16em; font-size: 10px; text-transform: uppercase; }
.mark {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 10px; background: #101108; color: var(--lime);
  border: 1px solid var(--line); font-family: Anton, sans-serif; font-size: 26px;
  box-shadow: inset 0 4px 0 var(--pink);
}
.chip, .head-actions button, .modes button, .sheet button, dialog button {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
}
.chip {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 6px 12px; min-height: 44px; text-align: left;
}
.chip span { color: var(--dim); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; }
.chip b { font-size: 13px; font-weight: 600; }
.head-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.head-actions button, .reps {
  min-height: 44px; padding: 0 14px; display: inline-flex; align-items: center; gap: 6px;
}
.reps {
  border: 1px solid rgba(214, 255, 63, 0.55); border-radius: 999px;
  color: var(--lime); font-family: "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 0.08em; font-size: 13px; background: #12160a;
}
#cartCount {
  min-width: 1.4em; height: 1.4em; border-radius: 999px; display: grid; place-items: center;
  background: var(--pink); color: white; font-size: 12px;
}

#dock {
  position: fixed; z-index: 5; left: 50%; bottom: calc(12px + var(--safe-b));
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: min(560px, calc(100% - 24px)); pointer-events: none;
}
#dock > * { pointer-events: auto; }
.modes { display: flex; padding: 4px; border-radius: 999px; background: rgba(8, 9, 12, 0.88); border: 1px solid rgba(255,255,255,0.08); }
.modes button { border: 0; background: transparent; min-height: 40px; padding: 0 16px; border-radius: 999px; }
.modes button.on { background: var(--lime); color: #14180a; font-weight: 700; }
#hint { margin: 0; color: var(--dim); font-size: 12px; text-align: center; text-shadow: 0 1px 8px #000; }

#stick {
  position: fixed; z-index: 5; left: 16px; bottom: calc(92px + var(--safe-b));
  width: 112px; height: 112px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(8, 9, 12, 0.45);
  touch-action: none;
}
#knob {
  width: 48px; height: 48px; border-radius: 50%; background: var(--lime);
  position: absolute; left: 32px; top: 32px;
}

.sheet {
  position: fixed; z-index: 6; top: calc(72px + var(--safe-t)); bottom: calc(16px + var(--safe-b));
  width: min(380px, calc(100vw - 24px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 18px 16px 16px; overflow: auto;
  backdrop-filter: blur(10px);
}
#card { right: 12px; }
#rack, #cart { left: 12px; }
.sheet h2, dialog h2 { font-family: Anton, sans-serif; font-weight: 400; letter-spacing: 0.04em; font-size: 34px; margin: 0; line-height: 0.95; }
.kicker { margin: 0 0 6px; color: var(--pink); letter-spacing: 0.16em; text-transform: uppercase; font-size: 11px; }
.price { font-family: "IBM Plex Mono", ui-monospace, monospace; color: var(--lime); font-size: 28px; margin: 8px 0; }
.blurb { color: #dddcd4; line-height: 1.45; margin: 0 0 12px; }
.fine { color: var(--dim); font-size: 12px; line-height: 1.4; }
.banner { border: 1px dashed rgba(255, 61, 138, 0.7); border-radius: 10px; padding: 8px 10px; color: #ffd0e3; }
.x {
  position: absolute; right: 10px; top: 10px; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: #12140f; font-size: 22px;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { font-size: 28px; }
.sheet-head .x { position: static; }
fieldset { border: 0; margin: 0 0 12px; padding: 0; }
legend { color: var(--dim); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 6px; }
.sizes { display: flex; flex-wrap: wrap; gap: 6px; }
.sizes button { min-width: 44px; min-height: 44px; padding: 0 12px; border-radius: 10px; }
.sizes button.on { background: var(--lime); color: #14180a; border-color: var(--lime); font-weight: 700; }
#addBtn, #checkoutBtn, #receiptBtn, dialog button.full {
  width: 100%; min-height: 48px; border-radius: 12px; background: var(--lime); color: #14180a;
  border: 0; font-weight: 700;
}
#checkoutBtn:disabled, #addBtn:disabled { opacity: 0.45; }

.rack-item, .line {
  display: grid; grid-template-columns: 18px 1fr auto; gap: 10px; align-items: center;
  width: 100%; text-align: left; padding: 10px 8px; border-radius: 12px;
  border: 1px solid transparent; background: transparent; min-height: 52px;
}
.rack-item + .rack-item, .line + .line { border-top: 1px solid rgba(255,255,255,0.06); }
.swatch { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.3); }
.rack-item b, .line b { display: block; font-weight: 600; }
.rack-item small, .line small { color: var(--dim); }
.money { font-family: "IBM Plex Mono", ui-monospace, monospace; color: var(--lime); }
.qty { display: flex; align-items: center; gap: 4px; grid-column: 1 / -1; }
.qty button { width: 36px; height: 36px; border-radius: 8px; }
.totals { display: flex; justify-content: space-between; align-items: center; margin: 12px 0; font-size: 16px; }
.totals b { font-family: "IBM Plex Mono", ui-monospace, monospace; color: var(--lime); font-size: 22px; }

dialog {
  width: min(440px, calc(100vw - 24px)); border: 1px solid var(--line); border-radius: 18px;
  background: #0c0e12; color: var(--ink); padding: 18px 16px 16px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.62); }
.status {
  display: inline-block; margin: 8px 0; padding: 4px 8px; border-radius: 999px;
  background: var(--pink); letter-spacing: 0.14em; font-size: 12px; font-weight: 700;
}
.row { display: flex; gap: 8px; }
.row button { flex: 1; min-height: 48px; }
.ghost { background: transparent; border-radius: 12px; border: 1px solid var(--line); }

#loading {
  position: fixed; inset: 0; z-index: 9; display: grid; place-items: center; align-content: center; gap: 6px;
  background: radial-gradient(circle at 50% 40%, #171a12, #07080b 62%); text-align: center;
}
#loading strong { font-family: Anton, sans-serif; font-size: 64px; letter-spacing: 0.12em; }
#loading p { color: var(--dim); margin: 0; }
.noscript { position: fixed; inset: auto 12px calc(12px + var(--safe-b)); z-index: 10; background: #111; padding: 12px; }

body.overlay #dock, body.overlay #stick { visibility: hidden; }

@media (max-width: 760px) {
  .brand small, .chip span { display: none; }
  .brand strong { font-size: 26px; }
  .chip b { font-size: 12px; }
  .chip { min-width: 0; max-width: 34vw; }
  .chip b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28vw; }
  .reps { display: none; }
  .sheet {
    left: 0; right: 0; top: auto; width: auto;
    bottom: 0; max-height: min(78dvh, 640px);
    border-radius: 18px 18px 0 0; border-bottom: 0;
  }
  #hint { display: none; }
  header { gap: 6px; }
  .head-actions button { padding: 0 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
