/* Lore table */

:root {
  --felt: #1d5e3f;
  --felt-dark: #123f2a;
  --ink: #f4f1e8;
  --muted: #a9b8af;
  --gold: #f3c969;
  --card-face: #fdfcf7;
  --card-red: #d6001c;
  --card-black: #101114;
  --board-bg: #171b21;
  --board-line: #2b313a;
  --good: #6fd39a;
  --bad: #ff8a80;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--board-bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.lore-root, .lore { height: 100%; }

.lore {
  display: grid;
  grid-template-columns: 2fr 1fr;
  min-height: 560px;
}

/* --- felt and seats ------------------------------------------------------- */

.felt {
  --card: clamp(46px, min(5.2vw, 8.6vh), 96px);
  --big: calc(var(--card) * 1.5); /* your hand and cards on the table */
  --cw: var(--card);
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 45%, #2a7a52 0%, var(--felt) 45%, var(--felt-dark) 100%);
  box-shadow: inset 0 0 120px rgba(0, 0, 0, .45);
}

.banner {
  position: absolute;
  top: 14px;
  left: 16px;
  max-width: min(30%, 340px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .22);
  font-size: 13px;
  color: var(--muted);
}
.banner strong { color: var(--ink); font-size: 17px; }
.banner .deal-no { text-transform: uppercase; letter-spacing: .08em; font-size: 11px; }

.langs {
  position: absolute;
  top: 14px;
  right: 16px;
  display: flex;
  gap: 6px;
  z-index: 6;
}
.flag {
  display: block;
  width: 30px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  overflow: hidden;
  background: none;
  opacity: .5;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
  transition: opacity .15s, transform .15s;
}
.flag svg { display: block; width: 100%; height: 100%; }
.flag:hover { opacity: .85; transform: translateY(-1px); }
.flag.on { opacity: 1; box-shadow: 0 0 0 2px var(--gold), 0 1px 3px rgba(0, 0, 0, .4); }

.seat {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 8px;
}
.seat-bottom { bottom: 14px; left: 50%; transform: translateX(-50%); flex-direction: column-reverse; }
.seat-top { top: 16px; left: 50%; transform: translateX(-50%); flex-direction: column; }
.seat-left { left: 18px; top: 50%; transform: translateY(-50%); flex-direction: column; }
.seat-right { right: 18px; top: 50%; transform: translateY(-50%); flex-direction: column; }

.plate {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .3);
  font-size: 14px;
  white-space: nowrap;
  transition: box-shadow .3s, background .3s;
}
.seat.active .plate { background: rgba(243, 201, 105, .22); box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(243, 201, 105, .5); }
.plate .name { font-weight: 650; }
.plate .leader { color: var(--gold); }
.plate .total { color: var(--muted); font-variant-numeric: tabular-nums; }
.plate .total::before { content: "Σ "; opacity: .6; }

.pile {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px 2px 4px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.pile.mine { cursor: pointer; background: rgba(243, 201, 105, .16); }
.pile.mine:hover { background: rgba(243, 201, 105, .3); }
.pile:disabled { cursor: default; }

/* Pass dots sit between the name plate and the cards; for you, above your hand. */
.seat .hand { order: 2; }
.pass-dots { order: 1; display: flex; gap: 5px; min-height: 10px; }
.seat-bottom .pass-dots { order: 3; margin-bottom: -16px; position: relative; z-index: 1; }
.pass-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .35);
}
.mini-empty { width: 14px; height: 20px; border: 1px dashed rgba(255, 255, 255, .25); border-radius: 3px; }

.hand { display: flex; }
.hand.own { --cw: var(--big); padding-top: 18px; }
.hand.own .card + .card { margin-left: calc(var(--cw) * -.32); }
.hand.backs { --cw: calc(var(--card) * .55); }
.seat-top .hand.backs .card + .card { margin-left: calc(var(--cw) * -.5); }
.seat-left .hand.backs, .seat-right .hand.backs { flex-direction: column; }
.seat-left .hand.backs .card + .card, .seat-right .hand.backs .card + .card { margin-top: calc(var(--cw) * -1.02); }

/* --- cards -------------------------------------------------------------------- */

.card {
  position: relative;
  flex: none;
  width: var(--cw);
  height: calc(var(--cw) * 1.42);
  border-radius: calc(var(--cw) * .09);
  background: var(--card-face);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 4px 10px rgba(0, 0, 0, .18);
  color: var(--card-black);
  font-weight: 700;
  user-select: none;
  transition: transform .15s ease, filter .2s;
}
.card.red { color: var(--card-red); }
.suit { display: block; fill: currentColor; }
.card .corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--cw) * .02);
  min-width: calc(var(--cw) * .22);
  font-size: calc(var(--cw) * .24);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.04em;
}
.card .corner .suit { width: calc(var(--cw) * .2); height: calc(var(--cw) * .2); }
.card .tl { top: 5%; left: 6%; }
.card .br { bottom: 5%; right: 6%; transform: rotate(180deg); }
.card .pip, .card .face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.card .pip .suit { width: 52%; height: 52%; }
/* Picture cards: the same big suit mark, framed, so they still read as J/Q/K */
.card .face {
  inset: 19% 22%;
  border: calc(var(--cw) * .025) solid currentColor;
  border-radius: calc(var(--cw) * .06);
  background: color-mix(in srgb, currentColor 10%, transparent);
}
.card .face .suit { width: 78%; height: 78%; }

.card.back {
  background: #7a5a3a url("/assets/card-back-be4c4ce2.jpg") center / cover no-repeat;
  border: calc(var(--cw) * .05) solid #f6efe0;
}
.card.mini { --cw: 14px; border-width: 1.5px; }
.card.small { --cw: 40px; }

.hand.own .card.playable { cursor: pointer; }
.hand.own .card.playable:hover { transform: translateY(-22%); }
.hand.own .card.dim { filter: brightness(.62) saturate(.6); }
.card.winner { box-shadow: 0 0 0 3px var(--gold), 0 0 22px rgba(243, 201, 105, .8); }

/* --- centre: trick and layout -------------------------------------------------- */

.center {
  position: absolute;
  left: 50%;
  top: 47%;
  --cw: var(--big);
  width: calc(var(--big) * 4.2);
  height: calc(var(--big) * 3.4);
  transform: translate(-50%, -50%);
}
.center.lore-mode { top: 118px; width: auto; height: auto; transform: translateX(-50%); }
.slot { position: absolute; }
.slot-bottom { left: 50%; bottom: 0; transform: translateX(-50%); }
.slot-top { left: 50%; top: 0; transform: translateX(-50%); }
.slot-left { left: 0; top: 50%; transform: translateY(-50%); }
.slot-right { right: 0; top: 50%; transform: translateY(-50%); }

.layout {
  /* 50% larger than before, but shrunk to fit between the top seat and your hand */
  --cw: min(calc(var(--card) * .99), calc((100vh - var(--big) * 1.42 - 290px) / 5.68));
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: max-content;
}
.lstart { text-align: center; font-size: 13px; color: var(--muted); }
.lrow {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: calc(var(--cw) * 5.4);
  min-height: calc(var(--cw) * 1.42);
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .14);
}
.lsuit {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--card-face);
  color: var(--card-black);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.lsuit .suit { width: 18px; height: 18px; }
.lsuit.red { color: var(--card-red); }
.lcards { display: flex; }
.lcards .card + .card { margin-left: calc(var(--cw) * -.55); }

.status {
  position: absolute;
  left: 50%;
  bottom: calc(var(--big) * 1.42 + 70px);
  transform: translateX(-50%);
  padding: 4px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .3);
  font-size: 14px;
  white-space: nowrap;
}
.status:empty { display: none; }

/* --- overlays ------------------------------------------------------------------- */

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(6, 20, 13, .45);
  animation: fade-in .25s ease;
  z-index: 5;
}
.panel {
  max-width: min(560px, 92%);
  max-height: 88%;
  overflow: auto;
  padding: 20px 22px;
  border-radius: 14px;
  background: #fbf8ef;
  color: #1f2622;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
  animation: pop-in .3s cubic-bezier(.2, .9, .3, 1.2);
}
.panel h2 { margin: 0 0 14px; font-size: 20px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border: 1px solid #d9d2bf;
  border-radius: 10px;
  background: #fff;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.choice:hover { border-color: #1d5e3f; box-shadow: 0 0 0 2px rgba(29, 94, 63, .25); }
.choice span { font-size: 13px; color: #5a625d; }
.taken-trick { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.taken-trick > span { width: 24px; color: #5a625d; font-size: 13px; }
.mini-scores { width: 100%; margin-bottom: 14px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.mini-scores th, .mini-scores td { padding: 5px 8px; text-align: right; border-bottom: 1px solid #e6e0cf; }
.mini-scores th:first-child, .mini-scores td:first-child { text-align: left; }
.mini-scores .bad { color: #b3261e; }
.mini-scores .good { color: #1b7a43; }
.muted { color: #6b736e; }

.btn {
  padding: 8px 16px;
  border: 0;
  border-radius: 8px;
  background: #1d5e3f;
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: #24744e; }
.btn.ghost { background: transparent; border: 1px solid var(--board-line); color: var(--ink); }
.btn.ghost:hover { background: var(--board-line); }

.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.92) translateY(10px); } }

/* --- scoreboard ------------------------------------------------------------------ */

.board {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 18px 18px 14px;
  border-left: 1px solid var(--board-line);
  background: var(--board-bg);
  overflow: hidden;
}
.board header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.board h1 { margin: 0; font-size: 26px; letter-spacing: .02em; }
.board header p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.board h3 { margin: 16px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

.scores-wrap { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--board-line); border-radius: 10px; }
.scores { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.scores th, .scores td { padding: 6px 8px; border-bottom: 1px solid var(--board-line); }
.scores thead th { position: sticky; top: 0; background: #1f242c; color: var(--muted); font-weight: 600; font-size: 12px; z-index: 1; }
.scores tfoot td { position: sticky; bottom: 0; background: #1f242c; font-weight: 700; border-bottom: 0; }
.scores .no { width: 28px; color: var(--muted); text-align: right; }
.scores .game { text-align: left; }
.scores .game small { display: block; color: var(--muted); font-size: 11px; }
.scores .num { text-align: right; }
.scores .bad { color: var(--bad); }
.scores .good { color: var(--good); }
.scores .zero { color: #5d6670; }
.scores .lead { color: var(--gold); }
.scores tr.current td { background: rgba(243, 201, 105, .07); }
.scores .live { color: var(--muted); font-size: 12px; }

.remaining { width: 100%; border-collapse: collapse; font-size: 12px; }
.remaining th { color: var(--muted); font-weight: 600; padding: 3px; }
.remaining td { padding: 3px; text-align: center; color: #4c545d; }
.remaining td:first-child { text-align: left; color: var(--ink); }
.remaining td.used { color: var(--good); }
.remaining td.now { color: var(--gold); }

@media (max-width: 900px) {
  .lore { grid-template-columns: 1fr; grid-template-rows: minmax(520px, 75vh) auto; height: auto; }
  .felt { --card: clamp(34px, 6vw, 56px); }
  .board { border-left: 0; border-top: 1px solid var(--board-line); }
  .choices { grid-template-columns: 1fr; }
}
