:root {
  /* Baize (the default): the green felt of a card table. */
  --felt-1: #1f7a4d;
  --felt-2: #0f4d30;
  --felt-3: #0a3622;
  --bar: rgba(4, 22, 13, 0.42);
  --bar-line: rgba(255, 255, 255, 0.08);
  --text: #f3f7f2;
  --muted: rgba(235, 245, 236, 0.68);
  --accent: #f4c24f;
  --accent-ink: #2b2006;
  --tool: rgba(255, 255, 255, 0.08);
  --tool-hover: rgba(255, 255, 255, 0.16);
  --slot: rgba(255, 255, 255, 0.2);
  --slot-fill: rgba(0, 0, 0, 0.1);
  --hint: #ffd84d;
  --select: #74d4ff;

  --paper: #fbfaf6;
  --paper-2: #f1eee6;
  --ink: #1d221f;
  --ink-2: #59625c;
  --line: #ddd8cc;
  --primary: #1d6b45;
  --primary-ink: #ffffff;
  --danger: #b3261e;

  --texture: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.09 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  --cw: 80px;
  --ch: 112px;
  --radius: 6px;
  --move: 240ms;
  color-scheme: dark;
}

:root[data-theme="blue"] {
  --felt-1: #2a6aa8;
  --felt-2: #164577;
  --felt-3: #0e2f55;
  --bar: rgba(4, 14, 30, 0.45);
  --primary: #1f5c9a;
}

:root[data-theme="red"] {
  --felt-1: #94324a;
  --felt-2: #651a2c;
  --felt-3: #46101d;
  --bar: rgba(30, 4, 10, 0.45);
  --primary: #8a2a3b;
}

:root[data-theme="slate"] {
  --felt-1: #4f5d6d;
  --felt-2: #333e4b;
  --felt-3: #222a33;
  --bar: rgba(8, 10, 14, 0.45);
  --primary: #36506b;
}

:root[data-theme="walnut"] {
  --felt-1: #85593a;
  --felt-2: #5c3a22;
  --felt-3: #3f2614;
  --bar: rgba(24, 12, 4, 0.45);
  --primary: #6b4426;
  --texture: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='260' height='260'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.01 0.6' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.18 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

* { box-sizing: border-box; }

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

body {
  display: grid;
  grid-template: "bar tools" auto "table table" minmax(0, 1fr) / auto minmax(0, 1fr);
  background: var(--felt-2);
  background-image: var(--texture), radial-gradient(130% 100% at 50% 22%, var(--felt-1), var(--felt-2) 58%, var(--felt-3));
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] { display: none !important; }

/* --- the top bar ----------------------------------------------------------------------- */

.bar {
  grid-area: bar;
  display: flex;
  align-items: center;
  gap: 8px 20px;
  min-width: 0;
  padding: 6px 8px 6px max(10px, env(safe-area-inset-left));
  background: var(--bar);
  box-shadow: 0 1px 0 var(--bar-line);
}

.tools {
  grid-area: tools;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 6px max(10px, env(safe-area-inset-right)) 6px 8px;
  background: var(--bar);
  box-shadow: 0 1px 0 var(--bar-line);
}

.game-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 6px 10px 6px 6px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.game-title:hover { background: var(--tool); }

.brand {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: #fbf8f1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.brand svg {
  width: 20px;
  height: 20px;
  fill: #17171c;
}

.title-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.subtitle {
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.subtitle:empty { display: none; }

.chev {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.readouts {
  display: flex;
  gap: 18px;
}

.readout {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 44px;
}

.readout .lbl {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.readout .val {
  font-size: 17px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.tool {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 13px;
  border: 0;
  border-radius: 11px;
  background: var(--tool);
  cursor: pointer;
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
}

.tool:hover:not(:disabled) { background: var(--tool-hover); }
.tool:active:not(:disabled) { transform: translateY(1px); }
.tool:disabled { opacity: 0.38; cursor: default; }
.tool.icon { width: 40px; padding: 0; justify-content: center; }
.tool.on { background: var(--accent); color: var(--accent-ink); }

.tool.accent {
  background: var(--accent);
  color: var(--accent-ink);
  animation: glow 1.6s ease-in-out infinite;
}

.ico {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tools-gap { width: 6px; }
.narrow-only { display: none; }

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

/* --- the more menu --------------------------------------------------------------------- */

.menu {
  position: fixed;
  z-index: 60000;
  display: flex;
  flex-direction: column;
  min-width: 220px;
  padding: 6px;
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.menu button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 0;
  border-radius: 9px;
  background: none;
  cursor: pointer;
  font-size: 15px;
  text-align: left;
}

.menu button:hover { background: var(--paper-2); }

/* --- the table and cards ----------------------------------------------------------------- */

.table {
  grid-area: table;
  position: relative;
  min-height: 0;
  overflow: hidden;
  outline: none;
  touch-action: none;
}

.slots, .cards {
  position: absolute;
  inset: 0;
}

.slot {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: var(--cw);
  height: var(--ch);
  border: 2px solid var(--slot);
  border-radius: var(--radius);
  background: var(--slot-fill);
  color: var(--slot);
  font: 700 calc(var(--cw) * 0.34) / 1 Georgia, "Times New Roman", serif;
  text-align: center;
  white-space: pre-line;
}

.slot.cell { border-style: dashed; }
.slot.tableau { font-size: calc(var(--cw) * 0.3); }
.slot.foundation.discard { border-style: dotted; }

.slot.stock { cursor: pointer; }
.slot.stock[data-mode="recycle"]::after,
.slot.stock[data-mode="spent"]::after {
  content: "";
  width: 44%;
  height: 44%;
  border: calc(var(--cw) * 0.05) solid currentColor;
  border-radius: 50%;
  border-top-color: transparent;
  transform: rotate(45deg);
}
.slot.stock[data-mode="spent"]::after {
  border: calc(var(--cw) * 0.05) solid currentColor;
  border-radius: 50%;
  background: linear-gradient(45deg, transparent 46%, currentColor 46%, currentColor 54%, transparent 54%);
}
.slot.stock[data-mode="recycle"] { color: rgba(255, 255, 255, 0.55); }
.slot.stock[data-mode="redeal"] {
  border-style: solid;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  font: 650 calc(var(--cw) * 0.16) / 1.25 system-ui, sans-serif;
}
.slot.stock[data-mode="spent"]:empty { cursor: default; }

.slot.hint {
  border-color: var(--hint);
  box-shadow: 0 0 16px 2px rgba(255, 216, 77, 0.6);
}

.card {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--cw);
  height: var(--ch);
  transition: transform var(--move) cubic-bezier(0.2, 0.75, 0.25, 1);
  will-change: transform;
  cursor: pointer;
}

.card .face, .card .back {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background-size: 100% 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.38), 0 0 0 0.5px rgba(0, 0, 0, 0.12);
  transition: transform calc(var(--move) * 0.9) ease, box-shadow 0.15s;
}

.card .face { transform: perspective(900px) rotateY(0deg); }
.card .back { transform: perspective(900px) rotateY(180deg); background-image: var(--back); }
.card.down .face { transform: perspective(900px) rotateY(-180deg); }
.card.down .back { transform: perspective(900px) rotateY(0deg); }
.card.down { cursor: default; }

.card.dragging {
  transition: none;
  cursor: grabbing;
}

.card.dragging .face {
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.42), 0 0 0 0.5px rgba(0, 0, 0, 0.12);
}

.card.hint .face, .card.hint-to .face {
  box-shadow: 0 0 0 3px var(--hint), 0 0 18px 4px rgba(255, 216, 77, 0.65);
}

.card.hint-to .face {
  box-shadow: 0 0 0 3px #fff, 0 0 18px 4px rgba(255, 255, 255, 0.55);
}

.card.target .face { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 0 14px 2px rgba(255, 255, 255, 0.35); }
.slot.target { border-color: rgba(255, 255, 255, 0.8); background: rgba(255, 255, 255, 0.08); }

.card.selected .face {
  box-shadow: 0 0 0 3px var(--select), 0 0 16px 3px rgba(116, 212, 255, 0.6);
}

.card.shake { animation: shake 0.36s ease; }
.card.gone { visibility: hidden; }

@keyframes shake {
  20% { translate: -5px 0; }
  40% { translate: 5px 0; }
  60% { translate: -3px 0; }
  80% { translate: 2px 0; }
}

@keyframes glow {
  50% { box-shadow: 0 0 0 4px rgba(244, 194, 79, 0.35); }
}

.badge {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 9000;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font: 650 12px/20px system-ui, sans-serif;
  text-align: center;
  pointer-events: none;
}

.cursor {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 25000;
  border: 3px solid var(--hint);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

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

/* --- notices and captions ---------------------------------------------------------------- */

.notice, .caption {
  position: absolute;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 40000;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 14px;
  width: max-content;
  max-width: min(92%, 640px);
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(12, 16, 14, 0.9);
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transform: translateX(-50%);
  animation: rise 0.25s ease;
}

.caption {
  padding: 9px 14px;
  font-size: 14.5px;
  pointer-events: auto;
}

.notice-text { margin: 0; text-align: center; }

.notice-actions {
  display: flex;
  gap: 8px;
}

.notice button, .caption button {
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  cursor: pointer;
  font-weight: 600;
}

.notice button.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

@keyframes rise {
  from { opacity: 0; translate: 0 8px; }
}

.pause-cover {
  position: absolute;
  inset: 0;
  z-index: 50000;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.pause-box { text-align: center; }

/* --- dialogs --------------------------------------------------------------------------------- */

dialog {
  width: min(460px, calc(100vw - 20px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  color-scheme: light;
  -webkit-user-select: text;
  user-select: text;
}

dialog[open] {
  display: flex;
  flex-direction: column;
  animation: pop 0.2s ease;
}

dialog::backdrop {
  background: rgba(5, 12, 8, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

dialog.wide { width: min(760px, calc(100vw - 20px)); }
dialog.tall { height: min(880px, calc(100dvh - 24px)); }

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

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 8px 22px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 21px;
}

.dialog-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 6px 22px 16px;
  overflow: auto;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px 18px;
}

dialog button {
  height: 42px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
}

dialog button:hover { background: var(--paper-2); }

dialog button.primary, .pause-box button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-ink);
}

dialog button.primary:hover { filter: brightness(1.08); background: var(--primary); }
dialog button.icon { width: 40px; height: 40px; padding: 0; border: 0; background: none; font-size: 18px; }
dialog button.subtle { border-color: transparent; background: var(--paper-2); }
dialog button.danger { color: var(--danger); }

.pause-box button.big {
  height: 50px;
  padding: 0 26px;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  font-size: 17px;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pause-box .eyebrow { color: var(--text); font-size: 15px; margin-bottom: 14px; }

.fine { color: var(--ink-2); font-size: 13.5px; }
.warn { margin: 0; color: var(--danger); font-size: 13.5px; }

h3 { margin: 18px 0 8px; font-size: 15.5px; }

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: #fff;
  font: 600 12px/1.5 system-ui, sans-serif;
  text-align: center;
}

/* Choose a game */

.games-body { padding-top: 0; }

.daily-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 2px 0 6px;
  padding: 12px 14px;
  border-radius: 16px;
  background: linear-gradient(120deg, var(--primary), color-mix(in srgb, var(--primary) 70%, #000));
  color: #fff;
}

.daily-card h3 { margin: 0 0 2px; font-size: 16px; }
.daily-card .fine { margin: 0; color: rgba(255, 255, 255, 0.82); }
.daily-game { font-weight: 500; opacity: 0.9; }
.daily-text { flex: 1; min-width: 0; }

.daily-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: none;
  width: 52px;
  padding: 4px 0 6px;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.daily-month { color: var(--danger); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.daily-day { font-size: 22px; font-weight: 800; line-height: 1; }

.daily-card button.primary {
  border-color: #fff;
  background: #fff;
  color: var(--primary);
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(142px, 1fr));
  gap: 10px;
  padding-bottom: 8px;
}

.game-grid .family {
  grid-column: 1 / -1;
  margin: 12px 0 0;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

dialog button.game-tile {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  height: auto;
  padding: 8px 8px 10px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  text-align: left;
}

dialog button.game-tile[aria-selected="true"] {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);
}

.game-tile.current .tile-name::after {
  content: " · playing";
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 500;
}

.pv {
  aspect-ratio: 16 / 10;
  margin-bottom: 4px;
  padding: 6px;
  border-radius: 9px;
  background: radial-gradient(120% 120% at 50% 20%, var(--felt-1), var(--felt-2));
  overflow: hidden;
}

.pv svg { display: block; width: 100%; height: 100%; }
.pv-down { fill: #9d1d2e; stroke: #fbf8f1; stroke-width: 0.07; }
.pv-up { fill: #fffdf8; stroke: rgba(0, 0, 0, 0.25); stroke-width: 0.04; }
.pv-up.red { fill: #fff3f1; }
.pv-slot { fill: rgba(0, 0, 0, 0.12); stroke: rgba(255, 255, 255, 0.35); stroke-width: 0.05; }

.tile-name { font-size: 14.5px; font-weight: 700; }
.tile-diff { color: var(--primary); font-size: 9px; letter-spacing: 2px; }
.tile-stats { overflow: hidden; color: var(--ink-2); font-size: 12px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }

.game-detail {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 18px;
  padding: 12px 18px 16px 22px;
  border-top: 1px solid var(--line);
  background: var(--paper-2);
  border-radius: 0 0 20px 20px;
}

.detail-main { flex: 1 1 300px; min-width: 0; }
.detail-main h3 { margin: 0; font-size: 18px; }
.detail-main .fine { margin: 2px 0 6px; }
.detail-options { display: flex; flex-wrap: wrap; gap: 6px 16px; }

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.setting {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin: 8px 0;
}

.field-label { color: var(--ink-2); font-size: 13.5px; font-weight: 600; }

.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 12px;
  background: #e8e4da;
}

dialog .seg button {
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font-size: 13.5px;
}

dialog .seg button[aria-checked="true"] {
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  cursor: pointer;
}

.check input { width: 18px; height: 18px; accent-color: var(--primary); }

.number-row input {
  width: 120px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

/* Settings */

.settings-body section + section { border-top: 1px solid var(--line); margin-top: 14px; }

.swatches, .backs { display: flex; flex-wrap: wrap; gap: 10px; }

dialog button.swatch {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line);
}

dialog button.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--ink); }
.swatch.theme-green { background: #1d6b45; }
.swatch.theme-blue { background: #1e4f86; }
.swatch.theme-red { background: #7a2232; }
.swatch.theme-slate { background: #3b4654; }
.swatch.theme-walnut { background: #6b4426; }

dialog button.back-choice {
  width: 44px;
  height: 62px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background-size: 100% 100%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

dialog button.back-choice[aria-checked="true"] { box-shadow: 0 0 0 3px var(--ink); }

.stats-wrap { overflow-x: auto; }

.stats {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.stats th, .stats td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.stats th:first-child, .stats td:first-child { text-align: left; white-space: normal; }
.stats th { color: var(--ink-2); font-size: 11.5px; font-weight: 700; }

/* Help */

.rules { padding-left: 20px; }
.rules li { margin: 6px 0; }
.tips { padding-left: 20px; }
.tips li { margin: 5px 0; }
.keys { border-collapse: collapse; font-size: 13.5px; }
.keys td { padding: 4px 10px 4px 0; vertical-align: top; }

/* Win */

.win { padding-top: 24px; text-align: center; }
.win h2 { margin: 2px 0 6px; font-size: 30px; }

.win-stats {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: center;
  gap: 4px 18px;
  margin: 14px 0 6px;
}

.win-stats dt { color: var(--ink-2); text-align: right; }
.win-stats dd { margin: 0; font-weight: 700; text-align: left; font-variant-numeric: tabular-nums; }
.win-notes { margin: 8px 0 0; padding: 0; list-style: none; color: var(--primary); font-weight: 700; }

/* ?debug=faces */

.face-sheet {
  position: fixed;
  inset: 0;
  z-index: 70000;
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 6px;
  padding: 10px;
  overflow: auto;
  background: #18402c;
}

.face-sample {
  aspect-ratio: 5 / 7;
  background-size: 100% 100%;
}

/* --- narrower screens: the toolbar moves to the bottom ---------------------------------------- */

@media (max-width: 820px) {
  body {
    grid-template: "bar" auto "table" minmax(0, 1fr) "tools" auto / minmax(0, 1fr);
  }

  .bar { justify-content: space-between; padding-right: max(10px, env(safe-area-inset-right)); }
  .tools {
    justify-content: space-around;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    box-shadow: 0 -1px 0 var(--bar-line);
  }
  .tool { flex-direction: column; gap: 2px; height: 50px; min-width: 58px; padding: 0 8px; background: none; font-size: 11.5px; }
  .tool.accent { background: var(--accent); }
  .wide-only { display: none; }
  .narrow-only { display: inline-flex; }
  .readouts { gap: 12px; }
  .readout { min-width: 36px; }
  .readout .val { font-size: 15px; }
  #title { font-size: 16.5px; }
  .brand { width: 30px; height: 30px; }
}

@media (max-width: 600px) {
  #detail-blurb { display: none; }
  .game-detail { gap: 6px 12px; padding: 10px 14px 12px; }
  .game-detail .setting { margin: 4px 0; }
  .game-detail .check { margin: 4px 0; }
  #detail-stats { margin: 2px 0 0; font-size: 12.5px; }
  dialog .seg button { padding: 0 10px; }
  .detail-actions button { height: 40px; }
  .daily-card { padding: 10px 12px; }
}

@media (max-width: 420px) {
  .readouts { gap: 8px; }
  .readout .lbl { font-size: 9.5px; }
  .game-title { gap: 7px; padding-right: 4px; }
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dialog-body { padding-left: 16px; padding-right: 16px; }
  .game-detail { padding-left: 16px; }
}

/* Phones held sideways: the toolbar becomes a column on the right. */
@media (max-height: 500px) and (orientation: landscape) {
  body {
    grid-template: "bar tools" auto "table tools" minmax(0, 1fr) / minmax(0, 1fr) auto;
  }

  .bar { padding-top: 3px; padding-bottom: 3px; }
  .tools {
    flex-direction: column;
    justify-content: flex-start;
    padding: 6px max(8px, env(safe-area-inset-right)) 6px 6px;
    box-shadow: -1px 0 0 var(--bar-line);
  }
  .tool { flex-direction: column; gap: 1px; width: 62px; height: 46px; min-width: 0; padding: 0; background: none; font-size: 11px; }
  .tool.accent { background: var(--accent); }
  .wide-only { display: none; }
  .narrow-only { display: inline-flex; }
  .brand { width: 26px; height: 26px; }
  #title { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  .tool.accent, .notice, .caption, dialog[open] { animation: none; }
}

.pile-label {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 9000;
  width: var(--cw);
  color: var(--muted);
  font: 650 11.5px/1 system-ui, sans-serif;
  text-align: center;
  pointer-events: none;
}
