/* Lexicon - the whole look.
 *
 * The palette is the Windows build's Palette.xaml, key for key: warm ink rather than cold blue,
 * and cream cards with dark letters, because that is what a letter tile has looked like for
 * seventy years and the eye already knows how to read it.
 *
 * Motion rules, same as the desktop games: transforms and opacity only, nothing loops, every
 * animation bounded. --t is the one duration; the motion setting scales it, and
 * prefers-reduced-motion zeroes it.
 *
 * Sizes. Designed for the itch.io embed at 1180 x 900, and for a phone held upright at 390 x 844,
 * 390 x 664 and 360 x 640. The letter tiles are sized by view/table.js from the room there
 * actually is (--tile, --tray-tile); everything else is fixed, so the whole table is on screen at
 * once and nothing scrolls sideways. */

:root {
  --t: 180ms;
  /* Springs, for the moments something lands. --spring overshoots about 9% and settles back, the
     way a tile set down on a table has weight; --spring-soft overshoots about 3%, for a panel
     arriving. Both are a damped spring with a push at the start, sampled into linear() so they move
     from the first frame instead of easing in. A spring needs longer than a curve to say anything,
     so --t-spring is three beats - and still nothing when Motion is Instant or the device asks for
     less motion. Browsers before linear() get the nearest cubic-bezier. Same values in every game
     in the family. */
  --spring: cubic-bezier(.3, 1.35, .5, 1);
  --spring-soft: cubic-bezier(.25, 1.1, .4, 1);
  --t-spring: calc(var(--t) * 3);

  --ground: #12100e;
  --panel: #1c1917;
  --panel-deep: #171412;
  --edge: #2e2926;
  --text: #f0eae0;
  --dim: #a2968a;
  --faint: #6b6058;

  --accent: #e0a33e;
  --accent-soft: #4a3820;
  --danger: #d4553f;
  --good: #7fbf6a;

  /* The two halves of the score, which are colour-coded everywhere they appear. */
  --chips: #5aa9d6;
  --chips-soft: #1e3644;
  --mult: #e0653f;
  --mult-soft: #452019;
  --xmult: #9b7fd4;
  --xmult-soft: #342449;
  --utility-soft: #1e3a2c;
  --edit-soft: #3a3128;

  --scrim: rgba(18, 16, 14, 0.88);

  /* Buttons and pills: the one raised grey, its hover, and the play button's hover. */
  --button: #262220;
  --button-hover: #332d29;
  --play-hover: #6b5028;
  --boss-pill: #4a2019;

  --serif: Georgia, "Times New Roman", serif;
  --mono: Consolas, "Cascadia Mono", "SF Mono", Menlo, monospace;

  /* Set by view/table.js. The fallbacks are what the layout sees before it has measured anything,
     so they are small: eight tiles too wide for a phone would widen the page, and a phone answers
     a page wider than itself by zooming out - which changes the very numbers being measured. */
  --tile: 34px;
  --tray-tile: 34px;
  --tile-ratio: 1.3333;
  --hand-cols: 8;
  --gap: 8px;
  --radius: 8px;
}

@supports (animation-timing-function: linear(0, 1)) {
  :root {
    --spring: linear(0, 0.229 3.3%, 0.433 6.7%, 0.606 10%, 0.749 13.3%, 0.862 16.7%, 0.948 20%, 1.01 23.3%, 1.067 28.3%, 1.092 33.3%, 1.089 41.7%, 1.015 66.7%, 0.996 86.7%, 1);
    --spring-soft: linear(0, 0.203 3.3%, 0.375 6.7%, 0.518 10%, 0.636 13.3%, 0.732 16.7%, 0.841 21.7%, 0.916 26.7%, 0.978 33.3%, 1.015 41.7%, 1.028 55%, 1);
  }
}

html[data-motion="fast"] { --t: 90ms; }
html[data-motion="instant"] { --t: 0ms; }
/* `html:not([data-motion="full"])` ties the tier rules above on specificity, comes later, and so
   wins - except where the player has deliberately chosen Full, the one case it should lose. */
@media (prefers-reduced-motion: reduce) {
  html:not([data-motion="full"]) { --t: 0ms; }
}

* { box-sizing: border-box; }

/* The hidden attribute must beat any display rule below, or a "hidden" panel keeps showing. */
[hidden] { display: none !important; }

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

body {
  background: var(--ground);
  color: var(--text);
  font: 12px/1.4 "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

button {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--button);
  border: 1px solid var(--edge);
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
  transition: transform var(--t), opacity var(--t), scale var(--t-spring) var(--spring);
}
button:active { transform: translateY(1px); }
/* Everything a finger presses gives a little under it and springs back when it lets go: the press
   is quick, the release is the spring. `scale` on its own, so it never fights the lift a selected
   card already has on `transform`. */
button:active:not(:disabled):not([aria-disabled="true"]) { scale: .95; transition-duration: var(--t); }
button:disabled { opacity: 0.35; cursor: default; }
button.small { font-size: 11px; padding: 6px 9px; }

/* Play and Discard are dimmed rather than disabled, so a tap on them can still say why they are
   off. They look exactly like a disabled button and do not press. */
button[aria-disabled="true"] { opacity: 0.35; cursor: default; }
button[aria-disabled="true"]:active { transform: none; }

/* The one button the whole round funnels into. */
button.play { font-size: 15px; padding: 12px 30px; background: var(--accent-soft); border: 1.5px solid var(--accent); border-radius: 7px; }
button.play:disabled, button.play[aria-disabled="true"] { opacity: 0.3; }

@media (hover: hover) {
  button:hover:not(:disabled):not([aria-disabled="true"]) { border-color: var(--accent); background: var(--button-hover); }
  button.play:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--play-hover); }
}

/* Keyboard focus, in the game's own colour rather than the browser's blue. Only when it came from
   a key: a click lets go of focus, so a pressed button never keeps a ring. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card:focus-visible { outline-offset: 1px; }

.caption { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; color: var(--faint); }
.caption.good { color: var(--good); }
.accent { color: var(--accent); }
.chips-ink { color: var(--chips); font-weight: 700; }
.mult-ink { color: var(--mult); font-weight: 700; }
.xmult-ink { color: var(--xmult); font-weight: 700; }
.good-ink { color: var(--good); font-weight: 700; }
.compact-only { display: none; }

/* Said one way to a keyboard and mouse, another to a finger. Decided by the pointer, not the width:
   a narrow desktop window still has keys, and a phone on its side still has none. */
.touch-only { display: none; }
@media (hover: none) {
  .keys-only { display: none !important; }
  .touch-only { display: revert; }
}

/* ---------------------------------------------------------------- Layout */

.app {
  min-height: 100vh;
  min-height: min(100dvh, 980px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  max-width: 1330px;
  margin: 0 auto;
  padding: 14px;
  gap: 12px;
}

.top, .rail, .info, .scorebar, .hand-panel, .well {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.top {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  align-items: center;
  gap: 22px;
  padding: 9px 14px;
}

.wordmark { font-family: var(--serif); font-weight: 700; font-size: 21px; color: var(--accent); }
.round-kind { font-size: 15px; font-weight: 700; }

.boss {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--mult-soft);
  border: 1.25px solid var(--mult);
  grid-column: 3;
}
.boss b { font-size: 13px; color: var(--mult); white-space: nowrap; }
.coins { grid-column: 4; font-family: var(--mono); color: var(--accent); white-space: nowrap; }
.coins span { font-size: 22px; }
.coins b { font-size: 26px; }
.tools { grid-column: 5; display: flex; gap: 6px; }

.table {
  display: grid;
  grid-template-columns: 212px minmax(0, 1fr) 224px;
  gap: 12px;
  min-height: 0;
}

.centre {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 12px;
  min-width: 0;
}

/* ---------------------------------------------------------------- Relic rail */

.rail { display: flex; flex-direction: column; min-width: 0; }
.rail-caption { margin-bottom: 9px; }
.rail-note { font-size: 11px; color: var(--dim); margin-top: auto; padding-top: 8px; }
.relics { display: flex; flex-direction: column; gap: 7px; }

.relic {
  position: relative;
  white-space: normal;
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 9px;
  border-radius: 6px;
  border: 1.25px solid var(--chips);
  background: var(--chips-soft);
  font-weight: 400;
}
.relic b { display: block; font-size: 11px; font-weight: 700; }
.relic .what { display: block; font-size: 11px; color: var(--dim); margin-top: 2px; line-height: 1.35; }
.relic .charge { font-family: var(--mono); font-size: 13px; color: var(--accent); margin-top: 3px; display: block; }
/* The ring sits above the face so it never disturbs its colour, and only its opacity changes. */
.relic::after, .card::after, .deck-card::after, .shop-card::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  border: 2px solid var(--accent);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t);
}
.relic.firing::after { opacity: 1; }

[data-kind="Chips"] { background: var(--chips-soft); border-color: var(--chips); }
[data-kind="Mult"] { background: var(--mult-soft); border-color: var(--mult); }
[data-kind="XMult"] { background: var(--xmult-soft); border-color: var(--xmult); }
[data-kind="Utility"] { background: var(--utility-soft); border-color: var(--good); }
[data-kind="Edit"] { background: var(--edit-soft); border-color: var(--accent); }

/* ---------------------------------------------------------------- Score and target */

.scorebar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 24px; }
.readout.right { text-align: right; }
.number { font-family: var(--mono); font-size: 30px; line-height: 1.15; min-width: 7ch; transform-origin: left center; }
.readout.right .number { transform-origin: right center; }
/* The target met: the score turns the bar's green and settles, once, the way a stamp lands. */
.number.met { color: var(--good); animation: settle var(--t-spring) var(--spring) 1; }
@keyframes settle { from { scale: 1.18; } }
/* A play that adds to the round's score nudges it, smaller than the green landing above. */
.number.bump:not(.met) { animation: bump var(--t-spring) var(--spring) 1; }

.bar { height: 10px; border-radius: 5px; background: var(--panel-deep); border: 1px solid var(--edge); overflow: hidden; margin-top: 6px; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transform-origin: left center; transform: scaleX(0); transition: transform var(--t-spring) var(--spring-soft); }
.bar-fill.met { background: var(--good); }

/* ---------------------------------------------------------------- The well */

.well {
  background: var(--panel-deep);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto auto auto;
  min-width: 0;
  min-height: 0;
  padding: 12px;
}

.tray-wrap { display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; overflow-x: clip; min-height: calc(var(--tile) * var(--tile-ratio) + 28px); }
.tray-wrap > * { grid-area: 1 / 1; }
.tray-empty { font-size: 14px; color: var(--dim); text-align: center; }
.tray { display: flex; gap: var(--gap); justify-content: center; --w: var(--tray-tile); }

.problem { min-height: 18px; text-align: center; font-weight: 600; color: var(--danger); }
.stuck { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; justify-content: center; text-align: center; color: var(--dim); }
.stuck button { font-size: 12px; padding: 11px 14px; }

.tally { display: flex; align-items: center; justify-content: center; gap: 11px; margin-top: 10px; font-family: var(--mono); font-weight: 700; }
.tally.idle { visibility: hidden; }
.tally-chips, .tally-mult { font-size: 30px; line-height: 1.2; padding: 5px 18px; border-radius: 6px; border: 1.25px solid; min-width: 5ch; text-align: center; }
.tally-chips { color: var(--chips); background: var(--chips-soft); }
.tally-mult { color: var(--mult); background: var(--mult-soft); }
.tally-op { font-size: 26px; font-weight: 400; color: var(--faint); }
.tally-total { font-size: 34px; color: var(--accent); min-width: 6ch; }
/* The count-up, with weight. Each step the chips or the mult takes, its box gives a small push that
   the next step may cut short - the counting has a pulse. When the last step is in, the total is
   set down hard: it arrives too big and thumps into place. */
.tally-chips.bump, .tally-mult.bump { animation: bump var(--t-spring) var(--spring) 1; }
.tally-total.landed { animation: thump var(--t-spring) var(--spring) 1; }
@keyframes bump { from { scale: 1.1; } }
@keyframes thump { from { scale: 1.45; opacity: .4; } 20% { opacity: 1; } }

.receipt { display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start; gap: 6px; margin-top: 12px; height: 80px; overflow: hidden; }
.pill { display: inline-flex; gap: 7px; padding: 3px 8px; border-radius: 4px; font-size: 11px; background: var(--button); white-space: nowrap; }
.pill b { font-weight: 600; }
.pill span { font-family: var(--mono); color: var(--accent); }
.pill[data-step="Letter"] { background: var(--chips-soft); }
.pill[data-step="Relic"] { background: var(--xmult-soft); }
.pill[data-step="Boss"] { background: var(--boss-pill); }

/* ---------------------------------------------------------------- Letter cards */

.hand-panel { padding: 16px 12px; min-width: 0; overflow-x: clip; }
.hand {
  display: grid;
  grid-template-columns: repeat(var(--hand-cols), var(--tile));
  justify-content: center;
  gap: var(--gap);
  --w: var(--tile);
}

.card {
  position: relative;
  width: var(--w);
  height: calc(var(--w) * var(--tile-ratio));
  padding: 0;
  border-radius: 7px;
  border: 1.5px solid #c9b99a;
  background: #ede3d0;
  color: #1c1917;
  /* The lift on selection and on scoring springs, so a card raised to pay out bobs up and settles. */
  transition: transform var(--t-spring) var(--spring), opacity var(--t), scale var(--t-spring) var(--spring);
}
.card[data-edition="Foil"] { background: #cfe0ec; color: #132430; border-color: var(--chips); }
.card[data-edition="Glow"] { background: #f2cdbb; color: #35150d; border-color: var(--mult); }
.card[data-edition="Wild"] { background: #dfd0f0; color: #241838; border-color: var(--xmult); }
@media (hover: hover) {
  .card:hover:not(:disabled) { background: #ede3d0; border-color: #c9b99a; }
  .card[data-edition="Foil"]:hover:not(:disabled) { background: #cfe0ec; border-color: var(--chips); }
  .card[data-edition="Glow"]:hover:not(:disabled) { background: #f2cdbb; border-color: var(--mult); }
  .card[data-edition="Wild"]:hover:not(:disabled) { background: #dfd0f0; border-color: var(--xmult); }
  .card:hover::after, .deck-card:hover::after { opacity: 1; }
}

.card .face { position: absolute; inset: 0 0 8% 0; display: grid; place-items: center; font-family: var(--serif); font-weight: 700; font-size: calc(var(--w) * 0.55); line-height: 1; }
.card .value { position: absolute; right: 9%; bottom: 4%; font-family: var(--mono); font-weight: 700; font-size: max(11px, calc(var(--w) * 0.18)); opacity: 0.65; }
.card .edition { position: absolute; left: 9%; top: 5%; font-size: max(10px, calc(var(--w) * 0.11)); font-weight: 700; opacity: 0.7; }

/* Selection lifts the card rather than recolouring it, which reads at a glance and costs one
   transform rather than a repaint. */
.card.selected { transform: translateY(-14px); }
.card.selected::after { opacity: 1; }
.card.hinted { box-shadow: 0 0 0 3px var(--ground), 0 0 0 4.5px var(--good); }
/* The card currently paying out during the tally. */
.card.scoring { transform: translateY(-24px); }
.card.scoring::after { opacity: 1; border-color: var(--chips); }
.tray .card.selected { transform: none; }
.tray .card.selected::after { opacity: 0; }
.tray .card.scoring { transform: translateY(-8px); }
.tray .card.scoring::after { opacity: 1; }

/* A card dealt into the hand is set down: it arrives small and lands a touch too big before it
   settles. A card picked into the word drops onto the table from where the hand is. Both on the
   `scale`/`translate` properties, so neither fights the lift on `transform`. */
.card.dealt { animation: pop var(--t-spring) var(--spring) 1; }
@keyframes pop { from { scale: .55; opacity: 0; } 25% { opacity: 1; } }
.tray .card.landed { animation: land var(--t-spring) var(--spring) 1; }
@keyframes land { from { scale: .6; translate: 0 45%; opacity: 0; } 25% { opacity: 1; } }

/* A relic paying out during the tally jumps as its ring lights. */
.relic.firing { animation: bump var(--t-spring) var(--spring) 1; }

/* ---------------------------------------------------------------- Actions and status */

.actions { display: flex; justify-content: center; gap: 10px; }
.actions button:not(.play) { padding: 12px 20px; }

.status { color: var(--dim); min-height: 18px; padding: 0 4px; }

/* ---------------------------------------------------------------- Round information */

.info { display: flex; flex-direction: column; min-width: 0; }
.counts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 9px; }
.count { border-radius: 6px; padding: 7px 10px; display: flex; flex-direction: column; }
.count b { font-family: var(--mono); font-size: 26px; line-height: 1.2; }
.count.plays { background: var(--chips-soft); }
.count.plays .caption, .count.plays b { color: var(--chips); }
.count.discards { background: var(--mult-soft); }
.count.discards .caption, .count.discards b { color: var(--mult); }

.deckline { margin-top: 16px; display: flex; flex-direction: column; }
.deck-numbers { font-family: var(--mono); font-size: 15px; color: var(--dim); }
.deck-numbers b { color: var(--text); font-weight: 400; }
.deck-numbers span { margin: 0 3px; }
.cut { font-size: 11px; color: var(--dim); margin-top: 2px; }

.hintbox { margin-top: 16px; padding: 8px 10px; border-radius: 6px; background: var(--panel-deep); }
.hint-word { font-family: var(--serif); font-size: 18px; font-weight: 700; color: var(--good); }
.hint-note { font-size: 11px; color: var(--dim); margin-top: 2px; }

.runs { margin-top: auto; padding-top: 12px; display: flex; flex-direction: column; gap: 5px; }
.runs .caption { margin-bottom: 1px; }

/* ---------------------------------------------------------------- Overlays */

/* An overlay taller than the window scrolls inside itself, with its buttons pinned underneath:
   the way out of a panel must never be below the fold. */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: var(--scrim);
  animation: fade calc(var(--t) * 1.5) ease-out 1;
}
@keyframes fade { from { opacity: 0; } }

.panel {
  display: flex;
  flex-direction: column;
  max-width: min(100%, 700px);
  max-height: 100%;
  background: var(--panel);
  border: 1px solid var(--accent-soft);
  border-radius: 12px;
  overflow: hidden;
  animation: rise var(--t-spring) var(--spring-soft) 1;
}
/* A panel comes up from just below and arrives with a little give, over a table that dims. */
@keyframes rise { from { opacity: 0; translate: 0 18px; scale: .96; } 30% { opacity: 1; } }
.panel-head { padding: 22px 26px 0; }
.panel-head.centred { text-align: center; }
.panel-body { padding: 12px 26px; overflow-y: auto; min-height: 0; flex: 1 1 auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.panel-foot { padding: 12px 26px 20px; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; }
.panel-status { flex: 1 0 100%; text-align: center; color: var(--accent); min-height: 17px; font-weight: 600; }
/* The result, shown for copying by hand only when no route to the clipboard worked. */
.share-text { flex: 1 0 100%; resize: none; font: 12px/1.4 var(--mono); color: var(--text); background: var(--panel-deep); border: 1px solid var(--edge); border-radius: 6px; padding: 6px 8px; }

.panel h2 { margin: 0; font-size: 17px; font-weight: 700; }
.panel h2.big { font-size: 24px; }
.panel h3 { margin: 18px 0 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; color: var(--faint); }
.panel p { margin: 0 0 11px; color: var(--dim); line-height: 1.55; font-size: 13px; }
.panel p b { color: var(--text); }
.panel .lede { margin: 4px 0 0; font-size: 12px; }
.panel .lede.choose { color: var(--accent); font-weight: 600; }
.panel .fine { font-size: 11px; }
.head-row { display: flex; justify-content: space-between; align-items: center; }
.head-row .coins span { font-size: 20px; }

/* Shop */
.panel.shop { max-width: min(100%, 900px); }
.shop-items { display: grid; grid-template-columns: repeat(4, 196px); gap: 14px; }
.shop-card { position: relative; white-space: normal; text-align: left; padding: 11px 12px; border-radius: 7px; border-width: 1.25px; border-style: solid; font-weight: 400; display: flex; flex-direction: column; }
.shop-card .tag { font-size: 11px; font-weight: 700; opacity: 0.75; }
.shop-card .name { font-size: 14px; font-weight: 700; margin-top: 3px; }
.shop-card .what { font-size: 11px; color: var(--dim); margin-top: 6px; min-height: 46px; line-height: 1.4; flex: 1; }
.shop-card .price { font-family: var(--mono); font-size: 16px; font-weight: 700; color: var(--accent); margin-top: 6px; }
.shop-card .sold-label { position: absolute; inset: 0; display: none; place-items: center; font-size: 18px; font-weight: 700; }
.shop-card.sold > :not(.sold-label) { opacity: 0.22; }
.shop-card.sold .sold-label { display: grid; }
/* Bought just now: SOLD is stamped onto the card, dropped from above and thumped flat. */
.shop-card.just-sold .sold-label { animation: thump var(--t-spring) var(--spring) 1; }
/* A relic just bought joins the list below the shelf. */
.owned.arrived { animation: rise var(--t-spring) var(--spring-soft) 1; }
.shop-card.dear > * { opacity: 0.4; }
.shop-card.sold, .shop-card.dear { cursor: default; }
@media (hover: hover) {
  .shop-card[data-kind="Chips"]:hover { background: var(--chips-soft); border-color: var(--chips); }
  .shop-card[data-kind="Mult"]:hover { background: var(--mult-soft); border-color: var(--mult); }
  .shop-card[data-kind="XMult"]:hover { background: var(--xmult-soft); border-color: var(--xmult); }
  .shop-card[data-kind="Utility"]:hover { background: var(--utility-soft); border-color: var(--good); }
  .shop-card[data-kind="Edit"]:hover { background: var(--edit-soft); border-color: var(--accent); }
  .shop-card:not(.sold):not(.dear):hover::after { opacity: 1; }
  .relic:hover { border-color: var(--dim); }
}

.shop-caption { margin: 14px 0 6px; }
.shop-relics { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 7px; }
.owned { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 6px; border-width: 1.25px; border-style: solid; }
.owned .text { flex: 1; min-width: 0; }
.owned b { display: block; font-size: 11px; }
.owned .what { display: block; font-size: 11px; color: var(--dim); line-height: 1.35; }
.owned .charge { font-family: var(--mono); color: var(--accent); }

/* Deck */
.panel.deck { max-width: min(100%, 900px); }
.deck-cards { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; --w: 46px; --tile-ratio: 1.3; }
.deck-card { border-radius: 5px; border-width: 1.25px; }
.deck-card::after { border-color: var(--danger); }
.deck-cards:not(.choosing) .deck-card { cursor: default; }
.deck-cards:not(.choosing) .deck-card::after { display: none; }

/* Help */
.lengths { border-collapse: collapse; margin: 0 0 11px; font-family: var(--mono); font-size: 13px; }
.lengths th { text-align: left; font-weight: 600; padding: 2px 14px 2px 0; font-family: "Segoe UI", system-ui, sans-serif; font-size: 12px; color: var(--dim); }
.lengths td { padding: 2px 9px; text-align: right; color: var(--text); }
.keys { font-family: var(--mono); font-size: 12px; color: var(--dim); border-collapse: collapse; }
.keys td { padding: 2px 18px 2px 0; }
.keys td:nth-child(odd) { color: var(--accent); }

/* Stats and the end of a run */
.panel.stats, .panel.over { min-width: min(100%, 440px); }
.grid { display: grid; grid-template-columns: 1fr auto; gap: 3px 24px; margin: 0; font-size: 13px; }
.grid dt { color: var(--dim); }
.grid dd { margin: 0; text-align: right; }
.grid dd.accent { color: var(--accent); }
.best-runs > div { display: grid; grid-template-columns: 70px 1fr auto; gap: 8px; padding: 2px 0; color: var(--dim); font-size: 13px; }
.best-runs .word { color: var(--accent); }
.best-word { text-align: center; background: var(--panel-deep); border: 1px solid var(--edge); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px; }
.best-word .word { font-family: var(--serif); font-size: 26px; font-weight: 700; color: var(--accent); min-height: 34px; }
.best-word .word-score { font-family: var(--mono); font-size: 15px; color: var(--dim); }
/* The end of a run: the title is set down once the panel has arrived, then the best word after it. */
.panel.over h2 { animation: pop var(--t-spring) var(--spring) var(--t) 1 backwards; }
.panel.over .best-word .word { animation: pop var(--t-spring) var(--spring) calc(var(--t) * 2) 1 backwards; }

/* The wild picker and the menu */
.letters { display: grid; grid-template-columns: repeat(7, minmax(36px, 46px)); gap: 6px; justify-content: center; }
.letters button { padding: 0; aspect-ratio: 1 / 1.1; font-family: var(--serif); font-size: 20px; font-weight: 700; background: #dfd0f0; color: #241838; border: 1.5px solid var(--xmult); }
@media (hover: hover) { .letters button:hover:not(:disabled) { background: #efe6fa; border-color: var(--accent); } }
.panel-body.list { display: flex; flex-direction: column; gap: 8px; min-width: min(78vw, 260px); }
.panel-body.list button { padding: 12px 14px; font-size: 14px; }
.panel.confirm { max-width: min(100%, 420px); }

/* The rest between antes. Quiet on purpose: no flourish, just how far, and a plain choice. */
.panel.break { width: min(100%, 420px); }
.panel.break .caption { margin-bottom: 4px; }
.panel.break .lede { font-size: 13px; }
.ladder { display: flex; justify-content: center; gap: 6px; margin: 4px 0 12px; }
.ladder span { width: 22px; height: 8px; border-radius: 3px; background: var(--edge); }
.ladder span.done { background: var(--good); }
/* The step just climbed lands on the ladder a beat after the panel does. */
.ladder span.new { animation: pop var(--t-spring) var(--spring) var(--t) 1 backwards; }
.panel .break-next { text-align: center; margin: 0; font-size: 12px; }

/* After today's run: the days running and the wait for the next, on a strip of the dark the best
   word sits in. Said once, quietly, under what happened. */
.panel .comeback {
  display: table;
  margin: 10px auto 0;
  padding: 5px 13px;
  background: var(--panel-deep);
  border: 1px solid var(--accent-soft);
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--dim);
}
.panel .comeback[hidden] { display: none; }
.panel .comeback b { color: var(--good); font-weight: 600; }
.panel .comeback .next { white-space: nowrap; }
.panel .comeback b.wait { color: var(--accent); font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* The week under it: the ante-break ladder's steps, one per day, Monday to Sunday ending today.
   Played is a filled step in the colour a cleared round turns; a missed weekday an empty outline; a
   weekend not played fainter still, because it breaks nothing; today, still to play, a ring in the
   accent. The steps land one after another on the soft spring, and not at all when Motion is
   Instant. */
.week { display: flex; justify-content: center; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; }
.week li { display: flex; flex-direction: column; align-items: center; gap: 2px; animation: pop var(--t-spring) var(--spring-soft) backwards; }
.week li:nth-child(2) { animation-delay: calc(var(--t) * .2); }
.week li:nth-child(3) { animation-delay: calc(var(--t) * .4); }
.week li:nth-child(4) { animation-delay: calc(var(--t) * .6); }
.week li:nth-child(5) { animation-delay: calc(var(--t) * .8); }
.week li:nth-child(6) { animation-delay: calc(var(--t) * 1); }
.week li:nth-child(7) { animation-delay: calc(var(--t) * 1.2); }
.week i { width: 22px; height: 8px; border-radius: 3px; border: 1px solid var(--faint); }
.week [data-state="played"] i { background: var(--good); border-color: var(--good); }
.week [data-state="weekend"] i { border-color: var(--edge); }
.week [data-state="today"] i { border: 1.5px solid var(--accent); }
.week span { font-size: 9px; line-height: 1; color: var(--faint); font-family: var(--mono); }
.week [data-state="today"] span, .week li:last-child span { color: var(--dim); }

.week-row { display: flex; flex-direction: column; align-items: center; }

/* "Missed Friday? Play it." A line, not a button that shouts: the run can be mended, quietly. */
button.catch-up { color: var(--accent); }
.panel button.catch-up { display: block; margin: 4px auto 0; padding: 4px 10px; background: none; border: none; font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.panel-body.list button.catch-up { margin: 0; padding: 12px 14px; font-size: 14px; background: var(--button); border: 1px solid var(--edge); text-decoration: none; }

/* Today's run, once it is played: a tick in the colour a cleared round turns. */
button .tick { margin-left: 0.4em; color: var(--good); font-weight: 700; }

/* "Also today: ..." under the share button. A footnote, not an advert. */
.also-slot { flex: 1 0 100%; }
.also-slot:empty { display: none; }
.panel .also-today { margin: 2px 0 0; text-align: center; font-size: 11px; color: var(--faint); line-height: 1.45; }
.also-today a { color: var(--dim); text-decoration: underline; text-decoration-color: var(--edge); text-underline-offset: 2px; display: inline-block; padding: 10px 4px; margin: -10px -4px; }
@media (hover: hover) { .also-today a:hover { color: var(--accent); text-decoration-color: var(--accent); } }

/* What a tapped relic says about itself. */
.tip {
  position: fixed;
  z-index: 20;
  max-width: min(280px, calc(100vw - 16px));
  padding: 9px 11px;
  border-radius: 6px;
  background: var(--button);
  border: 1px solid var(--accent);
  color: var(--dim);
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;
}
.tip b { display: block; color: var(--text); margin-bottom: 2px; }

.loading { position: fixed; inset: 0; z-index: 30; display: grid; place-content: center; justify-items: center; gap: 10px; background: var(--ground); color: var(--dim); font-size: 14px; text-align: center; padding: 24px; }
.loading .wordmark { font-size: 32px; }

/* ---------------------------------------------------------------- Narrower than the design size */

@media (max-width: 1100px) {
  .table { grid-template-columns: 176px minmax(0, 1fr) 176px; }
  .top { gap: 14px; }
  .shop-items { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------------------------------------------------------------- A phone, either way up
 *
 * Everything needed to choose a word has to be on screen at once: the target, the plays and
 * discards, the relics in play, the word, the tally, the whole hand and the buttons. A comparison
 * you have to scroll for is one you make from memory. So here the two side panels fold down into
 * strips: the round's numbers become a row of pills and the relics a row of chips (tap one to
 * read it), and the things that are not part of a decision - new run, stats, motion - move
 * behind Menu. */

@media (max-width: 900px), (max-height: 520px) {
  :root { --gap: 6px; --tile-ratio: 1.2; --radius: 7px; }
  .wide-only { display: none !important; }
  .compact-only { display: inline-block; }

  .app { padding: 6px; gap: 6px; }
  .top, .rail, .info, .scorebar, .hand-panel, .well { padding: 6px 8px; }

  .top { grid-template-columns: auto 1fr auto auto; gap: 4px 10px; padding: 5px 8px; }
  .wordmark { font-size: 15px; }
  .round { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
  .round-kind { font-size: 13px; }
  .coins { grid-column: 3; grid-row: 1; }
  .coins span { font-size: 15px; }
  .coins b { font-size: 18px; }
  .tools { grid-column: 4; grid-row: 1; gap: 4px; }
  .tools button { padding: 8px 9px; min-height: 40px; }
  .boss { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; padding: 4px 8px; gap: 8px; }
  .boss b { font-size: 12px; }

  .number { font-size: 20px; min-width: 7ch; }
  .scorebar { gap: 12px; }
  .bar { margin-top: 0; height: 8px; }

  /* The round's numbers, as a strip. */
  .info { flex-direction: row; align-items: center; gap: 6px; padding: 5px 8px; }
  .info-caption, .hintbox, .runs { display: none !important; }
  .counts { display: contents; }
  .count { flex-direction: row; align-items: baseline; gap: 6px; padding: 3px 8px; margin: 0; }
  .count b { font-size: 16px; }
  .deckline { margin: 0 0 0 auto; flex-direction: row; align-items: baseline; gap: 6px; }
  .deck-numbers { font-size: 13px; }
  .cut { margin: 0; }

  /* The relics, as chips. */
  .rail { flex-direction: row; align-items: center; gap: 6px; padding: 5px 8px; min-height: 30px; }
  .rail-caption { margin: 0; }
  /* Chips need no heading, and the heading's width is half a chip. */
  .rail.has-relics .rail-caption { display: none; }
  .rail-note { margin: 0; padding: 0; }
  .relics { flex-direction: row; flex-wrap: wrap; gap: 6px 4px; }
  .relic { width: auto; padding: 6px 8px; display: flex; gap: 5px; align-items: baseline; }
  /* A chip is tapped to be read. Its hit area reaches into the gaps above and below it. */
  .relic::before { content: ""; position: absolute; inset: -6px 0; }
  .relic b { font-size: 11px; white-space: nowrap; }
  .relic .what { display: none; }
  .relic .charge { font-size: 11px; margin: 0; }

  .well { padding: 6px 8px; }
  .tray-wrap { min-height: calc(min(var(--tile), 56px) * var(--tile-ratio) + 12px); }
  .tray-empty { font-size: 13px; }
  .problem { min-height: 16px; font-size: 11.5px; }
  .tally { margin-top: 2px; gap: 7px; }
  .tally-chips, .tally-mult { font-size: 19px; padding: 2px 10px; min-width: 4.5ch; }
  .tally-op { font-size: 16px; }
  .tally-total { font-size: 22px; min-width: 5.5ch; }
  .receipt { margin-top: 6px; gap: 3px; height: 42px; }
  .pill { padding: 2px 5px; gap: 4px; font-size: 11px; }

  .hand-panel { padding: 8px 6px; }
  /* Lifting a tile fourteen pixels would push it into the row above; it fades back instead. */
  .card.selected { transform: translateY(-3px); opacity: 0.45; }
  .card.scoring { transform: translateY(-3px); opacity: 1; }
  .tray .card.selected { opacity: 1; }

  .actions { gap: 6px; }
  .actions button { flex: 1 1 0; min-width: 0; min-height: 40px; padding: 12px 4px; font-size: 13px; }
  .actions button.play { flex: 1.7 1 0; font-size: 14px; padding: 12px 4px; }
  .actions button:not(.play) { padding: 12px 4px; }
  .status { min-height: 16px; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .overlay { padding: 8px; }
  .panel-head { padding: 14px 16px 0; }
  .panel-body { padding: 10px 16px; }
  .panel-foot { padding: 10px 16px 12px; gap: 8px; }
  .panel-foot button { padding: 11px 16px; }
  .panel-foot button.play { padding: 11px 22px; }
  .lengths td { padding: 2px 6px; }

  .shop-items { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .shop-card { padding: 8px 9px; }
  .shop-card .what { min-height: 0; }
  .shop-relics { grid-template-columns: 1fr; }
  .owned button { padding: 9px 10px; }
}

/* Upright: one column, the table's parts stacked in the order a turn reads them. */
@media (max-width: 599px), (max-width: 900px) and (min-height: 521px) {
  .table { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto minmax(0, 1fr) auto auto; gap: 6px; }
  .centre { display: contents; }
  .scorebar { order: 1; }
  .info { order: 2; }
  .rail { order: 3; }
  .well { order: 4; }
  .hand-panel { order: 5; }
  .actions { order: 6; }
}

/* Upright and short: the receipt keeps one line of pills, so the hand keeps its size. The total
   above it is what decides anything. */
@media (max-width: 599px) and (max-height: 600px) {
  .receipt { height: 21px; margin-top: 4px; }
}

/* Short enough that the menu's six buttons would scroll: two columns. */
@media (max-height: 520px) {
  .panel-body.list { display: grid; grid-template-columns: 1fr 1fr; }
  /* The end of a run keeps every fact and the "also today" line in view: the best word gives up
     some of its frame instead. */
  .panel.over h2.big { font-size: 20px; }
  .best-word { padding: 6px 12px; margin-bottom: 8px; }
  .best-word .word { font-size: 21px; min-height: 0; }
  .best-word .word-score { font-size: 13px; }
  .panel.over .grid { font-size: 12px; gap: 1px 24px; }
}

@media (max-width: 420px) {
  .wordmark { display: none; }
  .top { grid-template-columns: 1fr auto auto; }
  .coins { grid-column: 2; }
  .tools { grid-column: 3; }
}

/* On its side: short rather than narrow. The word, the hand and the buttons keep the left; the
   numbers and the relics go down the right-hand edge, and the boss's rule joins the top line. */
@media (min-width: 600px) and (max-height: 520px) {
  .top { grid-template-columns: auto auto minmax(0, 1fr) auto auto; }
  .boss { grid-column: 3; grid-row: 1; justify-self: start; padding: 2px 8px; font-size: 11px; line-height: 1.25; }
  .coins { grid-column: 4; }
  .tools { grid-column: 5; }

  .table { grid-template-columns: minmax(0, 1fr) 236px; grid-template-rows: auto auto minmax(0, 1fr) auto auto; gap: 6px; }
  .centre { display: contents; }
  .well { grid-column: 1; grid-row: 1 / span 3; }
  .hand-panel { grid-column: 1; grid-row: 4; padding: 6px; }
  .actions { grid-column: 1; grid-row: 5; }
  .scorebar { grid-column: 2; grid-row: 1; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
  .scorebar .bar { grid-column: 1 / -1; grid-row: 2; }
  .info { grid-column: 2; grid-row: 2; flex-wrap: wrap; }
  .deckline { margin-left: 0; }
  .rail { grid-column: 2; grid-row: 3 / span 3; flex-direction: column; align-items: flex-start; }
  .actions button, .actions button.play, .actions button:not(.play) { padding: 8px 4px; }
  .receipt { height: 21px; }
}

/* The end of a run on its side: the best word beside the facts rather than above them, so the
   days-running line after today's run fits without the facts scrolling. */
@media (min-width: 600px) and (max-height: 520px) {
  .panel.over .panel-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 0 20px; align-items: center; }
  .panel.over .best-word { margin-bottom: 0; }
  .panel .comeback { margin-top: 6px; padding: 3px 12px; }
  /* The missed day goes beside the week rather than under it: the height is what is short here. */
  .week-row { flex-direction: row; justify-content: center; gap: 4px; }
  .week { margin-top: 5px; }
  .panel .week-row button.catch-up { margin: 5px 0 0; padding: 2px 8px; }
}
