/* Dialetti design system v3 — "Canopy Pop".
 * Light, joyful, tactile: white canvas, chunky press-down buttons, and a
 * biome accent that changes per unit — the interface is the chameleon.
 * --accent/--accent-deep are set from JS (current unit's biome color).
 * --heat (0..1) warms the accent as your combo climbs. */

:root {
  /* canvas */
  --night: #ffffff;            /* page background (name kept for JS compat) */
  --surface: #ffffff;          /* cards */
  --raised: #f4f7f4;           /* inputs, soft panels */
  --edge: #e7ece7;             /* hairline borders */
  --edge-strong: #d5ddd5;      /* pressed edges, strong borders */
  --ink: #30403a;
  --mist: #86948c;
  --good: #35b24a;
  --bad: #ff5d5d;
  /* biome accent (JS-driven per unit) */
  --brand: #7c5cf5;            /* Dialetti brand violet — fixed (logo/PWA/brand chrome) */
  --brand-deep: #5b3fd8;
  --accent: #7c5cf5;           /* default/brand accent — JS overrides per-unit with biome color */
  --accent-deep: #5b3fd8;
  --course: var(--accent);
  /* combo heat warms the accent toward mango/coral */
  --heat: 0;
  --glow-a: color-mix(in oklab, var(--accent) calc(100% - var(--heat) * 100%), #ff9f1c calc(var(--heat) * 100%));
  --glow-b: color-mix(in oklab, var(--accent) calc(100% - var(--heat) * 100%), #ff5d5d calc(var(--heat) * 100%));
  --grad: linear-gradient(135deg, var(--glow-a), var(--glow-b));
  --display: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", Quicksand, Nunito, system-ui, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --score: ui-monospace, "SF Mono", Menlo, monospace;
  --radius: 18px;
  --tab-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  min-height: 100%;
  background: var(--night);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select { font: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }

/* ---------- ambient warmth (barely-there, heats with combo) ---------- */

#aura {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(80vmax 55vmax at 50% -25%,
    color-mix(in oklab, var(--glow-a) calc(5% + var(--heat) * 9%), transparent), transparent 70%);
  transition: background 700ms ease;
}

/* ---------- frame ---------- */

#app {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

#screen {
  flex: 1;
  padding: 18px 18px calc(var(--tab-h) + 34px);
  outline: none;
  animation: screen-in 260ms cubic-bezier(0.25, 0.6, 0.3, 1) both;
}
@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- HUD ---------- */

#hud {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px 10px;
  background: color-mix(in srgb, #ffffff 88%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 2px solid var(--edge);
}

.hud-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid var(--edge);
  font-family: var(--display);
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
}
.hud-chip .num { font-variant-numeric: tabular-nums; }
.hud-chip.flag { font-size: 17px; padding: 6px 11px; }
.hud-goal { margin-left: auto; }
.hud-goal .bar {
  width: 64px;
  height: 10px;
  border-radius: 99px;
  background: var(--raised);
  border: 1px solid var(--edge);
  overflow: hidden;
}
.hud-goal .bar i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--grad);
  transition: width 500ms cubic-bezier(0.25, 0.6, 0.3, 1);
}

/* ---------- tab bar ---------- */

#tabs {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, 100%);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  padding: 8px 12px calc(6px + env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  background: #ffffff;
  border-top: 2px solid var(--edge);
  z-index: 6;
}
.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 14px;
  font-family: var(--display);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--mist);
  transition: color 160ms ease, background 160ms ease, transform 120ms ease;
}
.tab .ico { display: grid; place-items: center; width: 24px; height: 24px; }
.tab .ico svg { width: 22px; height: 22px; stroke-width: 2; }
.tab[aria-current="page"] {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, #fff);
}
.tab:active { transform: scale(0.93); }
.tab .badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 24px);
  min-width: 17px;
  height: 17px;
  border-radius: 9px;
  background: var(--bad);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: grid;
  place-items: center;
  padding: 0 4px;
  border: 2px solid #fff;
}

/* ---------- typography ---------- */

h1, h2, h3, .display { font-family: var(--display); }
h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 20px; font-weight: 800; letter-spacing: -0.015em; }
.eyebrow {
  font-family: var(--display);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mist);
}
.muted { color: var(--mist); }
.score { font-family: var(--score); font-variant-numeric: tabular-nums; }

/* ---------- buttons: the chunky press-down ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  padding: 13px 22px;
  border-radius: 16px;
  font-family: var(--display);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--edge-strong);
  box-shadow: 0 4px 0 0 var(--edge-strong);
  transition: transform 100ms ease, box-shadow 100ms ease, filter 140ms ease;
  user-select: none;
  -webkit-user-select: none;
}
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 0 var(--edge-strong); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.btn.primary {
  color: #fff;
  background: var(--glow-a);
  border-color: transparent;
  box-shadow: 0 4px 0 0 color-mix(in srgb, var(--glow-a) 70%, #000);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.primary:active { box-shadow: 0 0 0 0 transparent; }
.btn.ghost { background: transparent; border: 2px dashed var(--edge-strong); box-shadow: none; color: var(--mist); }
.btn.ghost:active { transform: scale(0.98); }
.btn.small { width: auto; min-height: 38px; padding: 8px 16px; font-size: 13px; border-radius: 12px; box-shadow: 0 3px 0 0 var(--edge-strong); }

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 2px solid var(--edge);
  border-radius: var(--radius);
  padding: 18px;
}
.card + .card { margin-top: 12px; }

/* ---------- toasts, overlay, confetti ---------- */

#toasts {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(400px, calc(100% - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-radius: 16px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 12px 30px -10px rgba(48, 64, 58, 0.45);
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  animation: toast-in 320ms cubic-bezier(0.34, 1.4, 0.5, 1) both;
}
.toast .emoji { font-size: 19px; }
.toast.gone { animation: toast-out 300ms ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(0.95); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px) scale(0.95); } }

#overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(48, 64, 58, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.ceremony {
  width: min(380px, 100%);
  text-align: center;
  padding: 32px 26px 26px;
  border-radius: 26px;
  background: #fff;
  border: 2px solid var(--edge);
  box-shadow: 0 30px 80px -20px rgba(48, 64, 58, 0.5);
  animation: pop-in 460ms cubic-bezier(0.34, 1.45, 0.5, 1) both;
}
.ceremony .big { font-size: 54px; line-height: 1.1; }
.ceremony h2 { margin: 12px 0 4px; font-size: 24px; }
.ceremony .btn { margin-top: 22px; }
@keyframes pop-in { from { opacity: 0; transform: scale(0.8) translateY(10px); } to { opacity: 1; transform: none; } }

#confetti { position: fixed; inset: 0; z-index: 50; pointer-events: none; }

/* ---------- progress ---------- */

.progress {
  height: 14px;
  border-radius: 99px;
  background: var(--raised);
  border: 1px solid var(--edge);
  overflow: hidden;
}
.progress i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--grad);
  transition: width 400ms cubic-bezier(0.25, 0.6, 0.3, 1);
}

/* ---------- utilities ---------- */

.row { display: flex; align-items: center; gap: 10px; }
.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.center { text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
