@layer components {
  /* ---- Type ------------------------------------------------------------ */

  .wordmark {
    font-family: var(--font-display);
    font-size: var(--text-hero);
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1;
    text-transform: uppercase;
    background: linear-gradient(180deg, var(--gold-bright), var(--gold));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }

  .eyebrow {
    font-size: var(--text-micro);
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--ink-soft);
  }

  .tagline {
    color: var(--ink-soft);
    max-width: 34rem;
    margin-inline: auto;
  }

  .section-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: var(--s3);
  }

  /* ---- Buttons ---------------------------------------------------------- */

  .button {
    padding: var(--s3) var(--s5);
    border-radius: var(--radius-sm);
    border: 1px solid var(--edge);
    background: var(--raised);
    font-weight: 600;
    letter-spacing: 0.04em;
    transition: background var(--tempo) var(--ease), border-color var(--tempo) var(--ease);
  }

  .button:hover {
    background: color-mix(in oklab, var(--raised), var(--gold) 12%);
    border-color: var(--gold);
  }

  .button--primary {
    font-family: var(--font-display);
    font-size: 1.125rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    padding: var(--s4) var(--s7);
    color: var(--void);
    background: linear-gradient(180deg, var(--gold-bright), var(--gold));
    border-color: var(--gold-bright);
  }

  .button--primary:hover {
    background: linear-gradient(180deg, #f4d689, var(--gold-bright));
  }

  .button--ghost {
    background: none;
    color: var(--ink-soft);
    border-color: transparent;
    font-size: var(--text-small);
  }

  .button--ghost:hover {
    color: var(--ink);
    background: var(--panel);
    border-color: var(--edge);
  }

  kbd {
    font-family: var(--font-mono);
    font-size: 0.75em;
    padding: 0.1em 0.45em;
    border-radius: 5px;
    border: 1px solid var(--edge);
    background: var(--raised);
    color: var(--ink);
  }

  .launch__hint {
    font-size: var(--text-small);
    color: var(--ink-soft);
    display: flex;
    align-items: center;
    gap: var(--s1);
    flex-wrap: wrap;
    justify-content: center;
  }

  .launch__best {
    font-size: var(--text-small);
    color: var(--gold);
  }

  /* ---- The grimoire (menu reference grid) ------------------------------- */

  .rune {
    display: grid;
    justify-items: center;
    gap: var(--s2);
    padding: var(--s3);
    border-radius: var(--radius);
    border: 1px solid var(--edge);
    background: var(--panel);
    text-align: center;
  }

  .rune__art {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: var(--radius-sm);
  }

  .rune__name {
    font-family: var(--font-display);
    font-size: var(--text-small);
    font-weight: 600;
    line-height: 1.2;
  }

  .rune__blurb {
    font-size: var(--text-micro);
    color: var(--ink-faint);
    line-height: 1.35;
  }

  /* Combo pips: three dots in orb colour, the compact form of a combo. Never
     the only representation — the pip row carries a text label for readers. */
  .pips {
    display: flex;
    gap: var(--s1);
  }

  .pip {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 50%;
    background: var(--orb);
    box-shadow: 0 0 0 1px rgb(0 0 0 / 35%);
  }

  .rule {
    padding: var(--s4);
    border-radius: var(--radius);
    border: 1px solid var(--edge);
    background: var(--panel);
  }

  .rule__title {
    font-family: var(--font-display);
    font-size: var(--text-small);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: var(--s1);
  }

  .rule__body {
    font-size: var(--text-small);
    color: var(--ink-soft);
  }

  /* ---- HUD --------------------------------------------------------------- */

  .hud__label {
    font-size: var(--text-micro);
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--ink-faint);
  }

  .hud__value {
    font-family: var(--font-mono);
    font-size: 1.125rem;
    /* Tabular figures so the numbers do not shuffle sideways as they change —
       the clock is updating every frame right beside the spell card. */
    font-variant-numeric: tabular-nums;
  }

  .hud__stat--clock .hud__value {
    font-size: var(--text-clock);
    color: var(--gold);
    line-height: 1;
  }

  .hud__value[data-misses]:not([data-misses="0"]) {
    color: var(--miss);
  }

  /* ---- The spell card ---------------------------------------------------- */

  .spell-card {
    display: grid;
    justify-items: center;
    gap: var(--s4);
  }

  .spell-card__art {
    width: clamp(9rem, 30vw, 12.5rem);
    height: clamp(9rem, 30vw, 12.5rem);
    border-radius: var(--radius);
    border: 2px solid var(--edge);
    box-shadow: var(--shadow);
    background: var(--panel);
  }

  .spell-card__name {
    font-family: var(--font-display);
    font-size: var(--text-spell);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: center;
  }

  /* ---- Orb tray ---------------------------------------------------------- */

  .tray {
    display: flex;
    gap: var(--s3);
  }

  .orb-slot {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 50%;
    border: 2px dashed var(--edge);
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-weight: 700;
    color: transparent;
    background: transparent;
  }

  .orb-slot[data-filled] {
    border-style: solid;
    border-color: var(--orb);
    color: var(--void);
    background: radial-gradient(circle at 34% 28%, var(--orb), var(--orb-deep));
    box-shadow: 0 0 18px -2px var(--orb);
  }

  /* ---- Orb keys (touch, and a visual key legend) ------------------------- */

  .orb-key {
    width: 4.25rem;
    padding: var(--s2) 0 var(--s3);
    display: grid;
    justify-items: center;
    gap: var(--s1);
    border-radius: var(--radius);
    border: 1px solid var(--edge);
    background: var(--raised);
    transition: transform var(--tempo-fast) var(--ease), border-color var(--tempo-fast) var(--ease);
  }

  .orb-key img {
    width: 2rem;
    height: 2rem;
  }

  .orb-key__key {
    font-family: var(--font-mono);
    font-size: var(--text-small);
    color: var(--orb, var(--gold));
  }

  .orb-key:hover {
    border-color: var(--orb, var(--gold));
  }

  /* Held down, or the physical key is down. Both routes set the same class so
     the on-screen keys mirror the keyboard exactly. */
  .orb-key.is-down {
    transform: translateY(2px);
    border-color: var(--orb, var(--gold));
    background: color-mix(in oklab, var(--raised), var(--orb, var(--gold)) 22%);
  }

  .orb-key--invoke {
    width: 6.5rem;
    font-family: var(--font-display);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gold);
    border-color: var(--gold);
  }

  .orb-key--invoke .orb-key__glyph {
    font-size: 1.5rem;
    line-height: 1;
  }

  /* ---- Countdown and pause ----------------------------------------------- */

  .countdown,
  .pause-veil {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    gap: var(--s2);
    background: color-mix(in oklab, var(--void), transparent 12%);
    border-radius: var(--radius);
    z-index: 2;
  }

  .countdown__value {
    font-family: var(--font-display);
    font-size: clamp(4rem, 16vw, 7rem);
    font-weight: 700;
    line-height: 1;
    color: var(--gold);
  }

  .pause-veil__title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gold);
  }

  .pause-veil__body {
    font-size: var(--text-small);
    color: var(--ink-soft);
    text-align: center;
    max-width: 22rem;
  }

  /* ---- Results ----------------------------------------------------------- */

  .rank-badge {
    display: grid;
    justify-items: center;
    gap: var(--s2);
    padding: var(--s5) var(--s7);
    border-radius: var(--radius);
    border: 1px solid var(--gold);
    background: var(--panel);
    box-shadow: var(--glow-gold);
  }

  .rank-badge__tier {
    font-family: var(--font-display);
    font-size: var(--text-rank);
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    line-height: 1;
    color: var(--gold-bright);
  }

  .rank-badge__stars {
    display: flex;
    gap: var(--s1);
    font-size: 1.25rem;
    color: var(--gold);
    letter-spacing: 0.1em;
  }

  .rank-badge__note {
    font-size: var(--text-small);
    color: var(--ink-soft);
  }

  .badge {
    font-size: var(--text-micro);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    padding: 0.2em 0.7em;
    border-radius: 999px;
    border: 1px solid currentcolor;
  }

  .badge--perfect {
    color: var(--hit);
  }

  .badge--flagged {
    color: var(--ink-faint);
  }

  .stat {
    padding: var(--s3);
    border-radius: var(--radius);
    border: 1px solid var(--edge);
    background: var(--panel);
    display: grid;
    gap: var(--s1);
    justify-items: center;
    text-align: center;
  }

  .stat__label {
    font-size: var(--text-micro);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-faint);
  }

  .stat__value {
    font-family: var(--font-mono);
    font-size: 1.35rem;
    font-variant-numeric: tabular-nums;
  }

  /* Per-spell breakdown. The bar is proportional to the slowest spell in the
     run, so the shape of the row shows where the time actually went — an
     absolute scale would make every row look the same on a fast run. */
  .split {
    display: grid;
    grid-template-columns: 1.5rem 1fr auto;
    align-items: center;
    gap: var(--s3);
    padding: var(--s2) var(--s3);
    border-radius: var(--radius-sm);
    background: var(--panel);
    font-size: var(--text-small);
  }

  .split__index {
    font-family: var(--font-mono);
    color: var(--ink-faint);
    font-size: var(--text-micro);
  }

  .split__name {
    display: flex;
    align-items: center;
    gap: var(--s2);
    min-width: 0;
  }

  .split__bar {
    height: 0.4rem;
    border-radius: 999px;
    background: var(--gold);
    opacity: 0.55;
    flex: 0 0 auto;
  }

  .split__label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .split__time {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
  }

  .split[data-fastest] .split__bar {
    background: var(--hit);
    opacity: 1;
  }

  .split[data-fastest] .split__time {
    color: var(--hit);
  }

  .split[data-slowest] .split__bar {
    background: var(--miss);
    opacity: 1;
  }

  .split[data-slowest] .split__time {
    color: var(--miss);
  }

  .split__misses {
    color: var(--miss);
    font-size: var(--text-micro);
  }
}
