/* Layout: header (brand, difficulty, clock) / felt table filling the screen / floating control dock.
   One deliberate look: deep green felt, ivory cards, navy and gold backs. */
:root {
  --felt-1: #1f6e50;
  --felt-2: #11483a;
  --felt-3: #072519;
  --ink: #17191c;
  --red: #c1272d;
  --paper: #fffdf7;
  --paper-2: #f3eee2;
  --back-1: #2b4576;
  --back-2: #141f3b;
  --gold: #dcb96f;
  --accent: #f3d58c;
  --ui-glass: rgba(4, 22, 15, 0.42);
  --ui-line: rgba(255, 255, 255, 0.1);
  --ui-text: #eef5f0;
  --ui-muted: rgba(238, 245, 240, 0.64);
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease-out: cubic-bezier(0.22, 0.8, 0.26, 1);
  --move: 280ms;
  --cw: 100px;
  --ch: 140px;
  --r: 8px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.22) transparent; }
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  background: var(--felt-3);
  color: var(--ui-text);
  font: 15px/1.4 var(--body);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
/* The game fills exactly one screen; rules and links sit below it, one scroll away. */
.stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100svh;
  position: relative;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(130% 95% at 50% 32%, var(--felt-1) 0%, var(--felt-2) 52%, var(--felt-3) 100%);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.22;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

button { font: inherit; color: inherit; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Header ---------- */
.bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding-top: max(12px, env(safe-area-inset-top, 0px));
  padding-bottom: 8px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  position: relative;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-weight: 600;
  font-size: 21px;
  letter-spacing: 0.005em;
  min-width: 0;
}
.brand { position: relative; }
.game-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: none;
  padding: 4px 10px 4px 4px;
  margin-left: -4px;
  border-radius: 14px;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: background 0.2s;
}
.game-switch:hover { background: rgba(255, 255, 255, 0.07); }
.game-switch .chev { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; opacity: 0.7; transition: transform 0.3s var(--ease-out); }
.game-switch[aria-expanded="true"] .chev { transform: rotate(180deg); }
.game-switch:hover .mark { transform: rotate(-12deg) translateY(-1px); }
.mark { transition: transform 0.35s cubic-bezier(0.3, 1.5, 0.5, 1); }
.game-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: -4px;
  z-index: 100;
  width: min(320px, calc(100vw - 32px));
  padding: 6px;
  border-radius: 18px;
  background: rgba(10, 30, 22, 0.94);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: inset 0 0 0 1px var(--ui-line), 0 20px 50px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--body);
  animation: menuIn 0.28s cubic-bezier(0.2, 1.2, 0.4, 1) both;
  transform-origin: top left;
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-6px) scale(0.96); } }
.game-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--ui-text);
  text-decoration: none;
  transition: background 0.15s;
}
.game-menu a:hover, .game-menu a:focus-visible { background: rgba(255, 255, 255, 0.08); outline: none; }
.game-menu a[aria-current="page"] { background: rgba(243, 213, 140, 0.12); }
.game-menu b { display: block; font-size: 15px; font-weight: 600; }
.game-menu small { display: block; font-size: 12.5px; color: var(--ui-muted); line-height: 1.35; margin-top: 1px; }
.gm-ico {
  flex: none;
  width: 34px;
  height: 44px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 20px;
  color: var(--ink);
  background: linear-gradient(160deg, var(--paper), var(--paper-2));
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.mark {
  width: 30px;
  height: 36px;
  border-radius: 6px;
  background: linear-gradient(160deg, var(--paper), var(--paper-2));
  color: var(--ink);
  display: grid;
  place-items: center;
  font-size: 19px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15), 0 3px 8px rgba(0, 0, 0, 0.35);
  transform: rotate(-6deg);
  flex: none;
}

.levels {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  box-shadow: inset 0 0 0 1px var(--ui-line), inset 0 2px 6px rgba(0, 0, 0, 0.25);
}
.levels button {
  position: relative;
  z-index: 1;
  border: 0;
  background: none;
  padding: 9px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ui-muted);
  cursor: pointer;
  transition: color 0.25s;
  white-space: nowrap;
}
.levels button:hover { color: var(--ui-text); }
.levels button[aria-checked="true"] { color: var(--ink); }
.levels .thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / 3);
  border-radius: 999px;
  background: linear-gradient(180deg, #fffefb, #efe9db);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35), inset 0 -1px 0 rgba(0, 0, 0, 0.08);
  transform: translateX(calc(var(--i, 0) * 100%));
  transition: transform 0.42s cubic-bezier(0.34, 1.36, 0.5, 1);
}

.meta {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ui-muted);
  font-variant-numeric: tabular-nums;
}
.meta-item { display: inline-flex; align-items: center; gap: 6px; }
.meta svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: 0.8; }

/* ---------- Table ---------- */
#table {
  position: relative;
  z-index: 0;
  isolation: isolate; /* card stacking stays inside the table, so menus and rails sit above it */
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}
#table.ready { opacity: 1; }

.slot {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cw);
  height: var(--ch);
  border-radius: var(--r);
  background: rgba(0, 0, 0, 0.13);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.13), inset 0 2px 8px rgba(0, 0, 0, 0.18);
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.2);
  font-family: var(--display);
  font-size: calc(var(--cw) * 0.44);
  line-height: 1;
  transition: box-shadow 0.2s, background 0.2s;
}
.slot.waste { visibility: hidden; }
.slot.stock { cursor: pointer; }
.slot.stock svg { width: 42%; height: 42%; fill: none; stroke: rgba(255, 255, 255, 0.45); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: opacity 0.3s; }
.slot.stock.can-recycle svg { opacity: 1; }
.slot.stock.can-recycle:hover { background: rgba(255, 255, 255, 0.06); }
.slot.col { color: rgba(255, 255, 255, 0.1); font-size: calc(var(--cw) * 0.36); }
.slot.cell svg { width: 30%; height: 30%; fill: none; stroke: rgba(255, 255, 255, 0.18); stroke-width: 1.6; }
.mark-red { color: var(--red); }
.game-spider .slot.found { font-size: calc(var(--cw) * 0.34); color: rgba(255, 255, 255, 0.12); }
.game-spider .slot.stock.empty { opacity: 0.5; }
.game-spider .levels button { padding-left: 16px; padding-right: 16px; }
.deal-pill {
  justify-self: center;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  box-shadow: inset 0 0 0 1px var(--ui-line);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 14px;
  color: var(--ui-text);
}
#deal-no { display: inline-block; min-width: 7ch; text-align: center; }
.deal-label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ui-muted); }
#stats-facts { grid-template-columns: repeat(3, 1fr); }
.slot.target {
  background: rgba(243, 213, 140, 0.1);
  box-shadow: inset 0 0 0 2px rgba(243, 213, 140, 0.85), 0 0 22px rgba(243, 213, 140, 0.3);
}
.slot.hint { animation: hintPulse 0.9s ease-in-out 2; }

/* ---------- Cards ---------- */
.card {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cw);
  height: var(--ch);
  will-change: transform;
  touch-action: none;
  perspective: calc(var(--cw) * 7);
  translate: 0 0;
  transition: translate 0.22s var(--ease-out);
}
.card.movable { cursor: pointer; }
.card.dragging { cursor: grabbing; }
@media (hover: hover) and (pointer: fine) {
  #table:not(.is-dragging) .card.movable:hover { translate: 0 -3px; }
  #table:not(.is-dragging) .card.movable:hover .front {
    box-shadow: 0 0 0 1px rgba(20, 30, 25, 0.16), 0 4px 10px rgba(0, 0, 0, 0.22), 0 1px 2px rgba(0, 0, 0, 0.18);
  }
}

.inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}
.card.down .inner { transform: rotateY(180deg); }

.face {
  position: absolute;
  inset: 0;
  border-radius: var(--r);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}
.front {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 18%),
    linear-gradient(165deg, var(--paper) 0%, var(--paper) 45%, var(--paper-2) 100%);
  color: var(--ink);
  box-shadow: 0 0 0 1px rgba(20, 30, 25, 0.16), 0 1px 1px rgba(0, 0, 0, 0.16), 0 2px 5px rgba(0, 0, 0, 0.16);
  transition: box-shadow 0.25s var(--ease-out);
}
.back { transition: box-shadow 0.25s var(--ease-out); }
.card.red .front { color: var(--red); }
.card.flying .front,
.card.flying .back {
  box-shadow: 0 0 0 1px rgba(20, 30, 25, 0.16), 0 10px 22px rgba(0, 0, 0, 0.3), 0 3px 8px rgba(0, 0, 0, 0.18);
}
.card.dragging .front,
.card.dragging .back {
  box-shadow: 0 0 0 1px rgba(20, 30, 25, 0.16), 0 22px 40px rgba(0, 0, 0, 0.38), 0 6px 14px rgba(0, 0, 0, 0.22);
}
.sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, 0.85) 50%, transparent 65%);
  background-size: 260% 100%;
  background-position: 140% 0;
}

.ripple {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cw);
  height: var(--ch);
  border-radius: var(--r);
  pointer-events: none;
  z-index: 900;
  box-shadow: 0 0 0 2px rgba(243, 213, 140, 0.9), 0 0 26px rgba(243, 213, 140, 0.55);
}

.fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4800;
}

.idx {
  position: absolute;
  display: flex;
  align-items: center;
  gap: calc(var(--cw) * 0.025);
  line-height: 1;
  font-family: var(--display);
  font-weight: 700;
}
.idx.tl { top: calc(var(--cw) * 0.07); left: calc(var(--cw) * 0.08); }
.idx.br { bottom: calc(var(--cw) * 0.07); right: calc(var(--cw) * 0.08); transform: rotate(180deg); }
.idx .r { font-size: calc(var(--cw) * 0.3); letter-spacing: -0.05em; }
.idx .s { font-size: calc(var(--cw) * 0.23); font-family: var(--body); }
.idx.br .r { font-size: calc(var(--cw) * 0.2); }
.idx.br .s { font-size: calc(var(--cw) * 0.16); }

/* Small cards (phones): a bigger corner index, since that's what you read in a column. */
#table.compact .idx.tl { top: calc(var(--cw) * 0.05); left: calc(var(--cw) * 0.07); gap: 0; }
#table.compact .idx .r { font-size: calc(var(--cw) * 0.36); letter-spacing: -0.06em; }
#table.compact .idx .s { font-size: calc(var(--cw) * 0.3); }
#table.compact .idx.br { display: none; }
#table.compact .pip { top: auto; bottom: 8%; font-size: calc(var(--cw) * 0.56); }
#table.compact .pip.ace { font-size: calc(var(--cw) * 0.7); }
#table.compact .court { left: 12%; right: 12%; top: auto; bottom: 7%; height: 48%; box-shadow: none; }
#table.compact .court-l { font-size: calc(var(--cw) * 0.4); }
#table.compact .court-s { display: none; }

.pip {
  position: absolute;
  left: 0;
  right: 0;
  top: 32%;
  text-align: center;
  font-size: calc(var(--cw) * 0.62);
  line-height: 1;
  font-family: var(--body);
}
.pip.ace { top: 26%; font-size: calc(var(--cw) * 0.84); }
.court {
  position: absolute;
  left: 19%;
  right: 19%;
  top: 31%;
  bottom: 15%;
  border-radius: calc(var(--r) * 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2%;
  background: rgba(23, 25, 28, 0.05);
  box-shadow: inset 0 0 0 1px currentColor;
}
.card.red .court { background: rgba(193, 39, 45, 0.06); }
.court-l { font-family: var(--display); font-weight: 700; font-size: calc(var(--cw) * 0.42); line-height: 1; }
.court-s { font-family: var(--body); font-size: calc(var(--cw) * 0.2); line-height: 1; }

.back {
  transform: rotateY(180deg);
  background:
    repeating-linear-gradient(45deg, rgba(220, 185, 111, 0.17) 0 1px, transparent 1px calc(var(--cw) * 0.085)),
    repeating-linear-gradient(-45deg, rgba(220, 185, 111, 0.17) 0 1px, transparent 1px calc(var(--cw) * 0.085)),
    radial-gradient(120% 90% at 50% 25%, var(--back-1), var(--back-2));
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 1px 1px rgba(0, 0, 0, 0.2), 0 2px 5px rgba(0, 0, 0, 0.2);
}
.back::before {
  content: "";
  position: absolute;
  inset: calc(var(--cw) * 0.065);
  border-radius: calc(var(--r) * 0.55);
  box-shadow: inset 0 0 0 1px rgba(220, 185, 111, 0.6), 0 0 0 calc(var(--cw) * 0.065) rgba(255, 255, 255, 0.04);
}
.back::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--cw) * 0.24);
  height: calc(var(--cw) * 0.24);
  transform: translate(-50%, -50%) rotate(45deg);
  border: 1px solid rgba(220, 185, 111, 0.85);
  background: radial-gradient(circle, rgba(220, 185, 111, 0.55) 0 22%, transparent 24%), var(--back-2);
}

/* Drop target and hint glows */
.card.target .front { box-shadow: 0 0 0 2px var(--accent), 0 0 20px rgba(243, 213, 140, 0.55); }
.card.hint .front,
.card.hint .back { animation: hintPulse 0.9s ease-in-out 2; }
@keyframes hintPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(20, 30, 25, 0.16), 0 2px 5px rgba(0, 0, 0, 0.16); }
  50% { box-shadow: 0 0 0 3px var(--accent), 0 0 26px rgba(243, 213, 140, 0.75); }
}

/* ---------- Dock ---------- */
.dock {
  display: flex;
  justify-content: center;
  padding-top: 6px;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  position: relative;
  z-index: 10;
}
.dock-inner {
  display: flex;
  gap: 4px;
  padding: 6px;
  border-radius: 22px;
  background: var(--ui-glass);
  box-shadow: inset 0 0 0 1px var(--ui-line), 0 10px 30px rgba(0, 0, 0, 0.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
}
.dock button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 72px;
  padding: 9px 12px 8px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--ui-text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.12s, opacity 0.2s;
}
.dock button:hover { background: rgba(255, 255, 255, 0.08); }
.dock button:active { transform: scale(0.95); }
.dock button:disabled { opacity: 0.35; cursor: default; background: transparent; }
.dock button.primary {
  background: linear-gradient(180deg, #fffefb, #ece5d5);
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3), inset 0 -1px 0 rgba(0, 0, 0, 0.08);
  min-width: 96px;
}
.dock button.primary:hover { background: linear-gradient(180deg, #ffffff, #f2ecdf); }
.dock svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dock button.tap svg { animation: tapPop 0.42s cubic-bezier(0.3, 1.6, 0.5, 1); }
#btn-new.tap svg { animation: spinOnce 0.75s cubic-bezier(0.35, 0.9, 0.3, 1); }
#btn-undo.tap svg { animation: undoKick 0.5s cubic-bezier(0.3, 1.4, 0.5, 1); }
#btn-hint.tap svg { animation: glowBulb 0.7s ease-out; }
@keyframes tapPop { 0% { transform: scale(1); } 35% { transform: scale(0.78); } 100% { transform: scale(1); } }
@keyframes spinOnce { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes undoKick { 0% { transform: none; } 40% { transform: rotate(-40deg) translateX(-2px); } 100% { transform: none; } }
@keyframes glowBulb { 0% { filter: none; transform: scale(1); } 40% { filter: drop-shadow(0 0 6px rgba(243, 213, 140, 0.95)); transform: scale(1.15); color: var(--accent); } 100% { filter: none; transform: scale(1); } }

#btn-sound .ico-off { display: none; }
#btn-sound[aria-pressed="false"] .ico-on { display: none; }
#btn-sound[aria-pressed="false"] .ico-off { display: block; }
#btn-sound[aria-pressed="false"] { color: var(--ui-muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 12px);
  max-width: calc(100% - 32px);
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(8, 18, 14, 0.82);
  box-shadow: inset 0 0 0 1px var(--ui-line), 0 10px 30px rgba(0, 0, 0, 0.35);
  color: var(--ui-text);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.4s var(--ease-out);
  z-index: 6000;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Panels ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: grid;
  place-items: center;
  padding-block: 16px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: rgba(3, 14, 9, 0.45);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.35s ease both;
}
.panel {
  width: min(420px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 30px 26px 24px;
  border-radius: 24px;
  background: linear-gradient(170deg, #fffefa, #f1ebdd);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 0, 0, 0.08);
  animation: popIn 0.55s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}
.panel-suits { display: flex; justify-content: center; gap: 10px; font-size: 18px; color: var(--ink); opacity: 0.85; margin-bottom: 8px; }
.panel-suits .r { color: var(--red); }
.panel h2 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 40px; line-height: 1.1; letter-spacing: -0.01em; }
.panel-sub { margin: 6px 0 0; color: #6a6e66; font-size: 14px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 22px 0 18px; }
.fact { padding: 12px 6px; border-radius: 14px; background: rgba(17, 72, 58, 0.06); }
.fact b { display: block; font-family: var(--display); font-weight: 700; font-size: 24px; font-variant-numeric: tabular-nums; }
.fact span { display: block; margin-top: 2px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: #6a6e66; }
.record { margin: -4px 0 16px; font-weight: 600; color: #8a6312; }
.btn {
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 15px 22px;
  background: linear-gradient(180deg, #1c6c4e, #11483a);
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(17, 72, 58, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: transform 0.12s, filter 0.2s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(0.98); }
.btn-quiet { background: rgba(17, 72, 58, 0.08); color: var(--ink); box-shadow: none; }
.stats-wrap { overflow-x: auto; margin: 20px 0; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.stats-table th, .stats-table td { padding: 9px 6px; text-align: right; border-bottom: 1px solid rgba(0, 0, 0, 0.07); }
.stats-table th:first-child, .stats-table td:first-child { text-align: left; }
.stats-table thead th { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: #6a6e66; }
.stats-table tbody th { font-weight: 600; }
.stats-table tr:last-child td, .stats-table tr:last-child th { border-bottom: 0; }

/* ---------- Daily ---------- */
.levels.none .thumb { opacity: 0; transform: translateX(calc(var(--i, 0) * 100%)) scale(0.85); }
.levels .thumb { transition: transform 0.42s cubic-bezier(0.34, 1.36, 0.5, 1), opacity 0.25s; }
.levels.none button { color: var(--ui-muted); }
.ico-wrap { position: relative; display: block; width: 22px; height: 22px; }
.ico-wrap svg { display: block; }
.badge {
  position: absolute;
  top: -2px;
  right: -4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(6, 30, 21, 0.9), 0 0 10px rgba(243, 213, 140, 0.8);
  transform: scale(0);
  transition: transform 0.3s cubic-bezier(0.34, 1.6, 0.5, 1);
}
#btn-daily.todo .badge { transform: scale(1); }
#btn-daily.active { background: rgba(243, 213, 140, 0.14); color: var(--accent); }

.eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: #8a6312; }
.streak { display: flex; align-items: baseline; justify-content: center; gap: 8px; margin: 22px 0 4px; }
.streak svg { width: 26px; height: 26px; align-self: center; fill: #e0892b; }
.streak b { font-family: var(--display); font-weight: 700; font-size: 52px; line-height: 1; font-variant-numeric: tabular-nums; }
.streak span { font-size: 15px; font-weight: 600; color: #6a6e66; }
.week { list-style: none; display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 16px 0 10px; padding: 0; }
.week li { display: flex; flex-direction: column; align-items: center; gap: 6px; animation: dayIn 0.5s cubic-bezier(0.3, 1.5, 0.5, 1) both; animation-delay: calc(var(--d, 0) * 45ms + 150ms); }
@keyframes dayIn { from { opacity: 0; transform: translateY(8px) scale(0.7); } }
#win { background: rgba(3, 14, 9, 0.3); -webkit-backdrop-filter: blur(1.5px); backdrop-filter: blur(1.5px); }
.fact b { display: block; }
.week .dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(17, 72, 58, 0.07);
  box-shadow: inset 0 0 0 1px rgba(17, 72, 58, 0.1);
}
.week li.won .dot { background: linear-gradient(180deg, #1c6c4e, #11483a); box-shadow: 0 3px 8px rgba(17, 72, 58, 0.35); }
.week li.today .dot { box-shadow: inset 0 0 0 2px #c9a24b; }
.week li.today.won .dot { box-shadow: 0 0 0 2px #fffaf0, 0 0 0 4px #c9a24b; }
.week .dot svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.week .day { font-size: 12px; font-weight: 600; color: #6a6e66; }
.week li.today .day { color: var(--ink); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.streak-note { margin: 0 0 18px; font-size: 13px; color: #6a6e66; text-wrap: balance; }
.streak-note b { color: var(--ink); }
.daily-status { margin: -6px 0 16px; font-weight: 600; color: #11483a; }
.btn-gap { margin-top: 8px; }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(18px) scale(0.94); } }

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
  .bar { grid-template-columns: auto 1fr auto; gap: 10px; }
  .brand-name { display: none; }
  .levels { justify-self: center; }
  .levels button { padding: 8px 13px; font-size: 13px; }
  .meta { gap: 10px; font-size: 13px; }
  .meta svg { display: none; }
  .dock button { min-width: 58px; padding: 8px 8px 7px; font-size: 11px; }
  .dock button.primary { min-width: 82px; }
}
@media (max-width: 480px) {
  .dock-inner { gap: 2px; padding: 5px; }
  .dock button { min-width: 48px; padding: 8px 5px 7px; }
  .dock button.primary { min-width: 74px; }
}
@media (max-width: 400px) {
  .levels button { padding: 8px 10px; }
  .meta { flex-direction: column; gap: 0; align-items: flex-end; }
  .dock button { min-width: 0; flex: 1; }
  .dock-inner { width: 100%; }
}

/* ---------- Game menu footer links, no-JS note ---------- */
.gm-foot { display: flex; gap: 4px; margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--ui-line); }
.game-menu .gm-foot a { flex: 1; justify-content: center; padding: 8px; font-size: 13px; color: var(--ui-muted); }
.game-menu .gm-foot a:hover { color: var(--ui-text); }
.noscript { position: fixed; inset: auto 16px 50% 16px; z-index: 20; margin: 0; padding: 16px 20px; border-radius: 16px; background: var(--paper); color: var(--ink); text-align: center; }
.noscript a { color: #11483a; }

/* ---------- Content pages (How to play, Privacy, 404) ---------- */
body.page {
  display: block;
  height: auto;
  min-height: 100vh;
  overflow: auto;
  -webkit-user-select: text;
  user-select: text;
}
.page-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding-block: max(20px, env(safe-area-inset-top, 0px)) 40px;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 28px; }
.page-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ui-text); text-decoration: none; font-family: var(--display); font-weight: 600; font-size: 21px; }
.page-nav { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(0, 0, 0, 0.28); box-shadow: inset 0 0 0 1px var(--ui-line); }
.page-nav a, .toc a { color: var(--ui-text); text-decoration: none; padding: 7px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.page-nav a:hover, .toc a:hover { background: rgba(255, 255, 255, 0.1); }
.prose {
  background: linear-gradient(170deg, #fffefa, #f3eee2);
  color: var(--ink);
  border-radius: 24px;
  padding: clamp(22px, 5vw, 44px);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.35);
  line-height: 1.65;
  font-size: 16px;
}
.prose h1 { font-family: var(--display); font-weight: 700; font-size: clamp(32px, 6vw, 44px); line-height: 1.1; margin: 0 0 12px; text-wrap: balance; }
.prose h2 { font-family: var(--display); font-weight: 700; font-size: 28px; margin: 36px 0 8px; scroll-margin-top: 16px; }
.prose h3 { font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: #8a6312; margin: 18px 0 4px; }
.prose p, .prose ul { margin: 0 0 12px; max-width: 64ch; }
.prose ul { padding-left: 20px; }
.prose li { margin: 4px 0; }
.prose .lede { font-size: 18px; color: #4f554d; }
.prose a { color: #11483a; }
.prose kbd { font: 600 12px var(--body); padding: 2px 6px; border-radius: 6px; background: #fff; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15), 0 1px 0 rgba(0, 0, 0, 0.1); }
.toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 8px; }
.toc a { color: #11483a; background: rgba(17, 72, 58, 0.08); }
.toc a:hover { background: rgba(17, 72, 58, 0.15); }
.prose a.play {
  display: inline-block;
  margin-top: 4px;
  padding: 11px 20px;
  border-radius: 14px;
  background: linear-gradient(180deg, #1c6c4e, #11483a);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 6px 16px rgba(17, 72, 58, 0.3);
}

.page-404 { display: grid; place-items: center; padding: 20px; }
.lost { text-align: center; max-width: 440px; }
.lost-cards { display: flex; justify-content: center; gap: 10px; margin-bottom: 22px; }
.lost-cards span {
  width: 74px;
  height: 104px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 46px;
  color: var(--ink);
  background: linear-gradient(165deg, var(--paper), var(--paper-2));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
.lost-cards span:nth-child(1) { transform: rotate(-8deg) translateY(6px); }
.lost-cards span:nth-child(3) { transform: rotate(8deg) translateY(6px); }
.lost-cards .r { color: var(--red); }
.lost h1 { font-family: var(--display); font-size: 30px; margin: 0 0 8px; }
.lost p { color: var(--ui-muted); margin: 0 0 18px; }
.lost-links { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.lost-links a { padding: 11px 18px; border-radius: 14px; background: var(--paper); color: var(--ink); font-weight: 600; text-decoration: none; }

/* ---------- Phones held sideways: header and controls become side rails ---------- */
@media (orientation: landscape) and (max-height: 540px) {
  .stage {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: minmax(0, 1fr);
  }
  .bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-block: max(10px, env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-bottom, 0px));
    padding-left: max(10px, env(safe-area-inset-left, 0px));
    padding-right: 4px;
    min-width: 0;
  }
  .brand-name, .game-switch .chev { display: none; }
  .game-switch { padding: 4px; margin: 0; }
  .game-menu { top: 0; left: calc(100% + 8px); }

  .levels { grid-template-columns: 1fr; grid-template-rows: repeat(3, 1fr); border-radius: 18px; }
  .levels button { padding: 9px 10px; font-size: 12px; border-radius: 14px; }
  .levels .thumb {
    left: 4px;
    right: 4px;
    width: auto;
    height: calc((100% - 8px) / 3);
    border-radius: 14px;
    transform: translateY(calc(var(--i, 0) * 100%));
  }
  .levels.none .thumb { transform: translateY(calc(var(--i, 0) * 100%)) scale(0.85); }

  .deal-pill { flex-direction: column; align-items: center; gap: 2px; padding: 8px 10px; border-radius: 14px; font-size: 12px; }
  .meta { flex-direction: column; align-items: center; gap: 2px; font-size: 12px; }
  .meta svg { display: none; }

  .dock {
    align-items: center;
    padding-block: max(8px, env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-bottom, 0px));
    padding-left: 4px;
    padding-right: max(10px, env(safe-area-inset-right, 0px));
  }
  .dock-inner { flex-direction: column; width: auto; gap: 2px; padding: 5px; border-radius: 18px; }
  .dock button, .dock button.primary { min-width: 58px; flex: none; padding: 6px 6px 5px; gap: 2px; font-size: 10px; border-radius: 13px; }
  .dock svg, .ico-wrap { width: 20px; height: 20px; }

  .toast { bottom: max(14px, env(safe-area-inset-bottom, 0px)); }
}

/* ---------- Short screens: compact panels so they never need scrolling ---------- */
@media (max-height: 540px) {
  .panel { padding: 18px 20px 16px; border-radius: 20px; }
  .panel h2 { font-size: 28px; }
  .panel-suits { margin-bottom: 2px; font-size: 14px; }
  .facts { margin: 12px 0 12px; }
  .fact { padding: 8px 4px; }
  .fact b { font-size: 20px; }
  .btn { padding: 12px 18px; }
  .streak { margin: 10px 0 0; }
  .streak b { font-size: 40px; }
  .week { margin: 8px 0 6px; }
  .week .dot { width: 28px; height: 28px; }
  .streak-note { margin-bottom: 10px; }
  .stats-wrap { margin: 10px 0; }
  .stats-table th, .stats-table td { padding: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --move: 1ms; }
  .inner, .levels .thumb { transition-duration: 1ms !important; }
  .overlay, .panel { animation: none; }
}

/* ---------- More games: menu, marks, piles ---------- */
.game-menu { max-height: calc(100dvh - 90px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.game-menu a { padding: 8px 12px; }
.gm-ico { width: 30px; height: 40px; }
.gm-ico.gm-red, .mark.mark-red { color: var(--red); }
.gm-rank, .mark-rank { font-family: var(--display); font-weight: 700; }
.gm-rank { font-size: 19px; }
.mark-rank { font-size: 18px; }
.gm-foot a { white-space: nowrap; }

.card.selected { translate: 0 calc(var(--ch) * -0.06); }
.card.selected .front { box-shadow: 0 0 0 2px rgba(243, 213, 140, 0.95), 0 0 18px rgba(243, 213, 140, 0.55), 0 8px 18px rgba(0, 0, 0, 0.3); }
.slot.discard { color: rgba(255, 255, 255, 0.12); }
.slot.stock { position: absolute; }
.slot.stock .passes {
  position: absolute; left: 0; right: 0; bottom: 10%;
  text-align: center; font: 600 calc(var(--cw) * 0.13) var(--body); color: rgba(255, 255, 255, 0.55);
}
.slot.stock.can-recycle svg { opacity: 1; }
.slot.stock.spent { opacity: 0.45; cursor: default; }
.game-yukon .slot.col, .game-golf .slot.col { font-family: var(--display); }

/* ---------- Content pages: rules and history ---------- */
.page-nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.14); }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: #6b716a; margin: 0 0 14px; }
.crumbs a { color: #11483a; text-decoration: none; font-weight: 600; }
.crumbs a:hover { text-decoration: underline; }
.crumbs [aria-hidden] { opacity: 0.5; }
.facts-box { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 20px 0; padding: 0; }
.facts-box div { padding: 12px 14px; border-radius: 14px; background: rgba(17, 72, 58, 0.06); box-shadow: inset 0 0 0 1px rgba(17, 72, 58, 0.1); }
.facts-box dt { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: #8a6312; }
.facts-box dd { margin: 2px 0 0; font-weight: 600; font-size: 14.5px; line-height: 1.35; }
.prose h3.q { font-size: 17px; letter-spacing: 0; text-transform: none; color: var(--ink); margin: 20px 0 4px; }
.play-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.play-row a:not(.play) { font-weight: 600; }
.related { margin-top: 40px; padding-top: 24px; border-top: 1px solid rgba(17, 72, 58, 0.14); }
.related h2 { font-size: 22px; margin-top: 26px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.prose .chips a { padding: 7px 14px; border-radius: 999px; background: rgba(17, 72, 58, 0.08); text-decoration: none; font-weight: 600; font-size: 14px; }
.prose .chips a:hover { background: rgba(17, 72, 58, 0.15); }
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin: 22px 0 10px; }
.prose a.hub-card {
  display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 16px; text-decoration: none; color: var(--ink);
  background: #fff; box-shadow: 0 0 0 1px rgba(17, 72, 58, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s;
}
.prose a.hub-card:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px rgba(17, 72, 58, 0.2), 0 10px 22px rgba(0, 0, 0, 0.1); }
.hub-card b { display: block; font-size: 15.5px; }
.hub-card small { display: block; font-size: 13px; line-height: 1.4; color: #5c625b; margin-top: 2px; }
.hub-card .gm-ico { box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.15); }
.page-foot { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; font-size: 14px; color: var(--ui-muted); }
.page-foot a { color: var(--ui-text); }
.foot-games, .foot-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.foot-games span { font-weight: 600; }
.foot-meta span { margin-left: auto; }

/* Partly covered cards show only their corner index, so big pips don't peek out between rows. */
.card .pip, .card .court { transition: opacity 0.3s ease; }
.card.covered .pip, .card.covered .court { opacity: 0; }

/* ---------- Table and card-back themes (chosen in the game menu) ---------- */
html[data-felt="midnight"] { --felt-1: #2a5a96; --felt-2: #15315c; --felt-3: #081731; }
html[data-felt="burgundy"] { --felt-1: #84303f; --felt-2: #521825; --felt-3: #280a11; }
html[data-felt="slate"] { --felt-1: #55616c; --felt-2: #2c343b; --felt-3: #13171b; }
html[data-back="crimson"] { --back-1: #9a3040; --back-2: #430f19; }
html[data-back="forest"] { --back-1: #2f7052; --back-2: #0f2e1e; }
html[data-back="charcoal"] { --back-1: #525862; --back-2: #1a1c21; }
body:not(.page)::before { opacity: 0; transition: opacity 0.45s ease; }
html.look-ready body:not(.page)::before { opacity: 1; }
.gm-look { display: grid; gap: 8px; margin-top: 4px; padding: 10px 12px 6px; border-top: 1px solid var(--ui-line); }
.look-row { display: flex; align-items: center; gap: 10px; }
.look-row > span { width: 44px; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ui-muted); }
.look-row button {
  width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, var(--sw), var(--sw2));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25), 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.25s cubic-bezier(0.3, 1.5, 0.5, 1), box-shadow 0.2s;
}
.look-row.backs button { width: 24px; height: 32px; border-radius: 5px; }
.look-row button:hover { transform: scale(1.12); }
.look-row button[aria-checked="true"] { box-shadow: 0 0 0 2px rgba(10, 30, 22, 1), 0 0 0 4px var(--accent), 0 2px 6px rgba(0, 0, 0, 0.4); }

/* ---------- "No more moves" helper ---------- */
.stuck {
  position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom, 0px)); z-index: 4000;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center;
  max-width: calc(100% - 24px); padding: 10px 10px 10px 18px; border-radius: 20px;
  background: rgba(8, 18, 14, 0.9); color: var(--ui-text); font-size: 14px; font-weight: 500;
  box-shadow: inset 0 0 0 1px var(--ui-line), 0 16px 40px rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  transform: translate(-50%, 0); animation: stuckIn 0.45s cubic-bezier(0.2, 1.2, 0.4, 1) both;
}
@keyframes stuckIn { from { opacity: 0; transform: translate(-50%, 14px) scale(0.96); } }
.stuck-actions { display: flex; gap: 6px; }
.stuck button { border: 0; padding: 9px 14px; border-radius: 12px; font-weight: 600; font-size: 13.5px; cursor: pointer; background: rgba(255, 255, 255, 0.1); color: var(--ui-text); }
.stuck button:hover { background: rgba(255, 255, 255, 0.18); }
.stuck button.go { background: linear-gradient(180deg, #fffefb, #efe9db); color: var(--ink); }
@media (orientation: landscape) and (max-height: 540px) { .stuck { bottom: max(12px, env(safe-area-inset-bottom, 0px)); } }

/* ---------- Win panel: try another game ---------- */
.next-games { margin: 14px 0 0; font-size: 13.5px; color: #5c625b; display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; justify-content: center; }
.next-games a { padding: 6px 12px; border-radius: 999px; background: rgba(17, 72, 58, 0.08); color: #11483a; font-weight: 600; text-decoration: none; }
.next-games a:hover { background: rgba(17, 72, 58, 0.16); }

/* ---------- Below the game: rules, links, footer ---------- */
.below { -webkit-user-select: text; user-select: text; position: relative; z-index: 1; }
.below .page-wrap { padding-top: 28px; }
.below .prose h1 { font-size: clamp(28px, 5vw, 38px); }
.below .prose h2:first-of-type { margin-top: 22px; }
.foot-meta span { margin-left: auto; }

/* ---------- Ads: only in reading areas, never beside the cards ---------- */
.ad { margin: 30px 0; min-height: 280px; text-align: center; }
.ad-label { display: block; margin-bottom: 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: #8a8f88; }
