/* Weekend Build — a card table. Every colour is a token here; dark mode redefines them. */
:root {
  --table: #E9E2D2;
  --table-2: #E1D8C5;
  --ink: #1D1A15;
  --ink-2: #4A443A;
  --paper: #FFFCF4;
  --paper-edge: #D9CFBB;
  --who: #A8321F;
  --itch: #835300;
  --twist: #2C6436;
  --size: #3A3631;
  --shadow: 29 26 21;
  --focus: #1D1A15;
  --focus-halo: #E9E2D2;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --cond: "Avenir Next Condensed", "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --table: #121110;
    --table-2: #1A1815;
    --ink: #F1EBDD;
    --ink-2: #BDB4A3;
    --paper: #23201B;
    --paper-edge: #3A352D;
    --who: #F2907A;
    --itch: #E5B556;
    --twist: #84C98F;
    --size: #D6CDBC;
    --shadow: 0 0 0;
    --focus: #F1EBDD;
    --focus-halo: #121110;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--table);
  background-image: radial-gradient(circle at 1px 1px, rgb(var(--shadow) / .07) 1px, transparent 1.4px);
  background-size: 18px 18px;
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.45;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; box-shadow: 0 0 0 6px var(--focus-halo); }

.table {
  flex: 1;
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 20px 16px 24px;
}

/* ---------- masthead ---------- */
.mast {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px 24px;
  align-items: end;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 12px;
}
.mark {
  margin: 0;
  font-weight: 700;
  font-size: clamp(34px, 9vw, 64px);
  line-height: .9;
  letter-spacing: -.02em;
}
.mark-a { font-style: italic; }
.mark-b {
  font-family: var(--cond);
  font-stretch: condensed;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .02em;
  font-size: .82em;
}
.lede { margin: 6px 0 0; max-width: 34em; font-size: 16px; color: var(--ink-2); }
.tally {
  margin: 0;
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  font-family: var(--mono); font-size: 12px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-2);
}
.tally b { color: var(--ink); font-weight: 700; }

/* ---------- the hand ---------- */
.hand {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  perspective: 1400px;
}
.card {
  --c: var(--who);
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 5 / 6.4;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 14px;
  container-type: inline-size;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform .25s var(--ease-out);
  transform: translateY(0) rotate(var(--tilt, 0deg));
}
.card[data-suit="itch"] { --c: var(--itch); }
.card[data-suit="twist"] { --c: var(--twist); }
.card[data-suit="size"] { --c: var(--size); }
.flip {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  border-radius: inherit;
}
.face {
  position: absolute; inset: 0;
  border-radius: inherit;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}
.front {
  display: flex; flex-direction: column;
  padding: 9cqi 9cqi 8cqi;
  background: var(--paper);
  box-shadow:
    0 0 0 1px var(--paper-edge),
    0 1px 0 rgb(var(--shadow) / .12),
    0 8px 18px -8px rgb(var(--shadow) / .45);
  text-align: left;
}
.front::before { /* the printed frame */
  content: "";
  position: absolute; inset: 4.5cqi;
  border: 1.5px solid var(--c);
  border-radius: 8px;
  opacity: .55;
  pointer-events: none;
}
.back {
  transform: rotateY(180deg);
  background-color: var(--c);
  background-image:
    repeating-linear-gradient(45deg, rgb(255 255 255 / .12) 0 2px, transparent 2px 11px),
    repeating-linear-gradient(-45deg, rgb(255 255 255 / .12) 0 2px, transparent 2px 11px);
  box-shadow: 0 0 0 1px rgb(var(--shadow) / .2), 0 8px 18px -8px rgb(var(--shadow) / .45);
}
.back::before {
  content: "WB";
  position: absolute; inset: 6cqi;
  display: grid; place-items: center;
  border: 2px solid rgb(255 255 255 / .55);
  border-radius: 8px;
  font-family: var(--serif); font-style: italic; font-weight: 700;
  font-size: 22cqi; color: rgb(255 255 255 / .8);
}
@media (prefers-color-scheme: dark) {
  .back { background-image:
    repeating-linear-gradient(45deg, rgb(0 0 0 / .18) 0 2px, transparent 2px 11px),
    repeating-linear-gradient(-45deg, rgb(0 0 0 / .18) 0 2px, transparent 2px 11px); }
  .back::before { border-color: rgb(0 0 0 / .4); color: rgb(0 0 0 / .55); }
}
.card.down .flip { transform: rotateY(180deg); }

.suitline {
  display: flex; align-items: center; gap: 2.4cqi;
  font-family: var(--cond); font-stretch: condensed; font-weight: 700;
  font-size: max(12px, 6.4cqi); letter-spacing: .12em; text-transform: uppercase;
  color: var(--c);
  position: relative;
}
.suitline svg { width: 8cqi; height: 8cqi; min-width: 14px; min-height: 14px; fill: currentColor; flex: none; }
.suitline .n { margin-left: auto; font-family: var(--mono); font-weight: 500; letter-spacing: 0; font-size: max(11px, 5.4cqi); }
.main {
  margin-top: auto;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -.01em;
  color: var(--ink);
  position: relative;
  hyphens: manual;
  overflow-wrap: break-word;
}
.card[data-suit="who"] .main, .card[data-suit="twist"] .main, .card[data-suit="size"] .main { font-size: 11.5cqi; }
.card[data-suit="itch"] .main { font-size: 9.6cqi; font-weight: 600; line-height: 1.16; margin-top: 8cqi; margin-bottom: auto; }
.sub {
  margin-top: 4cqi;
  font-size: max(12px, 6cqi);
  line-height: 1.3;
  color: var(--ink-2);
  position: relative;
  padding-right: 9cqi;
}
.ghost {
  position: absolute; left: 50%; top: 44%;
  width: 36cqi; height: 36cqi;
  transform: translate(-50%, -50%);
  fill: var(--c); color: var(--c);
  opacity: .13;
  pointer-events: none;
}
.card[data-suit="itch"] .ghost { top: auto; bottom: 4cqi; left: 9cqi; transform: none; width: 22cqi; height: 22cqi; }
.pips { display: inline-flex; gap: 3px; vertical-align: middle; margin-right: 6px; }
.pips i { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--c); }
.pips i.on { background: var(--c); }
.foot-idx {
  position: absolute; right: 8cqi; bottom: 7cqi;
  transform: rotate(180deg);
  color: var(--c); opacity: .9;
}
.foot-idx svg { width: 7cqi; height: 7cqi; min-width: 12px; min-height: 12px; fill: currentColor; display: block; }
.card[data-suit="itch"] .front { padding-bottom: 14cqi; }

/* kept */
.stamp {
  position: absolute; top: 18cqi; right: 6cqi;
  padding: 1.2cqi 3.4cqi;
  border: 2px solid var(--c);
  border-radius: 6px;
  font-family: var(--cond); font-stretch: condensed; font-weight: 700;
  font-size: max(12px, 6.4cqi); letter-spacing: .14em; text-transform: uppercase;
  color: var(--c);
  background: var(--paper);
  transform: rotate(-9deg) scale(.6);
  opacity: 0;
  transition: opacity .15s, transform .25s var(--ease-out);
  pointer-events: none;
}
.card[data-suit="itch"] .stamp { top: auto; bottom: 15cqi; right: 8cqi; }
.card[aria-pressed="true"] { transform: translateY(-8px) rotate(var(--tilt, 0deg)); }
.card[aria-pressed="true"] .front { box-shadow: 0 0 0 2.5px var(--c), 0 18px 26px -14px rgb(var(--shadow) / .6); }
.card[aria-pressed="true"] .stamp { opacity: 1; transform: rotate(-9deg) scale(1); }
@media (hover: hover) {
  .card:hover { transform: translateY(-4px) rotate(var(--tilt, 0deg)); }
  .card[aria-pressed="true"]:hover { transform: translateY(-10px) rotate(var(--tilt, 0deg)); }
}

/* ---------- the brief ---------- */
.brief { margin: 22px 0 0; }
.eyebrow {
  margin: 0 0 6px;
  font-family: var(--cond); font-stretch: condensed; font-weight: 700;
  font-size: 13px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-2);
}
.sentence {
  margin: 0;
  font-size: clamp(20px, 5.3vw, 32px);
  line-height: 1.32;
  letter-spacing: -.005em;
  max-width: 44em;
  text-wrap: pretty;
}
.sentence .p { text-decoration: underline; text-decoration-thickness: .12em; text-underline-offset: .2em; text-decoration-skip-ink: none; }
.sentence .p-who { text-decoration-color: var(--who); }
.sentence .p-itch { text-decoration-color: var(--itch); }
.sentence .p-twist { text-decoration-color: var(--twist); }
.sentence .p-size { text-decoration-color: var(--size); }
.sentence.fresh { animation: settle .45s var(--ease-out); }
@keyframes settle { from { opacity: .25; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- controls ---------- */
.controls { margin-top: 20px; display: grid; gap: 12px; }
.play, .share { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  min-height: 46px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--cond); font-stretch: condensed; font-weight: 700;
  font-size: 16px; letter-spacing: .03em;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 10px;
  transition: transform .12s var(--ease-out), background-color .15s;
  box-shadow: 0 2px 0 var(--ink);
}
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 0 0 var(--ink); }
.btn.primary { background: var(--ink); color: var(--paper); font-size: 19px; padding: 10px 22px; letter-spacing: .08em; text-transform: uppercase; box-shadow: 0 3px 0 rgb(var(--shadow) / .5); }
.btn.quiet { border-style: dashed; box-shadow: none; }
.btn:disabled { opacity: .45; cursor: default; }
@media (hover: hover) { .btn:hover:not(:disabled) { background: var(--table-2); } .btn.primary:hover { background: var(--ink); filter: brightness(1.15); } }
kbd {
  font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 0; text-transform: none;
  padding: 2px 6px; border-radius: 5px; border: 1px solid currentColor; opacity: .75;
}
.status { margin: 0; min-height: 1.4em; font-size: 15px; color: var(--ink); }
.keys { margin: 0; font-size: 13px; color: var(--ink-2); }
.keys kbd { opacity: 1; }

.foot {
  padding: 14px 16px 18px;
  text-align: center;
  font-family: var(--cond); font-stretch: condensed; font-size: 14px; letter-spacing: .03em;
  color: var(--ink-2);
}
.foot a { color: var(--ink); text-underline-offset: 3px; display: inline-block; padding: 12px 4px; margin: -12px 0; }

/* phone: Deal sits under the thumb */
@media (max-width: 699px) {
  .keys, .play kbd, .share kbd { display: none; }
  .foot { padding-bottom: 96px; }
  .play {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 2;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--table) 92%, transparent);
    backdrop-filter: blur(6px);
    border-top: 1px solid var(--paper-edge);
  }
  .play .btn { flex: 1 1 auto; justify-content: center; }
  .play .btn.primary { flex: 2 1 auto; }
  .share .btn { flex: 1 1 100%; justify-content: center; }
  .controls { display: flex; flex-direction: column; margin-top: 16px; }
  .card[aria-pressed="true"] { transform: translateY(-5px) rotate(var(--tilt, 0deg)); }
  .card { aspect-ratio: 5 / 5.9; }
  .lede { font-size: 15px; }
  .ghost { top: 42%; width: 30cqi; height: 30cqi; }
}

@media (min-width: 700px) {
  .table { padding: 28px 28px 28px; }
  .mast { grid-template-columns: auto 1fr auto; }
  .lede { margin: 0 0 4px; }
  .tally { justify-content: flex-end; padding-bottom: 6px; }
  .hand { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
  .card { aspect-ratio: 5 / 7; }
}
@media (min-width: 700px) and (max-width: 1023px) {
  .mast { grid-template-columns: 1fr; }
  .tally { justify-content: flex-start; }
  .hand { gap: 14px; }
}
@media (min-width: 1024px) {
  .controls { grid-template-columns: auto 1fr; align-items: start; column-gap: 28px; }
  .share { justify-content: flex-end; }
  .status, .keys { grid-column: 1 / -1; }
  .hand { max-width: 1104px; }
}
@media (min-width: 1024px) and (max-height: 760px) {
  .hand { max-width: 940px; }
  .brief { margin-top: 18px; }
  .sentence { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .stamp, .btn { transition: none; }
  .sentence.fresh { animation: none; }
}
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
