/* Tarot entre amis: "Atelier de Marseille". Tokens and rules: see DESIGN.md */
@font-face {
  font-family: "Young Serif";
  src: url("/static/fonts/young-serif-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-2199, U+2212, U+2215, U+2605, U+2660-2667;
}
@font-face {
  font-family: "Young Serif";
  src: url("/static/fonts/young-serif-400-ext.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0100-024F, U+1E00-1EFF;
}

:root {
  --paper: #f4ecdc;
  --sheet: #fbf7ee;
  --well: #ebe0c9;
  --ink: #1d1a16;
  --ink-2: #5b5348;
  --rule: #d9cdb6;
  --red: #b8321f;
  --ochre: #d99a1e;
  --ochre-soft: #f3dfae;
  --blue: #23468c;
  --green: #2f6b4f;
  --card: #fdf9f0;
  --card-trump: #f7efd9;
  --on-ink: #fbf7ee;
  --shadow: 0 1px 0 rgba(29, 26, 22, .08), 0 8px 18px -10px rgba(29, 26, 22, .45);
  --display: "Young Serif", Georgia, "Times New Roman", serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --cw: 52px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17140f;
    --sheet: #221d16;
    --well: #2b251c;
    --ink: #f1e8d6;
    --ink-2: #b4a891;
    --rule: #3b3326;
    --red: #e0644f;
    --ochre: #e8b04a;
    --ochre-soft: #4a3a17;
    --blue: #8eaaf0;
    --green: #7cc29f;
    --on-ink: #17140f;
    --shadow: 0 10px 22px -12px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 var(--body);
  -webkit-tap-highlight-color: transparent;
}
main {
  max-width: 760px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- type ---------- */
h1, h2, h3, .display { font-family: var(--display); font-weight: 400; letter-spacing: -.005em; margin: 0; }
h1 { font-size: 2.75rem; line-height: 1; }
h2 { font-size: 1.25rem; line-height: 1.2; }
h3 { font-size: 1rem; }
p { margin: 0; }
a { color: var(--blue); text-underline-offset: 3px; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.tiny { font-size: .75rem; }
.num { font-variant-numeric: tabular-nums; }
.eyebrow { font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }

/* ---------- sheets, forms, buttons ---------- */
.sheet {
  background: var(--sheet);
  border: 1.5px solid var(--ink);
  border-radius: 14px;
  padding: 16px;
}
.sheet > header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 10px; margin-bottom: 12px; border-bottom: 1px solid var(--rule); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }

label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: 6px; }
input {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
}
input:hover { border-color: var(--ink-2); }
input::placeholder { color: var(--ink-2); opacity: .7; }
.code-input { font-weight: 800; font-size: 1.375rem; letter-spacing: .3em; text-transform: uppercase; text-align: center; }

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

button, .btn {
  font: inherit;
  font-weight: 650;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 12px;
  border: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease, transform .12s ease, opacity .15s ease;
}
button:hover { background: var(--well); }
button:active { transform: translateY(1px) scale(.985); }
button.primary, .btn.primary { background: var(--ink); color: var(--on-ink); }
button.primary:hover, .btn.primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
button.go { background: var(--red); border-color: var(--red); color: #fff; }
button.go:hover { filter: brightness(1.08); background: var(--red); }
button.quiet { border-color: var(--rule); font-weight: 600; }
button.link { border: 0; min-height: 40px; padding: 8px 4px; color: var(--ink-2); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
button.link:hover { background: none; color: var(--ink); }
button:disabled { opacity: .4; cursor: not-allowed; transform: none; }
button.small { min-height: 40px; padding: 8px 12px; font-size: .875rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions > button { flex: 1 1 auto; }

.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1.5px solid var(--ink); border-radius: 12px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; min-height: 44px; font-weight: 600; }
.seg button + button { border-left: 1.5px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }

.stepper { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; border: 1.5px solid var(--rule); border-radius: 12px; }
.stepper button { border: 0; min-height: 48px; font-size: 1.25rem; }
.stepper output { text-align: center; font-weight: 800; font-size: 1.375rem; }

/* ---------- home ---------- */
.hero { padding: 20px 0 4px; }
.hero h1 { font-size: clamp(3rem, 14vw, 4.5rem); }
.hero p { margin-top: 8px; max-width: 32ch; color: var(--ink-2); font-size: 1.05rem; }
.hero-cards { display: flex; margin: 18px 0 2px; height: 96px; }
.hero-cards .card { --cw: 60px; box-shadow: var(--shadow); }
.hero-cards .card:nth-child(1) { transform: rotate(-9deg) translateY(8px); }
.hero-cards .card:nth-child(2) { transform: rotate(-2deg); margin-left: -18px; }
.hero-cards .card:nth-child(3) { transform: rotate(6deg) translateY(6px); margin-left: -18px; }
.foot { margin-top: auto; padding-top: 8px; display: flex; justify-content: center; }

/* ---------- top bar ---------- */
.bar { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.bar .tcode { font-weight: 800; font-size: 1.125rem; letter-spacing: .14em; }
.bar .deal { color: var(--ink-2); font-size: .875rem; }
.bar .grow { flex: 1; }
.conn { font-size: .75rem; font-weight: 700; color: var(--red); }

/* ---------- lobby ---------- */
.bigcode { font-weight: 800; font-size: clamp(2.75rem, 15vw, 4rem); letter-spacing: .16em; text-align: center; line-height: 1.1; padding: 4px 0 12px; }
.plist { list-style: none; margin: 0; padding: 0; }
.plist li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.plist li:last-child { border-bottom: 0; }
.plist .who { flex: 1; min-width: 0; }
.plist .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist li.empty { color: var(--ink-2); font-style: italic; }
.state-ok { color: var(--green); font-weight: 650; font-size: .875rem; }
.state-wait { color: var(--ink-2); font-size: .875rem; }

.disc {
  --c: var(--blue);
  width: 36px; height: 36px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--c);
  color: #fff;
  font-family: var(--display);
  font-size: 1.05rem;
  position: relative;
}
.disc.off::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; background: var(--paper); border: 2.5px solid var(--red); }
.c0 { --c: #b8321f; } .c1 { --c: #23468c; } .c2 { --c: #a6740e; } .c3 { --c: #2f6b4f; } .c4 { --c: #7a3e6e; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700; border: 1.5px solid currentColor; line-height: 1.4; white-space: nowrap; }
.chip.taker { color: var(--red); }
.chip.partner { color: var(--blue); }
.chip.host { color: var(--ink-2); }
.chip.solid { background: var(--ochre); border-color: var(--ochre); color: #2a1d02; }

/* ---------- table ---------- */
.seats { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; }
.plate {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px 8px;
  border-radius: 12px;
  border: 1.5px solid transparent;
  text-align: center;
  min-width: 0;
  transition: border-color .2s ease, background-color .2s ease;
}
.plate .nick { font-weight: 650; font-size: .875rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plate .meta { font-size: .75rem; color: var(--ink-2); }
.plate.turn { border-color: var(--ochre); background: var(--ochre-soft); }
.plate.turn .disc { animation: breathe 2s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--ochre) 45%, transparent); } }

.stage {
  flex: 1;
  min-height: 200px;
  border-radius: 20px;
  background: var(--well);
  border: 1.5px solid var(--rule);
  padding: 14px 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  text-align: center;
}
.contract { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 10px; font-size: .875rem; }
.contract .display { font-size: 1.1rem; }
.status { font-family: var(--display); font-size: 1.35rem; line-height: 1.2; }
.status.mine { color: var(--red); }
.trick { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; min-height: calc(64px * 1.45 + 22px); align-items: flex-start; }
.trick figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.trick .card { --cw: 64px; box-shadow: var(--shadow); }
.trick figcaption { font-size: .75rem; color: var(--ink-2); max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trick figure.win figcaption { color: var(--ink); font-weight: 700; }
.trick figure.win .card { outline: 3px solid var(--ochre); outline-offset: 2px; }
.trick .enter { animation: deal-in .22s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes deal-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }
.empty-trick { color: var(--ink-2); font-size: .875rem; padding: 32px 0; }
.infos { display: flex; flex-direction: column; gap: 6px; align-items: center; font-size: .8125rem; color: var(--ink-2); }
.mini-row { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
.mini-row .card { --cw: 30px; }

.bids { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.bid { font-size: .8125rem; padding: 4px 10px; border-radius: 999px; background: var(--sheet); border: 1px solid var(--rule); }
.bid b { font-weight: 700; }
.bid.pass { color: var(--ink-2); }
.bid.take { border-color: var(--red); color: var(--red); }

.dock { display: flex; flex-direction: column; gap: 10px; }
.bidgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bidgrid .pass { grid-column: 1 / -1; }
.hint { text-align: center; font-size: .875rem; color: var(--ink-2); min-height: 20px; }

/* ---------- cards ---------- */
.card {
  --h: calc(var(--cw) * 1.48);
  width: var(--cw);
  height: var(--h);
  flex: none;
  position: relative;
  border-radius: calc(var(--cw) * .14);
  background: var(--card);
  border: 1.5px solid #1d1a16;
  color: #1d1a16;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}
.card::before { content: ""; position: absolute; inset: calc(var(--cw) * .06); border: 1px solid rgba(29, 26, 22, .28); border-radius: calc(var(--cw) * .08); pointer-events: none; }
.card .ix { position: absolute; left: calc(var(--cw) * .1); top: calc(var(--cw) * .08); display: flex; flex-direction: column; align-items: center; line-height: .95; }
.card .r { font-family: var(--body); font-weight: 800; font-size: calc(var(--cw) * .34); letter-spacing: -.02em; font-variant-numeric: lining-nums; }
.card .s { font-size: calc(var(--cw) * .3); line-height: 1; margin-top: 1px; }
.card .pip { position: absolute; inset: 0; display: grid; place-items: center; padding-top: calc(var(--cw) * .32); font-size: calc(var(--cw) * .62); opacity: .9; }
.card.red { color: var(--red); }
@media (prefers-color-scheme: dark) { .card.red { color: #b8321f; } }
.card.trump { background: var(--card-trump); }
.card.trump .r { font-size: calc(var(--cw) * .36); color: #23468c; }
.card.trump .band { position: absolute; left: 0; right: 0; bottom: calc(var(--cw) * .2); height: calc(var(--cw) * .2); background: #23468c; display: grid; place-items: center; color: #fbf7ee; font-size: calc(var(--cw) * .12); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; overflow: hidden; }
.card.trump .pip { display: none; }
.card.excuse .pip { display: grid; color: #23468c; font-size: calc(var(--cw) * .5); padding-top: 0; padding-bottom: calc(var(--cw) * .2); }
.card.oudler { border-color: #a6740e; box-shadow: inset 0 0 0 2px #d99a1e; }
.card.excuse .r { font-family: var(--body); }

/* hand */
.hand { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 16px; }
.hand .line { display: flex; }
.hand .card { margin-left: var(--ov); transition: transform .14s cubic-bezier(.2, .8, .2, 1), opacity .15s ease, filter .15s ease; box-shadow: -2px 0 4px -2px rgba(29, 26, 22, .35); }
.hand .card:first-child { margin-left: 0; }
.hand .card .band { font-size: 0; }
.hand .card[role="button"] { cursor: pointer; }
.hand .card.dim { filter: saturate(.25); opacity: .45; }
.hand .card.sel { transform: translateY(-16px); box-shadow: 0 0 0 3px var(--ochre), var(--shadow); }
.hand .card.pick { transform: translateY(-10px); box-shadow: 0 0 0 3px var(--red), var(--shadow); }
@media (hover: hover) { .hand .card[role="button"]:hover:not(.sel):not(.pick) { transform: translateY(-6px); } }
.me-line { display: flex; justify-content: center; align-items: center; gap: 8px; font-size: .875rem; color: var(--ink-2); }

/* ---------- results and scores ---------- */
.verdict { text-align: center; padding: 6px 0 2px; }
.verdict .big { font-family: var(--display); font-size: 2.25rem; line-height: 1.05; }
.verdict .big.win { color: var(--green); }
.verdict .big.lose { color: var(--red); }
.verdict p { margin-top: 6px; color: var(--ink-2); }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.fact { background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; padding: 8px 6px; text-align: center; }
.fact .v { font-weight: 800; font-size: 1.35rem; }
.fact .k { font-size: .6875rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.extras { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 12px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .9375rem; }
th, td { padding: 9px 6px; text-align: right; border-bottom: 1px solid var(--rule); }
th:first-child, td:first-child { text-align: left; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); font-weight: 600; }
td.pos { color: var(--green); font-weight: 650; }
td.neg { color: var(--red); font-weight: 650; }
tr.total td { border-top: 1.5px solid var(--ink); border-bottom: 0; font-weight: 750; }
tr.me td:first-child { font-weight: 700; }
.scroll { overflow-x: auto; }
.rise { animation: rise .26s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
.podium { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.podium li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--paper); border: 1px solid var(--rule); }
.podium li:first-child { border: 1.5px solid var(--ochre); background: var(--ochre-soft); }
.podium .rank { font-weight: 800; font-size: 1.35rem; width: 1.6em; }
.podium .who { flex: 1; font-weight: 650; }
.podium .pts { font-weight: 800; font-size: 1.1rem; }

.notice { border: 1.5px solid var(--ochre); background: var(--ochre-soft); padding: 10px 14px; border-radius: 12px; font-size: .9375rem; text-align: center; }

/* history */
.glist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.glist a { display: block; text-decoration: none; color: inherit; }
.glist a:hover .sheet { background: var(--well); }
.glist .sheet { padding: 14px 16px; transition: background-color .15s ease; }
.glist .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }

#toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: var(--ink); color: var(--on-ink);
  padding: 12px 16px; border-radius: 12px;
  font-weight: 600; font-size: .9375rem;
  box-shadow: var(--shadow);
  z-index: 20;
  animation: rise .2s ease both;
}

@media (min-width: 640px) {
  :root { --cw: 60px; }
  main { padding-left: 24px; padding-right: 24px; }
  .trick .card { --cw: 76px; }
  .trick { min-height: calc(76px * 1.48 + 22px); }
}
@media (min-width: 1024px) {
  :root { --cw: 68px; }
  main { max-width: 980px; }
  .trick .card { --cw: 88px; }
  .trick { min-height: calc(88px * 1.48 + 22px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.verdict .big .n { font-family: var(--body); font-weight: 800; }
.disc .dealer { position: absolute; right: -6px; top: -4px; width: 18px; height: 18px; border-radius: 50%; background: var(--sheet); color: var(--ink); border: 1.5px solid var(--ink); font: 800 10px/15px var(--body); text-align: center; }
