:root {
  --hue: 0;
  --sat: 90%;
  --light: 32%;
  --glow: 0.35;
  --weight: 200;
  --bg: #050407;
  --fg: #ece6e2;
  --dim: #8a817c;
  --line: #ffffff14;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  background-image: radial-gradient(ellipse at 50% 40%, hsl(var(--hue) 40% 6% / 1), transparent 70%);
  color: var(--fg);
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  transition: background-color 2s;
}

.sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; }
body.has-sky { background: #020103; }
body.has-sky .glow { display: none; }
.glow {
  position: fixed;
  left: 50%; top: 40%;
  width: min(140vw, 1400px); aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle,
    hsl(var(--hue) var(--sat) var(--light) / var(--glow)) 0%,
    hsl(var(--hue) var(--sat) calc(var(--light) * 0.6) / calc(var(--glow) * 0.45)) 22%,
    transparent 58%);
  pointer-events: none;
  transition: background 2s;
  animation: breathe 9s ease-in-out infinite;
}
@keyframes breathe { 50% { transform: translate(-50%, -50%) scale(1.04); } }

.top {
  position: fixed; inset: 0 0 auto 0;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim);
  z-index: 3;
}
.brand { color: var(--fg); font-weight: 600; }
.season { flex: 1; }
.signin {
  background: none; border: 1px solid var(--line); color: var(--dim);
  padding: 6px 12px; border-radius: 999px; font: inherit; cursor: pointer;
}
.kofi {
  color: var(--dim); text-decoration: none; text-transform: none; letter-spacing: 0; font-size: 13px;
  padding: 6px 10px; border-radius: 999px; transition: color .2s, background .2s;
}
.kofi:hover, .kofi:focus-visible { color: var(--fg); background: #ffffff0d; }
@media (max-width: 520px) { .kofi-text { display: none; } .kofi { font-size: 16px; padding: 4px 8px; } }
.signin:hover:not(:disabled) { color: var(--fg); border-color: #ffffff30; }
.signin:disabled { cursor: not-allowed; opacity: .6; }

.core {
  position: relative; z-index: 2;
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 16px; text-align: center;
  margin-right: 340px;
}
.temp {
  font-size: clamp(36px, 10.5vw, 132px);
  font-weight: var(--weight);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 0 40px hsl(var(--hue) var(--sat) var(--light) / calc(var(--glow) * 0.9));
  transition: font-weight 1.5s, text-shadow 2s;
}
.temp small { font-size: .38em; font-weight: 300; color: var(--dim); margin-left: .15em; }
/* Star-tinted, slightly translucent number with rolling digits. */
body.has-sky .temp { text-shadow: none; }
.temp .num {
  display: inline-block; color: rgb(255 250 245 / .88);
  filter: drop-shadow(0 0 3px rgb(0 0 0 / .55)) drop-shadow(0 0 18px rgb(var(--star, 255 140 90) / .5)) drop-shadow(0 0 60px rgb(var(--star, 255 140 90) / .25));
}
/* A soft shadow behind the readout keeps it legible when the star fills the screen. */
body.has-sky .core::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: min(820px, 100%); height: 600px; z-index: -1;
  transform: translate(-50%, -50%); pointer-events: none;
  background: radial-gradient(ellipse closest-side, rgb(2 1 3 / .62), rgb(2 1 3 / .5) 45%, rgb(2 1 3 / .22) 75%, transparent);
}
/* During a supernova the readout steps aside, then returns with the new ember. */
.core > * { transition: opacity 2.4s ease-in; }
body.nova-active .core > * { opacity: 0; transition: opacity .15s; }
body.has-sky .act { background: rgb(10 8 14 / .62); backdrop-filter: blur(6px); }
body.has-sky .act:disabled { opacity: .55; }
/* Labels sit over the star once it grows: a soft dark halo keeps them legible. */
body.has-sky .stage, body.has-sky .rate, body.has-sky .me, body.has-sky .toast { text-shadow: 0 0 6px rgb(0 0 0 / .85), 0 0 14px rgb(0 0 0 / .6); }
.temp .dg { display: inline-block; height: 1em; overflow: hidden; vertical-align: top; }
.temp .strip { display: block; white-space: pre; line-height: 1; transition: transform 0ms cubic-bezier(.2, .7, .2, 1); }
.temp .sep { display: inline-block; vertical-align: top; }
.stage.ignite { animation: ignite 2.4s cubic-bezier(.2, .8, .2, 1); }
@keyframes ignite {
  0% { transform: translateY(-18vh) scale(3.2); opacity: 0; color: #fff; text-shadow: 0 0 30px rgb(var(--star) / .9); }
  18% { transform: translateY(-18vh) scale(3); opacity: 1; color: #fff; text-shadow: 0 0 30px rgb(var(--star) / .9); }
  100% { transform: none; opacity: 1; }
}
.core.shake { animation: shake .55s linear; }
@keyframes shake {
  10%, 50%, 90% { transform: translate(-5px, 2px); }
  30%, 70% { transform: translate(5px, -3px); }
  20%, 60% { transform: translate(3px, 4px); }
  40%, 80% { transform: translate(-3px, -2px); }
}
@media (prefers-reduced-motion: reduce) {
  .stage.ignite { animation: ignite-calm 1.2s ease-out; }
  @keyframes ignite-calm { from { opacity: 0; } }
  .core.shake { animation: none; }
}
.preview {
  position: fixed; bottom: 16px; left: 16px; z-index: 5;
  padding: 3px 10px; border-radius: 999px; border: 1px solid #ffffff26; background: #0008;
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim);
}
.stage { margin-top: 18px; font-size: 18px; letter-spacing: .04em; color: hsl(var(--hue) 70% 72%); transition: color 2s; }
/* With the canvas star the stage name takes the star's colour, lifted toward white so deep reds stay legible. */
body.has-sky .stage { color: color-mix(in srgb, rgb(var(--star, 255 140 90)) 70%, white); }
.rate { color: #aaa19b; font-variant-numeric: tabular-nums; margin-top: 2px; }
.eta { margin-top: 4px; font-size: 13px; letter-spacing: .04em; color: color-mix(in srgb, rgb(var(--star, 255 140 90)) 55%, white); font-variant-numeric: tabular-nums; }
.eta[hidden], .share[hidden] { display: none; }
.share {
  margin-top: 8px; font: inherit; font-size: 13px; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  color: var(--fg); background: rgb(10 8 14 / .6); border: 1px solid #ffffff24;
}
.share:hover { border-color: #ffffff44; }
.me { margin-top: 28px; color: var(--dim); }
.me b { color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums; }
.me #name { color: var(--fg); }
.dot { margin: 0 6px; }

.actions { display: flex; gap: 12px; margin-top: 16px; }
.act {
  font: inherit; font-size: 16px; font-weight: 600;
  padding: 12px 22px; min-width: 132px;
  border-radius: 12px; border: 1px solid var(--line);
  background: #ffffff0a; color: var(--fg);
  cursor: pointer; transition: background .2s, border-color .2s, transform .1s;
}
.act small { display: block; margin-top: 2px; font-size: 12.5px; font-weight: 400; color: var(--dim); font-variant-numeric: tabular-nums; }
.act.cool:hover:not(:disabled) { border-color: #6fb6ff80; background: #6fb6ff14; }
.act.stoke:hover:not(:disabled) { border-color: #ff8a5c80; background: #ff8a5c14; }
.act:active:not(:disabled) { transform: scale(.97); }
.act:disabled { opacity: .4; cursor: default; }
.act { position: relative; overflow: hidden; }
.act.waiting:disabled { opacity: .8; }
.act.waiting { color: var(--dim); }
.act.waiting small { color: #f3eff8; font-weight: 600; }
.act.cooling small { color: var(--fg); }
.act.cooling::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 2px;
  width: calc(var(--cd, 0) * 100%); background: rgb(var(--star, 255 140 90)); opacity: .8;
  transition: width .25s linear;
}
.act.waiting::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 2px;
  width: calc(var(--progress, 0) * 100%); background: #f3eff8; opacity: .6;
  transition: width .25s linear;
}
.act.pulse { animation: pulse .9s ease-out; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 #ffffff55; } 100% { box-shadow: 0 0 0 14px #ffffff00; } }
.act.resisting { opacity: .55; border-style: dashed; }
.act.resisting small { color: #9fc8ff; }
.watching { margin: 14px auto 0; max-width: 34em; padding: 8px 14px; border: 1px solid #ffffff1f; border-radius: 8px; font-size: 14px; color: var(--dim); background: #ffffff08; }
.ts:not(:empty) { margin-top: 14px; }
.toast { min-height: 1.4em; margin-top: 12px; font-size: 14px; color: var(--dim); transition: opacity .4s; }

.log {
  position: fixed; top: 0; right: 0; bottom: 0; width: 340px; z-index: 2;
  border-left: 1px solid var(--line);
  background: #07060acc; backdrop-filter: blur(8px);
  display: flex; flex-direction: column;
  padding-top: 56px;
}
.log-toggle {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--line);
  color: var(--dim); font: inherit; font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  padding: 0 16px 10px; cursor: default;
}
.log ol { list-style: none; margin: 0; padding: 6px 0; overflow-y: auto; flex: 1; }
.log li { padding: 7px 16px; font-size: 13.5px; border-bottom: 1px solid #ffffff08; }
.log li time { display: block; font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
.log li .detail { display: block; margin-top: 2px; font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.log li.milestone { color: hsl(var(--hue) 60% 75%); }
.log li.stage { color: #ffd59a; font-weight: 600; }
.log li.supernova { color: #fff; font-weight: 700; background: #ffffff10; }
.log li.fresh { animation: fresh 1.2s ease-out; }
@keyframes fresh { from { background: #ffffff18; } }

.nova {
  position: fixed; inset: 0; z-index: 10; pointer-events: none;
  display: grid; place-items: center;
  background: radial-gradient(circle, #fff 0%, #cfe3ff 30%, #050407 75%);
}
/* With the canvas star: a ≤1s blinding flash above everything (UI included), then the
   canvas carries the shockwave and violet afterglow; the word is light on the dark sky. */
body.has-sky .nova { background: none; transform: none; }
body.has-sky .nova::before { content: ""; position: absolute; inset: 0; background: #fff; opacity: 0; }
body.has-sky .nova.go { animation: none; opacity: 1; }
body.has-sky .nova.go::before { animation: nova-flash .5s linear forwards; }
body.has-sky .nova span {
  position: relative; opacity: 0; color: #eef0ff; letter-spacing: .32em; font-weight: 600;
  font-size: clamp(24px, 6vw, 72px); text-shadow: 0 0 24px rgb(150 120 255 / .8), 0 0 60px rgb(90 60 220 / .6);
}
body.has-sky .nova.go span { animation: nova-word 4.6s ease-out forwards; }
/* Blinding but brief: full white for ~0.1s, mostly gone by 0.3s, so the UI never sits under a grey wash. */
@keyframes nova-flash { 0% { opacity: 0; } 12% { opacity: 1; } 24% { opacity: 1; } 60% { opacity: .08; } 100% { opacity: 0; } }
/* Gone by ~3.0s, before the readout returns with the ember at 3.2s. */
@keyframes nova-word { 0%, 17% { opacity: 0; transform: scale(.94); } 27% { opacity: 1; } 50% { opacity: 1; transform: scale(1); } 65%, 100% { opacity: 0; transform: scale(1.03); } }
@media (prefers-reduced-motion: reduce) { body.has-sky .nova.go::before { animation-duration: .6s; } body.has-sky .nova.go span { animation-name: nova-word-calm; } @keyframes nova-word-calm { 0%, 17% { opacity: 0; } 27%, 50% { opacity: 1; } 65%, 100% { opacity: 0; } } }
.nova {
  opacity: 0; transform: scale(.2);
}
.nova span { font-size: clamp(32px, 9vw, 110px); font-weight: 800; color: #050407; letter-spacing: .1em; }
.nova.go { animation: nova 6s ease-out forwards; }
@keyframes nova {
  0% { opacity: 0; transform: scale(.05); }
  12% { opacity: 1; transform: scale(1.4); }
  55% { opacity: 1; transform: scale(2.2); }
  100% { opacity: 0; transform: scale(3); }
}

.conn {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 4;
  padding: 6px 14px; border-radius: 999px; background: #1a1418; color: var(--dim); font-size: 13px;
  opacity: 0; transition: opacity .3s; pointer-events: none;
}
.conn.show { opacity: 1; }

@media (max-width: 860px) {
  .core { margin-right: 0; padding-bottom: 64px; }
  .log {
    top: auto; left: 0; width: auto; height: 60vh;
    border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0;
    padding-top: 0;
    transform: translateY(calc(100% - 48px)); transition: transform .3s ease;
  }
  .log.open { transform: none; }
  .log-toggle { height: 48px; padding: 0 16px; cursor: pointer; }
  .conn { bottom: 64px; }
  .act { min-width: 0; flex: 1; }
  .actions { width: 100%; max-width: 360px; }
}

.link { background: none; border: 0; padding: 0 2px; font: inherit; font-size: 12px; color: var(--dim); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link:hover:not(:disabled) { color: var(--fg); }
.link:disabled { opacity: .5; cursor: default; text-decoration: none; }
.purchased { font-size: 12px; color: var(--dim); }
.rename[hidden] { display: none; }
.rename { display: flex; gap: 8px; justify-content: center; margin: 10px auto 0; }
.rename input { font: inherit; font-size: 14px; padding: 7px 10px; width: 14em; border-radius: 8px; border: 1px solid var(--line); background: #ffffff0a; color: inherit; }
.rename button { font: inherit; font-size: 14px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line); background: #ffffff10; color: inherit; cursor: pointer; }
.countdown { margin-left: 6px; font-size: 13px; font-variant-numeric: tabular-nums; opacity: .8; }
.drop {
  margin-top: 14px; font: inherit; font-size: 14px; font-weight: 600;
  padding: 9px 18px; border-radius: 999px; cursor: pointer;
  color: #ffe2b0; background: #ffb34714; border: 1px solid #ffb34766;
  font-variant-numeric: tabular-nums;
  animation: pulse 1.6s ease-in-out infinite;
}
.drop[hidden] { display: none; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px #ffb34714; } }
