/* Solitaire · Dune Scholars Play
   Palette follows the site: deep navy ground, pearl card faces,
   volcanic glass backs, a warm sand accent. */

:root {
  --ink: #0A192F;
  --ink-deep: #050E1C;
  --felt-1: #123A52;
  --felt-2: #07182B;
  --pearl: #F5F7F9;
  --pearl-dim: #DCE3EA;
  --card-black: #15202C;
  --card-red: #B32F24;
  --sand: #E3B261;
  --sand-soft: rgba(227, 178, 97, 0.22);
  --line: rgba(236, 243, 250, 0.16);
  --text: #E8EEF5;
  --text-dim: #93A6BC;
  --bar: rgba(5, 14, 28, 0.92);
  --radius: 7px;
  --face-bg: linear-gradient(170deg, #FFFFFF 0%, #F5F7F9 45%, #DCE3EA 100%);
  --face-ink: #15202C;
  --face-red: #B32F24;
  --face-weave: rgba(21, 32, 44, 0.02);
  /* The cut edge of the card. Faint, but it has to be enough to tell one
     card from the next where they overlap. */
  --face-edge: rgba(21, 32, 44, 0.24);
  /* A card is not a sheet of paper: it has a thickness, and the strip along
     its bottom edge is where you see it. */
  --card-thickness: rgba(21, 32, 44, 0.16);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* Several things here set `display`, which silently beats the browser's own
   rule for the hidden attribute and leaves hidden elements on show. This is
   the one place it is worth being heavy-handed about. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--ink-deep);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

/* Bars */

.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bar);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  z-index: 50;
}

.bar-top {
  padding: calc(6px + var(--safe-top)) 12px 6px;
  min-height: 46px;
}

.home {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--sand);
  text-decoration: none;
  border: 1px solid var(--line);
  font-size: 15px;
  flex: 0 0 auto;
}

.title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin: 0;
  flex: 0 0 auto;
}

.counters {
  display: flex;
  gap: 14px;
  margin-left: auto;
}

.counter {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
}

.counter small {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.counter b {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* The controls used to sit along the bottom edge, where they were simply not
   noticed: the eye is on the cards and the bottom of the screen is where a
   browser puts its own furniture. They now share a row with the game
   switcher, so everything that is not the table is in one band under the
   title, and they carry the same sand colour the current game is marked
   with, which is already the one thing on the page the eye goes to. */
.control-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--bar);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  z-index: 45;
}

.bar-tools {
  border: 0;
  background: none;
  padding: 7px 10px;
  gap: 6px;
  flex: 0 0 auto;
  margin-left: auto;
}

.tool {
  appearance: none;
  background: var(--sand-soft);
  border: 1px solid var(--sand);
  color: var(--sand);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 10px;
  border-radius: 11px;
  font: inherit;
  cursor: pointer;
  flex: 1 1 0;
  min-width: 0;
}

.tool .glyph { font-size: 19px; line-height: 1; }
.tool .label { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; color: inherit; }
.tool:disabled { opacity: 0.3; cursor: default; }
.tool:not(:disabled):active { background: rgba(201, 164, 107, 0.34); }
.tool:not(:disabled):hover { background: rgba(201, 164, 107, 0.3); }

/* Finish is the one control that does something to the whole table, so with
   the rest now wearing the sand outline it takes the solid fill to stay the
   loudest thing in the row. */
.tool.accent {
  background: var(--sand);
  border-color: var(--sand);
  color: #241a08;
}
.tool.accent .glyph, .tool.accent .label { color: #241a08; }
.tool.accent:not(:disabled):hover { background: #d9b57e; }

/* Game switcher */

.switcher {
  display: flex;
  gap: 6px;
  flex: 1 1 auto;
  padding: 7px 10px;
  background: none;
  border-bottom: 0;
  z-index: 40;
}

.switcher a {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 6px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.switcher a svg { width: 23px; height: 17px; flex: none; }
.switcher a:hover { color: var(--text); border-color: rgba(236, 243, 250, 0.32); }

.switcher a[aria-current="page"] {
  background: var(--sand-soft);
  border-color: var(--sand);
  color: var(--sand);
}

/* Table */

.board {
  position: relative;
  /* The bar that used to sit here kept the lowest cards clear of a phone's
     home indicator. Nothing else was doing it, so the table does it now. */
  padding-bottom: var(--safe-bottom);
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 0%, var(--felt-1) 0%, var(--felt-2) 72%),
    var(--ink);
  touch-action: none;
}

.board::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(100deg, rgba(255,255,255,0.016) 0 2px, transparent 2px 9px);
  opacity: 0.9;
}

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

/* Each scene tints the felt a little, so the table reads as the same place
   as whatever is moving across it. */
.board[data-bg="night"] { background: radial-gradient(120% 90% at 50% 0%, #10243C 0%, #060B16 72%), #05080F; }
.board[data-bg="aurora"] { background: radial-gradient(120% 95% at 50% 10%, #10263A 0%, #070F1C 70%), #050A12; }
.board[data-bg="rain"] { background: radial-gradient(120% 90% at 50% 0%, #1B2733 0%, #0A1119 72%), #070C12; }
.board[data-bg="snow"] { background: radial-gradient(120% 90% at 50% 0%, #243247 0%, #0D1522 72%), #0A111B; }
.board[data-bg="fireflies"] { background: radial-gradient(120% 90% at 50% 100%, #14240F 0%, #080D06 70%), #060903; }
.board[data-bg="deep"] { background: radial-gradient(130% 100% at 50% -10%, #0F4A44 0%, #04201D 68%), #03110F; }

.slot, .card {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
}

.slot {
  z-index: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* A pyramid position is a hole in a shape, not a place to put something back.
   Twenty-eight outlined boxes appearing as the pyramid empties would read as
   clutter, so the slot carries no border and no fill of its own. The target
   and hint highlights below still apply, which is the only time one of these
   needs to be visible. */
.slot-slot {
  border-color: transparent;
  background: none;
  box-shadow: none;
}

.slot-foundation::after {
  content: "";
  position: absolute;
  inset: 22%;
  border: 1px dashed rgba(236, 243, 250, 0.2);
  border-radius: 50%;
}

.slot.target {
  border-color: var(--sand);
  box-shadow: 0 0 0 2px var(--sand-soft);
}

.slot.hint {
  animation: pulse 0.9s ease-in-out infinite;
}

.slot-stock {
  cursor: pointer;
  display: grid;
  place-items: center;
}

.stock-mark {
  width: 46%;
  height: 46%;
  border: 2px solid rgba(236, 243, 250, 0.26);
  border-radius: 50%;
  position: relative;
}

.stock-mark::after {
  content: "";
  position: absolute;
  inset: 24%;
  border-radius: 50%;
  border: 2px solid rgba(236, 243, 250, 0.18);
}

.slot-stock.recycle .stock-mark { border-color: var(--sand); }
.slot-stock.recycle .stock-mark::after { border-color: var(--sand-soft); }
.slot-stock.exhausted { opacity: 0.4; }

/* Cards */

.card {
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 180ms cubic-bezier(0.2, 0.75, 0.3, 1);
  perspective: 600px;
}

/* Picking a card up before you have picked it up. Hovering, or a finger on
   the screen, raises the run that would come away in your hand. The faces
   move rather than the card, because the card's own transform is the thing
   that positions it on the table and is set inline. */
.card .face, .card .back {
  transition: transform 150ms cubic-bezier(0.2, 0.75, 0.3, 1), box-shadow 150ms ease;
}

.card.lift .face { transform: translateY(-7px); }
.card.lift .back { transform: rotateY(180deg) translateY(-7px); }

/* Further from the table means a softer, wider shadow, or it reads as the
   card growing rather than rising. */
.card.lift .face, .card.lift .back {
  box-shadow:
    0 -1px 0 rgba(0, 0, 0, 0.6),
    0 -3px 7px rgba(0, 0, 0, 0.45),
    0 4px 4px rgba(0, 0, 0, 0.3),
    0 14px 24px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    inset 0 -2px 0 var(--card-thickness);
}

@media (prefers-reduced-motion: reduce) {
  .card .face, .card .back { transition: none; }
}

.card.dragging {
  transition: none;
  cursor: grabbing;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.55));
}

/* Lift and land. Both scale the faces rather than the card itself, because
   the card's own transform is set inline to position it and an animation
   there would fight the renderer. */
.card.dragging .face { transform: scale(1.035); }
.card.dragging .back { transform: rotateY(180deg) scale(1.035); }

.card.landing .face { animation: land 200ms cubic-bezier(0.3, 0.9, 0.4, 1); }
.card.landing .back { animation: land-back 200ms cubic-bezier(0.3, 0.9, 0.4, 1); }

@keyframes land {
  0% { transform: scale(1.03); }
  45% { transform: scale(0.965); }
  100% { transform: scale(1); }
}

@keyframes land-back {
  0% { transform: rotateY(180deg) scale(1.03); }
  45% { transform: rotateY(180deg) scale(0.965); }
  100% { transform: rotateY(180deg) scale(1); }
}

/* While being dealt, a card sits at the stock with no transition, so it does
   not slide in from wherever it happened to be before. */
.card.dealing { transition: none; }

.card.falling { transition: none; }

.flipper {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 220ms ease;
}

.card.down .flipper { transform: rotateY(180deg); }

.face, .back {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  /* A card in a column laps over the one above it, so the edge you actually
     see is its TOP one. The shadow used to fall only downwards, where there
     is nothing to catch it, and a column of five read as one tall card with
     numbers printed down it. The backs were worse: five of them ran together
     into a single sheet of pattern.

     So each card now throws a shadow upwards onto the card above, and carries
     a hairline of light just inside its own top edge. The pair of them is
     what a real stack of cards looks like: a dark crease, then the next card
     catching the light. */
  box-shadow:
    /* A hard line first. A blurred shadow alone vanishes into a busy card
       back: five sadu cards still read as one sheet of zigzag. One unblurred
       pixel of black cuts through any pattern, whatever colours a deck uses. */
    0 -1px 0 rgba(0, 0, 0, 0.6),
    0 -3px 7px rgba(0, 0, 0, 0.45),
    /* Two shadows below rather than one. The tight one is where the card
       touches the table and is what stops it looking printed on; the wide
       soft one is the room between the card and the table, and is what makes
       it sit above it rather than on it. One shadow has to be either sharp or
       soft and ends up doing neither job. */
    0 2px 2px rgba(0, 0, 0, 0.38),
    0 7px 16px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    /* The cut edge along the bottom, which is the card's own thickness. */
    inset 0 -2px 0 var(--card-thickness);
}

.face {
  background: var(--face-bg);
  overflow: hidden;
}

/* A faint linen weave so the faces read as printed stock rather than paper
   white, and a hairline inside the edge the way a real card is cut. */
.face::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(0deg, var(--face-weave) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, var(--face-weave) 0 1px, transparent 1px 4px);
  box-shadow: inset 0 0 0 1px var(--face-edge);
}

.back {
  transform: rotateY(180deg);
  border: 1px solid var(--back-edge);
}

.back::after {
  content: "";
  position: absolute;
  inset: 11%;
  border: 1px solid var(--back-line);
  border-radius: 3px;
}

/* Card backs
   One block per deck, listing both the card back and the picker swatch, so a
   deck can never look one way in the menu and another on the table. Adding a
   deck means a block here and a row in decks.js. All of it is drawn with
   gradients, so a deck weighs nothing and there is no image to load.
   --back-edge is the card's own edge, --back-line the border inside it. */

.back, .swatch {
  --back-edge: rgba(227, 178, 97, 0.28);
  --back-line: rgba(227, 178, 97, 0.3);
  background-repeat: repeat;
}

.board[data-deck="dune"] .back,
.swatch[data-deck="dune"] {
  background-color: #0A192F;
  background-image:
    repeating-linear-gradient(45deg, rgba(227,178,97,0.16) 0 3px, transparent 3px 7px),
    linear-gradient(160deg, #1D3F63 0%, #10233C 60%, #0A192F 100%);
}

.board[data-deck="sadu"] .back,
.swatch[data-deck="sadu"] {
  --back-edge: rgba(36, 26, 18, 0.55);
  --back-line: rgba(36, 26, 18, 0.45);
  background-color: #D8C3A0;
  background-image:
    linear-gradient(135deg, #6B4A2E 25%, transparent 25%),
    linear-gradient(225deg, #6B4A2E 25%, transparent 25%),
    linear-gradient(315deg, #6B4A2E 25%, transparent 25%),
    linear-gradient(45deg, #6B4A2E 25%, transparent 25%),
    repeating-linear-gradient(0deg, #241A12 0 2px, transparent 2px 9px, #F2E9DA 9px 11px, transparent 11px 18px);
  background-size: 11px 11px, 11px 11px, 11px 11px, 11px 11px, 100% 18px;
  background-position: -5.5px 0, -5.5px 0, 0 0, 0 0, 0 0;
}

.board[data-deck="mashrabiya"] .back,
.swatch[data-deck="mashrabiya"] {
  --back-edge: rgba(227, 178, 97, 0.5);
  --back-line: rgba(227, 178, 97, 0.42);
  background-color: #0C2340;
  background-image:
    radial-gradient(circle, rgba(227,178,97,0.5) 1.3px, transparent 1.8px),
    repeating-linear-gradient(45deg, rgba(227,178,97,0.42) 0 1px, transparent 1px 11px),
    repeating-linear-gradient(-45deg, rgba(227,178,97,0.42) 0 1px, transparent 1px 11px),
    linear-gradient(160deg, #15385C 0%, #0A1C30 100%);
  background-size: 15.56px 15.56px, auto, auto, auto;
}

.board[data-deck="pearl"] .back,
.swatch[data-deck="pearl"] {
  --back-edge: rgba(226, 232, 226, 0.34);
  --back-line: rgba(226, 232, 226, 0.26);
  background-color: #08312B;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.55) 1.5px, rgba(255,255,255,0.14) 2.3px, transparent 2.7px),
    radial-gradient(circle, rgba(255,255,255,0.2) 0.9px, transparent 1.5px),
    linear-gradient(160deg, #0E4038 0%, #06211E 100%);
  background-size: 15px 15px, 15px 15px, auto;
  background-position: 0 0, 7.5px 7.5px, 0 0;
}

.board[data-deck="midnight"] .back,
.swatch[data-deck="midnight"] {
  --back-edge: rgba(180, 196, 224, 0.3);
  --back-line: rgba(180, 196, 224, 0.22);
  background-color: #05080F;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.85) 0.9px, transparent 1.3px),
    radial-gradient(circle, rgba(255,236,190,0.5) 0.7px, transparent 1.1px),
    radial-gradient(ellipse 130% 62% at 50% 120%, #4A3A24 0%, transparent 72%),
    linear-gradient(180deg, #0B1428 0%, #060A14 72%);
  background-size: 16px 21px, 11px 9px, auto, auto;
  background-position: 3px 5px, 8px 2px, 0 0, 0 0;
}

.card.red .face { color: var(--face-red); }
.card.black .face { color: var(--face-ink); }

.card.target .face { box-shadow: 0 0 0 2px var(--sand); }
.card.hint .face { animation: pulse 0.9s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(227, 178, 97, 0.75); }
  50% { box-shadow: 0 0 0 4px rgba(227, 178, 97, 0.12); }
}

.card.nudge { animation: nudge 300ms ease; }

@keyframes nudge {
  0%, 100% { filter: none; }
  50% { filter: brightness(1.25) saturate(0.6); }
}

/* Card faces */

/* The index sits in a box of a fixed share of the card, so the pips can be
   kept clear of it by geometry rather than by hoping about font metrics.
   Without this the ten sets its own width: "10" is about 1.1em wide where "9"
   is 0.65em, because the zero is wide, and it sprawled across the pips. */
.corner {
  position: absolute;
  width: calc(var(--card-w) * 0.19);
  line-height: 0.95;
  font-weight: 700;
  text-align: center;
}

.corner b, .corner i { display: block; width: 100%; }

/* The index lives in the margin, the pips keep out of it. Get this wrong and
   the rotated bottom-right index lands in among the pips. */
.corner b { font-size: calc(var(--card-w) * 0.25); }
.corner i { font-size: calc(var(--card-w) * 0.17); font-style: normal; }

/* "10" is twice the width of every other rank and would otherwise reach into
   the pips, so it is set smaller and tighter. */
/* The ten is the only two-character rank, and fonts draw a zero wide: "10"
   runs about 1.1em where "9" is 0.65em. It is set a little smaller and
   squeezed, so its painted width stops depending on the font. */
.corner b.two-char {
  font-size: calc(var(--card-w) * 0.2);
  letter-spacing: -0.03em;
  transform: scaleX(0.86);
}

.corner.tl { top: 4%; left: 5%; }
.corner.br { bottom: 4%; right: 5%; transform: rotate(180deg); }

.centre {
  position: absolute;
  inset: 20% 20% 20% 20%;
  display: grid;
}

.centre.ace {
  place-items: center;
  inset: 11% 11%;
}

.ace-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.ace-glyph {
  position: relative;
  font-size: calc(var(--card-w) * 0.52);
  line-height: 1;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.6));
}

/* Inset well clear of both corner indices, left and right. */
.centre.pips {
  inset: 8% 26%;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(7, 1fr);
  place-items: center;
}

.pip {
  font-size: calc(var(--card-w) * 0.17);
  line-height: 1;
}

.pip.flip { transform: rotate(180deg); }

.centre.court {
  inset: 4% 4%;
  place-items: stretch;
}

.court-art {
  width: 100%;
  height: 100%;
  display: block;
}

/* Narrow screens: pips get illegible, so the suit takes the middle. */

.board.compact .centre.pips {
  inset: 22% 20%;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  place-items: center;
}

.board.compact .pip {
  display: none;
  grid-column: 1 !important;
  grid-row: 1 !important;
}

.board.compact .pip:first-child {
  display: block;
  font-size: calc(var(--card-w) * 0.50);
  transform: none;
}

.board.compact .corner.br { display: none; }
.board.compact .corner b { font-size: calc(var(--card-w) * 0.34); }
.board.compact .corner i { font-size: calc(var(--card-w) * 0.26); }

/* The finest strokes stop reading below about 64px of card width. */
.board.compact .fine { display: none; }
.board.compact .centre.court { inset: 6% 6%; }
.board.compact .centre.ace { inset: 20% 22%; }
.board.compact .ace-glyph { font-size: calc(var(--card-w) * 0.52); }

/* Overlays */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(3, 9, 18, 0.72);
  backdrop-filter: blur(3px);
  z-index: 100;
}

.dialog {
  position: fixed;
  z-index: 110;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(380px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 20px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(165deg, #10233C, #081527);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.dialog h2 {
  margin: 0 0 4px;
  font-size: 19px;
  letter-spacing: 0.01em;
}

.dialog .muted { color: var(--text-dim); font-size: 13px; margin: 0 0 14px; }
.deal-line { color: var(--text-dim); font-size: 13px; margin: 0 0 14px; }
.deal-line b { color: var(--sand); font-variant-numeric: tabular-nums; }

.stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }

.wide, .chip {
  appearance: none;
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  padding: 11px 14px;
  text-align: left;
}

.wide:active, .chip:active { background: rgba(255, 255, 255, 0.11); }
.wide.accent { background: var(--sand); color: #241A08; border-color: transparent; font-weight: 600; text-align: center; }
.wide.ghost { background: none; color: var(--text-dim); text-align: center; }

.choice { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.choice-label { font-size: 12px; color: var(--text-dim); letter-spacing: 0.08em; text-transform: uppercase; }
.chip { padding: 8px 12px; font-size: 13px; }
.chip.selected { background: var(--sand-soft); border-color: var(--sand); color: var(--sand); }

/* Deck picker */

.decks { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }

.swatch {
  appearance: none;
  width: 46px;
  height: 65px;
  padding: 0;
  border-radius: 7px;
  border: 1px solid var(--back-edge);
  cursor: pointer;
  position: relative;
  flex: none;
}

.swatch::after {
  content: "";
  position: absolute;
  inset: 11%;
  border: 1px solid var(--back-line);
  border-radius: 3px;
}

.swatch.selected {
  outline: 2px solid var(--sand);
  outline-offset: 2px;
}

.swatch:focus-visible { outline: 3px solid var(--sand); outline-offset: 2px; }

.deck-note {
  font-size: 12.5px;
  color: var(--text-dim);
  margin: 0 0 14px;
  min-height: 2.6em;
}

.deck-note b { color: var(--text); font-weight: 600; display: block; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }

.field input {
  font: inherit;
  font-size: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
}

.prose p { font-size: 14px; line-height: 1.55; margin: 0 0 10px; }
.prose .muted { font-size: 12.5px; }

.stats-body { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.stat-group h3 { margin: 0 0 6px; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--sand); }
.stat-group dl { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.stat-group dl div { display: flex; justify-content: space-between; font-size: 13px; border-bottom: 1px solid rgba(255,255,255,0.06); padding-bottom: 3px; }
.stat-group dt { color: var(--text-dim); }
.stat-group dd { margin: 0; font-variant-numeric: tabular-nums; }

.win h2 { color: var(--sand); font-size: 22px; margin-bottom: 14px; }
.win-grid { margin: 0 0 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.win-grid div { background: rgba(255,255,255,0.05); border-radius: 10px; padding: 10px 12px; }
.win-grid dt { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim); }
.win-grid dd { margin: 2px 0 0; font-size: 19px; font-variant-numeric: tabular-nums; }

.toast {
  position: fixed;
  left: 50%;
  /* Used to clear the bar that ran along the bottom. With the controls moved
     up, the toast only has to clear the phone's own home indicator. */
  bottom: calc(22px + var(--safe-bottom));
  transform: translate(-50%, 8px);
  z-index: 90;
  padding: 9px 15px;
  border-radius: 999px;
  background: rgba(8, 20, 36, 0.95);
  border: 1px solid var(--line);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Wider screens get a centred table rather than stretched cards. */

/* On a desktop the table takes the whole window and the cards are sized from
   the height instead, which makes them as large as the screen allows. The
   renderer centres the columns when there is width to spare. */
@media (min-width: 760px) {
  .bar-top { padding-left: 20px; padding-right: 20px; min-height: 52px; }
  .bar-tools { gap: 8px; padding: 8px 20px 8px 0; }
  .tool { padding: 9px 14px; flex: 0 0 auto; min-width: 74px; }
  .tool .glyph { font-size: 21px; }
  .tool .label { font-size: 12px; }
  .switcher { justify-content: center; padding: 8px 10px 8px 20px; }
  .switcher a { flex: 0 1 190px; font-size: 13.5px; padding: 9px 10px; }
  .switcher a svg { width: 26px; height: 19px; }
  body { background: var(--ink-deep); }
}

@media (prefers-reduced-motion: reduce) {
  .card, .flipper { transition: none; }
  .card.hint .face, .slot.hint { animation: none; box-shadow: 0 0 0 2px var(--sand); }
  .card.landing .face, .card.landing .back { animation: none; }
  .card.dragging .face { transform: none; }
  .card.dragging .back { transform: rotateY(180deg); }
}

/* Game links in the menu read as chips but are ordinary links. */
.choice.games { flex-wrap: wrap; }
a.chip { text-decoration: none; display: inline-block; }
a.chip.selected { background: var(--sand-soft); border-color: var(--sand); color: var(--sand); }

/* A free cell that is out of play in this difficulty. */
.slot-cell.locked {
  opacity: 0.32;
  border-style: dashed;
}

.slot-cell.locked::after {
  content: "";
  position: absolute;
  inset: 38%;
  border-top: 1px solid rgba(236, 243, 250, 0.4);
}

/* The line under the win figures saying whether it was a clean win. */
.win-note {
  margin: -6px 0 16px;
  font-size: 13px;
  color: var(--text-dim);
}

.win-note.clean { color: var(--sand); font-weight: 600; }

/* Card fronts
   One block per face, keyed on the same id as the row in faces.js. Faces set
   the colour variables the cards read, so the picker swatch and the real card
   cannot disagree. Classic needs nothing: it is the default on :root. */

.board[data-face="night"],
.facesw[data-face="night"] {
  --face-bg: linear-gradient(170deg, #22303F 0%, #16212D 50%, #0E1721 100%);
  --face-ink: #E8EEF5;
  --face-red: #FF7B6B;
  --face-weave: rgba(255, 255, 255, 0.025);
  --face-edge: rgba(255, 255, 255, 0.3);
  --card-thickness: rgba(0, 0, 0, 0.4);
}

/* A colour per suit, which is a real aid to telling them apart quickly.
   Spades keep the ink colour, hearts the red. */
.board[data-face="four"] .card[data-suit="2"] .face { color: #1F6FB2; }
.board[data-face="four"] .card[data-suit="3"] .face { color: #1E7A4C; }
.facesw[data-face="four"] .sw-d { color: #1F6FB2; }
.facesw[data-face="four"] .sw-c { color: #1E7A4C; }

/* Large print: one big suit in the middle instead of the pip grid, and a
   much larger rank. The same trick the narrow-screen layout already uses. */
.board[data-face="bold"] .centre.pips {
  inset: 20% 22%;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  place-items: center;
}

.board[data-face="bold"] .pip {
  display: none;
  grid-column: 1 !important;
  grid-row: 1 !important;
}

.board[data-face="bold"] .pip:first-child {
  display: block;
  font-size: calc(var(--card-w) * 0.52);
  transform: none;
}

.board[data-face="bold"] .corner { width: calc(var(--card-w) * 0.26); }
.board[data-face="bold"] .corner b { font-size: calc(var(--card-w) * 0.34); }
.board[data-face="bold"] .corner i { font-size: calc(var(--card-w) * 0.22); }
.board[data-face="bold"] .corner b.two-char { font-size: calc(var(--card-w) * 0.27); }
.board[data-face="bold"] .corner.br { display: none; }
.board[data-face="bold"] .centre.ace { inset: 18% 18%; }
.board[data-face="bold"] .ace-glyph { font-size: calc(var(--card-w) * 0.6); }

/* Face picker swatches: a miniature card front using the same variables. */
.faces { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }

.facesw {
  appearance: none;
  width: 46px;
  height: 65px;
  padding: 0;
  border-radius: 7px;
  border: 1px solid var(--face-edge);
  background: var(--face-bg);
  color: var(--face-ink);
  cursor: pointer;
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  font-weight: 700;
  line-height: 1;
}

.facesw .sw-rank { position: absolute; top: 5px; left: 5px; font-size: 13px; }
.facesw .sw-suits { display: flex; gap: 3px; font-size: 13px; }
.facesw .sw-h { color: var(--face-red); }
.facesw .sw-d { color: var(--face-red); }
.facesw[data-face="bold"] .sw-rank { font-size: 19px; }
.facesw[data-face="bold"] .sw-suits { font-size: 17px; }
.facesw[data-face="bold"] .sw-suits span:not(:first-child) { display: none; }

.facesw.selected { outline: 2px solid var(--sand); outline-offset: 2px; }
.facesw:focus-visible { outline: 3px solid var(--sand); outline-offset: 2px; }

/* The court figures carry their own cream and gold, so on the dark face they
   would sit on it rather than in it. Dimming settles them without redrawing
   the artwork or costing legibility. */
.board[data-face="night"] .court-art { filter: brightness(0.86) saturate(0.88); }
.board[data-face="night"] .ace-art { opacity: 0.75; }

/* Table picker: plain chips rather than swatches, because a still thumbnail
   of a moving background tells you nothing. */
.scenes { flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.scenes .chip { font-size: 12.5px; padding: 7px 11px; }

/* The daily deal banner, above the table while playing today's deal. */
.daily-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  padding: 7px 14px;
  background: linear-gradient(90deg, rgba(227, 178, 97, 0.16), rgba(227, 178, 97, 0.06));
  border-bottom: 1px solid rgba(227, 178, 97, 0.4);
  font-size: 12.5px;
  z-index: 40;
}

.daily-label { font-weight: 600; color: var(--sand); white-space: nowrap; }
.daily-state { color: var(--text-dim); flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.daily-leave { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line); white-space: nowrap; }
.daily-leave:hover { border-color: var(--sand); color: var(--sand); }

/* Shown only if the clipboard refuses, so the result can still be copied. */
.share-box {
  width: 100%;
  min-height: 96px;
  margin: 0 0 10px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  resize: vertical;
}

@media (min-width: 760px) {
  .daily-bar { padding-left: 20px; padding-right: 20px; font-size: 13.5px; }
}

/* On a phone the row wraps: the games on one line, the controls on the next,
   both still under the title rather than down at the bottom edge. */
@media (max-width: 759px) {
  /* min-width lets the row shrink to the screen, and the games then scroll
     sideways inside it. Squeezing six of them into a phone's width instead
     would leave every label clipped to a few letters. */
  .switcher {
    flex: 1 1 100%;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .switcher::-webkit-scrollbar { display: none; }
  .switcher a { flex: 0 0 auto; }
  .bar-tools {
    flex: 1 1 100%;
    margin-left: 0;
    padding-top: 0;
    justify-content: space-between;
  }
  .bar-tools .tool { flex: 1 1 0; }
}
