:root {
  --page: #0E0D0C;
  --page-2: #141211;
  --ink: #EDE6DA;
  --ink-2: #A69C8E;
  --ink-3: #6E665C;
  --line: rgba(237, 230, 218, .14);
  --line-2: rgba(237, 230, 218, .32);
  --housing: #1C1917;
  --housing-hi: #2B2724;
  --panel: #070605;
  --led: #FFB03B;
  --led-glow: rgba(255, 176, 59, .55);
  --led-ghost: rgba(255, 176, 59, .08);
  --accent: #FFB03B;
  --accent-ink: #14100A;
  --danger: #E0432B;
  --glow: 0;
  --glow-c: 255, 176, 59;
  --smoke: 0;
  --flame: 0;
  --display: "Secular One", "Heebo", system-ui, sans-serif;
  --body: "Heebo", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* heat stages: the page stays dark, the meter and the air around it get hotter */
body[data-heat="1"] { --glow: .18; }
body[data-heat="2"] { --glow: .32; --smoke: .5; }
body[data-heat="3"] { --glow: .5; --smoke: 1; --led: #FF8A3B; --led-glow: rgba(255, 138, 59, .6); --led-ghost: rgba(255, 138, 59, .09); --glow-c: 255, 120, 40; }
body[data-heat="4"] { --glow: .7; --smoke: 1; --flame: .45; --led: #FF5A32; --led-glow: rgba(255, 90, 50, .65); --led-ghost: rgba(255, 90, 50, .1); --glow-c: 240, 70, 35; --accent: #FF5A32; }
body[data-heat="5"] { --glow: .95; --smoke: 1; --flame: .8; --led: #FF3B2A; --led-glow: rgba(255, 59, 42, .75); --led-ghost: rgba(255, 59, 42, .11); --glow-c: 230, 45, 30; --accent: #FF3B2A; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--page); }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--body);
  color: var(--ink);
  background: linear-gradient(180deg, var(--page) 0%, var(--page-2) 100%);
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
  position: relative;
}
/* heat haze behind the meter */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(70% 45% at 50% 24%, rgba(var(--glow-c), .55), rgba(var(--glow-c), 0) 70%);
  opacity: var(--glow); transition: opacity 1.4s ease;
}
body[data-heat="5"] { animation: jitter .18s infinite steps(2); }
@keyframes jitter { 0% { transform: translate(0,0); } 50% { transform: translate(-1px, 1px); } 100% { transform: translate(1px, 0); } }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; top: -50px; right: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; }
.skip:focus { top: 8px; z-index: 50; }

/* header */
.top {
  max-width: 560px; margin: 0 auto; padding: 14px 16px 0; position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--display); font-size: 22px; letter-spacing: .01em; direction: ltr; text-align: right; }
.brand-tag { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1.5px solid var(--line-2);
  background: transparent; color: var(--ink); cursor: pointer; display: grid; place-items: center;
  transition: background .2s, color .2s, border-color .2s;
}
.icon-btn:hover { background: var(--ink); color: var(--page); border-color: var(--ink); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .spk { fill: currentColor; }
.icon-btn[aria-pressed="true"] .mute { display: none; }
.icon-btn[aria-pressed="false"] .waves { display: none; }

.wrap { max-width: 560px; margin: 0 auto; padding: 10px 16px 48px; position: relative; z-index: 2; }

.headline {
  font-family: var(--display); font-weight: 400; font-size: clamp(28px, 7.4vw, 40px);
  line-height: 1.12; margin: 14px 0 18px; letter-spacing: -.01em;
}
.headline .burn { position: relative; display: inline-block; }
.headline .burn::after {
  content: ""; position: absolute; inset: auto 0 2px; height: .22em; z-index: -1;
  background: var(--led); opacity: .45; border-radius: 3px; transform: skewX(-8deg); transition: background .8s;
}

/* the meter */
.meter {
  position: relative;
  background: linear-gradient(180deg, var(--housing-hi), var(--housing) 18%, #141211 100%);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 22px;
  padding: 14px 14px 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,.6), 0 0 calc(60px * var(--glow)) rgba(var(--glow-c), calc(.45 * var(--glow))), inset 0 1px 0 rgba(255,255,255,.08), inset 0 -2px 0 rgba(0,0,0,.6);
  color: var(--ink);
  transition: box-shadow 1.2s;
}
.meter-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 4px 10px; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.lamp { display: inline-flex; align-items: center; gap: 6px; }
.lamp i { width: 9px; height: 9px; border-radius: 50%; background: #3A3430; box-shadow: inset 0 1px 1px rgba(0,0,0,.6); transition: background .3s, box-shadow .3s; }
.lamp-rate i { background: var(--led); box-shadow: 0 0 8px var(--led-glow); }
body[data-mode="running"] .lamp-run i { background: #4CE07A; box-shadow: 0 0 8px rgba(76,224,122,.7); animation: blink 1s infinite; }
body[data-mode="paused"] .lamp-run i { background: #FFD24C; box-shadow: 0 0 8px rgba(255,210,76,.7); }
body[data-heat="3"] .lamp-warn i, body[data-heat="4"] .lamp-warn i, body[data-heat="5"] .lamp-warn i { background: #FF3B2A; box-shadow: 0 0 10px rgba(255,59,42,.9); animation: blink .5s infinite; }
@keyframes blink { 0%, 60% { opacity: 1; } 61%, 100% { opacity: .35; } }

.display {
  position: relative; background: var(--panel); border-radius: 12px; padding: 12px 12px 8px;
  box-shadow: inset 0 3px 12px rgba(0,0,0,.95), inset 0 -1px 0 rgba(255,255,255,.04);
  display: flex; align-items: center; gap: 10px; overflow: hidden;
}
.display::after { content: ""; position: absolute; inset: 0 0 55%; pointer-events: none; background: linear-gradient(180deg, rgba(255,255,255,.04), transparent); }
.currency { font-family: var(--display); font-size: clamp(20px, 6vw, 30px); color: var(--led); text-shadow: 0 0 10px var(--led-glow); flex: 0 0 auto; transition: color .8s; }
.digits { flex: 1 1 auto; min-width: 0; direction: ltr; }
.digits svg { display: block; width: 100%; height: auto; }
.digits .seg { fill: var(--led-ghost); transition: fill .08s; }
.digits .seg.on { fill: var(--led); filter: drop-shadow(0 0 3px var(--led-glow)); }
.digits.small { max-width: 190px; }
.digits.small .seg.on { filter: drop-shadow(0 0 2px var(--led-glow)); }

.meter-sub { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 6px 2px; }
.per-min { font-size: 14px; color: var(--ink-2); font-weight: 500; white-space: nowrap; }
.per-min span { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }

/* smoke off the housing */
.smoke { position: absolute; inset: -60px 0 auto; height: 60px; pointer-events: none; opacity: var(--smoke); transition: opacity 1s; }
.smoke i {
  position: absolute; bottom: -10px; width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle, rgba(200,190,175,.28), rgba(200,190,175,0) 70%);
  animation: rise 3.2s infinite ease-out; filter: blur(3px);
}
.smoke i:nth-child(1) { left: 22%; animation-delay: 0s; }
.smoke i:nth-child(2) { left: 48%; animation-delay: .9s; width: 34px; height: 34px; }
.smoke i:nth-child(3) { left: 66%; animation-delay: 1.7s; }
.smoke i:nth-child(4) { left: 80%; animation-delay: 2.4s; width: 20px; height: 20px; }
@keyframes rise { 0% { transform: translateY(0) scale(.6); opacity: 0; } 20% { opacity: .9; } 100% { transform: translateY(-70px) translateX(10px) scale(1.8); opacity: 0; } }

/* embers along the bottom of the viewport, only when things are bad */
.flames { position: fixed; inset: auto 0 0; height: 22vh; pointer-events: none; z-index: 1; opacity: var(--flame); transition: opacity 1.2s; }
.flames i {
  position: absolute; bottom: -8vh; width: 26vw; height: calc(8vh + 12vh * var(--flame));
  border-radius: 50% 50% 40% 40%;
  background: radial-gradient(ellipse at 50% 100%, #FFD36A 0%, #FF8A1F 30%, #D8301A 62%, rgba(216,48,26,0) 78%);
  filter: blur(10px); mix-blend-mode: screen; transform-origin: 50% 100%;
  animation: flicker 1.1s infinite ease-in-out alternate;
}
.flames i:nth-child(1) { left: -6vw; animation-duration: .9s; }
.flames i:nth-child(2) { left: 10vw; animation-duration: 1.3s; animation-delay: -.4s; }
.flames i:nth-child(3) { left: 26vw; animation-duration: .8s; animation-delay: -.7s; }
.flames i:nth-child(4) { left: 40vw; animation-duration: 1.15s; animation-delay: -.2s; height: calc(11vh + 15vh * var(--flame)); }
.flames i:nth-child(5) { left: 54vw; animation-duration: .95s; animation-delay: -.9s; }
.flames i:nth-child(6) { left: 68vw; animation-duration: 1.25s; animation-delay: -.5s; }
.flames i:nth-child(7) { left: 82vw; animation-duration: .85s; animation-delay: -.3s; }
@keyframes flicker { from { transform: scaleY(.86) scaleX(1.02) translateX(-6px); } to { transform: scaleY(1.08) scaleX(.96) translateX(6px); } }

/* the driver */
.driver { margin: 22px 0 8px; position: relative; padding-right: 4px; }
.driver-label {
  display: inline-block; font-family: var(--display); font-size: 12px; letter-spacing: .14em;
  background: var(--accent); color: var(--accent-ink); padding: 3px 10px 2px; border-radius: 6px 6px 0 0; margin-right: 12px; transition: background .8s;
}
.driver-line {
  margin: 0; background: var(--housing); border: 1px solid var(--line); border-radius: 16px 4px 16px 16px;
  padding: 12px 14px; font-size: 17px; line-height: 1.45; font-weight: 500; min-height: 3.2em;
}
.driver-line.pop { animation: pop .35s ease-out; }
@keyframes pop { 0% { transform: scale(.97); } 60% { transform: scale(1.015); } 100% { transform: scale(1); } }

/* equivalents */
.equiv { margin: 14px 0 6px; }
.equiv-line { margin: 0 0 10px; font-family: var(--display); font-size: clamp(19px, 5.4vw, 24px); line-height: 1.3; min-height: 1.3em; }
.equiv-line.swap { animation: swap .5s ease-out; }
@keyframes swap { 0% { opacity: 0; transform: translateY(6px); } 100% { opacity: 1; transform: none; } }
.next-bar { height: 8px; border-radius: 6px; background: rgba(255,255,255,.08); overflow: hidden; }
.next-bar i { display: block; height: 100%; width: 0; background: var(--led); box-shadow: 0 0 10px var(--led-glow); transition: width .6s ease-out, background .8s; }
.next-text { margin: 6px 0 0; font-size: 14px; color: var(--ink-2); font-weight: 500; }

/* toast */
.toast {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 40;
  max-width: min(92vw, 520px); background: var(--housing); color: var(--ink);
  border: 1.5px solid var(--led); border-radius: 14px; padding: 12px 18px;
  font-family: var(--display); font-size: 18px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.6), 0 0 24px var(--led-glow);
  animation: toastIn .4s cubic-bezier(.2,.9,.3,1.3);
}
.toast small { display: block; font-family: var(--body); font-size: 14px; font-weight: 500; color: var(--ink-2); margin-top: 2px; }
@keyframes toastIn { from { transform: translate(-50%, -30px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* controls */
.controls { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 8px; }
.btn {
  flex: 1 1 140px; min-height: 52px; border-radius: 14px; border: 1.5px solid var(--line-2);
  background: transparent; color: var(--ink); font-family: var(--display); font-size: 19px; cursor: pointer;
  transition: transform .08s, background .2s, color .2s, border-color .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(2px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); flex-basis: 100%; font-size: 22px; min-height: 60px; box-shadow: 0 8px 30px var(--led-glow); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-style: dashed; }
body[data-mode="running"] .btn.primary { display: none; }
.btn:focus-visible, .icon-btn:focus-visible, .chip:focus-visible, input:focus-visible { outline: 2px solid var(--led); outline-offset: 2px; }

/* setup */
.setup { margin-top: 18px; display: grid; gap: 18px; }
.field label { display: block; font-weight: 700; margin-bottom: 8px; font-size: 15px; }
.stepper { display: flex; align-items: stretch; border: 1.5px solid var(--line-2); border-radius: 14px; overflow: hidden; background: var(--housing); }
.step { width: 56px; border: 0; background: transparent; font-family: var(--display); font-size: 26px; color: var(--ink); cursor: pointer; }
.step:hover { background: rgba(255,255,255,.06); }
input[type="number"] {
  width: 100%; min-height: 52px; border: 1.5px solid var(--line-2); border-radius: 14px; background: var(--housing);
  font: 700 22px var(--body); color: var(--ink); text-align: center; padding: 6px 12px; -moz-appearance: textfield;
  font-variant-numeric: tabular-nums;
}
.stepper input { border: 0; border-radius: 0; min-height: 50px; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  border: 1px solid var(--line-2); background: transparent; color: var(--ink); border-radius: 999px;
  padding: 7px 12px; font: 500 14px var(--body); cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { border-color: var(--ink); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.hint { margin: 10px 0 0; font-size: 13px; color: var(--ink-2); }

/* about (SEO text) */
.about { margin-top: 40px; padding-top: 22px; border-top: 1px dashed var(--line-2); color: var(--ink-2); }
.about h2 { font-family: var(--display); font-weight: 400; font-size: 22px; margin: 0 0 10px; color: var(--ink); }
.about p { margin: 0 0 12px; line-height: 1.6; font-size: 15px; }
.foot { margin-top: 24px; font-size: 13px; color: var(--ink-3); text-align: center; }
.foot a { color: inherit; }

/* receipt modal: the one bright thing, on purpose */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.72); display: grid; place-items: center; padding: 16px; overflow: auto; backdrop-filter: blur(3px); }
.receipt {
  width: min(100%, 400px); background: #FBF7EE; color: #1A1408; padding: 26px 22px 22px; position: relative;
  font-family: "Heebo", monospace; box-shadow: 0 30px 60px rgba(0,0,0,.7);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 10px), 97% 100%, 94% calc(100% - 10px), 91% 100%, 88% calc(100% - 10px), 85% 100%, 82% calc(100% - 10px), 79% 100%, 76% calc(100% - 10px), 73% 100%, 70% calc(100% - 10px), 67% 100%, 64% calc(100% - 10px), 61% 100%, 58% calc(100% - 10px), 55% 100%, 52% calc(100% - 10px), 49% 100%, 46% calc(100% - 10px), 43% 100%, 40% calc(100% - 10px), 37% 100%, 34% calc(100% - 10px), 31% 100%, 28% calc(100% - 10px), 25% 100%, 22% calc(100% - 10px), 19% 100%, 16% calc(100% - 10px), 13% 100%, 10% calc(100% - 10px), 7% 100%, 4% calc(100% - 10px), 1% 100%, 0 calc(100% - 10px));
  animation: printOut .6s cubic-bezier(.2,.8,.3,1);
}
@keyframes printOut { from { transform: translateY(-40px); opacity: 0; } to { transform: none; opacity: 1; } }
.receipt-head { text-align: center; border-bottom: 2px dashed #1A1408; padding-bottom: 12px; margin-bottom: 12px; }
.receipt-brand { font-family: var(--display); font-size: 14px; letter-spacing: .2em; }
.receipt-head h2 { font-family: var(--display); font-weight: 400; font-size: 26px; margin: 4px 0; }
.receipt-sub { font-size: 12px; color: #6A5A3A; }
.receipt-lines { margin: 0; display: grid; gap: 6px; }
.receipt-lines div { display: flex; justify-content: space-between; gap: 12px; font-size: 16px; }
.receipt-lines dt { color: #6A5A3A; }
.receipt-lines dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.receipt-lines .total { border-top: 2px dashed #1A1408; margin-top: 6px; padding-top: 10px; font-size: 22px; font-family: var(--display); }
.receipt-lines .total dd { color: var(--danger); }
.receipt-equiv { margin: 12px 0 4px; font-family: var(--display); font-size: 18px; }
.receipt-note { margin: 0 0 14px; font-size: 14px; color: #6A5A3A; line-height: 1.5; }
.stamp {
  position: absolute; top: 74px; left: 18px; transform: rotate(-14deg);
  border: 3px solid var(--danger); color: var(--danger); font-family: var(--display); font-size: 18px;
  padding: 4px 10px; border-radius: 6px; opacity: .8; letter-spacing: .06em; pointer-events: none;
}
.receipt-actions { display: grid; gap: 8px; margin-top: 8px; }
.receipt .btn { min-height: 46px; font-size: 17px; flex-basis: auto; box-shadow: none; }
.receipt .btn.primary { background: #1A1408; border-color: #1A1408; color: #FBF7EE; }
.receipt .btn.ghost { border-color: #1A1408; color: #1A1408; }

@media (min-width: 600px) {
  .top { padding-top: 22px; }
  .meter { padding: 18px 18px 14px; }
  .digits.small { max-width: 230px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
  body[data-heat="5"] { animation: none !important; }
}
