/*
 * The Pictorial Telegram - one stylesheet, no build step. Mobile first, scales up.
 *
 * The design language is lifted deliberately from The Third Space Initiative
 * so the two read as a pair: the same gold-on-deep-green palette, the same
 * Limelight / Cormorant / Poiret One trio, the same double-ruled deco frame,
 * and square corners throughout. Art Deco is angular, so nothing here is
 * rounded except the drawing itself.
 */

:root {
  /* straight from the sister app */
  --gold: #d4af37;
  --gold-light: #f0d98c;
  --gold-dark: #9c7c1e;
  --black: #06130e;
  --charcoal: #0c231a;
  --cream: #f5ecd7;
  --emerald: #1d5c4d;
  --emerald-light: #3aa585;

  /* local roles */
  --ink: var(--cream);
  --muted: #a9b8ab;
  --line: rgba(212, 175, 55, 0.28);
  --bad: #c25b4e;
  /* Warm enough to sit in the palette, light enough that a white highlight
     still reads against it. */
  --paper: #f7efdc;
  --tap: 46px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  /*
   * Kills double-tap-to-zoom, which otherwise fires when you tap two letter
   * tiles in quick succession and leaves the board zoomed and off-centre.
   * `manipulation` keeps panning and pinch-zoom, so this is not the
   * accessibility-hostile user-scalable=no. touch-action does not inherit, so
   * it has to go on everything rather than just the root.
   *
   * The canvas and the colour swatches override this with `none`, since they
   * need raw pointer events.
   */
  touch-action: manipulation;
}

/*
 * The `hidden` attribute is only a UA-stylesheet `display: none`, so any author
 * rule that sets a display beats it. Several things here are flex or grid and
 * were quietly ignoring `hidden` altogether.
 */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background-color: var(--black);
  /* Emerald glow above, gold below, over a fine diagonal lattice. */
  background-image:
    radial-gradient(at 50% -20%, rgba(58, 165, 133, 0.14), transparent 60%),
    radial-gradient(at 50% 120%, rgba(212, 175, 55, 0.08), transparent 55%),
    repeating-linear-gradient(45deg, transparent 0 58px, rgba(212, 175, 55, 0.035) 58px 60px),
    repeating-linear-gradient(-45deg, transparent 0 58px, rgba(58, 165, 133, 0.05) 58px 60px);
  background-attachment: fixed;
  color: var(--ink);
  font: 17px/1.55 'Cormorant Garamond', Georgia, serif;
  overscroll-behavior: none;
}

.app {
  position: relative;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

/* ── the deco frame ───────────────────────────────────────────── */

.deco-frame {
  border: 2px solid var(--gold);
  box-shadow: 0 0 60px rgba(212, 175, 55, 0.1), inset 0 0 40px rgba(0, 0, 0, 0.55);
}
/* the inner hairline that makes it read as double-ruled */
.deco-frame::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(212, 175, 55, 0.45);
  pointer-events: none;
}

.corner {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 0 solid var(--gold);
  pointer-events: none;
}
.corner.tl { top: 12px; left: 12px; border-top-width: 2px; border-left-width: 2px; }
.corner.tr { top: 12px; right: 12px; border-top-width: 2px; border-right-width: 2px; }
.corner.bl { bottom: 12px; left: 12px; border-bottom-width: 2px; border-left-width: 2px; }
.corner.br { bottom: 12px; right: 12px; border-bottom-width: 2px; border-right-width: 2px; }

@media (min-width: 600px) {
  /*
   * The breathing room is body padding rather than a margin on .app. A margin
   * here collapses straight out through the body, which pushed the document
   * 22px taller than the viewport and left every screen with a stub scrollbar.
   */
  body {
    padding: 22px 0;
  }
  .app {
    padding: 34px 30px;
  }
}

/* ── screens ──────────────────────────────────────────────────── */

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  animation: rise 0.22s ease both;
}
.screen[data-active] {
  display: flex;
}
.screen.center {
  /*
   * Every stacked box on a centred screen shares this width. Without it the
   * preview, the scoreboard, the result card and the button all sized
   * themselves independently and the column looked ragged.
   */
  --col: min(100%, 320px);
  align-items: center;
  text-align: center;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .screen {
    animation: none;
  }
}

/* ── type ─────────────────────────────────────────────────────── */

.logo {
  font-family: Limelight, 'Cormorant Garamond', serif;
  font-weight: 400;
  font-size: clamp(30px, 8.5vw, 46px);
  line-height: 1.15;
  margin: 0;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 0 26px rgba(212, 175, 55, 0.28);
}
.logo.small {
  font-size: clamp(22px, 6vw, 30px);
}

.title {
  font-family: Limelight, 'Cormorant Garamond', serif;
  font-weight: 400;
  font-size: clamp(19px, 5vw, 26px);
  margin: 0;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold);
}

.tagline {
  margin: 0;
  font-style: italic;
  font-size: clamp(17px, 4.6vw, 20px);
  color: var(--ink);
}

.muted {
  color: var(--muted);
  margin: 0;
}
.small {
  font-size: 14px;
}
.footnote {
  margin-top: 4px;
  max-width: 36ch;
}

/* The spaced-out gold caps used for labels and asides. */
.smallcaps {
  margin: 0;
  font-size: 12px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--gold-dark);
}

.deco-rule {
  margin: 0;
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 5px;
  opacity: 0.75;
}

/* ── controls ─────────────────────────────────────────────────── */

.btn {
  font-family: 'Poiret One', 'Cormorant Garamond', serif;
  font-size: 15px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--gold);
  background: transparent;
  border: 1px solid var(--gold-dark);
  border-radius: 0;
  min-height: var(--tap);
  padding: 0 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  text-decoration: none;
  user-select: none;
}
.btn:active {
  transform: scale(0.98);
}
.btn:focus-visible {
  outline: 1px solid var(--gold-light);
  outline-offset: 3px;
}
.btn[disabled] {
  opacity: 0.35;
  pointer-events: none;
}

.btn.primary {
  background: linear-gradient(var(--gold-light), var(--gold) 45%, var(--gold-dark));
  border-color: transparent;
  color: var(--black);
  box-shadow: 0 4px 18px rgba(212, 175, 55, 0.35);
}
.btn.big {
  min-height: 52px;
  font-size: 17px;
  width: var(--col, min(100%, 320px));
}
.btn.wide {
  width: 100%;
}
.btn.ghost {
  background: transparent;
}
.btn.chip {
  min-height: 40px;
  padding: 0 13px;
  font-size: 12px;
  letter-spacing: 2px;
  border-color: var(--line);
}
.btn.chip small {
  color: var(--gold-dark);
  letter-spacing: 1px;
}
.btn.chip[aria-pressed='true'] {
  background: rgba(212, 175, 55, 0.16);
  border-color: var(--gold);
  color: var(--gold-light);
}
.btn.subtle {
  color: var(--muted);
  border-color: rgba(245, 236, 215, 0.16);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-align: left;
  width: var(--col, min(100%, 320px));
}
.field span {
  font-size: 11px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--gold-dark);
}

input[type='text'],
textarea {
  font-family: 'Cormorant Garamond', Georgia, serif;
  color: var(--ink);
  background: rgba(212, 175, 55, 0.05);
  border: 1px solid var(--gold-dark);
  border-radius: 0;
  min-height: var(--tap);
  padding: 10px 14px;
  width: 100%;
  /* 16px minimum stops iOS Safari zooming the page on focus */
  font-size: 16px;
}
input[type='text']:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.09);
}
textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  word-break: break-all;
}

/* ── bars, pills, scores ──────────────────────────────────────── */

.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.pill {
  background: rgba(212, 175, 55, 0.05);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 7px 14px;
  font-size: 14px;
  letter-spacing: 1px;
}
.pill b {
  color: var(--gold-light);
  font-weight: 600;
}
/* This number is a clock, not a score, and it falls while you think. Saying so
   costs one line and stops the drain being a nasty surprise. */
.pill.points {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 5px 14px;
  min-width: 62px;
  text-align: center;
}
.pill.points b {
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  font-size: 19px;
  font-weight: 400;
  line-height: 1;
}
.pill.points small {
  font-size: 8px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--gold-dark);
  line-height: 1;
}
/* Down to the last couple of points, stop being subtle about it. */
.pill.points.low b {
  color: var(--bad);
}
.pill.points.low {
  border-color: var(--bad);
}

.scoreboard {
  display: flex;
  gap: 12px;
  justify-content: center;
  width: var(--col, auto);
}
.score {
  background: rgba(212, 175, 55, 0.04);
  border: 1px solid var(--gold-dark);
  border-radius: 0;
  padding: 10px 20px;
  flex: 1; /* two equal halves of the column */
  min-width: 0;
}
.score b {
  display: block;
  font-family: Limelight, serif;
  font-weight: 400;
  font-size: 26px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.score span {
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
}
.score.lead {
  border-color: var(--gold);
  box-shadow: 0 0 22px rgba(212, 175, 55, 0.15);
}

/*
 * The report on the last round is retrospective, so it sits under the turn in
 * front of you rather than competing with it. Separated by a hairline and set
 * quieter than everything above it.
 */
.aside {
  width: var(--col);
  margin-top: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.prev-line {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
}
.prev-line b {
  color: var(--gold-light);
  font-weight: 600;
}
/* The verdict is a deco mark, not a colour-emoji tick fighting the palette. */
.prev-line .mark {
  color: var(--emerald-light);
  margin-right: 6px;
}
.prev-line.miss .mark {
  color: var(--bad);
}

/* Typing the note should already feel like a telegram. */
input[data-el='share-note'] {
  font-family: 'Poiret One', 'Cormorant Garamond', serif;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* Quiet, but present at every resting point in the loop: after you send,
   before you begin, and when a round closes. Home alone is not enough,
   because once you have a name you never see it again. */
.archive-link {
  align-self: center;
  color: var(--gold-dark);
  border-color: transparent;
}
.archive-link:hover {
  color: var(--gold);
  border-color: var(--line);
}

/* A turn only moves forward on its own, and it lives entirely in memory, so
   every step needs a way back that is not a page reload. Kept quiet, so it
   never competes with the thing you are meant to press. */
/* .btn.chip sets a border, so this has to out-specify it or the "quiet" part
   never lands. */
.btn.back-link {
  align-self: center;
  color: var(--muted);
  border-color: transparent;
}
.btn.back-link:hover {
  color: var(--gold);
  border-color: var(--line);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

/* ── the archive ──────────────────────────────────────────────── */

/* The plates carry their owner in the label colour. A shelf of two does not
   need explaining; a shelf of sixty does. */
.key {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 0;
  font-size: 10px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}
.key span::before {
  content: '\25a0';
  margin-right: 5px;
}
.key-mine {
  color: var(--gold-dark);
}
.key-theirs {
  color: var(--emerald-light);
}


.gallery {
  width: var(--col);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.plate {
  /* Grid items default to min-width:auto, so a long nowrap label like
     "cow in wellies" widens its whole column. Let it ellipsise instead. */
  min-width: 0;
  padding: 0;
  border: 1px solid var(--gold-dark);
  background: rgba(212, 175, 55, 0.05);
  cursor: pointer;
  display: block;
  transition: border-color 0.15s ease;
}
.plate:hover,
.plate:focus-visible {
  border-color: var(--gold);
  outline: none;
}
.plate canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  background: var(--paper);
}
.plate .label {
  display: block;
  padding: 5px 4px 6px;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gold-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Theirs is marked, so the shelf reads as a conversation rather than a pile. */
.plate.theirs .label {
  color: var(--emerald-light);
}

/* One short line from the sender, in the telegram voice. */
.telegram {
  margin: 0;
  width: var(--col);
  padding: 11px 14px;
  border: 0;
  border-top: 1px solid var(--gold-dark);
  border-bottom: 1px solid var(--gold-dark);
  background: rgba(212, 175, 55, 0.04);
  font-family: 'Poiret One', 'Cormorant Garamond', serif;
  font-size: 15px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold-light);
}

/* ── canvas ───────────────────────────────────────────────────── */

/*
 * The canvas is square, so its width is also its height - size it against
 * whatever vertical room the screen's controls leave over, or the page
 * scrolls and the primary button falls off the bottom.
 */
.screen {
  --chrome: 330px;
}
[data-screen='draw'] {
  --chrome: 420px; /* palette wraps to two rows on narrow screens */
}
@media (min-width: 470px) {
  [data-screen='draw'] {
    --chrome: 360px;
  }
}
[data-screen='guess'],
[data-screen='watch'] {
  --chrome: 370px; /* slots + tile tray + controls */
}

.stage {
  position: relative;
  width: min(100%, max(190px, calc(100dvh - var(--chrome))));
  margin-inline: auto;
  /* the gold mount the drawing sits in */
  padding: 5px;
  border: 1px solid var(--gold-dark);
  background: rgba(212, 175, 55, 0.06);
}
.stage.small {
  width: var(--col, min(100%, 240px));
}

/* A recording, not a keyboard: flat, dimmed, and visibly not pressable. */
[data-screen='watch'] .slot,
[data-screen='watch'] .tile {
  cursor: default;
  box-shadow: none;
}
[data-screen='watch'] .tile {
  background: rgba(212, 175, 55, 0.13);
  border-color: var(--gold-dark);
  color: var(--gold-dark);
}
[data-screen='watch'] .tile.spent {
  opacity: 0.3;
}

/* Preview canvases are for looking at, not drawing on. */
.paper.still {
  cursor: default;
}
.stage.small .paper {
  cursor: default;
}

.paper {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  /* Stops a stray drag off the canvas from selecting the page text */
  user-select: none;
  -webkit-user-select: none;
  background: var(--paper);
  box-shadow: 0 10px 34px -14px #000;
  /* critical on mobile: stop the browser scrolling/zooming mid-stroke */
  touch-action: none;
  cursor: crosshair;
}

.progress {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  height: 3px;
  background: rgba(6, 19, 14, 0.15);
  overflow: hidden;
}
.progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--gold-dark);
}

/* ── palette ──────────────────────────────────────────────────── */

.palette-wrap {
  position: relative;
}
.palette {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  justify-items: center;
  gap: 6px;
}
.swatch,
.shade {
  aspect-ratio: 1;
  width: 100%;
  max-width: 38px;
  min-width: 24px;
  border-radius: 0;
  border: 1px solid rgba(6, 19, 14, 0.5);
  outline: 1px solid transparent;
  outline-offset: 2px;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s ease, outline-color 0.1s ease;
  /* A long press here means "show me the shades", not "select this" or
     "open the OS callout". */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.swatch[aria-pressed='true'] {
  outline-color: var(--gold);
  transform: scale(1.1);
}

/* The ramp, floating above the swatch it belongs to. */
.shades {
  position: absolute;
  bottom: calc(100% + 12px);
  display: flex;
  gap: 6px;
  padding: 9px;
  background: var(--charcoal);
  border: 1px solid var(--gold);
  box-shadow: 0 12px 30px -8px #000d;
  z-index: 5;
  animation: rise 0.13s ease both;
}
.shades::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -6px;
  border: 6px solid transparent;
  border-top-color: var(--gold);
}
.shade {
  width: 36px;
  max-width: 36px;
}
.shade[aria-pressed='true'] {
  outline-color: var(--gold);
}

/* Only a container on desktop, where it becomes the column beside the canvas.
   Everywhere else it has to vanish so its children stay in the page stack. */
.rail {
  display: contents;
}

.tools {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.tools.centered {
  justify-content: center;
}

/*
 * On a centred screen everything in the stack shares the column, including
 * secondary buttons and the caption row above the replay. Chips are the one
 * exception: they are a control cluster, not a row in the stack.
 */
.screen.center .btn:not(.chip) {
  width: var(--col);
}
.screen.center .tools.centered {
  width: var(--col);
  justify-content: space-between;
}
.widths {
  display: flex;
  gap: 6px;
  margin-right: auto;
}
.width-btn {
  width: 40px;
  height: 40px;
  background: rgba(212, 175, 55, 0.05);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.width-btn i {
  display: block;
  border-radius: 50%;
  background: var(--gold);
}
.width-btn[aria-pressed='true'] {
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.16);
}

/* ── guess: slots you fill from a tray of tiles ───────────────── */

.slots,
.tray {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px;
}

.slots {
  min-height: 40px;
  align-items: flex-end;
  gap: 6px 16px; /* wider between words than between letters */
}
/*
 * A word is one unbreakable run of slots, which is right until the run is
 * wider than what holds it: "toothbrush" is ten tiles, and neither a 375px
 * phone nor the desktop rail can show that on one line. It wraps as a last
 * resort, and the 16px gap between words still keeps the grouping readable.
 */
.word {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
}
.sep {
  align-self: center;
  color: var(--gold-dark);
  font-size: 18px;
}
.slots.wrong {
  animation: shake 0.34s ease;
}
@keyframes shake {
  20% {
    transform: translateX(-8px);
  }
  60% {
    transform: translateX(8px);
  }
  85% {
    transform: translateX(-3px);
  }
}

/* Sized off the longest word we ship, so a phrase still fits a phone
   without the tiles turning into confetti. */
.slot,
.tile {
  font-family: 'Poiret One', 'Cormorant Garamond', serif;
  font-size: clamp(14px, 4.2vw, 19px);
  line-height: 1;
  display: grid;
  place-items: center;
  border-radius: 0;
  padding: 0;
  border: 1px solid transparent;
  width: clamp(24px, 8vw, 38px);
  height: clamp(32px, 9.6vw, 44px);
}

.slot {
  background: rgba(212, 175, 55, 0.05);
  border-color: var(--line);
  border-bottom: 2px solid var(--gold-dark);
  color: var(--ink);
  cursor: default;
}
.slot.filled {
  background: rgba(212, 175, 55, 0.1);
  border-color: var(--gold-dark);
  border-bottom-color: var(--gold);
  cursor: pointer;
}
.slot.locked {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--gold);
  color: var(--gold-light);
  cursor: not-allowed;
}

.tile {
  background: linear-gradient(var(--gold-light), var(--gold) 55%, var(--gold-dark));
  border-color: var(--gold-dark);
  color: var(--black);
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(6, 19, 14, 0.7);
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.tile:active {
  transform: translateY(2px);
  box-shadow: none;
}
.tile.spent {
  opacity: 0.16;
  box-shadow: none;
  cursor: default;
}
.slot:focus-visible,
.tile:focus-visible {
  outline: 1px solid var(--gold-light);
  outline-offset: 2px;
}
/*
 * On a desktop the whole app was a 560px phone column with a 484px canvas and
 * several hundred pixels of empty green either side, which is a poor place to
 * draw with a mouse. The centred screens keep their narrow column - a
 * scoreboard does not improve by getting wider - but the ones built around a
 * canvas take the room.
 */
@media (min-width: 860px) and (min-height: 700px) {
  .app:has([data-screen='draw'][data-active]),
  .app:has([data-screen='guess'][data-active]),
  .app:has([data-screen='watch'][data-active]) {
    /* The deco frame lives on .app, so it needs room to sit inside the
       viewport rather than butting against both edges. */
    max-width: min(1240px, 100vw - 64px);
  }

  /*
   * Simply widening the column bought almost nothing: the canvas is bound by
   * height, not width, and the palette, tools and buttons stacked underneath
   * ate 500px of it. Put that stack in a rail beside the canvas instead and
   * the only things left above and below are the bar and nothing.
   */
  /* [data-active] is load-bearing: .screen is display:none until it is the one
     being shown, and an unqualified display:grid here shows all three at once. */
  [data-screen='draw'][data-active],
  [data-screen='guess'][data-active],
  [data-screen='watch'][data-active] {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    /* Both rows size to content so align-content can centre the pair. A 1fr
       second row would swallow the slack and pin the canvas to the top. */
    grid-template-rows: auto auto;
    align-content: center;
    justify-content: center;
    column-gap: 26px;
    --chrome: 180px;
  }
  [data-screen='draw'][data-active] .bar,
  [data-screen='guess'][data-active] .bar,
  [data-screen='watch'][data-active] .bar {
    grid-column: 1 / -1;
  }
  [data-screen='draw'][data-active] .stage,
  [data-screen='guess'][data-active] .stage,
  [data-screen='watch'][data-active] .stage {
    grid-row: 2;
    align-self: start;
  }

  /* Everything that was under the canvas becomes the rail to its right. */
  .rail {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 14px;
    min-width: 0;
  }
  .rail .tools {
    justify-content: flex-start;
  }
  /* The rail is narrower than the phone the tiles were sized for, so they keep
     their clamp rather than growing into it. */
  .rail .slots,
  .rail .tray {
    width: 100%;
  }
}

@media (hover: hover) and (pointer: fine) {
  .tile:not(.spent):hover {
    filter: brightness(1.12);
  }
}

/* The result mark. Deliberately the same star and cross the prev-line uses, so
   a win and a miss read the same wherever they appear. */
.verdict {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 46px;
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 0 30px rgba(212, 175, 55, 0.45);
}
.verdict.miss {
  color: var(--bad);
  text-shadow: none;
  opacity: 0.75;
}

/* Retired the first time they open a ramp, so it is a nudge and not furniture. */
.hint {
  margin: -2px 0 0;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gold-dark);
  text-align: center;
}

/* ── word choice ──────────────────────────────────────────────── */

/* Not a fourth subject. It shuffles the three above it, so it is a chip: sized
   to its own text and weighted like a control rather than a card.
   (.screen.center .btn:not(.chip) is what stretches everything else to --col,
   which is the other half of why this has to be a chip.) */
[data-el='choose-shuffle'] {
  align-self: center;
  margin-top: 2px;
  padding: 0 18px;
  color: var(--gold-dark);
}
[data-el='choose-shuffle']:hover {
  color: var(--gold);
  border-color: var(--gold-dark);
}


.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: var(--col, min(100%, 340px));
}
.choice {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: rgba(212, 175, 55, 0.04);
  border: 1px solid var(--gold-dark);
  min-height: 60px;
  padding: 12px 18px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  color: var(--ink);
  cursor: pointer;
  /* The screen is centred, but these read as a left-aligned list. Without this
     a word long enough to wrap inherits the centring and its lines sit in the
     middle while short words sit flush left. */
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.08s ease;
}
.choice:active {
  transform: scale(0.985);
}
.choice:hover {
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.09);
}
.choice b {
  font-size: 20px;
  font-weight: 600;
  color: var(--gold-light);
  /* Take the leftover space and wrap inside it, rather than overflow the row
     and shove the tier badge off the edge. */
  flex: 1;
  min-width: 0;
}
.choice span {
  font-size: 10px;
  color: var(--gold-dark);
  text-transform: uppercase;
  letter-spacing: 3px;
  text-align: right;
  flex-shrink: 0; /* the tier badge never wraps or gets crushed */
}

/* An honorific earned by a run of solves. */
.honorific {
  display: block;
  margin-top: 3px;
  font-family: 'Poiret One', 'Cormorant Garamond', serif;
  font-style: normal;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--emerald-light);
}

.link-box {
  width: var(--col, min(100%, 400px));
  text-align: left;
}
.link-box summary {
  cursor: pointer;
  color: var(--gold-dark);
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  padding: 8px 0;
  text-align: center;
}

/* ── misc ─────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--charcoal);
  border: 1px solid var(--gold);
  color: var(--ink);
  font-size: 14px;
  padding: 11px 22px;
  z-index: 9;
  max-width: calc(100vw - 40px);
  text-align: center;
  animation: rise 0.2s ease both;
}

.spinner {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

/* ── desktop ──────────────────────────────────────────────────── */

@media (hover: hover) and (pointer: fine) {
  :root {
    --tap: 42px;
  }
  .swatch:hover {
    transform: scale(1.08);
  }
  .btn:hover {
    border-color: var(--gold);
    color: var(--gold-light);
  }
  .btn.primary:hover {
    filter: brightness(1.06);
    color: var(--black);
  }
}

/* The result screen carries a replay now, so it is the tallest thing here. */
@media (max-height: 720px) {
  .screen.center {
    --col: min(100%, 240px);
  }
  [data-screen='outcome'] .verdict {
    font-size: 34px;
  }
}

/* Very short viewports: trim the padding the canvas is competing with. */
@media (max-height: 560px) {
  .screen {
    gap: 10px;
  }
  .deco-rule,
  .smallcaps {
    display: none;
  }
}
