/* Earth’s Last Light -- the field, the strip beside it, and the spray buttons.

   Everything that is not specific to this game (the bars, the buttons, the
   readout, the stage, the dialogs) is in css/games/arcade.css, and the screens
   are css/games/screens.css. The layout below is Knock Down's, for the same
   reasons, and knockDown.css says them at length: the page is exactly the
   window, the canvas is the field's own shape and not the room it sits in, and
   the numbers live in a rail beside the board (a line over it on a phone). */

.ll-page .Master {
  height: 100dvh;
}

.ll-play {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.ll-stage {
  flex: 1;
  min-width: 0;
  border-color: transparent;
  background: none;
}

/* The whole stage takes the pointer, so a thumb in the room above or below the
   board steers as well as one on it, and none of it scrolls the page. */
.ll-stage { touch-action: none; }

/* The field is 360 by 520 units: eighteen by twenty-six. */
.ll-stage > canvas {
  position: absolute;
  top: 0;
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translateX(-50%);
  width: auto;
  height: 100%;
  max-width: 100%;
  aspect-ratio: 18 / 26;
  border: 1px solid var(--rule-strong);
  border-radius: 12px;
  background: #02030a;
  /* A finger on the field slides the ship; it must not scroll the page. */
  touch-action: none;
  cursor: crosshair;
}

.ll-side {
  flex: 0 0 12.5rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
  overflow-y: auto;
}

.ll-side__title {
  margin: 8px 0 0;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.ll-side__level {
  margin: 2px 0 6px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
}

.ll-side__hint {
  margin: 10px 0 0;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--ink-muted);
}

/* The numbers are a column in the rail. */
.ll-side .ar-readout {
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 0;
  margin-bottom: 2px;
}

.ll-side .ar-readout__item {
  justify-content: space-between;
  width: 100%;
}

.ll-coins {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--rule);
}

.ll-coins b { color: var(--warn); }

/* Narrow: the rail lies down over the board, and the hints go. */
@media (max-width: 720px) {
  .ll-play { flex-direction: column-reverse; }

  .ll-side {
    flex: 0 0 auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    overflow: visible;
  }

  .ll-side__title,
  .ll-side__level { margin: 0; }
  .ll-side__hint { display: none; }

  .ll-side .ar-readout {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 2px 12px;
  }

  .ll-side .ar-readout__item { width: auto; }

  .ll-coins {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }
}

@media (max-height: 560px) {
  .ll-side__hint { display: none; }
  .ll-side { flex-basis: 10rem; }
}


/* ======================================================================
   HANDHELD MODE
   ====================================================================== */

/* Out of the way while a screen before play is up. */
.hh-app:has(.ar-screen:not([hidden])) .ll-side { display: none; }

/* A phone: the numbers are one line, and the wave's name is on its card. */
@media (pointer: coarse) and (max-width: 720px) {
  .hh-app .ll-side {
    padding: 4px 6px;
    gap: 4px 10px;
  }

  .hh-app .ll-side__title,
  .hh-app .ll-side__level,
  .hh-app .ll-coins { display: none; }

  .hh-app .ll-side .ar-readout { width: 100%; }
  .hh-app .ll-side .ar-readout__item { width: auto; }
}

/* The board as wide as the stage or three-quarters... of its height allows,
   whichever is less: see the long note at the foot of knockDown.css. The
   shape here is 18 by 26, so the width is 18/26 of the height. */
.hh-app .ll-stage { container-type: size; }

.hh-app .ll-stage > canvas {
  top: 50%;
  width: min(100cqw, 69.2cqh);
  height: auto;
  max-width: none;
  transform: translate(-50%, -50%);
}


/* ----------------------------------------------------- the spray buttons */

/* Part of the dock when the wave has more than one spray. */
.hh-dock .ll-sprays:not([hidden]) { display: contents; }

/* Each button wears its colour and its shape on a round chip, drawn by
   main.js, with the word under it like every other dock button. */
.ll-sprays button {
  position: relative;
}

.ll-chip {
  width: 28px;
  height: 28px;
  display: block;
}

/* The loaded one: a heavy ring in the accent, and the word in it. */
.ll-sprays button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent);
}

/* The number key, small in the corner, for the people with a keyboard. */
.ll-key {
  position: absolute;
  top: 3px;
  left: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ink-faint);
}

@media (pointer: coarse) {
  .ll-key { display: none; }
}

/* Under a finger the buttons are played like keys (main.js, "fingers on the
   buttons"): held down, two at once with the thumb on the board. So nothing
   the browser does with a held touch may happen on them: no scroll or zoom
   (MDN: touch-action), no text picked up, no long-press menu. */
.ll-sprays button {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* A tablet held sideways is held by its edges, and the row under the board is
   then out of both thumbs' reach. So there the colour buttons leave the dock
   and stand in a column down the LEFT edge, under the left thumb, bigger; the
   right thumb slides the ship from the strip of numbers on the right (main.js
   lets a finger steer from there). Menu stays under the board.

   The room for the column is the space beside the board: the board is as wide
   as its height allows and centred, and a sideways tablet has more than a
   button's width left over on each side of it. A sideways PHONE never gets
   here: the game is played upright on one (the "turn your phone" card). */
@media (pointer: coarse) and (orientation: landscape) and (min-width: 800px) {
  .ll-play { position: relative; }

  .hh-dock .ll-sprays:not([hidden]) {
    position: absolute;
    left: max(8px, env(safe-area-inset-left));
    bottom: 12%;
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .hh-dock .ll-sprays button {
    flex: none;
    width: 6rem;
    min-height: 5rem;
  }

  .hh-dock .ll-sprays .ll-chip {
    width: 36px;
    height: 36px;
  }

  /* A sideways slide on the strip steers; up and down still scrolls it. */
  .ll-side { touch-action: pan-y; }
}

/* On glass, hover sticks to the last button touched and made it look half
   chosen beside the one that is loaded. Only the loaded one is lit there. */
@media (hover: none) {
  .hh-dock .ll-sprays button:hover:not([aria-pressed="true"]) {
    border-color: var(--rule-strong);
    background: var(--surface);
  }
}

/* Held down and firing. */
.ll-sprays button.is-held {
  transform: scale(0.94);
  box-shadow: 0 0 0 3px var(--accent), 0 0 14px var(--accent);
}


/* ======================================================================
   THE WINDING MAP (map.js)

   Wave 1 at the bottom, the path climbing up through five regions of Earth.
   The stops are absolutely placed on a tall box whose height map.js sets; the
   page that holds it (the handheld screen) scrolls it, opened on the next stop.
   ====================================================================== */

.ll-map__summary {
  margin: 0 0 8px;
  text-align: center;
  font-weight: 700;
  color: var(--accent);
}

.ll-map {
  position: relative;
  width: 100%;
  margin: 10px 0 6px;
  border-radius: 16px;
  overflow: hidden;
  isolation: isolate;
}

.ll-map__region {
  position: absolute;
  left: 0;
  right: 0;
  overflow: hidden;
}

.ll-map__scenery {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* The region's name, at the top of its stretch of path. */
.ll-map__title {
  position: absolute;
  left: 0;
  right: 0;
  top: 8px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 0 12px;
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.ll-map__title b { font-size: 1.05rem; letter-spacing: 0.04em; text-transform: uppercase; }
.ll-map__title span { font-size: 0.78rem; opacity: 0.92; }

.ll-map__route {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.ll-map__path { stroke-linecap: round; }

.ll-map__path--all {
  stroke: rgba(255, 255, 255, 0.5);
  stroke-width: 5;
  stroke-dasharray: 2 9;
}

.ll-map__path--open {
  stroke: #fff;
  stroke-width: 7;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}

.ll-map__stop {
  position: absolute;
  z-index: 3;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  padding: 0;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #5b8f3a;
  color: #fff;
  font: inherit;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
  touch-action: manipulation;
}

.ll-map__stop.is-boss {
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  background: #b0302a;
  border-color: #ffd34d;
}

.ll-map__stop.is-done { background: #d49a1c; }
.ll-map__stop.is-done.is-boss { background: #b0302a; }

.ll-map__stop.is-locked {
  background: #8a8f98;
  border-color: rgba(255, 255, 255, 0.55);
  box-shadow: none;
  cursor: default;
  opacity: 0.85;
}

.ll-map__stop.is-next {
  background: #e0453a;
  animation: ll-pulse 1.2s ease-in-out infinite;
}

.ll-map__stop.is-next.is-boss { background: #b0302a; }

@keyframes ll-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4), 0 0 0 0 rgba(255, 255, 255, 0.7); }
  50% { transform: scale(1.1); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4), 0 0 0 10px rgba(255, 255, 255, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .ll-map__stop.is-next { animation: none; }
}

.ll-map__num { display: block; font-size: 1.05rem; line-height: 1; }

.ll-map__stars {
  position: absolute;
  left: 50%;
  bottom: -15px;
  transform: translateX(-50%);
  display: flex;
  gap: 0;
  font-size: 0.78rem;
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.ll-map__stars i { font-style: normal; color: rgba(255, 255, 255, 0.45); }
.ll-map__stars i.on { color: #ffd34d; }

.ll-map__name {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  max-width: 7.5rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.ll-map__name.is-right { left: calc(100% + 6px); }
.ll-map__name.is-left { right: calc(100% + 6px); }

.ll-map__end {
  position: absolute;
  left: 50%;
  z-index: 2;
  transform: translateX(-50%);
  padding: 3px 12px;
  border-radius: 999px;
  background: #ffd34d;
  color: #3a1d00;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ======================================================================
   COLOUR CHANGE, THE RAINBOW SHOT, AND THE STORE
   ====================================================================== */

/* Ship shield row in the readout: only there while one is carried. */
.ll-side .ar-readout__item[hidden] { display: none; }

/* The count on the rainbow button: how many shots are left. */
.ll-count {
  position: absolute;
  top: 2px;
  right: 6px;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--accent);
}

/* The store's door on the map and the card: a quiet pill, not a second Start. */
.ar-extra.ll-store-link {
  display: block;
  margin: 12px auto 10px;
  padding: 7px 16px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.ar-extra.ll-store-link:hover { border-color: var(--accent); background: var(--accent-soft); }

.ll-shop__purse {
  margin: 0 0 12px;
  text-align: center;
  font-size: 1.05rem;
}

.ll-shop__purse b { color: var(--warn); }

.ll-shop__item {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 0 10px;
  padding: 12px;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--surface);
}

.ar-stage .ll-shop__icon {
  /* arcade.css pins every canvas in a stage to all four sides; this one is an
     icon in a list, inside the stage only because the screens are. */
  position: static;
  inset: auto;
  transform: none;
  width: 44px;
  height: 44px;
  max-width: none;
  aspect-ratio: auto;
  flex: none;
}

.ll-shop__words { flex: 1 1 12rem; min-width: 0; }
.ll-shop__words h3 { margin: 0 0 2px; font-size: 1.02rem; }
.ll-shop__text { margin: 0 0 4px; font-size: 0.86rem; line-height: 1.4; color: var(--ink-muted); }
.ll-shop__owned { margin: 0; font-size: 0.82rem; font-weight: 700; color: var(--ink-faint); }

.ll-shop__buy { display: flex; gap: 8px; flex-wrap: wrap; }

.ll-shop__buy button {
  padding: 9px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.ll-shop__buy button:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.ll-shop__buy button:disabled { opacity: 0.45; cursor: default; }

.ll-shop__note {
  margin: 8px 0 0;
  text-align: center;
  font-size: 0.82rem;
  color: var(--ink-faint);
}

/* The opening story. */
.ll-intro__art { display: block; width: auto; max-width: 100%; max-height: 46vh; margin: 0 auto 10px; border-radius: 14px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); }
.ll-intro__title { margin: 6px 0 8px; text-align: center; font-size: 1.2rem; line-height: 1.25; }
.ll-intro__text { margin: 0 0 8px; text-align: center; line-height: 1.45; color: var(--ink-muted); }
.ll-intro__tip { margin: 0 0 14px; text-align: center; font-weight: 800; color: #F5A623; }
.ll-intro__hope { margin: 12px 0 14px; text-align: center; font-size: 1.1rem; font-weight: 800; color: var(--accent); }
.ar-screen .ll-intro__go { display: block; margin: 0 auto; min-width: 12rem; }

/* The shipyards, beside the path. */
.ar-screen .ll-map__yard {
  position: absolute;
  z-index: 3;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 2px solid #fff;
  border-radius: 12px;
  background: #3A4A63;
  color: #fff;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

.ar-screen .ll-map__yard.is-locked { background: #8a8f98; opacity: 0.8; cursor: default; box-shadow: none; }

.ll-yard__head { margin: 14px 0 6px; font-size: 0.82rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); }

.ll-shop__item.is-flying { border-color: var(--accent); }

.ll-ship__swatch { flex: none; width: 40px; height: 40px; border-radius: 12px; border: 2px solid var(--rule-strong); }

/* screens.css rounds every button in a screen; the stops are round. */
.ar-screen .ll-map__stop {
  border-radius: 50%;
  line-height: 1;
  font-weight: 800;
}
.ar-screen .ll-map__stop.is-locked .ll-map__num { color: rgba(255, 255, 255, 0.7); }


/* ======================================================================
   THE CITIES REPORT (cities.js): the end of the ladder, and a button on the map
   ====================================================================== */

.ll-end__title { margin: 4px 0 2px; text-align: center; font-size: 1.4rem; }
.ll-end__sub { margin: 0 0 12px; text-align: center; color: var(--ink-muted); }

.ll-end__big { display: flex; gap: 12px; margin-bottom: 14px; }

.ll-end__num {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  border-radius: 14px;
  border: 2px solid var(--rule);
  background: var(--surface);
}

.ll-end__num b { font-size: 2.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ll-end__num span { font-size: 0.85rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.ll-end__num.is-saved { border-color: #4ea860; } .ll-end__num.is-saved b { color: #2f8a45; }
.ll-end__num.is-lost { border-color: #d0584a; } .ll-end__num.is-lost b { color: #b23a2c; }

.ll-end__regions { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.ll-end__region { display: grid; grid-template-columns: 8.5rem 1fr; gap: 2px 10px; align-items: center; font-size: 0.86rem; }
.ll-end__region small { grid-column: 2; color: var(--ink-faint); }
.ll-end__bar { display: block; height: 8px; border-radius: 4px; background: #d0584a55; overflow: hidden; }
.ll-end__bar i { display: block; height: 100%; background: #4ea860; }

.ll-end__tiles { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 10px; }
.ll-end__tile { width: 14px; height: 14px; border-radius: 3px; background: #8a8f98; }
.ll-end__tile.is-saved { background: #4ea860; }
.ll-end__tile.is-lost { background: #d0584a; }
.ll-end__tile.is-none { background: var(--rule); }

/* The line about a wave, under its name on the card. */
.ar-card__note { max-width: 30rem; margin: 0 auto 10px; text-align: center; line-height: 1.45; color: var(--ink-muted); }

.ll-intro__skip { display: flex; justify-content: center; align-items: center; gap: 6px; margin: 12px 0 0; font-size: 0.84rem; color: var(--ink-muted); cursor: pointer; }

/* The cut scene between planets. */
.ll-cut__art { display: block; width: 100%; max-width: 420px; height: auto; margin: 0 auto 10px; border-radius: 14px; }

/* Difficulty: four buttons across the top of the map, and a line about the one chosen. */
.ll-diff { margin: 0 auto 10px; text-align: center; }
.ll-diff__row { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.ar-screen .ll-diff__btn {
  padding: 6px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.ar-screen .ll-diff__btn:hover { border-color: var(--accent); }
.ar-screen .ll-diff__btn.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.ll-diff__blurb { max-width: 30rem; margin: 8px auto 0; font-size: 0.82rem; line-height: 1.4; color: var(--ink-muted); }

/* The first-time question: how do you want to play? */
.ll-diff__ask { margin: 4px 0 2px; text-align: center; font-size: 1.15rem; font-weight: 700; color: var(--ink); }
.ar-screen .ll-diffcard {
  display: block;
  width: 100%;
  max-width: 28rem;
  margin: 8px auto;
  padding: 12px 16px;
  border: 1px solid var(--rule-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ar-screen .ll-diffcard b { display: block; font-size: 1rem; }
.ar-screen .ll-diffcard span { display: block; margin-top: 3px; font-size: 0.82rem; line-height: 1.4; color: var(--ink-muted); }
.ar-screen .ll-diffcard:hover, .ar-screen .ll-diffcard:focus-visible { border-color: var(--accent); }
.ar-screen .ll-diffcard.is-default { border-color: var(--accent); background: var(--accent-soft); }
.ar-screen .ll-diffcard.is-current { border-color: var(--accent); background: var(--accent-soft); }

/* Under the story on the opening screen: the difficulty, and a way to change it. */
.ar-screen .ll-intro__diff {
  display: block;
  margin: 10px auto 0;
  padding: 7px 16px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.ar-screen .ll-intro__diff:hover { border-color: var(--accent); background: var(--accent-soft); }

/* The receipt: a till roll of every wave played and every purchase, newest at the bottom. */
.ll-receipt {
  list-style: none;
  max-width: 34rem;
  margin: 10px auto;
  padding: 10px 12px;
  border: 1px dashed var(--rule-strong);
  border-radius: 8px;
  background: var(--surface);
  font: 0.8rem/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--ink);
  max-height: 55vh;
  overflow-y: auto;
}
.ll-receipt li { padding: 2px 0; border-bottom: 1px dotted var(--rule); }
.ll-receipt li:last-child { border-bottom: 0; }
.ll-receipt__buy { padding-left: 1.4em !important; color: var(--ink-muted); }
.ll-receipt__lost { color: var(--ink-muted); }
