/* Salon Teckel — walnut panelling, mustard vinyl, one barber pole. */

:root {
  --ink: #2b1d15;
  --walnut: #4a2e1e;
  --walnut-light: #6b452c;
  --cream: #f2e4c9;
  --tile: #e4d3b0;
  --mustard: #e8a32c;
  --mustard-dark: #b87d18;
  --avocado: #6e7f3a;
  --oxblood: #9b3520;
  --teal: #2e6e70;
  --gold: #f0c24b;

  --display: 'Bungee', 'Archivo', system-ui, sans-serif;
  --body: 'Archivo', system-ui, -apple-system, sans-serif;

  --edge: 3px solid var(--ink);
  --lift: 6px 6px 0 var(--ink);
}

* { box-sizing: border-box; }

/* Several panels below set `display`, which would otherwise beat [hidden]. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--walnut);
  background-image:
    repeating-linear-gradient(90deg, rgba(0,0,0,0.16) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.035) 0 1px, transparent 1px 26px);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.frame {
  max-width: 1320px;
  margin: 0 auto;
  padding: clamp(10px, 2vw, 22px);
  display: flex;
  flex-direction: column;
  justify-content: safe center;
  gap: 14px;
  min-height: 100dvh;
}

/* ---------- Header ---------- */

.hud {
  display: flex;
  align-items: center;
  gap: clamp(12px, 3vw, 34px);
  flex-wrap: wrap;
  background: var(--mustard);
  border: var(--edge);
  box-shadow: var(--lift);
  padding: 10px clamp(12px, 2vw, 20px);
}

.brand {
  font-family: var(--display);
  font-size: clamp(19px, 2.6vw, 27px);
  line-height: 1;
  margin: 0;
  color: var(--oxblood);
  text-shadow: 2px 2px 0 var(--cream);
}
.brand span { color: var(--ink); margin-left: 0.35em; }

.hud-stats {
  display: flex;
  gap: clamp(12px, 3vw, 30px);
  margin-left: auto;
  flex-wrap: wrap;
}

.stat { margin: 0; display: flex; flex-direction: column; line-height: 1.15; }

.stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--walnut);
}

.stat-value { font-family: var(--display); font-size: 19px; }
.coins .stat-value { color: var(--oxblood); }

/* ---------- Stage ---------- */

.stage {
  position: relative;
  border: var(--edge);
  box-shadow: var(--lift);
  background: var(--tile);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  width: 100%;
  /* Keep the whole salon — header, stage and tool rail — on one screen. */
  max-width: calc((100dvh - 270px) * 16 / 9);
  min-width: min(100%, 560px);
  margin-inline: auto;
}

#scene { display: block; width: 100%; height: 100%; touch-action: manipulation; }
#scene.armed { cursor: crosshair; }
#scene.clickable { cursor: pointer; }

.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: clamp(10px, 1.6vw, 20px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-content: start;
  gap: 12px;
  container-type: inline-size;
}

.client-card, .meter-card {
  background: var(--cream);
  border: var(--edge);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 12px 16px;
}

/* cqw, not vw: these are measured against the stage so they always stop short
   of the dog, whatever size the window is. */
.client-card { max-width: 24cqw; }
.client-card h2 { font-family: var(--display); font-size: clamp(15px, 1.7vw, 23px); margin: 2px 0 1px; }

.client-note {
  margin: 0 0 8px;
  font-size: clamp(10px, 1.05vw, 13px);
  font-style: italic;
  color: var(--walnut);
}

.eyebrow {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--oxblood);
}

.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }

.checklist li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: clamp(11px, 1.15vw, 15px);
  font-weight: 500;
}

.checklist li::before {
  content: '';
  flex: none;
  width: 12px; height: 12px;
  border: 2px solid var(--ink);
  background: transparent;
}
.checklist li.done::before { background: var(--avocado); }
.checklist li.done { text-decoration: line-through; opacity: 0.6; }
.checklist li .step-n {
  font-family: var(--display);
  font-size: 11px;
  color: var(--oxblood);
}

.meter-card { width: 26cqw; text-align: right; }

/* The signature: a barber pole that fills up. */
.pole {
  height: 26px;
  margin: 6px 0 4px;
  border: 2px solid var(--ink);
  background: var(--cream);
  overflow: hidden;
}

.pole-fill {
  height: 100%;
  width: 50%;
  transition: width 0.45s cubic-bezier(0.2, 0.8, 0.3, 1);
  background-image: repeating-linear-gradient(
    115deg,
    var(--oxblood) 0 12px,
    var(--cream) 12px 24px,
    var(--teal) 24px 36px,
    var(--cream) 36px 48px
  );
  background-size: 48px 100%;
  animation: pole-spin 1.4s linear infinite;
}

@keyframes pole-spin { to { background-position: 48px 0; } }

.meter-read { margin: 0; font-family: var(--display); font-size: 14px; }

.ticker {
  position: absolute;
  left: 50%;
  bottom: 14px;
  pointer-events: none;
  margin: 0;
  max-width: min(60ch, 88%);
  text-align: center;
  font-size: clamp(12px, 1.3vw, 17px);
  font-weight: 500;
  background: var(--ink);
  color: var(--cream);
  padding: 8px 18px;
  border-radius: 999px;
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity 0.25s, transform 0.25s;
}
.ticker.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Tool rail ---------- */

.tray {
  background: var(--walnut-light);
  border: var(--edge);
  box-shadow: var(--lift);
  padding: 10px clamp(10px, 1.6vw, 16px) 14px;
}

.tray-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}
.tray-head .eyebrow { color: var(--gold); }

.rail {
  list-style: none;
  margin: 0;
  padding: 0 0 4px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: thin;
  /* Holds its height while empty so the stage never jumps between scenes. */
  min-height: 74px;
}

.tool-slot {
  flex: 1 1 0;
  min-width: 158px;
  height: 70px;
  border: 3px dashed rgba(242, 228, 201, 0.28);
}

.tool {
  flex: 1 1 0;
  min-width: 158px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 21px 12px 9px;
  background: var(--cream);
  border: var(--edge);
  box-shadow: 4px 4px 0 var(--ink);
  font-family: var(--body);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}

.tool:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.tool:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.tool[aria-pressed='true'] { background: var(--gold); transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.tool:disabled { opacity: 0.34; cursor: not-allowed; filter: grayscale(1); }

.tool::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 10px;
  background: var(--avocado);
}
.tool.chaos::before {
  background: repeating-linear-gradient(45deg, var(--oxblood) 0 9px, var(--gold) 9px 18px);
}

.tool-key {
  position: absolute;
  top: 12px; right: 8px;
  font-family: var(--display);
  font-size: 10px;
  color: var(--walnut);
}

.tool svg { width: 28px; height: 28px; flex: none; }
.tool-text { display: grid; gap: 1px; min-width: 0; }
.tool-name { font-weight: 700; font-size: 13.5px; line-height: 1.15; }
/* Clamped to one line so the rail is the same height whatever the blurb says. */
.tool-blurb {
  font-size: 11px;
  line-height: 1.3;
  color: var(--walnut);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Buttons ---------- */

.btn {
  font-family: var(--display);
  font-size: 15px;
  padding: 11px 20px;
  background: var(--oxblood);
  color: var(--cream);
  border: var(--edge);
  box-shadow: 4px 4px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.btn-quiet { background: var(--cream); color: var(--ink); font-size: 13px; padding: 8px 16px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: 4px 4px 0 var(--ink); }

.ghost-btn {
  font-family: var(--body);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  background: transparent;
  border: 2px solid var(--ink);
  padding: 6px 12px;
  cursor: pointer;
  color: var(--ink);
}
.ghost-btn[aria-pressed='false'] { opacity: 0.5; text-decoration: line-through; }

:where(button, a, [tabindex]):focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 3px;
}

/* ---------- Panels ---------- */

.panel-scrim {
  /* Fixed rather than pinned to the stage: on short windows a panel would
     otherwise be squeezed into a box shorter than its own content. */
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(43, 29, 21, 0.78);
  display: grid;
  /* `safe` so a panel taller than the stage scrolls from its top rather than
     being clipped at both ends. */
  place-content: safe center;
  justify-items: center;
  padding: clamp(10px, 2vw, 28px);
  overflow: auto;
}

.panel {
  width: min(760px, 100%);
  /* Panels live inside the stage, so on short screens they scroll rather
     than spilling past its edges. */
  max-height: 100%;
  overflow-y: auto;
  background: var(--cream);
  border: var(--edge);
  box-shadow: 10px 10px 0 var(--ink);
  padding: clamp(16px, 2.4vw, 30px);
}

.panel h2 {
  font-family: var(--display);
  font-size: clamp(20px, 3vw, 34px);
  line-height: 1.1;
  margin: 4px 0 10px;
  color: var(--oxblood);
}

.panel p { margin: 0 0 12px; font-size: clamp(13px, 1.3vw, 16px); }
.panel .lede { font-size: clamp(14px, 1.5vw, 18px); font-weight: 500; }

/* Sticky so the way forward is always reachable, however long the shop gets. */
.panel-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding: 12px 0 2px;
  background: var(--cream);
}

.ledger { list-style: none; margin: 14px 0; padding: 0; border-top: 2px dashed var(--walnut); }
.ledger li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 0;
  border-bottom: 2px dashed var(--walnut);
  font-size: 14px;
  font-weight: 500;
}
.ledger .value { font-family: var(--display); font-size: 14px; }
.ledger .value.minus { color: var(--oxblood); }
.ledger .value.plus { color: var(--avocado); }

.payout {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  background: var(--mustard);
  border: var(--edge);
  padding: 12px 18px;
  margin-top: 14px;
}
.payout .amount { font-family: var(--display); font-size: clamp(22px, 3vw, 32px); }

.grade-badge {
  display: inline-block;
  font-family: var(--display);
  font-size: 13px;
  background: var(--walnut);
  color: var(--cream);
  padding: 5px 12px;
  border: 2px solid var(--ink);
}
.grade-badge[data-grade='flawless'] { background: var(--avocado); }
.grade-badge[data-grade='good'] { background: var(--teal); }
.grade-badge[data-grade='rough'] { background: var(--mustard-dark); }
.grade-badge[data-grade='catastrophe'] { background: var(--oxblood); }

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
  gap: 10px;
  margin: 14px 0 4px;
}

.offer {
  text-align: left;
  background: var(--tile);
  border: var(--edge);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 9px 11px;
  cursor: pointer;
  display: grid;
  gap: 3px;
  align-content: start;
  font-family: var(--body);
  color: var(--ink);
  transition: transform 0.12s, box-shadow 0.12s;
}
.offer:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.offer:disabled { opacity: 0.4; cursor: not-allowed; }
.offer .offer-name { font-weight: 700; font-size: 14px; }
.offer .offer-blurb { font-size: 11.5px; color: var(--walnut); line-height: 1.3; }
.offer .offer-price {
  font-family: var(--display);
  font-size: 14px;
  color: var(--oxblood);
  margin-top: 2px;
}
.offer.upgrade { background: var(--gold); }

.cupboard {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}
.cupboard li {
  font-size: 12px;
  font-weight: 600;
  background: var(--walnut);
  color: var(--cream);
  padding: 3px 9px;
  border-radius: 999px;
}

.hint {
  font-size: 12.5px;
  color: var(--walnut);
  border-left: 4px solid var(--mustard);
  padding-left: 10px;
}

.noscript { color: var(--cream); text-align: center; padding: 40px; font-size: 18px; }


@media (max-width: 560px) {
  .hud-stats { width: 100%; margin-left: 0; justify-content: space-between; }
  .tool { min-width: 116px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
