:root {
  --ink: #0b0e12;
  --panel: #121820;
  --panel-edge: #2a3544;
  --text: #e8edf4;
  --muted: #8b97a8;
  --yellow: #ffc400;
  --yellow-dim: #c49200;
  --hazard: #ffc400;
  --ok: #6fd3a0;
  --font-display: "Chakra Petch", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --bg-media-opacity: 0.65;
  --bg-crossfade-ms: 5000ms;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--text);
  font-family: var(--font-display);
  background: var(--ink);
  line-height: 1.4;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: #07090c;
}

/* One dimming + grade pass for poster and video alike */
.atmosphere__stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: var(--bg-media-opacity);
  filter: saturate(0.92) brightness(0.88) contrast(1.05);
}

.atmosphere__poster,
.atmosphere__art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--bg-pos-x, 50%) var(--bg-pos-y, 45%);
  pointer-events: none;
  transition: none;
}

.atmosphere__poster {
  z-index: 2;
}

.atmosphere__poster.is-behind {
  z-index: 0;
}

.atmosphere__poster.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.atmosphere__art {
  z-index: 1;
  opacity: 0;
  visibility: hidden;
}

.atmosphere__art.is-visible {
  opacity: 1;
  visibility: visible;
}

/* Crossfade only after the final frame hold — never during playback */
.atmosphere.is-crossfading .atmosphere__poster.is-hidden {
  visibility: visible;
  opacity: 1;
  transition: opacity var(--bg-crossfade-ms) ease;
}

.atmosphere.is-crossfading .atmosphere__art.is-visible {
  opacity: 0;
  transition: opacity var(--bg-crossfade-ms) ease;
}

/* Soft grade so the centered calculator stays readable */
.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(ellipse 90% 55% at 50% -10%, rgba(255, 196, 0, 0.06), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 100%, rgba(20, 40, 70, 0.14), transparent 55%),
    linear-gradient(
      90deg,
      rgba(7, 9, 12, 0.06) 0%,
      rgba(7, 9, 12, 0.14) 35%,
      rgba(7, 9, 12, 0.38) 50%,
      rgba(7, 9, 12, 0.32) 100%
    ),
    linear-gradient(180deg, rgba(7, 9, 12, 0.12) 0%, rgba(7, 9, 12, 0.22) 55%, rgba(7, 9, 12, 0.38) 100%),
    repeating-linear-gradient(
      -18deg,
      transparent,
      transparent 11px,
      rgba(255, 196, 0, 0.018) 11px,
      rgba(255, 196, 0, 0.018) 12px
    );
  pointer-events: none;
}

.shell {
  --shell-bias: 0;
  --shell-width: min(640px, calc(100% - 2rem));
  width: var(--shell-width);
  margin-left: auto;
  /* bias 0: centered · bias 1: right-parked so Helldiver can stay left of content */

  margin-right: max(
    calc(1rem + 1.25rem * var(--shell-bias)),
    calc((100% - var(--shell-width)) / 2 * (1 - var(--shell-bias)))
  );
  padding: clamp(2.5rem, 8vh, 5rem) 0 3rem;
  transition: margin-right 0.45s ease;
}

.brand {
  margin-bottom: 2rem;
  animation: rise 0.7s ease-out both;
}

.brand__mark {
  margin: 0 0 0.35rem;
  color: var(--yellow);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.brand__title {
  margin: 0;
  font-size: clamp(2.6rem, 9vw, 4rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 0.95;
  text-transform: uppercase;
}

.brand__sub {
  margin: 0.9rem 0 0;
  max-width: 36ch;
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 500;
}

.brand__sub a {
  color: var(--yellow);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.calc {
  padding: 1.35rem;
  border: 1px solid var(--panel-edge);
  background:
    linear-gradient(145deg, rgba(255, 196, 0, 0.05), transparent 40%),
    rgba(18, 24, 32, 0.92);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  animation: rise 0.7s ease-out 0.08s both;
}

.field {
  display: grid;
  gap: 0.55rem;
}

.field__label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.field__input {
  width: 100%;
  padding: 0.95rem 1rem;
  border: 1px solid var(--panel-edge);
  border-radius: 0;
  background: #0a0e14;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 500;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field__input:focus {
  border-color: var(--yellow);
  box-shadow: 0 0 0 1px rgba(255, 196, 0, 0.35);
}

.field__input::placeholder {
  color: #4d5a6b;
}

.result {
  margin-top: 1.4rem;
  padding-top: 1.3rem;
  border-top: 1px solid rgba(255, 196, 0, 0.18);
}

.result__eyebrow {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.result__level {
  margin: 0.15rem 0 0;
  color: var(--yellow);
  font-size: clamp(3.5rem, 14vw, 5.5rem);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.result__level.is-updating {
  opacity: 0.55;
  transform: translateY(4px);
}

.result__title {
  margin: 0.55rem 0 0;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result__meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 1.35rem;
}

.stat {
  display: grid;
  gap: 0.25rem;
}

.stat__label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stat__value {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.bar {
  margin-top: 1.1rem;
  height: 6px;
  background: #0a0e14;
  border: 1px solid var(--panel-edge);
  overflow: hidden;
}

.bar__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--yellow-dim), var(--yellow));
  transition: width 0.35s ease;
}

.share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: 1.25rem;
}

.share__btn {
  appearance: none;
  margin: 0;
  padding: 0.7rem 1rem;
  border: 1px solid var(--yellow);
  background: transparent;
  color: var(--yellow);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.share__btn:hover {
  background: var(--yellow);
  color: #12110a;
}

.share__btn:active {
  transform: translateY(1px);
}

.share__btn:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 3px;
}

.share__btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.share__hall {
  margin-left: auto;
  padding: 0.7rem 1rem;
  border: 1px solid rgba(255, 196, 0, 0.45);
  color: var(--yellow);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    opacity 0.35s ease,
    transform 0.15s ease;
}

.share__hall:hover {
  background: rgba(255, 196, 0, 0.12);
  border-color: var(--yellow);
}

.share__hall:active {
  transform: translateY(1px);
}

.share__hall:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 3px;
}

.share__status {
  flex: 1 0 100%;
  color: var(--ok);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  min-height: 1.1em;
}

.share__status.is-error {
  color: #ff8d8d;
}

.footnote {
  margin: 1.25rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  max-width: 52ch;
  animation: rise 0.7s ease-out 0.16s both;
}

.curve {
  margin-top: 1.25rem;
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  animation: rise 0.7s ease-out 0.2s both;
}

.curve.is-collapsed {
  background: transparent;
}

.curve__bar {
  display: flex;
}

.curve__toggle {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.75rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  text-align: left;
  transition: color 0.15s ease, background 0.15s ease;
}

.curve__toggle:hover {
  color: var(--yellow);
  background: rgba(255, 196, 0, 0.04);
}

.curve__toggle:focus-visible {
  outline: 1px solid var(--yellow);
  outline-offset: -1px;
}

.curve__toggle-chevron {
  width: 0.45rem;
  height: 0.45rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.curve:not(.is-collapsed) .curve__toggle-chevron {
  transform: rotate(225deg);
}

.curve__body {
  padding: 0 1.15rem 0.85rem;
}

.curve__body[hidden] {
  display: none;
}

.curve:not(.is-collapsed) {
  background:
    linear-gradient(145deg, rgba(255, 196, 0, 0.04), transparent 42%),
    var(--panel);
}

.curve:not(.is-collapsed) .curve__toggle {
  margin-bottom: 0.35rem;
  color: var(--yellow);
}

.curve__header {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.65rem 0.75rem;
  margin-bottom: 0.55rem;
}

.curve__heading {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
  flex: 1 1 auto;
}

.curve__title {
  margin: 0;
  color: var(--yellow);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.curve__caption {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.curve__scale {
  display: inline-flex;
  flex-wrap: nowrap;
  flex-shrink: 0;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem;
  border: 1px solid var(--panel-edge);
  background: #0a0e14;
}

.curve__scale-label {
  margin: 0 0.35rem 0 0.25rem;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.curve__scale-btn {
  appearance: none;
  margin: 0;
  padding: 0.28rem 0.38rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.curve__scale-btn:hover {
  color: var(--text);
}

.curve__scale-btn.is-active {
  background: rgba(255, 196, 0, 0.12);
  color: var(--yellow);
}

.curve__scale-btn:focus-visible {
  outline: 1px solid var(--yellow);
  outline-offset: 1px;
}

.curve__canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
}

.credit {
  margin: 1.75rem 0 0;
  color: var(--yellow);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  animation: rise 0.7s ease-out 0.22s both;
}

.support {
  max-width: 34rem;
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.55;
  animation: rise 0.7s ease-out 0.25s both;
}

.footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
  animation: rise 0.7s ease-out 0.28s both;
}

.discord-btn,
.kofi-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0;
  padding: 0.7rem 1rem;
  background: transparent;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-decoration: none;
  text-transform: uppercase;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.discord-btn {
  border: 1px solid #5865f2;
  color: #7289da;
}

.discord-btn:hover {
  background: #5865f2;
  border-color: #5865f2;
  color: #fff;
}

.discord-btn:focus-visible {
  outline: 2px solid #7289da;
  outline-offset: 3px;
}

.discord-btn__icon,
.kofi-btn__icon {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
}

.kofi-btn {
  border: 1px solid var(--yellow-dim);
  color: var(--yellow);
}

.kofi-btn:hover {
  background: var(--yellow);
  border-color: var(--yellow);
  color: var(--ink);
}

.kofi-btn:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 3px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 520px) {
  .result__meta {
    grid-template-columns: 1fr;
  }

  :root {
    --bg-media-opacity: 0.44;
  }
}
