/* Shared look for AdaptED's card games: felt table, playing cards, chips, and the study panel. */
:root {
  --felt: #17603f;
  --felt-deep: #0c3b27;
  --rail: #2b1a12;
  --rail-hi: #4a2e1f;
  --ink: #141a24;
  --paper: #fffdf7;
  --paper-edge: #e9e3d4;
  --muted: #6b7280;
  --red-suit: #c22f2f;
  --black-suit: #161b26;
  --gold: #f2c14e;
  --blue: #2557d6;
  --blue-deep: #17378d;
  --good: #1f9d55;
  --bad: #d64545;
  --cw: clamp(40px, min(7.2vw, 10.5vh), 76px);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #0a0f0c;
  color: #f4f1e8;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- table ---------- */
.room { position: relative; height: 100%; display: flex; flex-direction: column; padding: 10px; gap: 10px; }
.table {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 140px / 110px;
  padding: 18px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse 70% 60% at 50% 42%, #1f7a51 0%, var(--felt) 45%, var(--felt-deep) 100%);
  border: 14px solid var(--rail);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.06),
    inset 0 18px 40px rgba(0, 0, 0, 0.35),
    0 0 0 1px var(--rail-hi),
    0 24px 60px rgba(0, 0, 0, 0.55);
}
.table::after {
  content: "";
  position: absolute;
  inset: 26px;
  border-radius: 120px / 92px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: none;
}
@media (max-width: 640px) {
  .room { padding: 6px; gap: 6px; }
  .table { border-width: 9px; border-radius: 60px / 48px; padding: 10px; }
  .table::after { inset: 14px; border-radius: 48px / 40px; }
}

/* ---------- top bar ---------- */
.bar { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 4px; font-size: 13px; }
.bar .title { font-weight: 700; letter-spacing: -0.01em; font-size: 15px; }
.bar .set { color: #a8b3ab; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.08); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill b { font-weight: 700; }

/* ---------- playing cards ---------- */
.pc {
  position: relative;
  width: var(--cw);
  aspect-ratio: 5 / 7;
  border-radius: calc(var(--cw) * 0.08);
  background: linear-gradient(180deg, #fffefa, var(--paper));
  box-shadow: 0 1px 0 var(--paper-edge) inset, 0 0 0 1px rgba(0, 0, 0, 0.18), 0 6px 14px -6px rgba(0, 0, 0, 0.6);
  font-family: Georgia, "Times New Roman", serif;
  color: var(--black-suit);
  flex: none;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.pc.red { color: var(--red-suit); }
.pc .ix { position: absolute; display: flex; flex-direction: column; align-items: center; line-height: 0.92; font-weight: 700; }
.pc .ix .r { font-size: calc(var(--cw) * 0.26); letter-spacing: -0.04em; }
.pc .ix .s { font-size: calc(var(--cw) * 0.2); }
.pc .ix.tl { top: 6%; left: 7%; }
.pc .ix.br { bottom: 6%; right: 7%; transform: rotate(180deg); }
.pc .mid { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--cw) * 0.5); }
.pc .mid.ace { font-size: calc(var(--cw) * 0.62); }
.pc .face {
  position: absolute;
  inset: 22% 20%;
  border: 1px solid currentColor;
  border-radius: 3px;
  display: grid;
  place-items: center;
  font-size: calc(var(--cw) * 0.38);
  font-weight: 700;
  background: repeating-linear-gradient(135deg, transparent 0 4px, rgba(0, 0, 0, 0.035) 4px 5px);
}
.pc.back {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.09) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.09) 0 2px, transparent 2px 7px),
    linear-gradient(160deg, var(--blue), var(--blue-deep));
  box-shadow: inset 0 0 0 3px #fffdf7, inset 0 0 0 4px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.25), 0 6px 14px -6px rgba(0, 0, 0, 0.6);
}
.pc.slot { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.14); }
.pc.dim { filter: brightness(0.55) saturate(0.6); }
.pc.win { box-shadow: 0 0 0 2px var(--gold), 0 10px 22px -8px rgba(242, 193, 78, 0.7); transform: translateY(-4px); }
.pc.peeked { z-index: 1; box-shadow: 0 0 0 2px var(--gold), 0 6px 14px -6px rgba(0, 0, 0, 0.6); }
.pc.deal { animation: deal 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes deal { from { opacity: 0; transform: translateY(-22px) rotate(-5deg) scale(0.92); } }
.cards { display: flex; gap: calc(var(--cw) * 0.1); }
.cards.tight .pc + .pc { margin-left: calc(var(--cw) * -0.45); }

/* ---------- chips ---------- */
.chip {
  --c: #d64545;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--c) 0 46%, #fff 47% 52%, var(--c) 53%);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.85), inset 0 0 0 5px var(--c), 0 2px 0 rgba(0, 0, 0, 0.35);
  border: 2px dashed rgba(255, 255, 255, 0.9);
  flex: none;
}
.chip.c10 { --c: #2f6fd6; }
.chip.c25 { --c: #1f9d55; }
.chip.c50 { --c: #d64545; }
.chip.c100 { --c: #1b1f2a; }
.bet { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px; }
.bet .chip { width: 18px; height: 18px; border-width: 1.5px; }

/* ---------- buttons ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; }
.btn {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  font-weight: 650;
  font-size: 15px;
  transition: background 0.15s, transform 0.1s;
}
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.14); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; }
.btn.primary { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.btn.primary:hover:not(:disabled) { background: #fff; }
.btn.gold { background: var(--gold); color: #2a1d00; border-color: var(--gold); }
.btn.gold:hover:not(:disabled) { background: #f6cf6d; }
.btn.danger { color: #ffb4b4; }
.btn kbd { margin-left: 8px; font: 600 11px ui-monospace, monospace; opacity: 0.55; }
@media (max-width: 640px) { .btn { padding: 0 13px; font-size: 14px; } .btn kbd { display: none; } }

.toast {
  position: absolute;
  left: 50%;
  top: 62px;
  transform: translate(-50%, -8px);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(10, 15, 12, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-weight: 650;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 40;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- study panel ---------- */
.study-wrap {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(4, 8, 6, 0.55);
  backdrop-filter: blur(2px);
  animation: fade 0.18s ease both;
}
@keyframes fade { from { opacity: 0; } }
.study {
  outline: none;
  width: min(520px, 100%);
  border-radius: 18px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: rise 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
.study header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 16px 20px 0; }
.study .kind { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--blue); }
.study .stake { font-size: 13px; color: var(--muted); text-align: right; }
.study h2 { margin: 8px 20px 16px; font-size: 21px; line-height: 1.3; letter-spacing: -0.01em; font-weight: 650; text-wrap: balance; }
.study ol { list-style: none; margin: 0; padding: 0 14px 14px; display: grid; gap: 8px; }
.study li button {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #e4e0d4;
  background: #fff;
  text-align: left;
  font-size: 16px;
  color: var(--ink);
}
.study li button:hover:not(:disabled) { border-color: #b9c4d8; background: #f7f9fd; }
.study li .n { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: #f1efe7; font: 700 12px ui-monospace, monospace; color: var(--muted); flex: none; }
.study li button.right { border-color: var(--good); background: #eaf7ef; }
.study li button.right .n { background: var(--good); color: #fff; }
.study li button.wrong { border-color: var(--bad); background: #fdeeee; }
.study li button.wrong .n { background: var(--bad); color: #fff; }
.study footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-top: 1px solid #ece8dc; background: #faf8f1; min-height: 64px; }
.study .result { font-size: 14px; font-weight: 650; }
.study .result.good { color: var(--good); }
.study .result.bad { color: var(--bad); }
.study .result small { display: block; margin-top: 2px; font-weight: 500; color: var(--muted); }
.study .hint { font-size: 13px; color: var(--muted); }
.study .go { min-height: 40px; padding: 0 16px; border-radius: 10px; border: 0; background: var(--ink); color: #fff; font-weight: 650; }

/* ---------- intro / end sheets ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; padding: 16px; background: rgba(4, 8, 6, 0.6); }
.sheet { width: min(460px, 100%); border-radius: 20px; background: var(--paper); color: var(--ink); padding: 26px 26px 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); }
.sheet h1 { margin: 0; font-size: 30px; letter-spacing: -0.03em; }
.sheet p { margin: 8px 0 0; color: #4b5563; line-height: 1.5; }
.sheet ul { margin: 16px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; font-size: 15px; line-height: 1.4; }
.sheet li { display: flex; gap: 10px; }
.sheet li::before { content: "♠"; color: var(--blue); font-family: Georgia, serif; }
.sheet li:nth-child(2)::before { content: "♥"; color: var(--red-suit); }
.sheet li:nth-child(3)::before { content: "♣"; }
.sheet li:nth-child(4)::before { content: "♦"; color: var(--red-suit); }
.sheet .row { display: flex; gap: 10px; margin-top: 22px; }
.sheet .start { flex: 1; min-height: 48px; border-radius: 12px; border: 0; background: var(--ink); color: #fff; font-weight: 700; font-size: 16px; }
.sheet .set-name { margin-top: 14px; font-size: 13px; color: var(--muted); }

/* ---------- fitting any screen ---------- */
/* A question or the intro that is taller than the screen scrolls instead of being cut off. */
.study-wrap, .sheet-wrap { overflow-y: auto; place-items: start center; }
.study, .sheet { margin: auto; }

/* Short screens (a phone on its side, a small window): everything tightens so the whole table shows. */
@media (max-height: 480px) {
  :root { --cw: clamp(24px, 10.5vh, 76px); }
  .room { padding: 4px; gap: 4px; }
  .bar { min-height: 28px; }
  .table { border-width: 6px; border-radius: 48px / 38px; padding: 6px; }
  .table::after { display: none; }
  .btn { min-height: 36px; }
  .study-wrap, .sheet-wrap { padding: 8px; }
  .study { width: min(680px, 100%); }
  .study header { padding: 10px 16px 0; }
  .study h2 { margin: 4px 16px 8px; font-size: 17px; }
  .study ol { grid-template-columns: 1fr 1fr; gap: 6px; padding: 0 10px 8px; }
  .study li button { min-height: 40px; padding-block: 6px; }
  .study footer { min-height: 48px; padding: 8px 16px; }
  .sheet { width: min(640px, 100%); padding: 16px 18px; }
  .sheet h1 { font-size: 22px; }
  .sheet ul { gap: 6px; margin-top: 10px; font-size: 14px; }
  .sheet .row { margin-top: 12px; }
  .sheet .start { min-height: 42px; }
}
