/* Sueca — a tasca card table: baize cloth, azulejo-backed cards, a pencil scorepad. */

:root {
  --baize: #1b4a3c;
  --baize-lit: #24604d;
  --baize-deep: #0d2a22;
  --cobalt: #2447a2;
  --cobalt-deep: #17306f;
  --porcelain: #fcfbf8;
  --paper: #f2ead3;
  --graphite: #34332f;
  --brass: #e3ac3e;
  --red: #b42330;
  --ink: #18181c;

  --serif: 'Alegreya', Georgia, 'Times New Roman', serif;
  --sans: 'Alegreya Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --hand: 'Caveat', 'Segoe Print', 'Bradley Hand', cursive;

  /* card sizes */
  --w: clamp(48px, min(calc((100vw - 28px) / 6.3), 13dvh), 96px);   /* my hand */
  --tw: clamp(44px, min(15vw, 11dvh), 84px);                         /* cards on the table */
  --mw: clamp(14px, 3.2vw, 22px);                                    /* opponents' backs */
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.45;
  color: var(--porcelain);
  background: var(--baize-deep);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { opacity: .7; }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  padding: .62em 1.15em;
  border-radius: 10px;
  border: 1.5px solid rgba(24, 24, 28, .18);
  background: var(--porcelain);
  color: var(--ink);
  font-weight: 700;
  letter-spacing: .01em;
  transition: transform .08s ease, background-color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--cobalt); border-color: var(--cobalt-deep); color: #fff; box-shadow: 0 2px 0 var(--cobalt-deep); }
.btn.primary:hover:not(:disabled) { background: #2b53bb; }
.btn.ghost { background: transparent; border-color: rgba(252, 251, 248, .45); color: var(--porcelain); }
.btn.ghost:hover:not(:disabled) { background: rgba(252, 251, 248, .1); }
.btn.small { padding: .45em .9em; font-size: .92rem; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1.5px solid rgba(252, 251, 248, .35);
  background: rgba(0, 0, 0, .15);
  font-size: 1.15rem; line-height: 1;
}

/* ======================================================== HOME (azulejo wall) */
#screen-home {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: 28px 16px;
  color: var(--ink);
  background-color: #eef1f7;
  background-image:
    radial-gradient(circle at 50% 50%, var(--cobalt) 0 5px, transparent 5.5px),
    radial-gradient(circle at 50% 50%, transparent 0 19px, var(--cobalt) 19.5px 22px, transparent 22.5px),
    radial-gradient(circle at 0 0, var(--cobalt) 0 15px, transparent 15.5px),
    radial-gradient(circle at 100% 0, var(--cobalt) 0 15px, transparent 15.5px),
    radial-gradient(circle at 0 100%, var(--cobalt) 0 15px, transparent 15.5px),
    radial-gradient(circle at 100% 100%, var(--cobalt) 0 15px, transparent 15.5px),
    linear-gradient(45deg, transparent calc(50% - 1px), rgba(36, 71, 162, .45) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(-45deg, transparent calc(50% - 1px), rgba(36, 71, 162, .45) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(to right, rgba(23, 48, 111, .18) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(23, 48, 111, .18) 1px, transparent 1px);
  background-size: 88px 88px;
}
.plaque {
  width: min(420px, 100%);
  background: var(--porcelain);
  border-radius: 18px;
  padding: 30px 28px 22px;
  box-shadow: 0 0 0 6px rgba(252, 251, 248, .85), 0 0 0 8px var(--cobalt), 0 24px 60px rgba(23, 48, 111, .35);
}
.hero-fan {
  --w: 68px;
  position: relative;
  height: calc(var(--w) * 1.62);
  margin: 0 auto 6px;
  width: calc(var(--w) * 3);
}
.hero-fan .card {
  position: absolute; left: 50%; bottom: 0;
  transform-origin: 50% 120%;
  margin-left: calc(var(--w) * -.5);
}
.plaque h1 {
  font-family: var(--serif);
  font-weight: 800;
  font-size: 3.4rem;
  line-height: 1;
  margin: 10px 0 6px;
  text-align: center;
  color: var(--cobalt-deep);
  letter-spacing: -.01em;
}
.tagline { text-align: center; margin: 0 0 22px; color: #4a4a55; }
.home-form { display: grid; gap: 8px; }
.home-form label { font-weight: 700; font-size: .95rem; }
.plaque input {
  width: 100%;
  padding: .62em .8em;
  border-radius: 10px;
  border: 1.5px solid #c9ccd8;
  background: #fff;
  color: var(--ink);
}
.plaque input:focus { border-color: var(--cobalt); outline: none; box-shadow: 0 0 0 3px rgba(36, 71, 162, .2); }
.home-form .btn { margin-top: 4px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 12px; color: #6a6a75; font-size: .92rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: #d9dbe4; }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: .3em; font-weight: 700; font-family: var(--serif); text-align: center; }
.rules { margin-top: 20px; font-size: .95rem; color: #3a3a44; }
.rules summary { cursor: pointer; font-weight: 700; color: var(--cobalt-deep); }
.rules ul { padding-left: 1.1em; margin: 10px 0 0; }
.rules li { margin: 0 0 6px; }
.lang-switch { display: flex; justify-content: center; gap: 4px; margin-top: 18px; }
.lang-switch button {
  border: 0; background: none; padding: 4px 10px; border-radius: 6px;
  color: #6a6a75; font-size: .9rem;
}
.lang-switch button[aria-pressed="true"] { color: var(--cobalt-deep); font-weight: 700; background: #e8ecf6; }

/* ============================================================ CARDS */
.card {
  --cw: var(--w);
  position: relative;
  flex: none;
  width: var(--cw);
  aspect-ratio: 5 / 7;
  border-radius: calc(var(--cw) * .09);
  background: var(--porcelain);
  color: var(--ink);
  font-family: var(--serif);
  box-shadow: 0 1px 1px rgba(0, 0, 0, .25), 0 4px 10px rgba(0, 0, 0, .22);
  user-select: none;
  -webkit-user-select: none;
}
.card.red { color: var(--red); }
.card .idx {
  position: absolute; top: 5%; left: 7%;
  display: flex; flex-direction: column; align-items: center;
  font-weight: 800;
  font-size: calc(var(--cw) * .27);
  line-height: .92;
}
.card .idx i { font-style: normal; font-size: .78em; font-family: var(--sans); }
.card .idx.br { top: auto; left: auto; bottom: 5%; right: 7%; transform: rotate(180deg); }
.card .pip {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: calc(var(--cw) * .5);
  font-family: var(--sans);
}
.card .pip.ace { font-size: calc(var(--cw) * .66); }
.card .face {
  position: absolute; inset: 22% 20%;
  display: grid; place-items: center;
  border: 1.5px solid currentColor;
  border-radius: calc(var(--cw) * .05);
  font-weight: 800;
  font-size: calc(var(--cw) * .36);
  opacity: .9;
}
.card .face::after {
  content: attr(data-suit);
  position: absolute; bottom: 4%; font-size: .45em; font-family: var(--sans);
}
/* azulejo-pattern back */
.card.back, .mini-back {
  background-color: var(--cobalt);
  background-image:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, .95) 0 1.4px, transparent 1.8px),
    radial-gradient(circle at 50% 50%, transparent 0 3.6px, rgba(255, 255, 255, .8) 4px 5px, transparent 5.4px),
    radial-gradient(circle at 0 0, rgba(255, 255, 255, .8) 0 2.6px, transparent 3px),
    radial-gradient(circle at 100% 0, rgba(255, 255, 255, .8) 0 2.6px, transparent 3px),
    radial-gradient(circle at 0 100%, rgba(255, 255, 255, .8) 0 2.6px, transparent 3px),
    radial-gradient(circle at 100% 100%, rgba(255, 255, 255, .8) 0 2.6px, transparent 3px);
  background-size: 13px 13px;
  background-position: center;
}
.card.back { box-shadow: inset 0 0 0 calc(var(--cw) * .06) var(--porcelain), inset 0 0 0 calc(var(--cw) * .075) var(--cobalt-deep), 0 4px 10px rgba(0, 0, 0, .25); }

/* ============================================================ LOBBY */
#screen-lobby {
  min-height: 100dvh;
  background: radial-gradient(ellipse at 50% 30%, var(--baize-lit), var(--baize) 45%, var(--baize-deep));
  padding: max(16px, env(safe-area-inset-top)) 18px 24px;
}
.lobby-head {
  max-width: 980px; margin: 0 auto 10px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.room-code {
  font-family: var(--serif); font-weight: 800;
  font-size: 2.6rem; letter-spacing: .14em; line-height: 1;
}
.lobby-head-actions { display: flex; gap: 8px; }
.lobby-body {
  max-width: 980px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr 320px; gap: 22px; align-items: start;
}
.hint { margin: 6px 0 0; opacity: .78; font-size: .95rem; text-align: center; }
.lobby-table {
  position: relative;
  height: 360px;
  margin: 10px auto 0;
  max-width: 560px;
}
.felt-oval {
  position: absolute; inset: 70px 90px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 40%, #2a6b57, #1d5040 70%);
  box-shadow: inset 0 0 0 8px #5b3a22, inset 0 0 0 11px #3e2614, inset 0 10px 30px rgba(0, 0, 0, .35), 0 14px 30px rgba(0, 0, 0, .35);
}
.seat-btn {
  position: absolute;
  min-width: 132px; max-width: 46%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px dashed rgba(252, 251, 248, .4);
  background: rgba(0, 0, 0, .18);
  text-align: center;
  line-height: 1.2;
}
.seat-btn .who { display: block; font-weight: 700; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-btn .meta { display: block; font-size: .82rem; opacity: .8; margin-top: 2px; }
.seat-btn.filled { border-style: solid; background: var(--porcelain); color: var(--ink); }
.seat-btn.filled.team-0 { border-color: var(--cobalt); box-shadow: 0 3px 0 var(--cobalt-deep); }
.seat-btn.filled.team-1 { border-color: var(--brass); box-shadow: 0 3px 0 #a87a1f; }
.seat-btn.mine { outline: 3px solid var(--brass); outline-offset: 3px; }
.seat-btn.offline .who { opacity: .5; }
.seat-btn:not(.mine):hover { transform: translateY(-1px); }
.seat-btn .team-dot { display: inline-block; width: .6em; height: .6em; border-radius: 50%; margin-right: .35em; vertical-align: .05em; }
.team-0 .team-dot, .team-dot.team-0 { background: var(--cobalt); }
.team-1 .team-dot, .team-dot.team-1 { background: var(--brass); }
.lobby-table .pos-top { top: 0; left: 50%; transform: translateX(-50%); }
.lobby-table .pos-bottom { bottom: 0; left: 50%; transform: translateX(-50%); }
.lobby-table .pos-left { left: 0; top: 50%; transform: translateY(-50%); }
.lobby-table .pos-right { right: 0; top: 50%; transform: translateY(-50%); }
.lobby-table .pos-top:not(.mine):hover, .lobby-table .pos-bottom:not(.mine):hover { transform: translate(-50%, -1px); }
.lobby-table .pos-left:not(.mine):hover, .lobby-table .pos-right:not(.mine):hover { transform: translateY(calc(-50% - 1px)); }
.lobby-actions { display: flex; justify-content: center; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

/* ============================================================ CHAT */
.chat {
  display: flex; flex-direction: column;
  background: var(--porcelain); color: var(--ink);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
  height: 420px;
  overflow: hidden;
}
.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; font-weight: 700; border-bottom: 1px solid #e3e1da;
}
.chat-head .icon-btn { border-color: #d6d3ca; background: transparent; width: 32px; height: 32px; }
.chat:not(.drawer) .close-chat { display: none; }
.chat-log { list-style: none; margin: 0; padding: 10px 14px; flex: 1; overflow-y: auto; font-size: .95rem; }
.chat-log li { margin: 0 0 6px; overflow-wrap: anywhere; }
.chat-log .from { font-weight: 700; margin-right: .3em; }
.chat-log .from.team-0 { color: var(--cobalt); }
.chat-log .from.team-1 { color: #9b6c10; }
.chat-log .empty { opacity: .55; font-style: italic; }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid #e3e1da; }
.chat-form input { flex: 1; min-width: 0; padding: .45em .7em; border-radius: 8px; border: 1.5px solid #d6d3ca; }
.chat-form .btn { background: var(--cobalt); color: #fff; border-color: var(--cobalt-deep); }

.chat.drawer {
  position: fixed; z-index: 40;
  right: 14px; bottom: 14px;
  width: min(340px, calc(100vw - 28px));
  height: min(440px, 70dvh);
  transform: translateY(calc(100% + 30px));
  visibility: hidden;
  transition: transform .22s ease, visibility 0s .22s;
}
.chat.drawer.open { transform: none; visibility: visible; transition: transform .22s ease; }
.chat-btn { position: relative; }
.badge {
  position: absolute; top: -3px; right: -3px;
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--red); color: #fff; font-size: .75rem; font-weight: 700;
  display: grid; place-items: center;
}

/* ============================================================ GAME */
#screen-game {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 70% at 50% 48%, var(--baize-lit) 0%, var(--baize) 55%, var(--baize-deep) 100%);
}
.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 14px 0;
}
.hud-left { position: relative; }
.code-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid rgba(252, 251, 248, .35);
  background: rgba(0, 0, 0, .2);
  font-family: var(--serif); font-weight: 800; letter-spacing: .12em;
}
.code-chip .chev { font-family: var(--sans); font-size: .8em; opacity: .7; letter-spacing: 0; }
.menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 50;
  min-width: 200px;
  background: var(--porcelain); color: var(--ink);
  border-radius: 12px; padding: 6px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
  display: grid;
}
.menu button { text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: 8px; }
.menu button:hover { background: #ecebe5; }

.trump { display: flex; align-items: center; gap: 10px; }
.trump-suit {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--porcelain); color: var(--ink);
  display: grid; place-items: center;
  font-size: 28px; line-height: 1;
  box-shadow: 0 0 0 3px rgba(252, 251, 248, .25), 0 4px 10px rgba(0, 0, 0, .3);
}
.trump-suit.red { color: var(--red); }
.trump-text { display: flex; flex-direction: column; line-height: 1.1; }
.trump-label { font-size: .82rem; opacity: .75; }
.trump-name { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; }

/* the pencil scorepad — the one loud thing on the table */
.scorepad {
  justify-self: end;
  position: relative;
  display: grid; grid-template-columns: 1fr 1fr;
  min-width: 140px;
  padding: 4px 6px 6px;
  font-family: var(--hand);
  color: var(--graphite);
  background-color: var(--paper);
  background-image: repeating-linear-gradient(to bottom, transparent 0 23px, rgba(74, 104, 170, .16) 23px 24px);
  border-radius: 2px 2px 4px 3px;
  transform: rotate(1.6deg);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .1), 0 10px 18px rgba(0, 0, 0, .35);
}
.scorepad::before {
  content: ''; position: absolute; left: 50%; top: 4px; bottom: 6px; width: 2px;
  background: var(--graphite); opacity: .85; border-radius: 2px; transform: rotate(-.8deg);
}
.scorepad .col { text-align: center; padding: 0 8px; }
.scorepad .who {
  font-size: 1.45rem; font-weight: 700; line-height: 1.15;
  border-bottom: 2px solid var(--graphite);
  margin: 0 -4px 4px;
}
.scorepad .col:first-child .who { transform: rotate(-1deg); }
.scorepad .pts { font-size: 1.25rem; line-height: 1; margin-top: 2px; }
.scorepad .pts small { font-size: .8em; opacity: .7; }
.tally { display: flex; justify-content: center; align-items: flex-end; gap: 5px; height: 26px; padding-bottom: 2px; }
.tally i {
  display: block; width: 2.6px; height: 21px; border-radius: 2px;
  background: var(--graphite);
  transform: rotate(var(--r, 0deg));
}
/* games still needed: faint pencil dots */
.tally i.todo { width: 3.5px; height: 3.5px !important; border-radius: 50%; opacity: .35; transform: none; }
.tally i:nth-child(2) { --r: 4deg; height: 23px; }
.tally i:nth-child(3) { --r: -3deg; }
.tally i:nth-child(4) { --r: 6deg; height: 20px; }
.tally i:nth-child(5) { --r: -5deg; }

/* board */
.board { position: relative; min-height: 0; }
.opp {
  position: absolute;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  max-width: 34vw;
}
.opp.pos-top { top: 6px; left: 50%; transform: translateX(-50%); }
.opp.pos-left { left: 14px; top: 44%; transform: translateY(-50%); }
.opp.pos-right { right: 14px; top: 44%; transform: translateY(-50%); }
.backs { display: flex; padding-left: calc(var(--mw) * .62); }
.backs .mini-back {
  width: var(--mw); aspect-ratio: 5 / 7; border-radius: 3px;
  margin-left: calc(var(--mw) * -.62);
  background: var(--cobalt);
  box-shadow: inset 0 0 0 2px var(--porcelain), -1px 0 2px rgba(0, 0, 0, .3);
}
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 100%;
  padding: 4px 12px 4px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .28);
  border: 1.5px solid transparent;
  font-weight: 700;
  white-space: nowrap;
}
.tag .name { overflow: hidden; text-overflow: ellipsis; }
.tag.turn { background: var(--brass); color: var(--ink); border-color: #fff3d6; box-shadow: 0 0 0 4px rgba(227, 172, 62, .28); }
.tag.offline .name { text-decoration: line-through; opacity: .6; }
.tag .off { font-weight: 400; font-size: .8rem; opacity: .8; }
.dealer-chip {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--porcelain); color: var(--ink);
  font-family: var(--serif); font-weight: 800; font-size: .72rem;
  box-shadow: inset 0 0 0 2px var(--cobalt);
}
.face-up-trump { --w: calc(var(--tw) * .62); transform: rotate(-8deg); margin-top: -2px; }
.opp .face-up-trump { position: absolute; top: 100%; margin-top: 6px; }

.trick {
  position: absolute; left: 50%; top: 46%;
  transform: translate(-50%, -50%);
  width: calc(var(--tw) * 3.4);
  height: calc(var(--tw) * 3.25);
}
.trick .slot { position: absolute; width: var(--tw); }
.trick .slot .card { --w: var(--tw); }
.trick .slot.pos-top { top: 0; left: calc(50% - var(--tw) / 2); }
.trick .slot.pos-bottom { bottom: 0; left: calc(50% - var(--tw) / 2); }
.trick .slot.pos-left { left: 0; top: calc(50% - var(--tw) * .7); }
.trick .slot.pos-right { right: 0; top: calc(50% - var(--tw) * .7); }
.trick .slot.pos-top .card { transform: rotate(-4deg); }
.trick .slot.pos-bottom .card { transform: rotate(3deg); }
.trick .slot.pos-left .card { transform: rotate(-9deg); }
.trick .slot.pos-right .card { transform: rotate(8deg); }
.trick .card.win { box-shadow: 0 0 0 3px var(--brass), 0 0 22px rgba(227, 172, 62, .65), 0 6px 14px rgba(0, 0, 0, .3); z-index: 2; }
.trick.showing-last .card { opacity: .78; }
.trick-msg {
  position: absolute; left: 50%; top: calc(46% + var(--tw) * 1.62 + 10px);
  transform: translateX(-50%);
  margin: 0; padding: 3px 12px; border-radius: 999px;
  white-space: nowrap; font-weight: 700; font-size: .95rem;
  background: rgba(0, 0, 0, .3);
}
.trick-msg:empty { display: none; }

/* new cards slide in from their player's side */
@keyframes from-bottom { from { translate: 0 60%; opacity: 0; } }
@keyframes from-top { from { translate: 0 -60%; opacity: 0; } }
@keyframes from-left { from { translate: -60% 0; opacity: 0; } }
@keyframes from-right { from { translate: 60% 0; opacity: 0; } }
.slot.pos-bottom .card.enter { animation: from-bottom .22s ease-out; }
.slot.pos-top .card.enter { animation: from-top .22s ease-out; }
.slot.pos-left .card.enter { animation: from-left .22s ease-out; }
.slot.pos-right .card.enter { animation: from-right .22s ease-out; }

/* my side */
.me { padding: 0 10px max(12px, env(safe-area-inset-bottom)); }
.me-bar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  max-width: 760px; margin: 0 auto 10px;
}
.me-bar .tag { justify-self: start; }
.me-tools { justify-self: end; display: flex; gap: 8px; }
.icon-btn:disabled { opacity: .4; cursor: default; }
.prompt { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 1.15rem; text-align: center; white-space: nowrap; }
.prompt.mine { color: var(--brass); }
.hand {
  display: flex; justify-content: center;
  padding: 18px 0 0;
  min-height: calc(var(--w) * 1.4 + 18px);
}
.hand .card { margin-left: calc(var(--w) * -.42); transition: transform .12s ease, filter .12s ease; }
.hand .card:first-child { margin-left: 0; }
.hand.my-turn .card.legal { cursor: pointer; }
.hand.my-turn .card:not(.legal) { filter: brightness(.62) saturate(.6); }
.hand .card.selected { transform: translateY(-22%); box-shadow: 0 0 0 3px var(--brass), 0 10px 20px rgba(0, 0, 0, .35); }
.hand .card.is-trump::before {
  content: ''; position: absolute; left: 7%; right: 7%; bottom: 3%; height: 3px; border-radius: 2px;
  background: var(--brass);
}
@media (hover: hover) {
  .hand.my-turn .card.legal:hover { transform: translateY(-16%); z-index: 1; }
}

/* ============================================================ MODAL */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(8, 26, 20, .55);
  backdrop-filter: blur(2px);
}
.sheet {
  width: min(420px, 100%);
  max-height: calc(100dvh - 32px); overflow-y: auto;
  padding: 22px 24px 20px;
  color: var(--graphite);
  background-color: var(--paper);
  background-image: repeating-linear-gradient(to bottom, transparent 0 27px, rgba(74, 104, 170, .16) 27px 28px);
  border-radius: 3px;
  transform: rotate(-.6deg);
  box-shadow: 0 24px 50px rgba(0, 0, 0, .45);
}
.sheet h2 { font-family: var(--serif); font-weight: 800; font-size: 1.8rem; line-height: 1.1; margin: 0 0 4px; color: var(--ink); }
.modal-sub { margin: 0 0 14px; }
.big-score { display: grid; grid-template-columns: 1fr 1fr; font-family: var(--hand); text-align: center; position: relative; margin-bottom: 8px; }
.big-score::before { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: var(--graphite); transform: rotate(1deg); }
.big-score .who { font-size: 1.7rem; font-weight: 700; border-bottom: 2px solid var(--graphite); }
.big-score .n { font-size: 2.6rem; line-height: 1.1; }
.big-score .sub { font-size: 1.2rem; opacity: .75; }
.big-score .tally { height: 32px; }
.big-score .tally i { height: 26px; }
.big-score .winner .n { text-decoration: underline wavy rgba(180, 35, 48, .55) 2px; text-underline-offset: 6px; }
.history { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; font-size: .85rem; }
.history li { padding: 1px 8px; border-radius: 999px; border: 1px solid rgba(52, 51, 47, .3); }
.ready-list { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin: 16px 0 0; font-size: .95rem; }
.ready-list span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ready-list .ok::before { content: '✓ '; color: #1f7a4d; font-weight: 700; }
.ready-list .wait::before { content: '… '; opacity: .6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.modal-actions .btn.ghost { color: var(--graphite); border-color: rgba(52, 51, 47, .35); }

/* ============================================================ misc */
.toast {
  position: fixed; z-index: 80; left: 50%; bottom: calc(var(--w) * 1.4 + 80px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px);
  padding: 9px 16px; border-radius: 10px;
  background: var(--ink); color: #fff; font-weight: 500;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .35);
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
#conn-banner {
  position: fixed; z-index: 90; top: 0; left: 0; right: 0;
  padding: 6px 12px; text-align: center; font-weight: 700;
  background: var(--brass); color: var(--ink);
}
.host-only { display: none; }
body.is-host .host-only { display: revert; }
body.is-host .menu .host-only, body.is-host .modal-actions .host-only { display: inline-flex; }
body.is-host .menu .host-only { display: block; }

/* ============================================================ responsive */
@media (max-width: 820px) {
  .lobby-body { grid-template-columns: 1fr; }
  .chat-dock .chat { height: 300px; }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  .room-code { font-size: 2.1rem; }
  .lobby-table { height: 300px; }
  .felt-oval { inset: 64px 56px; }
  .seat-btn { min-width: 110px; padding: 8px 10px; }
  .hud { padding-left: 10px; padding-right: 10px; gap: 6px; }
  .trump { flex-direction: column; gap: 2px; }
  .trump-text { display: none; }
  .trump-suit { width: 40px; height: 40px; font-size: 24px; }
  .scorepad { min-width: 118px; }
  .scorepad .who { font-size: 1.2rem; }
  .scorepad .pts { font-size: 1.1rem; }
  .tally { height: 22px; gap: 4px; }
  .tally i { height: 18px; width: 2.4px; }
  :root {
    --w: clamp(48px, min(calc((100vw - 24px) / 5.6), 13dvh), 96px);
    --tw: clamp(44px, min(18vw, 11dvh), 84px);
  }
  .hand .card { margin-left: calc(var(--w) * -.5); }
  .opp.pos-left { left: 6px; top: 16%; transform: none; align-items: flex-start; }
  .opp.pos-right { right: 6px; top: 16%; transform: none; align-items: flex-end; }
  .lobby-table { width: calc(100% - 12px); }
  .tag { padding: 3px 9px 3px 8px; font-size: .9rem; }
  .opp .tag .name { max-width: 76px; }
  .prompt { font-size: 1rem; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .hud { padding-top: 6px; }
  .me-bar { margin-bottom: 4px; }
  .hand { padding-top: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
