:root {
  --bg: #f3f7f6;
  --card: #ffffff;
  --ink: #1d2b2a;
  --ink-soft: #55686a;
  --line: #d5e1df;
  --accent: #2f8f83;
  --accent-ink: #ffffff;
  --calm: #3fb39f;
  --near: #f2b632;
  --loud: #ee6a5a;
  --mood: var(--calm);
  --glass: rgba(120, 170, 180, .18);
  --radius: 18px;
  --shadow: 0 2px 10px rgba(20, 50, 50, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111a1a;
    --card: #1a2726;
    --ink: #e7f0ee;
    --ink-soft: #9db1ae;
    --line: #2e403e;
    --accent: #4fc0b0;
    --accent-ink: #0d1716;
    --glass: rgba(150, 200, 210, .12);
    --shadow: 0 2px 10px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--card); padding: 8px; z-index: 9; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.site-head { text-align: center; padding: 20px 16px 8px; }
.site-head h1 { margin: 0; font-size: 2rem; }
.tagline { margin: 4px 0; color: var(--ink-soft); }
.privacy-badge {
  display: inline-block; margin: 8px 0 4px; padding: 6px 14px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 999px; font-size: .92rem; font-weight: 600;
}

/* Ad slots: reserved sizes so nothing jumps (no CLS). */
.ad-slot {
  position: relative; display: flex; align-items: center; justify-content: center;
  margin: 0 auto; border: 2px dashed var(--line); border-radius: 12px; overflow: hidden;
}
.ad-slot__label {
  position: absolute; top: 4px; left: 8px; font-size: .68rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-soft); pointer-events: none;
}
.ad-slot--leaderboard { width: calc(100% - 32px); max-width: 728px; height: 66px; margin-bottom: 8px; }
.ad-slot--rect { width: 300px; max-width: 100%; height: 250px; margin-top: 16px; }
.ad-slot--bottom { width: 100%; max-width: 728px; height: 100px; margin: 24px auto; }
@media (min-width: 760px) { .ad-slot--leaderboard { height: 94px; } }

.layout { display: grid; gap: 16px; padding: 8px 16px 24px; max-width: 1180px; margin: 0 auto; }
@media (min-width: 980px) { .layout { grid-template-columns: 1fr 320px; align-items: start; } }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 16px; }

/* ---- Stage ---- */
.stage { text-align: center; }
.stage-title { margin: 0 0 8px; font-size: clamp(1.4rem, 4vw, 2.4rem); }
.meter-area { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: center; }
.face { width: 100%; max-width: 320px; height: auto; }
.face__head { fill: var(--mood); transition: fill .4s; }
.face__eyes ellipse { fill: #1d2b2a; }
.face__brow { stroke: #1d2b2a; stroke-width: 6; stroke-linecap: round; fill: none; opacity: 0; transition: opacity .3s; }
.face__mouth { stroke: #1d2b2a; stroke-width: 8; stroke-linecap: round; fill: none; }
.mood-2 .face__brow { opacity: 1; }
.mood-word { margin: 4px 0 0; font-size: clamp(1.3rem, 4vw, 2rem); font-weight: 800; color: var(--ink); }

.jar { width: 100%; max-width: 200px; height: auto; }
.jar__lid { fill: var(--ink-soft); }
.jar__glass { fill: var(--glass); stroke: var(--ink-soft); stroke-width: 3; }
.marble { stroke: rgba(0,0,0,.18); stroke-width: 1; }
.marble.pop { animation: drop .5s ease-out; }
@keyframes drop { from { transform: translateY(-120px); opacity: .2; } to { transform: none; opacity: 1; } }
.jar-count { margin: 4px 0; font-size: 1.15rem; }
.jar-count strong { font-size: 1.6rem; }
.next-bar { height: 8px; max-width: 200px; margin: 0 auto; border-radius: 8px; background: var(--line); overflow: hidden; }
.next-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s linear; }

.meter {
  position: relative; height: 34px; margin: 34px 0 8px; border-radius: 17px;
  background: linear-gradient(90deg, var(--calm), var(--near) 70%, var(--loud));
  overflow: visible;
}
.meter__fill {
  position: absolute; inset: 0 0 0 auto; width: 100%; border-radius: 0 17px 17px 0;
  background: var(--line); opacity: .92;
}
.meter__line { position: absolute; top: -8px; bottom: -8px; width: 4px; margin-left: -2px; background: var(--ink); border-radius: 2px; }
.meter__line span {
  position: absolute; top: -22px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-size: .75rem; font-weight: 700; color: var(--ink-soft);
}

.status { min-height: 1.5em; margin: 18px 0 8px; font-weight: 600; }
.start-panel { padding: 8px 0; }
.small { font-size: .88rem; color: var(--ink-soft); }
.error {
  margin: 8px auto; max-width: 520px; padding: 10px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--loud) 16%, transparent); text-align: left;
}
.controls, .btn-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.session-line { color: var(--ink-soft); font-size: .92rem; margin: 10px 0 0; }

/* ---- Buttons & inputs ---- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; min-height: 44px;
}
.btn:hover { border-color: var(--accent); }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn--big { font-size: 1.35rem; padding: 16px 32px; border-radius: 16px; }
.btn--link { background: none; border: 0; text-decoration: underline; color: var(--ink-soft); }
.btn--step { width: 44px; padding: 0; font-size: 1.3rem; }

.settings h2 { margin: 0 0 8px; font-size: 1.2rem; }
fieldset { border: 0; padding: 0; margin: 0 0 12px; }
legend { font-weight: 600; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 38px; padding: 6px 12px; border-radius: 999px; font-size: .9rem; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.field { display: block; margin: 12px 0; }
.field > span { display: flex; justify-content: space-between; font-weight: 600; }
.field input[type=range] { width: 100%; accent-color: var(--accent); }
.field input[type=text] {
  width: 100%; font: inherit; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); margin-top: 4px;
}
.stepper-row { display: grid; gap: 8px; margin: 12px 0; }
.stepper { display: grid; grid-template-columns: 1fr 44px 3.2em 44px; align-items: center; gap: 6px; }
.stepper__label { font-weight: 600; font-size: .92rem; }
.stepper output { text-align: center; font-weight: 700; font-size: 1.1rem; }
.toggle { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }
.embed-code {
  width: 100%; margin-top: 10px; font: .8rem/1.3 ui-monospace, monospace; padding: 8px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}

/* ---- SEO / footer ---- */
.seo { max-width: 760px; margin: 16px auto; padding: 0 16px; }
.seo h2 { font-size: 1.3rem; }
details { border-bottom: 1px solid var(--line); padding: 10px 0; }
summary { cursor: pointer; font-weight: 600; }
.site-foot { text-align: center; color: var(--ink-soft); font-size: .9rem; padding: 16px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; max-width: calc(100% - 32px);
}
.celebrate { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(0,0,0,.45); padding: 16px; }
.celebrate__box { background: var(--card); border-radius: var(--radius); padding: 24px; text-align: center; max-width: 420px; }
.celebrate__big { font-size: 2.4rem; font-weight: 800; margin: 0; }

.embed-link { display: none; }

/* ---- Embed mode ---- */
body.embed .chrome { display: none !important; }
body.embed .layout { grid-template-columns: 1fr; padding: 8px; }
body.embed .side { display: none; }
body.embed .embed-link { display: block; text-align: center; font-size: .85rem; color: var(--ink-soft); padding-bottom: 8px; }

/* ---- Projector mode: only the stage, big ---- */
body.projector { overflow: hidden; }
body.projector .chrome, body.projector .side, body.projector .skip, body.projector .embed-link { display: none !important; }
body.projector .layout { display: block; max-width: none; padding: 0; }
body.projector .stage {
  min-height: 100vh; border-radius: 0; box-shadow: none; display: flex; flex-direction: column;
  justify-content: center; padding: 3vh 4vw;
}
body.projector .face { max-width: 52vh; }
body.projector .jar { max-width: 34vh; }
body.projector .jar-count { font-size: 2rem; }
body.projector .meter { height: 5vh; border-radius: 3vh; }
body.projector .status { font-size: 1.6rem; }

@media (max-width: 520px) {
  .meter-area { grid-template-columns: 1fr 0.8fr; gap: 8px; }
  .btn--big { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
