:root {
  --bg: #15102a;
  --cream: #f7efe0;
  --amber: #ffc24a;
  --amber2: #ff9d3c;
  --teal: #5fd0b0;
  --rose: #ff6f8a;
  --ink: #120a1c;
  --panel: rgba(22, 14, 38, 0.94);
  --line: rgba(247, 239, 224, 0.15);
  --font: "Avenir Next", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #0c0715; color: var(--cream); font-family: var(--font);
}
body {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
canvas#bg {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  touch-action: none; z-index: 0;
}
button { font-family: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

/* ---- HUD ---- */
#hud {
  position: fixed; left: 0; right: 0; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 8px calc(12px + env(safe-area-inset-left));
}
#embers { display: flex; gap: 5px; align-items: center; flex: 0 0 auto; }
.ember {
  width: 20px; height: 24px; position: relative; transition: transform .2s, opacity .3s;
}
.ember svg { width: 100%; height: 100%; display: block; }
.ember.spent { opacity: 0.22; transform: scale(0.8); }
#qcount {
  flex: 1 1 auto; text-align: center; font-weight: 800; font-size: 15px;
  letter-spacing: 0.04em; opacity: 0.9; font-variant-numeric: tabular-nums;
}
.ib {
  background: rgba(247, 239, 224, 0.08); border: 1px solid var(--line); border-radius: 12px;
  min-width: 42px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.ib:active { background: rgba(247, 239, 224, 0.2); }
.ib svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }

/* ---- Stage ---- */
#stage {
  position: fixed; inset: 0; z-index: 3; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
  padding: calc(64px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
  pointer-events: none;
}
#stageInner {
  width: min(560px, 100%); display: flex; flex-direction: column; align-items: center;
  gap: 16px; pointer-events: auto;
}
#prompt {
  font-size: clamp(19px, 5.2vw, 27px); font-weight: 800; line-height: 1.25; text-align: center;
  text-shadow: 0 2px 14px rgba(0,0,0,0.55); min-height: 1.2em; padding: 0 4px;
  max-width: 540px;
}
#prompt.teal { color: var(--teal); }
#prompt.amber { color: var(--amber); }
#prompt.rose { color: var(--rose); }

#area { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; min-height: 180px; justify-content: center; }

/* choice buttons */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.opt {
  border: 1.5px solid var(--line); border-radius: 16px; padding: 16px 12px; font-size: 18px;
  font-weight: 800; background: rgba(247, 239, 224, 0.06); color: var(--cream);
  min-height: 60px; transition: transform .08s, background .15s, border-color .15s;
  display: flex; align-items: center; justify-content: center; text-align: center;
}
.opt:active { transform: translateY(2px); }
.opt.good { background: rgba(95, 208, 176, 0.3); border-color: var(--teal); }
.opt.bad { background: rgba(255, 111, 138, 0.26); border-color: var(--rose); }
.opt.swatch { min-height: 76px; }

/* tappable targets (flames/shapes/candles/faces) */
.targets { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; align-items: flex-end; width: 100%; }
.tgt {
  background: none; border: 2px solid transparent; border-radius: 16px; padding: 6px;
  display: inline-flex; align-items: flex-end; justify-content: center; transition: transform .1s, border-color .15s;
  position: relative;
}
.tgt:active { transform: scale(0.94); }
.tgt.good { border-color: var(--teal); }
.tgt.bad { border-color: var(--rose); }
.tgt.picked { border-color: var(--amber); background: rgba(255,194,74,0.12); }
.tgt svg { display: block; overflow: visible; }
.tgt .ordnum {
  position: absolute; top: -8px; right: -6px; background: var(--amber); color: var(--ink);
  width: 22px; height: 22px; border-radius: 50%; font-size: 13px; font-weight: 900;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* ring (timed questions) */
.ringwrap { position: relative; width: 160px; height: 160px; display: flex; align-items: center; justify-content: center; }
.ringwrap svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(247,239,224,0.12); stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--amber); stroke-width: 10; stroke-linecap: round; transition: stroke .2s; }
.ringlabel { font-size: 15px; font-weight: 700; opacity: 0.85; text-align: center; padding: 0 20px; }

/* hold button */
.holdbtn {
  width: 150px; height: 150px; border-radius: 50%; border: 3px solid var(--line);
  background: radial-gradient(circle at 50% 60%, rgba(255,194,74,0.18), rgba(247,239,224,0.05));
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; color: var(--cream);
}
.holdbtn .fill {
  position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(var(--amber), var(--amber2));
  height: 0%; opacity: 0.55; pointer-events: none;
}
.holdbtn .lbl { position: relative; z-index: 2; pointer-events: none; }
.holdbtn:active { border-color: var(--amber); }

/* slider */
.sliderwrap { width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.jar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; min-height: 70px; align-items: center; margin-bottom: 4px; }
.dialrow { display: flex; align-items: center; gap: 14px; width: 100%; }
.dialval { font-size: 34px; font-weight: 900; min-width: 48px; text-align: center; color: var(--amber); font-variant-numeric: tabular-nums; }
input[type=range].dial {
  -webkit-appearance: none; appearance: none; flex: 1 1 auto; height: 14px; border-radius: 10px;
  background: rgba(247,239,224,0.14); outline: none;
}
input[type=range].dial::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(var(--amber), var(--amber2)); border: 2px solid #3a2606; cursor: pointer;
}
input[type=range].dial::-moz-range-thumb {
  width: 34px; height: 34px; border-radius: 50%; background: var(--amber); border: 2px solid #3a2606; cursor: pointer;
}
.setbtn {
  border: 0; border-radius: 14px; padding: 13px 26px; font-size: 17px; font-weight: 900;
  background: linear-gradient(var(--amber), var(--amber2)); color: var(--ink); box-shadow: 0 4px 0 #a3701d;
}
.setbtn:active { transform: translateY(2px); box-shadow: 0 2px 0 #a3701d; }

/* catch spark */
.catchfield { position: relative; width: 100%; max-width: 440px; height: 220px; border: 1.5px dashed var(--line); border-radius: 18px; overflow: hidden; }
.spark {
  position: absolute; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
  background: radial-gradient(circle, #fff6d8, #ffc24a 55%, rgba(255,120,40,0) 72%);
  will-change: transform;
}

/* swipe pad */
.swipepad { position: relative; width: 100%; max-width: 420px; height: 220px; border: 1.5px dashed var(--line); border-radius: 18px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.swipearrow { position: absolute; bottom: 10px; opacity: 0.5; animation: nudge 1.3s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(8px); } }

#feedback { min-height: 22px; font-size: 15px; font-weight: 700; text-align: center; opacity: 0; transition: opacity .2s; }
#feedback.show { opacity: 1; }
#feedback.good { color: var(--teal); }
#feedback.bad { color: var(--rose); }

/* ---- Veils / panels ---- */
.veil {
  position: fixed; inset: 0; z-index: 10; display: none; align-items: center; justify-content: center;
  background: rgba(6, 4, 14, 0.62); padding: calc(14px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom));
}
.veil.on { display: flex; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 24px; padding: 22px 20px 18px;
  width: min(440px, 100%); max-height: 100%; overflow-y: auto; text-align: center;
  box-shadow: 0 24px 70px rgba(0,0,0,0.55); -webkit-overflow-scrolling: touch;
}
.logo {
  font-size: 50px; font-weight: 900; letter-spacing: -0.02em; margin: 4px 0 2px; line-height: 1;
  background: linear-gradient(90deg, var(--amber), var(--teal) 60%, var(--amber));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sub { opacity: 0.82; font-size: 14.5px; margin: 6px 0 16px; line-height: 1.4; }
.big {
  width: 100%; border: 0; border-radius: 16px; padding: 15px; font-size: 19px; font-weight: 900;
  background: linear-gradient(var(--amber), var(--amber2)); color: var(--ink);
  box-shadow: 0 4px 0 #a3701d; margin-top: 8px;
}
.big:active { transform: translateY(2px); box-shadow: 0 2px 0 #a3701d; }
.big small { display: block; font-size: 12px; font-weight: 700; opacity: 0.8; margin-top: 2px; }
.sec {
  width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 12px; font-size: 15px;
  font-weight: 800; background: rgba(247, 239, 224, 0.07); margin-top: 10px;
}
.how { text-align: left; font-size: 13.5px; line-height: 1.5; opacity: 0.9; margin: 16px 2px 2px; }
.how p { margin: 0 0 7px; }
.how b { color: var(--amber); }
.stats { display: flex; justify-content: center; gap: 26px; margin: 12px 0 6px; }
.stats span { display: flex; flex-direction: column; }
.stats b { font-size: 28px; font-variant-numeric: tabular-nums; }
.stats i { font-style: normal; font-size: 11px; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.07em; }
.note { font-size: 14px; opacity: 0.88; margin: 8px 0; min-height: 18px; line-height: 1.4; }
.foot { margin-top: 12px; font-size: 12.5px; opacity: 0.55; }

/* landscape: shrink the top gap so targets fit */
@media (orientation: landscape) and (max-height: 560px) {
  #stage { padding-top: calc(54px + env(safe-area-inset-top)); justify-content: center; }
  #prompt { font-size: clamp(16px, 3.4vh, 22px); }
  #area { min-height: 120px; }
  .ringwrap, .holdbtn { width: 118px; height: 118px; }
  .catchfield, .swipepad { height: 150px; }
  .logo { font-size: 40px; }
}
