:root {
  --bg: #1a1233;
  --panel: #2a1f4d;
  --panel-2: #33275c;
  --line: #43357a;
  --text: #fff8ee;
  --muted: #b9b0d6;
  --accent: #ff6b4a;   /* coral */
  --accent-2: #ffc145; /* sun */
  --good: #3ddc97;     /* mint */
  --sky: #4cc9f0;
  --grape: #9b5de5;
  --ink: #1a1233;      /* text on bright fills */
  --round: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", -apple-system, system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif; }
body { overscroll-behavior: none;
  background: radial-gradient(120% 50% at 50% -8%, #ff6b4a33, transparent 60%),
              radial-gradient(80% 40% at 110% 25%, #9b5de533, transparent 70%), var(--bg); background-attachment: fixed; }
#app { min-height: 100%; }
h1, h2, h3, .brand, .btn, .card-title, .hud-item, .count, .result-big, .calib-msg, #breathWord, .mood b, .tile-title { font-family: var(--round); }

.screen { min-height: 100dvh; padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px; max-width: 520px; margin: 0 auto; }
.screen.center { justify-content: center; text-align: center; align-items: center; }
.screen[hidden] { display: none; }
.screen:not([hidden]) > * { animation: rise .35s ease-out backwards; }
.screen:not([hidden]) > *:nth-child(2) { animation-delay: .04s; }
.screen:not([hidden]) > *:nth-child(3) { animation-delay: .08s; }
.screen:not([hidden]) > *:nth-child(4) { animation-delay: .12s; }
.screen:not([hidden]) > *:nth-child(n+5) { animation-delay: .16s; }
.screen.play > * { animation: none !important; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

h1 { font-size: 34px; line-height: 1.1; margin: 4px 0; font-weight: 800; }
h2 { font-size: 28px; line-height: 1.15; margin: 8px 0; font-weight: 800; }
.lead { font-size: 18px; color: var(--muted); margin: 0 0 8px; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; }
.fine { font-size: 13px; color: var(--muted); margin-top: 18px; }
.stats { color: var(--accent-2); font-weight: 600; min-height: 1em; margin: 4px 0; }

.btn { appearance: none; border: 0; background: var(--panel); color: var(--text); box-shadow: inset 0 0 0 1.5px var(--line);
  font-weight: 700; font-size: 17px; padding: 15px 18px; border-radius: 18px; cursor: pointer; width: 100%;
  transition: transform .08s, box-shadow .08s; }
.btn.primary { background: var(--good); color: var(--ink); box-shadow: 0 5px 0 #22a874; }
.btn.primary:active { transform: translateY(4px); box-shadow: 0 1px 0 #22a874; }
.btn.big { font-size: 21px; padding: 19px; border-radius: 22px; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--muted); }
.btn:disabled { opacity: .4; box-shadow: none; transform: none; }
.btn:active { transform: scale(.98); }

.card { appearance: none; text-align: left; border: 0; box-shadow: inset 0 0 0 1.5px var(--line); background: var(--panel); color: var(--text);
  border-radius: 22px; padding: 18px; display: flex; flex-direction: column; gap: 6px; font: inherit; cursor: pointer; }
.card:active { transform: scale(.98); }
.card-title { font-size: 21px; font-weight: 800; }
.card-sub { color: var(--muted); font-size: 15px; line-height: 1.35; }

/* ---------- home ---------- */
.home-top { width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; text-align: left; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 30px; font-weight: 800; letter-spacing: .01em; color: var(--text); }
.brand b { color: var(--accent-2); }
.brand svg { width: 34px; height: 34px; }
.home-tag { font-size: 16px; color: var(--muted); margin: 0; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; min-height: 0; }
.pill { font-size: 13px; font-weight: 700; padding: 7px 12px; border-radius: 999px; background: #ffffff14; color: var(--text); }
.pill.hot { background: #ff6b4a2e; color: #ffb39f; }
.pill.cool { background: #4cc9f02e; color: #a8e6f8; }
.screen[data-screen="home"] { justify-content: center; align-items: center; }
.screen[data-screen="home"] > .btn, .screen[data-screen="home"] > .card, .screen[data-screen="home"] > .level { max-width: 380px; }

.card.daily { position: relative; overflow: hidden; width: 100%; gap: 4px; box-shadow: none; color: var(--ink); padding: 20px 20px 18px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent)); min-height: 150px; }
.card.daily .card-title { font-size: 28px; color: var(--ink); position: relative; }
.card.daily .card-sub { color: #3a2340; font-weight: 600; font-size: 14px; max-width: 64%; position: relative; }
.daily-tag { font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #3a2340; position: relative; }
.daily-go { margin-top: 10px; align-self: flex-start; background: var(--ink); color: #fff; font-family: var(--round); font-weight: 700;
  font-size: 15px; padding: 10px 16px; border-radius: 14px; position: relative; }
.daily-fig { position: absolute; right: -4px; bottom: -6px; width: 118px; height: 118px; opacity: .85; }
.card.daily.met { background: linear-gradient(135deg, #8ef0c4, var(--good)); }

.level { width: 100%; display: flex; gap: 14px; align-items: center; text-align: left; background: #ffffff0d; border-radius: 22px; padding: 14px; }
.ring { --p: 0; flex: none; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--accent-2) calc(var(--p) * 1%), #ffffff1f 0); transition: --p .6s; }
.ring span { width: 42px; height: 42px; border-radius: 50%; background: var(--bg); display: grid; place-items: center;
  font: 800 18px var(--round); }
.level-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.level-row { display: flex; flex-direction: column; gap: 2px; font-weight: 700; font-family: var(--round); font-size: 16px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; background: var(--c); cursor: pointer; padding: 0;
  box-shadow: 0 0 10px var(--c); }
.swatch.on { border-color: var(--text); outline: 2px solid var(--c); outline-offset: 2px; }
.swatch.locked { display: grid; place-items: center; background: #ffffff12; box-shadow: none; cursor: default;
  font-size: 11px; font-weight: 700; color: var(--muted); }
.swatch:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }

/* ---------- mood ---------- */
.moods { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; width: 100%; margin-top: 12px; }
.mood { appearance: none; border: 0; background: var(--panel); color: var(--text); border-radius: 20px;
  padding: 12px 2px 10px; font: inherit; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer;
  box-shadow: inset 0 0 0 1.5px var(--line); transition: transform .12s; }
.mood svg { width: 42px; height: 42px; }
.mood b { font-size: 18px; font-weight: 800; }
.mood span { font-size: 11px; color: var(--muted); font-weight: 600; }
.mood:active, .mood.sel { transform: scale(1.08); box-shadow: inset 0 0 0 2.5px var(--m); }

/* ---------- pick ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { appearance: none; border: 0; position: relative; overflow: hidden; border-radius: 24px; min-height: 158px; padding: 12px;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; gap: 2px; text-align: left; cursor: pointer;
  background: var(--t, var(--panel)); color: var(--ink); font: inherit; transition: transform .1s; }
.tile:active { transform: scale(.96); }
.tile > svg, .tile > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile-tag { position: relative; font-size: 10px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; opacity: .72; }
.tile-title { position: relative; font-size: 18px; font-weight: 800; line-height: 1.1; }
.tile.dark { color: #fff; }
.tile.dark .tile-tag { opacity: .9; }
.tile.photo .tile-title, .tile.photo .tile-tag { color: #fff; opacity: 1; text-shadow: 0 2px 8px #000a; }
.tile.photo::after { content: ''; position: absolute; inset: 40% 0 0; background: linear-gradient(transparent, #0008); }
.tile.photo > span { z-index: 1; }
.pick-blurb { color: var(--muted); font-size: 14px; margin: -6px 2px 0; }

#stressForm { display: flex; gap: 8px; }
#stressForm input { flex: 1; font: inherit; font-size: 17px; padding: 14px; border-radius: 16px; border: 0; box-shadow: inset 0 0 0 1.5px var(--line);
  background: var(--panel); color: var(--text); min-width: 0; }
#stressForm .btn { width: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 0; box-shadow: inset 0 0 0 1.5px var(--line); background: var(--panel); color: var(--text); border-radius: 999px; padding: 9px 15px;
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--sky); color: var(--ink); box-shadow: none; }
.chip.ok { background: var(--good); color: var(--ink); box-shadow: none; }
.chip.no { color: var(--muted); }
#stressNext { margin-top: auto; }

.checks { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; font-size: 16px; }
.checks li { display: flex; gap: 10px; align-items: flex-start; background: #ffffff0a; border-radius: 16px; padding: 12px 14px; line-height: 1.35; }
.checks li::before { content: '✓'; flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--good); color: var(--ink);
  display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.consent { display: flex; gap: 12px; align-items: flex-start; background: var(--panel); box-shadow: inset 0 0 0 1.5px var(--line);
  border-radius: 18px; padding: 14px; font-size: 15px; line-height: 1.35; margin-top: auto; }
.consent input { width: 22px; height: 22px; accent-color: var(--good); flex: none; margin: 0; }

/* Play */
.screen.play { padding: 0; max-width: none; position: fixed; inset: 0; min-height: 0; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  background: radial-gradient(circle at 50% 30%, #3a2a6e, #1a1233 72%); }
#cam { position: absolute; width: 2px; height: 2px; opacity: 0.01; pointer-events: none; left: 0; bottom: 0; }
.hud { position: absolute; left: 0; right: 0; top: max(12px, env(safe-area-inset-top)); display: flex; justify-content: space-between; align-items: flex-start;
  padding: 0 14px; pointer-events: none; }
.hud[hidden] { display: none; }
.hud-item { display: flex; flex-direction: column; align-items: center; min-width: 66px; font-weight: 800; font-size: 24px;
  background: #00000045; border-radius: 18px; padding: 6px 10px; }
.hud-item.big { font-size: 46px; background: none; line-height: 1; text-shadow: 0 3px 0 #0005; }
.hud-item small { font-size: 10px; color: #e8defc; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-family: -apple-system, system-ui, sans-serif; }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 24px; text-align: center; }
.overlay[hidden] { display: none; }
#calib { justify-content: flex-end; padding-bottom: max(40px, env(safe-area-inset-bottom)); pointer-events: none; }
#calib .btn { pointer-events: auto; width: auto; }
.calib-msg { font-size: 24px; font-weight: 800; margin: 0; text-shadow: 0 2px 12px #000; }
.count { font-size: 140px; font-weight: 900; color: var(--accent-2); pointer-events: none; text-shadow: 0 8px 0 #b4501f; }
#playError { background: rgba(26,18,51,.96); }
.toast { position: absolute; left: 50%; bottom: max(40px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(42,31,77,.94); padding: 10px 16px; border-radius: 999px; font-weight: 700; white-space: nowrap; }
.toast[hidden] { display: none; }
.quit { position: absolute; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); width: 42px; height: 42px; border-radius: 50%;
  border: 0; background: #00000055; color: #e8defc; font-size: 16px; }
.spinner { width: 46px; height: 46px; border: 5px solid #ffffff22; border-top-color: var(--accent-2); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- results ---------- */
.result-card { position: relative; width: 100%; max-width: 360px; border-radius: 28px; padding: 26px 18px 20px; overflow: hidden;
  background: linear-gradient(160deg, var(--grape), #5b3bb0); box-shadow: 0 10px 30px #0006; }
.result-big { font-size: 104px; font-weight: 900; color: #fff; line-height: 1; text-shadow: 0 6px 0 #0003; }
.result-unit { font-size: 15px; text-transform: uppercase; letter-spacing: .12em; color: #f1e8ff; font-weight: 800; }
.result-card .lead { color: #f1e8ff; margin: 10px 0 0; font-size: 16px; }
.result-pills { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.result-pills .pill:empty { display: none; }
.mood-change { font-size: 18px; font-weight: 800; color: var(--good); min-height: 1em; margin: 0; font-family: var(--round); }
.xp-line { color: var(--accent-2); font-weight: 700; margin: 0; min-height: 1em; }
.screen.center .btn { max-width: 360px; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }

/* Breathe screen */
.breath { position: relative; width: 250px; height: 250px; display: grid; place-items: center; margin: 24px auto; }
.breath-ring { position: absolute; inset: 0; border-radius: 50%; border: 0;
  background: radial-gradient(circle, #4cc9f066 0, #9b5de544 55%, transparent 70%); box-shadow: 0 0 0 3px #4cc9f0aa inset;
  transform: scale(.55); transition: transform 4s ease-in-out; }
.breath-ring.out { transition-duration: 6s; }
#breathWord { font-size: 24px; font-weight: 800; position: relative; }
.card.quiet { background: transparent; }
.link { appearance: none; background: none; border: 0; color: var(--muted); font: inherit; font-size: 14px; text-decoration: underline; padding: 10px; cursor: pointer; }
.link.done { text-decoration: none; color: var(--good); }
.qr { background: #fff; padding: 10px; border-radius: 12px; line-height: 0; }
.qr svg { width: 180px; height: 180px; }
#playError p { max-width: 340px; text-align: center; }

.share { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 8px; }
.share pre { margin: 0; padding: 12px 14px; background: var(--panel); border-radius: 16px;
  text-align: left; white-space: pre-wrap; font: 600 14px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; user-select: text; }

@media (prefers-reduced-motion: reduce) { .screen:not([hidden]) > * { animation: none; } .breath-ring { transition: none; } }

[hidden] { display: none !important; }

/* ---------- VS ---------- */
.vs-badge { display: inline-grid; place-items: center; width: 46px; height: 46px; flex: none; border-radius: 14px; font: 900 18px var(--round);
  background: linear-gradient(135deg, var(--accent), var(--grape)); color: #fff; letter-spacing: .02em; box-shadow: 0 4px 0 #0004; }
.card.vs-home { flex-direction: row; align-items: center; gap: 14px; width: 100%; max-width: 380px; }
.vs-home-text { display: flex; flex-direction: column; gap: 2px; }
.vs-home .card-title { font-size: 19px; }
.vs-home .card-sub { font-size: 14px; }
.card.vs-in { width: 100%; max-width: 380px; box-shadow: none; color: #fff; padding: 18px 20px; gap: 4px;
  background: linear-gradient(135deg, var(--accent), var(--grape)); }
.card.vs-in .card-sub { color: #f1e8ff; font-weight: 600; }
.card.vs-in .daily-go { background: var(--ink); color: #fff; }
.card.vs-in .vs-badge { width: auto; height: auto; padding: 3px 9px; border-radius: 8px; font-size: 12px; background: #ffffff33; box-shadow: none; align-self: flex-start; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); font-weight: 600; }
.field input, .vsbox input { font: 600 17px inherit; font-family: inherit; padding: 13px 14px; border-radius: 14px; border: 0; background: var(--panel);
  color: var(--text); box-shadow: inset 0 0 0 1.5px var(--line); width: 100%; }
.vs-card { cursor: default; }
.vs-card .btn { margin-top: 8px; }
.vs-card .tile-tag, #vsAsync .tile-tag { font-size: 11px; font-weight: 800; letter-spacing: .08em; color: var(--accent-2); }
#vsAsync { cursor: default; background: transparent; }
.vs-room { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.vs-room .lead { margin: 0; color: var(--text); font-weight: 700; font-family: var(--round); }
.vs-players { display: flex; gap: 10px; align-items: center; font: 800 20px var(--round); }
.vs-players span { padding: 8px 14px; border-radius: 14px; background: var(--panel); }
.vs-players span.me { background: #ff6b4a33; color: #ffb39f; }
.vs-players span.them { background: #4cc9f033; color: #a8e6f8; }
.vs-players i { font-style: normal; color: var(--muted); font-size: 14px; }
.hud-opp { position: absolute; left: 50%; transform: translateX(-50%); top: calc(max(12px, env(safe-area-inset-top)) + 78px);
  padding: 6px 14px; border-radius: 999px; font: 800 16px var(--round); background: #4cc9f033; color: #a8e6f8; pointer-events: none; white-space: nowrap; }
.hud-opp.ahead { background: #ff6b4a40; color: #ffb39f; }
.vs-verdict { font: 900 26px var(--round); margin: 0; color: var(--accent-2); }
.vs-verdict.lose { color: var(--sky); font-size: 22px; }
.vsbox { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 8px; }
.vsbox .fine { margin: 0; min-height: 0; }
.vs-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.vs-pick .btn { font-size: 15px; padding: 12px; }
.screen.play { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.vs-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.vs-team { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 18px; background: var(--panel); text-align: left; }
.vs-team b { font: 900 13px var(--round); letter-spacing: .1em; text-transform: uppercase; }
.vs-team.t0 { box-shadow: inset 0 0 0 2px #ff6b4a66; } .vs-team.t0 b { color: var(--accent); }
.vs-team.t1 { box-shadow: inset 0 0 0 2px #4cc9f066; } .vs-team.t1 b { color: var(--sky); }
.vs-team span { font: 800 16px var(--round); }
.vs-team span.me { color: var(--accent-2); }
.vs-team span.bot { color: var(--muted); }
.vs-team span i { font-style: normal; font-size: 11px; font-weight: 700; color: var(--muted); margin-left: 4px; text-transform: uppercase; letter-spacing: .06em; }
.vs-team span.empty { color: var(--muted); font-weight: 600; font-size: 14px; }
.vs-ctl { width: 100%; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.vs-ctl .tile-tag { font-size: 11px; font-weight: 800; letter-spacing: .08em; color: var(--accent-2); margin-top: 4px; }
#vsZapCtl { display: flex; flex-direction: column; gap: 8px; }
.vs-pick.four { grid-template-columns: repeat(4, 1fr); }
.vs-pick.four .btn { padding: 10px 4px; font-size: 14px; }
.vs-bots { display: flex; gap: 10px; align-items: center; font-weight: 700; color: var(--muted); }
.vs-bots input { width: 20px; height: 20px; accent-color: var(--good); }
a.tile { text-decoration: none; color: var(--text); }
