/* ═══════════════════════════════════════════════════════════════════════
   FISH THE LAKE — the landing page.

   The art direction is taken from the KillJoy logo: flat, saturated,
   friendly colour; heavy warm-dark outlines; chunky rounded shapes; a
   soft, daylight palette. The palette is sampled from the logo itself —
   grass #6a9f2c, water #1c96d6, olive #676f45, cream #d4d1b2, ink
   #101a22 — so the game and the mark are the same world.

   Animal Crossing's UI signature: a cream panel, a chunky dark outline,
   a soft drop shadow, and a button that looks pressed.
   ═══════════════════════════════════════════════════════════════════════ */

@layer reset, tokens, layout, components, motion;

@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html,
  body {
    margin: 0;
    padding: 0;
  }

  button,
  fieldset,
  legend {
    font: inherit;
    color: inherit;
  }

  fieldset {
    margin: 0;
    padding: 0;
    border: 0;
  }

  img {
    display: block;
    max-width: 100%;
  }
}

@layer tokens {
  :root {
    color-scheme: light;

    /* — the palette, sampled from the logo — */
    --grass: oklch(0.63 0.16 122);
    --grass-deep: oklch(0.48 0.13 122);
    --grass-pale: oklch(0.87 0.09 122);
    --water: oklch(0.68 0.15 229);
    --water-deep: oklch(0.53 0.13 232);
    --water-pale: oklch(0.9 0.06 229);
    --olive: oklch(0.52 0.06 116);
    --cream: oklch(0.95 0.04 92);
    --cream-deep: oklch(0.9 0.05 92);
    --ink: oklch(0.22 0.03 210);
    --sun: oklch(0.88 0.13 84);
    --coral: oklch(0.7 0.15 35);

    /* — type — */
    --font-ui: "Nunito", ui-rounded, "Hiragino Maru Gothic ProN", system-ui, sans-serif;

    /* — the chunky outline every AC shape wears — */
    --edge: 3px solid var(--ink);
    --edge-thin: 2px solid var(--ink);

    /* — the shadow under a panel — */
    --lift: 0 4px 0 0 var(--ink);

    /* — motion — */
    --ease: cubic-bezier(0.34, 1.3, 0.64, 1);
  }
}

@layer layout {
  body {
    min-height: 100svh;
    background: var(--water-pale);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 16px;
    line-height: 1.55;
    font-weight: 500;
    -webkit-font-smoothing: antialiased;
  }

  #gameCanvas {
    position: fixed;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
  }

  body[data-screen="landing"] #gameCanvas {
    visibility: hidden;
  }

  .kj-landing {
    position: relative;
    z-index: 2;
    min-height: 100svh;
    /* a soft daylight sky over a pale green shore */
    background:
      radial-gradient(circle at 78% 12%, oklch(0.97 0.06 92 / 0.9) 0 7rem, transparent 7.1rem),
      linear-gradient(180deg, var(--water-pale) 0%, oklch(0.94 0.05 105) 62%, var(--grass-pale) 100%);
    padding-bottom: 3rem;
  }

  body[data-screen="playing"] .kj-landing {
    display: none;
  }

  .kj-landing-inner {
    max-width: 62rem;
    margin: 0 auto;
    padding: 1.75rem clamp(1rem, 4vw, 2.5rem) 0;
  }

  .kj-landing-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
  }

  .kj-landing-logo {
    width: auto;
    height: 5.5rem;
    filter: drop-shadow(0 3px 0 rgb(16 26 34 / 0.12));
  }

  .kj-landing-kicker {
    margin: 0;
    padding: 0.35rem 0.9rem;
    border: var(--edge-thin);
    border-radius: 999px;
    background: var(--cream);
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink);
  }

  .kj-landing-hero {
    margin-top: clamp(1.5rem, 5vw, 3rem);
    padding: clamp(1.5rem, 4vw, 2.5rem);
    border: var(--edge);
    border-radius: 1.6rem;
    background: var(--cream);
    box-shadow: var(--lift);
  }

  .kj-landing-title {
    margin: 0;
    max-width: 16ch;
    font-size: clamp(2.2rem, 6.5vw, 3.9rem);
    line-height: 1.02;
    letter-spacing: -0.02em;
    font-weight: 800;
    color: var(--ink);
    text-wrap: balance;
  }

  .kj-landing-lede {
    margin: 1rem 0 0;
    max-width: 56ch;
    font-size: 1.02rem;
    line-height: 1.65;
    font-weight: 500;
    color: oklch(0.32 0.03 210);
  }

  .kj-pours {
    margin: clamp(1.5rem, 4vw, 2.25rem) 0 0;
  }

  .kj-pours-legend {
    padding: 0;
    margin: 0 0 0.9rem;
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink);
  }

  .kj-pours-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13.5rem, 1fr));
    gap: 1rem;
  }

  .kj-landing-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.25rem;
    margin-top: clamp(1.5rem, 4vw, 2.25rem);
  }

  .kj-landing-note {
    margin: 0;
    max-width: 42ch;
    font-size: 0.85rem;
    font-weight: 600;
    color: oklch(0.36 0.03 210);
  }
}

@layer components {
  /* — a pour card: a cream panel with a chunky edge — */
  .kj-pour {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    padding: 1.1rem 1.15rem 1.2rem;
    border: var(--edge);
    border-radius: 1.15rem;
    background: var(--cream);
    box-shadow: var(--lift);
    text-align: left;
    cursor: pointer;
    transition:
      transform 180ms var(--ease),
      box-shadow 180ms var(--ease),
      background-color 180ms var(--ease);
  }

  .kj-pour:hover {
    transform: translateY(-3px);
    box-shadow: 0 7px 0 0 var(--ink);
  }

  .kj-pour:active {
    transform: translateY(1px);
    box-shadow: 0 2px 0 0 var(--ink);
  }

  .kj-pour[aria-checked="true"] {
    background: oklch(0.97 0.07 122);
    box-shadow: 0 7px 0 0 var(--grass-deep), 0 0 0 4px oklch(0.63 0.16 122 / 0.28);
  }

  .kj-pour:focus-visible {
    outline: 3px solid var(--water);
    outline-offset: 3px;
  }

  .kj-pour-swatch {
    width: 3rem;
    height: 3rem;
    border: var(--edge-thin);
    border-radius: 999px;
    box-shadow: inset 0 2px 0 rgb(255 255 255 / 0.4);
  }

  .kj-pour-name {
    margin: 0;
    font-size: 1.2rem;
    line-height: 1.15;
    font-weight: 800;
    color: var(--ink);
  }

  .kj-pour-note {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    font-weight: 500;
    color: oklch(0.34 0.03 210);
  }

  .kj-pour-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: auto;
    padding-top: 0.7rem;
    border-top: 2px dashed oklch(0.22 0.03 210 / 0.18);
    font-size: 0.82rem;
    font-weight: 700;
    color: oklch(0.38 0.03 210);
  }

  .kj-pour-price {
    font-variant-numeric: tabular-nums;
    color: var(--grass-deep);
  }

  /* — the call to action: a chunky green button that presses — */
  .kj-cta {
    padding: 0.95rem 1.9rem;
    border: var(--edge);
    border-radius: 999px;
    background: var(--grass);
    color: oklch(0.99 0.02 122);
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: 0 5px 0 0 var(--grass-deep), var(--lift);
    transition:
      transform 160ms var(--ease),
      box-shadow 160ms var(--ease);
  }

  .kj-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 0 0 var(--grass-deep), var(--lift);
  }

  .kj-cta:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 0 var(--grass-deep), var(--lift);
  }

  .kj-cta:focus-visible {
    outline: 3px solid var(--water);
    outline-offset: 4px;
  }

  .kj-cta[disabled] {
    background: oklch(0.78 0.04 92);
    border-color: oklch(0.5 0.03 210);
    color: oklch(0.5 0.03 210);
    box-shadow: 0 4px 0 0 oklch(0.6 0.03 210);
    cursor: not-allowed;
    transform: none;
  }
}

@layer motion {
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
  }

  @media (prefers-reduced-motion: no-preference) {
    .kj-pour {
      animation: kj-pop 420ms var(--ease) both;
    }

    .kj-landing-hero {
      animation: kj-pop 520ms var(--ease) both;
    }
  }

  @keyframes kj-pop {
    from {
      opacity: 0;
      transform: translateY(14px) scale(0.98);
    }
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   THE HUD
   The lake is on the canvas. The readouts are not: text belongs to the
   DOM, where it stays crisp at any pixel ratio, can be read aloud, and
   is styled by this one stylesheet.

   The same register as the landing — cream panels, a 3px ink edge, a
   hard offset shadow, Nunito — so the game and its front door are one
   piece of work.
   ═══════════════════════════════════════════════════════════════════════ */

@layer hud {
  .kj-hud {
    position: fixed;
    inset: 0;
    z-index: 3;
    pointer-events: none;
  }

  .kj-hud[hidden] {
    display: none;
  }

  .kj-panel {
    position: absolute;
    padding: 0.85rem 1rem;
    border: var(--edge);
    border-radius: 1rem;
    background: var(--cream);
    box-shadow: var(--lift);
    color: var(--ink);
  }

  .kj-panel-clock {
    display: flex;
    align-items: baseline;
    gap: 0.55rem;
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
  }

  .kj-panel-tag {
    padding: 0.1rem 0.5rem;
    border: 2px solid var(--ink);
    border-radius: 999px;
    background: var(--sun);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .kj-readout {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.15rem 0.75rem;
    margin: 0;
    font-size: 0.82rem;
  }

  .kj-readout > div {
    display: contents;
  }

  .kj-readout dt {
    font-weight: 700;
    color: oklch(0.45 0.03 210);
  }

  .kj-readout dd {
    margin: 0;
    font-weight: 700;
  }

  .kj-panel-fit {
    margin: 0.5rem 0 0;
    padding-top: 0.45rem;
    border-top: 2px dashed oklch(0.22 0.03 210 / 0.18);
    font-size: 0.76rem;
    font-weight: 800;
    color: var(--grass-deep);
  }

  .kj-panel-fit[data-fit="wrong"] {
    color: var(--coral);
  }

  .kj-panel-conditions {
    top: 1rem;
    left: 1rem;
    width: 14.5rem;
  }

  .kj-panel-score {
    top: 1rem;
    right: 1rem;
    min-width: 11.5rem;
  }

  .kj-panel-score-head {
    margin: 0 0 0.35rem;
    font-size: 1.15rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
  }

  .kj-panel-line {
    margin: 0.1rem 0 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: oklch(0.38 0.03 210);
  }

  .kj-panel-lure {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
    padding-top: 0.45rem;
    border-top: 2px dashed oklch(0.22 0.03 210 / 0.18);
  }

  .kj-panel-lure-swatch {
    width: 0.85rem;
    height: 0.85rem;
    border: 2px solid var(--ink);
    border-radius: 999px;
  }

  /* — the cast meter — */
  .kj-panel-cast {
    left: 50%;
    bottom: 1.5rem;
    width: min(22rem, calc(100vw - 2rem));
    transform: translateX(-50%);
  }

  .kj-panel-title {
    margin: 0 0 0.5rem;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  .kj-meter {
    position: relative;
    height: 0.85rem;
    border: 2px solid var(--ink);
    border-radius: 999px;
    background: oklch(0.9 0.03 92);
    overflow: hidden;
  }

  .kj-meter-fill {
    display: block;
    height: 100%;
    width: 0%;
    background: var(--grass);
  }

  .kj-meter-gold {
    background: var(--sun);
  }

  .kj-meter-mark {
    position: absolute;
    top: -2px;
    bottom: -2px;
    left: 50%;
    width: 3px;
    background: var(--ink);
  }

  .kj-meter-net {
    margin-top: 0.5rem;
    height: 0.6rem;
  }

  /* — the tension bar — */
  .kj-panel-fight {
    left: 50%;
    bottom: 1.5rem;
    width: min(22rem, calc(100vw - 2rem));
    transform: translateX(-50%);
  }

  .kj-tension {
    position: relative;
    height: 1.1rem;
    border: 2px solid var(--ink);
    border-radius: 999px;
    background: oklch(0.9 0.03 92);
    overflow: hidden;
  }

  .kj-tension-safe {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 15%;
    width: 70%;
    background: oklch(0.63 0.16 122 / 0.35);
  }

  .kj-tension-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 0%;
    background: oklch(0.63 0.16 122 / 0.6);
  }

  .kj-tension-pin {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 1.1rem;
    height: 1.1rem;
    margin-left: -0.55rem;
    border: 2px solid var(--ink);
    border-radius: 999px;
    background: var(--grass);
    transform: translateY(-50%);
  }

  /* — the strike window — */
  .kj-strike {
    position: absolute;
    top: 42%;
    left: 50%;
    width: min(20rem, calc(100vw - 2rem));
    padding: 1rem 1.25rem 1.1rem;
    border: var(--edge);
    border-radius: 1.1rem;
    background: var(--cream);
    box-shadow: var(--lift);
    text-align: center;
    transform: translate(-50%, -50%);
  }

  .kj-strike[hidden] {
    display: none;
  }

  .kj-strike-title {
    margin: 0 0 0.6rem;
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: -0.01em;
  }

  .kj-strike-bar {
    height: 0.6rem;
    border: 2px solid var(--ink);
    border-radius: 999px;
    background: oklch(0.9 0.03 92);
    overflow: hidden;
  }

  .kj-strike-bar span {
    display: block;
    height: 100%;
    width: 100%;
    background: var(--coral);
  }

  .kj-strike-note {
    margin: 0.55rem 0 0;
    font-size: 0.8rem;
    font-weight: 700;
    color: oklch(0.4 0.03 210);
  }

  /* — the toast — */
  .kj-toast {
    position: absolute;
    left: 50%;
    top: 5.5rem;
    margin: 0;
    padding: 0.55rem 1.1rem;
    border: var(--edge-thin);
    border-radius: 999px;
    background: var(--cream);
    box-shadow: var(--lift);
    font-size: 0.9rem;
    font-weight: 800;
    transform: translateX(-50%);
  }

  .kj-toast[hidden] {
    display: none;
  }

  @media (max-width: 40rem) {
    .kj-panel-conditions {
      width: 12rem;
      font-size: 0.9em;
    }

    .kj-panel-score {
      min-width: 9rem;
    }
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   THE CATCH CARD
   A DOM card. The bass on it is drawn by the same code that draws the
   bass in the lake, so the card always shows the fish you actually
   caught — no stock art, no a different fish from the catalogue.
   ═══════════════════════════════════════════════════════════════════════ */

@layer catch {
  .kj-catch {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgb(7 16 20 / 0.72);
  }

  .kj-catch[hidden] {
    display: none;
  }

  .kj-catch-card {
    width: min(34rem, 100%);
    max-height: calc(100svh - 2rem);
    overflow-y: auto;
    padding: 1.4rem 1.5rem 1.5rem;
    border: var(--edge);
    border-radius: 1.4rem;
    background: var(--cream);
    box-shadow: 0 8px 0 0 var(--ink);
    text-align: center;
  }

  .kj-catch-kicker {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--grass-deep);
  }

  .kj-catch-species {
    margin: 0.3rem 0 0;
    font-size: 1.85rem;
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-weight: 800;
    color: var(--ink);
  }

  .kj-catch-fish {
    display: block;
    width: 100%;
    max-width: 26rem;
    height: auto;
    margin: 0.5rem auto 0;
  }

  .kj-catch-weight {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.4rem;
    margin: 0.2rem 0 0;
    font-size: 2.4rem;
    line-height: 1;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
  }

  .kj-catch-unit {
    font-size: 0.95rem;
    font-weight: 700;
    color: oklch(0.45 0.03 210);
  }

  .kj-catch-facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem 1rem;
    margin: 1.1rem 0 0;
    padding: 0.9rem 0 0;
    border-top: 2px dashed oklch(0.22 0.03 210 / 0.18);
    text-align: left;
  }

  .kj-catch-facts > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.6rem;
  }

  .kj-catch-facts dt {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: oklch(0.48 0.03 210);
  }

  .kj-catch-facts dd {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 700;
    text-align: right;
  }

  .kj-catch-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
    margin-top: 1.25rem;
  }

  .kj-btn {
    padding: 0.7rem 1.15rem;
    border: var(--edge-thin);
    border-radius: 999px;
    background: transparent;
    color: var(--ink);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition:
      background-color 160ms var(--ease),
      transform 160ms var(--ease);
  }

  .kj-btn:hover {
    background: oklch(0.92 0.04 92);
    transform: translateY(-1px);
  }

  .kj-btn:focus-visible {
    outline: 3px solid var(--water);
    outline-offset: 3px;
  }

  /* The saved card is shown in the card itself, because iOS ignores the
     download attribute on a data URL — on a phone, long-press it. */
  .kj-catch-preview {
    margin: 1.1rem 0 0;
    padding-top: 1rem;
    border-top: 2px dashed oklch(0.22 0.03 210 / 0.18);
  }

  .kj-catch-preview[hidden] {
    display: none;
  }

  .kj-catch-preview img {
    display: block;
    width: 100%;
    max-width: 21rem;
    margin: 0 auto;
    border: var(--edge-thin);
    border-radius: 0.7rem;
    box-shadow: 0 3px 0 0 oklch(0.22 0.03 210 / 0.25);
  }

  .kj-catch-note {
    margin: 0.7rem 0 0;
    font-size: 0.74rem;
    font-weight: 700;
    line-height: 1.5;
    color: var(--grass-deep);
    overflow-wrap: anywhere;
  }

  .kj-catch-note[hidden] {
    display: none;
  }

  /* ══ THE RECORD BOOK ═══════════════════════════════════════════════ */
  .kj-record {
    margin-top: clamp(1.5rem, 4vw, 2.25rem);
    padding: 1.2rem 1.3rem 1.3rem;
    border: var(--edge);
    border-radius: 1.2rem;
    background: var(--cream);
    box-shadow: var(--lift);
  }

  .kj-record-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--ink);
  }

  .kj-record-line {
    margin: 0.2rem 0 0.85rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: oklch(0.4 0.03 210);
    font-variant-numeric: tabular-nums;
  }

  .kj-record-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .kj-record-list li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.7rem;
    border: 2px solid oklch(0.22 0.03 210 / 0.16);
    border-radius: 0.75rem;
  }

  .kj-record-fish {
    width: 2.4rem;
    height: 1.15rem;
    flex: 0 0 auto;
  }

  .kj-record-what {
    min-width: 0;
  }

  .kj-record-name {
    display: block;
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--ink);
  }

  .kj-record-meta {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: oklch(0.42 0.03 210);
    font-variant-numeric: tabular-nums;
  }

  .kj-record-empty {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: oklch(0.48 0.03 210);
  }

  .kj-record-empty[hidden] {
    display: none;
  }

  @media (prefers-reduced-motion: no-preference) {
    .kj-catch-card {
      animation: kj-pop 320ms var(--ease) both;
    }
  }
}
