/* Play Cards Free: a quiet card room. Warm paper page, green felt table, ivory cards,
   oxblood card backs, a brass accent. Fraunces for headings and card indices, system sans for text. */
@font-face {
  font-family: "Fraunces";
  src: url("/fraunces.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f3eee3;
  --surface: #fbf8f1;
  --ink: #23211c;
  --muted: #6a6457;
  --line: #ddd4c1;
  --accent: #1d5a3f;
  --brass: #b5862c;
  --felt: #2a6248;
  --felt-deep: #1d4a35;
  --felt-ink: #f1ecdf;
  --card: #fdfaf2;
  --card-edge: rgb(30 25 15 / 0.32);
  --black: #1d1c19;
  --red: #b3261e;
  --blue: #1d56a3;
  --green: #22703a;
  --back: #7a2333;
  --back-line: rgb(253 245 225 / 0.16);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sym: "Segoe UI Symbol", "Apple Symbols", "Noto Sans Symbols 2", "DejaVu Sans", sans-serif;
  color-scheme: light dark;
  font: 18px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14130f;
    --surface: #1d1b16;
    --ink: #ece6d8;
    --muted: #a69e8c;
    --line: #34302a;
    --accent: #8fcfa9;
    --brass: #d9ad57;
    --felt: #18402f;
    --felt-deep: #0f2c20;
    --felt-ink: #e9e3d3;
    --card: #ece6d6;
    --card-edge: rgb(0 0 0 / 0.55);
    --black: #1a1916;
    --red: #b02a22;
    --blue: #1d4f96;
    --green: #1f6a35;
    --back: #5f1b29;
  }
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; text-underline-offset: 3px; text-decoration-color: var(--line); text-decoration-thickness: 1.5px; }
a:hover { text-decoration-color: var(--accent); }
:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
main.wrap > :not(.game):not(.title):not(.tiles):not(.more) { max-width: 70ch; }
.content > * { max-width: 70ch; }

/* Header */
header.site { position: relative; border-bottom: 1px solid var(--line); background: var(--surface); }
header.site .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 56px; }
.brand { font: 650 1.08rem/1 var(--serif); letter-spacing: -0.01em; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand .mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--felt); color: var(--felt-ink); font: 1rem/1 var(--sym); }
nav.site { display: flex; gap: 24px; font-size: 0.95rem; }
nav.site a { text-decoration: none; color: var(--muted); }
nav.site a:hover { color: var(--ink); }

.menu { display: none; }
.menu summary { list-style: none; cursor: pointer; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; }
.menu summary::-webkit-details-marker { display: none; }
.bars, .bars::before, .bars::after { display: block; width: 18px; height: 1.5px; background: var(--ink); border-radius: 2px; transition: transform 0.2s ease, opacity 0.2s ease; }
.bars { position: relative; }
.bars::before, .bars::after { content: ""; position: absolute; left: 0; }
.bars::before { top: -6px; }
.bars::after { top: 6px; }
.menu[open] .bars { background: transparent; }
.menu[open] .bars::before { transform: translateY(6px) rotate(45deg); }
.menu[open] .bars::after { transform: translateY(-6px) rotate(-45deg); }
.menu nav { position: absolute; left: 0; right: 0; top: 56px; z-index: 400; display: grid; padding: 4px 20px 12px; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: 0 12px 24px rgb(0 0 0 / 0.08); }
.menu nav a { padding: 12px 0; text-decoration: none; border-bottom: 1px solid var(--line); }
.menu nav a:last-child { border-bottom: 0; }

/* Type */
h1, h2, h3 { font-family: var(--serif); font-weight: 620; letter-spacing: -0.015em; }
h1 { font-size: clamp(2rem, 4.5vw, 2.8rem); line-height: 1.1; margin: 44px 0 10px; }
h2 { font-size: 1.55rem; line-height: 1.25; margin: 52px 0 10px; }
h3 { font-size: 1.15rem; margin: 28px 0 4px; }
.lede { color: var(--muted); font-size: 1.1rem; margin: 0 0 24px; }
p strong { font-weight: 640; }
ol, ul { padding-left: 1.3em; }
li { margin: 8px 0; }
table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 0.95rem; }
th, td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
thead th { font-weight: 550; color: var(--muted); font-size: 0.86rem; }
tbody th { font-weight: 650; white-space: nowrap; }
tbody tr:last-child > * { border-bottom: 0; }

/* Game page title: one line above the table */
.title { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 14px; margin: 14px 0 10px; }
.title h1 { font-size: 1.7rem; margin: 0; }
.title p { margin: 0; color: var(--muted); font-size: 0.95rem; }

/* ---------- The table ---------- */
.game {
  --pad: 12px;
  display: flex; flex-direction: column;
  height: calc(100svh - 56px - 72px); min-height: 440px; max-height: 980px;
  border-radius: 18px; color: var(--felt-ink);
  background: radial-gradient(120% 90% at 50% 20%, var(--felt), var(--felt-deep));
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.18), inset 0 2px 30px rgb(0 0 0 / 0.25);
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.game.tall { height: auto; max-height: none; }
.hud { display: flex; align-items: center; gap: 12px; padding: var(--pad) var(--pad) 0; min-height: 64px; }
.found { display: flex; gap: 4px; flex: none; }
.found i { display: grid; place-items: center; width: 26px; height: 36px; border-radius: 4px; border: 1.5px dashed rgb(241 236 223 / 0.28); font: normal 1rem/1 var(--sym); }
.found i.full { border: 0; background: var(--card); color: var(--black); box-shadow: 0 1px 2px rgb(0 0 0 / 0.35); }
.found i.red { color: var(--red); }
.four .found i.s2 { color: var(--blue); }
.four .found i.s3 { color: var(--green); }
.stats { flex: 1; display: flex; justify-content: center; gap: 18px; margin: 0; font-size: 0.92rem; color: rgb(241 236 223 / 0.78); white-space: nowrap; }
.stats b { color: var(--felt-ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.stock { flex: none; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 4px 12px 4px 8px; border: 1px solid rgb(241 236 223 / 0.22); border-radius: 12px; background: rgb(0 0 0 / 0.14); color: var(--felt-ink); font: inherit; font-size: 0.95rem; font-weight: 600; cursor: pointer; }
.stock:hover { background: rgb(0 0 0 / 0.24); }
.stock[aria-disabled="true"] { opacity: 0.5; cursor: default; }
.stock.blocked .deal-label { opacity: 0.6; }
.stock .pile { position: relative; width: 44px; height: 38px; }
.stock .pile i { position: absolute; top: 0; width: 26px; height: 38px; border-radius: 4px; background: var(--back); box-shadow: 0 0 0 1px rgb(253 245 225 / 0.55) inset, 0 1px 2px rgb(0 0 0 / 0.4); }
.stock .pile i:nth-child(2) { left: 4px; } .stock .pile i:nth-child(3) { left: 8px; } .stock .pile i:nth-child(4) { left: 12px; } .stock .pile i:nth-child(5) { left: 16px; }
.deal-label b { display: inline-grid; place-items: center; min-width: 1.6em; height: 1.6em; margin-left: 4px; border-radius: 999px; background: var(--brass); color: #1d1a12; font-size: 0.85em; }

.board { position: relative; flex: 1; min-height: 0; touch-action: pan-y; }
.slot { position: absolute; left: 0; top: 0; width: var(--cw); height: var(--ch); border-radius: calc(var(--cw) * 0.1); border: 1.5px dashed rgb(241 236 223 / 0.22); }
.slot { display: grid; place-items: center; color: rgb(241 236 223 / 0.32); font: calc(var(--cw) * 0.5)/1 var(--sym); }
.slot.draw { cursor: pointer; }
.card.covered .p { display: none; }
.slot.gone { border-style: solid; border-color: rgb(241 236 223 / 0.1); }

.card {
  position: absolute; left: 0; top: 0; width: var(--cw); height: var(--ch);
  border-radius: calc(var(--cw) * 0.1); background: var(--card); color: var(--black);
  box-shadow: 0 0 0 1px var(--card-edge), 0 1px 2px rgb(0 0 0 / 0.22);
  touch-action: none; cursor: default; will-change: transform; overflow: hidden;
}
.card.movable { cursor: grab; }
.card.lift { z-index: 500 !important; cursor: grabbing; box-shadow: 0 0 0 1px var(--card-edge), 0 10px 24px rgb(0 0 0 / 0.35); }
.card.red { color: var(--red); }
.four .card.s2 { color: var(--blue); }
.four .card.s3 { color: var(--green); }
.card .r { position: absolute; left: calc(var(--cw) * 0.07); top: calc(var(--cw) * 0.05); font: 700 var(--fs)/1 var(--serif); letter-spacing: -0.06em; font-variant-numeric: lining-nums; }
.card .u { position: absolute; right: calc(var(--cw) * 0.06); top: calc(var(--cw) * 0.07); font: calc(var(--fs) * 0.85)/1 var(--sym); }
.card .p { position: absolute; left: 0; right: 0; bottom: 9%; text-align: center; font: calc(var(--cw) * 0.56)/1 var(--sym); opacity: 0.9; }
.card .p.face { font: 600 calc(var(--cw) * 0.5)/1 var(--serif); bottom: 12%; }
.card.down { background: repeating-linear-gradient(45deg, var(--back-line) 0 1.5px, transparent 1.5px 7px), repeating-linear-gradient(-45deg, var(--back-line) 0 1.5px, transparent 1.5px 7px) var(--back); box-shadow: 0 0 0 1px rgb(0 0 0 / 0.4), inset 0 0 0 2px var(--back), inset 0 0 0 3px rgb(253 245 225 / 0.7); }
.card.down > span { display: none; }
.card:focus-visible { outline: 3px solid var(--brass); outline-offset: 1px; z-index: 300; }

.hint { animation: glow 0.9s ease-in-out 2; }
.hint-to { animation: glow 0.9s ease-in-out 2; }
@keyframes glow { 50% { box-shadow: 0 0 0 3px var(--brass), 0 0 18px 4px rgb(217 173 87 / 0.7); } }

.toast { position: absolute; left: 50%; bottom: 14px; z-index: 600; max-width: calc(100% - 24px); margin: 0; padding: 10px 16px; border-radius: 12px; background: rgb(20 18 14 / 0.88); color: #f3eee3; font-size: 0.95rem; text-align: center; transform: translate(-50%, 8px); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.noscript { padding: 24px; text-align: center; }

.controls { display: flex; align-items: center; gap: 8px; padding: 0 var(--pad) var(--pad); }
.controls .btn { background: rgb(0 0 0 / 0.14); color: var(--felt-ink); border-color: rgb(241 236 223 / 0.22); }
.controls .btn:hover { background: rgb(0 0 0 / 0.26); }
.controls .btn:disabled { opacity: 0.45; cursor: default; }
.mode { margin-left: auto; font-size: 0.88rem; color: rgb(241 236 223 / 0.7); white-space: nowrap; }

.btn { min-height: 46px; padding: 8px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 0.95rem; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--bg); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn.link { background: none; border-color: transparent; color: var(--muted); }

/* Dialogs */
dialog { width: min(420px, calc(100vw - 32px)); padding: 24px; border: 0; border-radius: 18px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px rgb(0 0 0 / 0.35); }
dialog::backdrop { background: rgb(15 12 8 / 0.55); }
dialog h2 { margin: 0 0 12px; font-size: 1.5rem; }
dialog p { margin: 0 0 12px; color: var(--muted); }
.suits { border: 0; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.suits legend { font-size: 0.88rem; color: var(--muted); margin-bottom: 6px; }
.suits label { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.suits label:has(:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.suits input { grid-row: span 2; width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.suits span { font-size: 0.88rem; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; margin: -4px 0 16px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.field { display: grid; gap: 2px; margin: 0 0 16px; font-weight: 600; }
.field span { font-size: 0.88rem; font-weight: 400; color: var(--muted); }
.field input { margin-top: 6px; min-height: 46px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); font: inherit; }
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 20px; }
.statgrid div { padding: 8px 10px; border-radius: 10px; background: var(--bg); }
.statgrid dt { font-size: 0.78rem; color: var(--muted); }
.statgrid dd { margin: 0; font: 650 1.15rem/1.3 var(--serif); font-variant-numeric: tabular-nums; }
.dlg-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Hub home */
.tiles { list-style: none; padding: 0; margin: 16px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tiles li { margin: 0; }
.tile { display: grid; align-content: start; gap: 6px; height: 100%; padding: 20px; border-radius: 18px; text-decoration: none; color: var(--felt-ink); background: radial-gradient(120% 90% at 50% 20%, var(--felt), var(--felt-deep)); box-shadow: 0 1px 2px rgb(0 0 0 / 0.15); transition: transform 0.15s ease; }
.tile:hover { transform: translateY(-2px); }
.tile b { font: 650 1.35rem/1.2 var(--serif); }
.tile > span:last-child { color: rgb(241 236 223 / 0.8); font-size: 0.95rem; }
.tile-cards { position: relative; height: 64px; margin-bottom: 6px; }
.tile-cards i { position: absolute; top: 0; width: 44px; height: 62px; padding: 4px 5px; border-radius: 5px; background: var(--card); color: var(--black); font: normal 700 15px/1 var(--serif); box-shadow: 0 0 0 1px var(--card-edge), 0 2px 4px rgb(0 0 0 / 0.25); }
.tile-cards i.red { color: var(--red); }
.tile-cards i:nth-child(2) { left: 30px; }
.tile-cards i:nth-child(3) { left: 60px; }
.more .tiles { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

footer.site { margin-top: 88px; border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 0.92rem; }
footer.site .wrap { padding-block: 36px 28px; }
.footer-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.footer-cols h2 { font: 600 0.92rem/1.4 system-ui, sans-serif; letter-spacing: 0; margin: 0 0 8px; color: var(--ink); }
.footer-cols ul { list-style: none; padding: 0; margin: 0; }
.footer-cols li { margin: 6px 0; }
.footer-cols a { text-decoration: none; }
.footer-cols a:hover { color: var(--ink); }

@media (max-width: 760px) {
  :root { font-size: 17px; }
  .wrap { padding: 0 16px; }
  header.site .wrap { height: 52px; }
  .menu nav { top: 52px; }
  nav.site { display: none; }
  .menu { display: block; }
  h1 { margin-top: 28px; }
  h2 { margin-top: 44px; }
  .title { margin: 8px 0 8px; column-gap: 10px; }
  .title h1 { font-size: 1.35rem; }
  .title p { font-size: 0.82rem; }
  /* Full-bleed table on phones: every pixel of width goes to the cards */
  .game { --pad: 8px; margin: 0 -16px; border-radius: 0; height: calc(100svh - 52px - 70px); min-height: 420px; }
  .hud { gap: 8px; min-height: 56px; }
  .found { display: grid; grid-template-columns: repeat(4, auto); gap: 3px; }
  .found i { width: 18px; height: 22px; font-size: 0.75rem; border-radius: 3px; }
  .stats { flex-direction: column; align-items: center; gap: 0; font-size: 0.84rem; line-height: 1.35; }
  .hud:not(:has(.stock)) { min-height: 40px; }
  .hud:not(:has(.stock)) .stats { flex-direction: row; gap: 14px; }
  .stock { padding: 4px 10px 4px 6px; gap: 6px; }
  .controls { gap: 6px; }
  .controls .btn { padding: 8px 12px; }
  .mode { font-size: 0.8rem; }
  .footer-cols { grid-template-columns: 1fr 1fr; }
  th, td { padding: 8px 6px; }
}

@media (max-width: 359px) {
  .mode { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .btn:active:not(:disabled) { transform: none; }
  .tile, .tile:hover { transition: none; transform: none; }
  .bars, .bars::before, .bars::after, .toast { transition: none; }
  .hint, .hint-to { animation: none; box-shadow: 0 0 0 3px var(--brass); }
}
