:root {
  --bg: #2a1720;
  --panel: #fff8f6;
  --ink: #2d1b22;
  --muted: #8a6f78;
  --accent: #d6457a;
  --accent-dark: #a92f5c;
  --gold: #e6b450;
  --line: #ecd6dc;
  --good: #2f8f5b;
  --bad: #c0392b;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg) radial-gradient(ellipse at 50% 30%, #6b3a4c 0%, #2a1720 70%);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.hidden { display: none !important; }
button {
  font: inherit;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  touch-action: manipulation;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent-dark); color: #fff; font-weight: 700; }
button.primary:hover { background: var(--accent-dark); }
button.big { font-size: 1.15rem; padding: 12px 22px; }
button.icon { padding: 6px 10px; background: transparent; border-color: transparent; font-size: 1.1rem; }
button.chip { border-radius: 999px; padding: 6px 12px; font-size: 0.9rem; white-space: nowrap; }
button.chip.on { background: var(--accent); color: #fff; border-color: var(--accent-dark); }

.screen { position: fixed; inset: 0; }
.overlay { display: flex; align-items: center; justify-content: center; background: rgba(30, 12, 20, 0.6); z-index: 20; padding: 16px; }
.panel { background: var(--panel); border-radius: 18px; padding: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4); max-height: 100%; overflow: auto; }
.muted { color: var(--muted); }
.sw { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.18); vertical-align: middle; flex: none; box-shadow: inset -2px -3px 4px rgba(0, 0, 0, 0.15), inset 2px 2px 3px rgba(255, 255, 255, 0.35); }
.sw.sm { width: 12px; height: 12px; }
.sw.big { width: 46px; height: 46px; }

/* ── Title ─────────────────────────────────────────────────────────────── */
#title { display: flex; align-items: center; justify-content: center; padding: 16px; }
.title-panel { width: min(520px, 100%); text-align: center; display: flex; flex-direction: column; gap: 12px; }
.logo { font-family: Georgia, "Times New Roman", serif; font-size: 3.2rem; margin: 0; letter-spacing: 1px; color: var(--ink); }
.logo span { color: var(--accent); font-style: italic; }
.tag { margin: 0; color: var(--muted); }
.stats { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; }
.help { text-align: left; font-size: 0.92rem; }
.help summary { cursor: pointer; font-weight: 600; }
.help li { margin: 6px 0; }

/* ── Salon ─────────────────────────────────────────────────────────────── */
#salon {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "top top" "card stage" "dock dock";
  background: linear-gradient(180deg, #4a2633, #2a1720);
}
#salon.hidden { display: none; }
.topbar {
  grid-area: top;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 14px; padding-top: max(8px, env(safe-area-inset-top));
  background: rgba(255, 248, 246, 0.96);
}
.who { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.who span { color: var(--muted); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer { font-variant-numeric: tabular-nums; font-size: 1.5rem; font-weight: 800; }
.timer.low { color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }
.top-actions { display: flex; align-items: center; gap: 8px; }
.wallet { font-weight: 600; white-space: nowrap; }

.look-card { grid-area: card; background: rgba(255, 248, 246, 0.94); margin: 10px 0 10px 10px; border-radius: 14px; padding: 14px; overflow: auto; }
.look-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.look-card h2, .shop-panel h2 { margin: 0; font-family: Georgia, serif; }
.blurb { color: var(--muted); font-size: 0.9rem; }
.want-list { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.want-list li { display: grid; grid-template-columns: 22px 92px 1fr; gap: 6px; align-items: center; font-size: 0.9rem; }
.want-list em { color: var(--bad); font-style: normal; font-size: 0.8rem; }
.skin-note { font-size: 0.85rem; color: var(--muted); }

.stage {
  grid-area: stage; position: relative; overflow: hidden; touch-action: none;
  background: radial-gradient(ellipse at 50% 40%, #f6e3e6 0%, #d9b3bd 55%, #8f5a6a 100%);
  margin: 10px; border-radius: 16px;
  box-shadow: inset 0 0 0 6px #f2d7a6, inset 0 0 0 8px #b98b45, 0 0 40px rgba(255, 230, 180, 0.25);
  cursor: none;
}
#face-canvas { position: absolute; inset: 0; display: block; }
.zoom-badge { position: absolute; right: 12px; top: 12px; background: rgba(0, 0, 0, 0.55); color: #fff; padding: 2px 8px; border-radius: 999px; font-size: 0.8rem; pointer-events: none; }

.dock { grid-area: dock; min-width: 0; background: rgba(255, 248, 246, 0.97); padding: 8px 10px; padding-bottom: max(8px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.dock-row { display: flex; gap: 8px; align-items: center; overflow-x: auto; scrollbar-width: none; }
.dock-row::-webkit-scrollbar { display: none; }
.size { display: flex; align-items: center; gap: 4px; }
.size input { width: 120px; accent-color: var(--accent); }
.shades { min-height: 40px; }
.shade { display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; white-space: nowrap; font-size: 0.85rem; flex: none; }
.shade .sw { width: 22px; height: 22px; }
.shade.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.hint { color: var(--muted); font-size: 0.9rem; }
.tool { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 76px; padding: 6px 8px; flex: none; }
.tool .ti { font-size: 1.4rem; line-height: 1; }
.tool .tn { font-size: 0.72rem; white-space: nowrap; }
.tool.on { background: var(--accent); color: #fff; border-color: var(--accent-dark); }
.touch-only { display: none; }

/* ── Brief / results / shop ────────────────────────────────────────────── */
.brief-panel { width: min(480px, 100%); text-align: center; }
.kicker { margin: 0; color: var(--accent); font-weight: 700; }
.brief-panel h2 { font-family: Georgia, serif; margin: 6px 0; }
.says { font-style: italic; }

.results-panel { width: min(900px, 100%); display: flex; gap: 18px; }
.photos { display: flex; gap: 10px; flex: none; }
.photos figure { margin: 0; text-align: center; }
.photos canvas { width: 180px; height: 225px; border-radius: 12px; display: block; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25); }
.photos figcaption { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.verdict { flex: 1; min-width: 0; }
.stars { font-size: 2.2rem; color: #d9cbd0; letter-spacing: 3px; }
.stars .lit { color: var(--gold); text-shadow: 0 0 10px rgba(230, 180, 80, 0.6); }
.notes { padding-left: 18px; margin: 6px 0; font-size: 0.9rem; }
.breakdown { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin: 8px 0; }
.breakdown th, .breakdown td { padding: 3px 6px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.breakdown tbody th { font-weight: 600; }
.breakdown tr.good th { color: var(--good); }
.breakdown tr.bad th { color: var(--bad); }
.pay { font-size: 1rem; }
.levelup { background: #fff1c9; border-radius: 10px; padding: 8px 12px; font-weight: 600; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }

.shop-panel { width: min(760px, 100%); display: flex; flex-direction: column; gap: 12px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.item { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 8px; font-size: 0.85rem; text-align: center; }
.item span { color: var(--accent-dark); font-weight: 700; }
.item.owned { opacity: 0.6; }
.item.owned span { color: var(--good); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; z-index: 50; pointer-events: none; }

/* ── Phones and tablets: the face fills the screen, the look card becomes a
   sheet, and the dock is a thumb-sized tray at the bottom ───────────────── */
@media (max-width: 820px), (pointer: coarse) and (max-width: 1100px) {
  #salon { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "stage" "dock"; }
  .touch-only { display: inline-block; }
  .look-card {
    position: fixed; left: 8px; right: 8px; top: 64px; z-index: 15; margin: 0;
    max-height: 60vh; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    transform: translateY(-120%); transition: transform 0.25s ease;
  }
  .look-card.open { transform: none; }
  .stage { margin: 6px; cursor: default; }
  .topbar { padding: 6px 10px; padding-top: max(6px, env(safe-area-inset-top)); }
  .timer { font-size: 1.25rem; }
  .wallet { display: none; }
  .dock { gap: 6px; padding: 6px 8px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .tool { min-width: 58px; min-height: 54px; padding: 6px; }
  .tool .ti { font-size: 1.6rem; }
  .tool .tn { display: none; }
  .tool.on .tn { display: block; font-size: 0.6rem; }
  .shade { padding: 6px 8px; }
  .shade span { display: none; }
  .shade.on span { display: inline; }
  .shade .sw { width: 30px; height: 30px; }
  button.chip { padding: 8px 12px; }
  .size input { width: 90px; }
  .results-panel { flex-direction: column; }
  .photos { justify-content: center; }
  .photos canvas { width: 140px; height: 175px; }
}
