@font-face {
  font-family: 'Stanley';
  src: url('/assets/fonts/subset-StanleyRegular.woff2') format('woff2');
  font-display: swap;
}

@font-face {
  font-family: 'Montserrat';
  font-weight: 400;
  src: url('/assets/fonts/montserrat-v14-latin-ext_latin-regular.woff2') format('woff2');
}

@font-face {
  font-family: 'Montserrat';
  font-weight: 500;
  src: url('/assets/fonts/montserrat-v14-latin-ext_latin-500.woff2') format('woff2');
}

:root {
  --greenOne: #2A7D50;
  --greenTwo: #27744A;
  --greenThree: #21633F;
  --greenFour: #1C5435;
  --yellow: #FCC537;
  --white: #ECECEC;
  --red: #9A0000;

  /* the game */
  --felt: #2A7D50;
  --felt-light: #34915F;
  --felt-deep: #226841;
  --rail: #1A4D31;
  --panel: rgba(14, 50, 31, 0.78);
  --panel-solid: #1A4D31;
  --ink: #143322;
  --cream: #F6EEDC;
  --gold: #FCC537;
  --line: rgba(246, 238, 220, 0.35);
}

/* the game is sized in rem, and a rem follows the viewport height (as in the Vue client) */
html { font-size: max(4px, 1vh); }
@media (min-height: 960px) { html { font-size: max(10px, 1vh); } }
/* mobile browsers: size by the viewport with their toolbars shown (svh), so the game always fits */
@supports (height: 1svh) {
  html { font-size: max(4px, 1svh); }
  @media (min-height: 960px) { html { font-size: max(10px, 1svh); } }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--greenOne);
  color: var(--yellow);
  font-family: 'Montserrat', sans-serif;
  font-weight: 500;
}

a { color: var(--yellow); cursor: pointer; }
a:hover { color: var(--white); }

h1, h2, h3 { font-weight: 500; }

/* buttons */

.ui-button {
  padding: max(7px, 1.1rem) max(12px, 1.8rem);
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--panel-solid);
  color: var(--cream);
  font: inherit;
  font-size: max(13px, 1.8rem);
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
.ui-button:hover:not(:disabled) { background: var(--felt-deep); }
.ui-button:focus-visible { outline: 2px solid var(--cream); outline-offset: 2px; }
.ui-button.active, .ui-button.active:hover:not(:disabled) { background: var(--gold); color: var(--ink); }
.ui-button.mandatory { border: 2px dashed var(--gold); }
.ui-button.primary, .ui-button.primary:hover:not(:disabled) { background: var(--gold); color: var(--ink); }
.ui-button:disabled { opacity: 0.4; cursor: default; }
.ui-button.secondary { background: transparent; border-color: var(--line); color: var(--cream); }

a.ui-button {
  text-align: center;
}

.spinner {
  width: max(28px, 5rem);
  height: max(28px, 5rem);
  margin: 2rem auto;
  border: max(3px, 0.5rem) solid rgba(236, 236, 236, 0.25);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/*
 * The landing page: the title, a hand of four heart courts held as a fan, and what to do next. Two columns on
 * wide screens and phones held sideways, stacked on phones held upright. Sized in px: it scrolls when short.
 */

.landing-page {
  --card: clamp(92px, min(13vw, 23vh), 200px);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(16px, 4vh, 40px);
  padding: clamp(16px, 4vh, 40px) 16px 16px;
  background: radial-gradient(ellipse 60% 55% at 50% 52%, var(--felt-light), var(--felt) 70%);
  color: var(--cream);
  font-size: 16px;
}

/* the title and the hand sit together in the middle, the footer at the bottom */
.landing-title { width: min(720px, 100%); margin-top: auto; }
.landing-title h1 { margin: 0; }
.landing-title img { display: block; width: 100%; height: auto; }

.landing-main {
  width: min(1040px, 100%);
  display: grid;
  grid-template-columns: 1fr minmax(280px, 400px);
  align-items: center;
  gap: clamp(24px, 6vw, 80px);
}

/* the hand: cards turn about a point below them, as fingers hold them */
.fan {
  position: relative;
  justify-self: center;
  width: calc(var(--card) * 3.1);
  height: calc(var(--card) * 1.725 * 1.18);
}
.fan-card {
  position: absolute;
  left: calc(50% - var(--card) / 2);
  bottom: 0;
  width: var(--card);
  aspect-ratio: 400 / 690;
  /* the images carry their own rounded, transparent corners: the shadow follows them */
  filter: drop-shadow(0 6px 9px rgba(0, 0, 0, 0.3));
  transform-origin: 50% 165%;
  rotate: calc(-21deg + var(--i) * 14deg);
  z-index: calc(var(--i) * 2);
  animation: fan-open 700ms cubic-bezier(0.2, 0.8, 0.2, 1) 150ms backwards;
}
@keyframes fan-open { from { rotate: 0deg; } }
.fan.dealt .fan-card { animation: none; }

/*
 * Clicked (Fan.scala, Web Animations): the hand closes into one card, turns over and becomes a deck of backs
 * (.fan-deck, in the closed hand's place) that is riffled and cut, then turns back and opens.
 */
.fan { cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.fan-card .turn {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: perspective(900px) rotateY(0deg);
}
.fan-card .face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.fan-card .face.back { transform: rotateY(180deg); }
.fan.shuffling .fan-card { visibility: hidden; }
.fan-deck { display: none; position: absolute; inset: 0; z-index: 10; }
.fan.shuffling .fan-deck { display: block; }
.deck-card {
  position: absolute;
  left: calc(50% - var(--card) / 2);
  bottom: 0;
  width: var(--card);
  aspect-ratio: 400 / 690;
  /*
   * each card's edge, so the cards of a pile tell apart, and the fan cards' shadow: fainter, as every card casts
   * one; a whole deck's add up to the closed hand's four (1 - 0.89^12 ≈ 1 - 0.7^4)
   */
  filter: drop-shadow(0 0 0.5px rgba(0, 0, 0, 0.35)) drop-shadow(0 6px 9px rgba(0, 0, 0, 0.11));
}

.landing-panel { display: flex; flex-direction: column; gap: 18px; }
.greeting { margin: 0 0 24px; font-size: 24px; color: var(--cream); }
.greeting .username { color: var(--gold); }
.main-buttons, .login-controls, .registration-controls { display: flex; flex-direction: column; gap: 12px; }

.btn-big {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 14px 20px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: transparent;
  color: var(--cream);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 120ms, border-color 120ms;
}
.btn-big .label { font-size: 19px; }
.btn-big .hint { font-size: 14px; font-weight: 400; opacity: 0.75; }
.btn-big:hover:not(:disabled) { border-color: var(--cream); background: rgba(246, 238, 220, 0.06); }
.btn-big.primary { border-color: var(--gold); background: var(--gold); color: var(--ink); }
.btn-big.primary:hover:not(:disabled) { border-color: #FFD45E; background: #FFD45E; }
.btn-big:focus-visible { outline: 3px solid var(--cream); outline-offset: 3px; }
.btn-big:disabled { opacity: 0.6; cursor: default; }
/* sign-in links: alike, light, each with its provider's own mark (brand marks are drawn on light grounds) */
.login-controls { gap: 10px; }
.login-controls .btn-big {
  position: relative;
  align-items: center;
  padding: 12px 16px 12px 52px;
  border-color: var(--cream);
  background: var(--cream);
  color: var(--ink);
  font-size: 16px;
}
.login-controls .btn-big:hover { border-color: #fff; background: #fff; }
.login-controls .btn-big span { white-space: nowrap; }
/* centred in a 24px slot; sized by eye to one visual weight: the round marks smaller, the open squares larger */
.provider-logo { position: absolute; left: 30px; top: 50%; width: 20px; height: 20px; transform: translate(-50%, -50%); }
.provider-google .provider-logo { width: 20px; height: 20px; }
.provider-facebook .provider-logo { width: 18px; height: 18px; }
.provider-microsoft .provider-logo { width: 22px; height: 22px; }
.provider-x .provider-logo { width: 17px; height: 17px; }
.provider-discord .provider-logo { width: 23px; height: 23px; }
.registration-controls input, .login-controls .dev-login {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: var(--cream);
  color: var(--ink);
  font: inherit;
  font-size: 18px;
}
.registration-controls input:focus, .login-controls .dev-login:focus { outline: none; border-color: var(--gold); }
/* the test login (dev and test servers only), set apart from the real sign-ins */
.login-controls .dev-login { margin-top: 8px; padding: 12px 16px; border-style: dashed; border-color: var(--gold); font-size: 16px; }

/* who is around: quiet, under what to do */
.lobby-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 16px;
  margin-top: 28px;
  font-size: 14px;
  text-align: center;
  color: rgba(246, 238, 220, 0.7);
}
.lobby-stats:empty { display: none; }
.lobby-stats .stat { white-space: nowrap; }
.lobby-stats .count { color: var(--cream); font-weight: 600; font-variant-numeric: tabular-nums; }
.lobby-stats .stat-online::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--gold);
  vertical-align: 1px;
}

.landing-panel .spinner { margin: 24px auto; }
.landing-panel .error { padding: 6px 12px; border-radius: 6px; background: var(--red); color: var(--white); font-size: 15px; }
.landing-panel .error:empty { display: none; }

/* the private table's option, in its card: a checkbox on the card's last row (beside the button in the markup, as
   a button can't hold one) */
.create-table { position: relative; }
.create-table.with-option .btn-big { padding-bottom: 44px; }
.table-option {
  position: absolute;
  left: 20px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--cream);
  font-size: 14px;
  cursor: pointer;
}
.table-option input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 5px;
  box-shadow: inset 0 0 0 2px var(--line);
  cursor: pointer;
  transition: background-color 120ms;
}
.table-option:hover input { box-shadow: inset 0 0 0 2px var(--cream); }
/* the tick: drawn in the checkbox's own background */
.table-option input:checked {
  background: var(--gold) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 10.5l3.2 3.2L15 7' fill='none' stroke='%23143322' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
  box-shadow: none;
}
.table-option input:focus-visible { outline: 3px solid var(--cream); outline-offset: 2px; }
.table-option:has(input:disabled) { opacity: 0.6; cursor: default; }

/* two columns: the panel's first button level with the top of the hand (the tallest card stands this far into the
   fan's box), the greeting a line above it; signing in, the first provider a row above it */
.landing-main { align-items: start; padding-top: calc(var(--card) * 0.13); }
.landing-panel { margin-top: calc(var(--card) * 0.27); }
.greeting { line-height: 1.25; margin: calc(-1.25em - 22px) 0 22px; }
.login-controls { margin-top: -52px; }
/*
 * The title and the hand stand where they would if the page held only them (a third of the way down the room the
 * footer leaves), whatever the panel beside the hand holds: they stay put on signing in. A taller panel only reaches
 * further down.
 */
.landing-page {
  --pad: clamp(16px, 4vh, 40px);
  --title-w: min(720px, 100vw - 32px);
  --title-h: calc(var(--title-w) * 0.10348);
  --hand-h: calc(var(--card) * (0.13 + 1.725 * 1.18));
  --foot-h: 34px;
}
.landing-title {
  width: var(--title-w);
  margin-top: max(0px, calc((100dvh - 2 * var(--pad) - 16px - var(--title-h) - var(--hand-h) - var(--foot-h)) / 2 * 0.35));
}

.landing-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px 24px;
  margin-top: auto;
  font-size: 14px;
  color: rgba(246, 238, 220, 0.7);
}
.landing-foot .menu { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; }
.landing-foot a { color: inherit; text-decoration: none; }
.landing-foot a:hover { color: var(--cream); text-decoration: underline; }
.menu .item { white-space: nowrap; }
.languages { display: flex; padding: 3px; border-radius: 999px; background: var(--panel); }
.language {
  padding: 4px 12px;
  border: none;
  border-radius: 999px;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.language.current { background: var(--cream); color: var(--ink); }
.landing-foot .version { font-size: 12px; opacity: 0.7; }

/* a phone held sideways: little height, so a smaller title and hand */
@media (max-height: 500px) and (orientation: landscape) {
  .landing-page { --card: clamp(72px, 24vh, 110px); gap: 12px; padding-top: 12px; }
  .landing-page { --pad: 12px; --title-w: min(420px, 60vw); }
  /* too short to centre anything: the title at the top */
  .landing-title { margin-top: 0; }
  .landing-main { grid-template-columns: 1fr minmax(260px, 360px); gap: 24px; }
  .btn-big, .login-controls .btn-big { padding: 8px 16px; }
  .login-controls .btn-big { font-size: 15px; }
  .btn-big .label { font-size: 17px; }
  .btn-big .hint { font-size: 13px; }
  .greeting { font-size: 20px; margin: calc(-1.25em - 8px) 0 8px; }
  /* no room above the hand under the title here: the first provider level with it */
  .login-controls { margin-top: 0; }
  .create-table.with-option .btn-big { padding-bottom: 36px; }
  .table-option { left: 16px; bottom: 9px; }
}

/* upright or narrow: one column, the hand under the title */
@media (orientation: portrait), (max-width: 640px) {
  .landing-page { --card: clamp(84px, 24vw, 160px); }
  .landing-title { margin-top: auto; }
  .landing-main { grid-template-columns: 1fr; align-content: start; gap: 24px; max-width: 440px; }
  .greeting { text-align: center; margin: 0 0 8px; }
  .landing-main { padding-top: 0; }
  .landing-panel, .login-controls { margin-top: 0; }
}

@media (prefers-reduced-motion: reduce) { .fan-card { animation: none; } }

/* the game: sized by the viewport (a rem is 1vh), laid out for a phone held sideways first */

.game {
  position: relative;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  --hdr: clamp(30px, 5.5rem, 52px);
  --gutter: max(8px, 1.6rem);
  /* cards on the table (the trick, the talon); this player's hand is larger, the others' backs smaller */
  /* the card images are 400px wide: up to 200px they stay sharp on a 2x screen */
  --card-w: min(11rem, 7.2vw, 200px);
  --card-h: calc(var(--card-w) * 1.725);
  --hand-w: min(13rem, 9.5vw, 200px);
  --hand-h: calc(var(--hand-w) * 1.725);
  --back-w: calc(var(--card-w) * 0.72);
  --back-h: calc(var(--back-w) * 1.725);
  /* the hand's room: twelve cards, the most one holds, each showing over half of itself, leaving room beside it
     for the discard piles */
  --hand-max: min(calc(var(--hand-w) * 7.2), 100vw - 2 * (var(--card-w) * 1.6 + 1.4rem + var(--gutter)));
  /* above the hand: room for a lifted card, then the name plate */
  --lift: 2.4rem;
  --plate-h: calc(max(12px, 1.9rem) * 1.6);
}
@media (max-height: 560px) { .game { --hand-w: min(15rem, 9.5vw, 200px); } }

/* the header: the logo tab, what the deal is about, the menu */

.game-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  height: var(--hdr);
  /* a gold stripe along the top, the logo tab and the menu hanging from it */
  border-top: 3px solid var(--gold);
  pointer-events: none;
}
.game-header > * { pointer-events: auto; }
.game-header .logo {
  position: relative;
  flex: none;
  height: 100%;
  padding: 0 calc(var(--hdr) * 0.3) 0 calc(var(--hdr) * 0.4);
  background: var(--gold);
  border-bottom-right-radius: calc(var(--hdr) * 0.45);
  display: flex;
  align-items: center;
}
.game-header .logo a { text-decoration: none; }
.game-header .logo h1 {
  margin: 0;
  color: var(--felt);
  font-family: 'Stanley', serif;
  font-weight: 400;
  font-size: calc(var(--hdr) * 0.5);
  white-space: nowrap;
}
.game-header .menu {
  flex: none;
  height: 100%;
  margin-left: auto;
  padding: 0 calc(var(--hdr) * 0.4);
  background: var(--panel);
  border-bottom-left-radius: calc(var(--hdr) * 0.45);
  display: flex;
  align-items: center;
  gap: 1.2em;
  font-size: max(11px, 1.6rem);
}
.game-header .menu a { color: var(--cream); text-decoration: none; }
.game-header .menu a:hover { color: var(--gold); }

/* what the deal is about, under the logo */
.contract {
  position: absolute;
  top: calc(var(--hdr) + 0.8rem);
  left: var(--gutter);
  z-index: 3;
  max-width: min(30vw, 56rem);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em;
  font-size: max(11px, 1.6rem);
  white-space: nowrap;
}
.contract > span {
  padding: 0.25em 0.75em;
  border-radius: 1em;
  background: var(--panel);
  color: var(--cream);
}
@media (max-height: 560px) { .contract { gap: 0.3em; max-width: 36vw; font-size: 11px; } }

/* cards */

.playing-card {
  display: block;
  width: var(--card-w);
  height: var(--card-h);
  /* the images' own rounded corners */
  border-radius: 5.5% / 3.2%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

/* the table: a felt with a rail, lighter where the trick lands */

.playfield { position: absolute; inset: 0; }
.table-surface {
  position: absolute;
  top: calc(var(--hdr) + var(--plate-h) + var(--back-h) * 0.5);
  bottom: calc(var(--hand-h) * 0.6);
  left: max(14vw, calc(50% - 60rem));
  right: max(14vw, calc(50% - 60rem));
  border-radius: 999px;
  background: radial-gradient(ellipse at 50% 50%, var(--felt-light) 0%, var(--felt) 75%);
  box-shadow: 0 0 0 max(4px, 0.7rem) var(--rail), inset 0 0.4rem 2rem rgba(0, 0, 0, 0.2);
}

/* the players: across the top, at the sides, and this player along the bottom */

.players { position: absolute; inset: 0; pointer-events: none; }
.player { position: absolute; display: flex; gap: 1.2rem; pointer-events: auto; }
.player.hidden { visibility: hidden; }
.player-main { position: relative; display: flex; flex-direction: column; gap: 0.6rem; }

.player-top { top: calc(var(--hdr) + 0.8rem); left: 50%; transform: translateX(-50%); align-items: center; }
/* the name plate centred above the cards, the discard pile beside them, out of the centring */
.player-top .player-main { align-items: center; }
.player-top .pile { position: absolute; right: calc(100% + 1.4rem); bottom: 0; }
/* anchored by their name plates, so a discard pile under the cards does not move them */
.player-left, .player-right { top: calc(50% - var(--back-h) * 0.9); flex-direction: column; }
.player-left { left: var(--gutter); align-items: flex-start; }
.player-right { right: var(--gutter); align-items: flex-end; }
.player-left .player-main { align-items: flex-start; }
.player-right .player-main { align-items: flex-end; }
/* a fixed width, so neither the name plate nor the discard piles move as the hand shrinks */
.player-bottom { bottom: 0; left: 50%; width: var(--hand-max); transform: translateX(-50%); justify-content: center; }
.player-bottom .player-main { align-items: center; gap: 0; }
.player-bottom .player-info { max-width: 100%; }
.player-bottom .pile { position: absolute; left: calc(100% + 1.4rem); bottom: max(6px, 1.2rem); padding: 0; min-width: 0; }
.player-bottom .pile-declarer { bottom: calc(max(6px, 1.2rem) + var(--card-h) * 0.5 + 0.8rem); }
.player-top .pile-others, .player-bottom .pile-others { order: -1; }

/* name plates; the player the table waits for is ringed in gold */
.player-info {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  max-width: 40vw;
  padding: 0.25em 0.8em;
  border-radius: 1em;
  background: var(--panel);
  font-size: max(12px, 1.9rem);
  white-space: nowrap;
}
/* over what lies in the middle (the talon, the trick) when they meet, under the bubbles */
.player-info { z-index: 3; }
.player-info .nickname { color: var(--cream); overflow: hidden; text-overflow: ellipsis; }
.player-info .nickname.offline { opacity: 0.45; }
/* a player can have two (declarer and dealer): the name gives way, the pictograms stay whole */
.player-info .role {
  flex: none;
  display: grid;
  place-items: center;
  padding: 0.2em;
  border-radius: 50%;
  background: rgba(252, 197, 55, 0.16);
  color: var(--gold);
  font-size: 0.78em;
}
.player-info .role.declarer { background: var(--gold); color: var(--ink); }
.player-info .role-icon { display: block; width: 1.25em; height: 1.25em; }
.player.to-act .player-info { box-shadow: 0 0 0 2px var(--gold); }
.player.to-act .nickname { color: var(--gold); }
/* a dot on the plate's corner: it never changes the plate's size, so nothing around it moves */
.player.to-act .player-info::before {
  content: '';
  position: absolute;
  top: -0.25em;
  left: -0.25em;
  width: 0.7em;
  height: 0.7em;
  box-shadow: 0 0 0 2px var(--felt-deep);
  border-radius: 50%;
  background: var(--gold);
  animation: waiting 1.4s ease-in-out infinite;
}
@keyframes waiting { 50% { opacity: 0.25; } }

/* speech bubbles: each player's last move, pointing at them; it fades once it is no longer news */
.bubble {
  position: absolute;
  z-index: 4;
  width: max-content;
  max-width: min(40rem, 26vw);
  padding: 0.45em 0.8em;
  border-radius: 0.7em;
  background: var(--cream);
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  font-size: max(12px, 1.8rem);
  line-height: 1.25;
  white-space: normal;
  animation: bubble-in 200ms cubic-bezier(0.3, 1.5, 0.5, 1);
  transition: opacity 400ms;
}
.bubble.stale { opacity: 0.6; }
.bubble::before { content: ''; position: absolute; border: 0.45em solid transparent; }
.player-top .bubble, .player-left .bubble { left: calc(100% + 0.9em); top: 0; }
.player-top .bubble::before, .player-left .bubble::before { right: 100%; top: 0.55em; border-right-color: var(--cream); }
.player-right .bubble { right: calc(100% + 0.9em); top: 0; }
.player-right .bubble::before { left: 100%; top: 0.55em; border-left-color: var(--cream); }
/* it pops in, opaque from the start: the discards it announces fly under it, and must not show through */
@keyframes bubble-in { from { scale: 0.6; } }

/* the others' cards: how many they hold */
.backs { display: flex; }
.backs .playing-card { width: var(--back-w); height: var(--back-h); }
.backs .playing-card + .playing-card { margin-left: calc(var(--back-w) * -0.72); }

/* this player's hand */
/* its own stacking context: the seals are above every card of the hand, and nothing else */
.hand { display: flex; justify-content: center; align-items: flex-end; padding: var(--lift) 0 max(6px, 1.2rem); isolation: isolate; }
/*
 * positioned so lifted cards keep painting in DOM order instead of jumping above their neighbours; lifted by top,
 * not a transform, which would make each card a layer of its own and keep its seal under the next card
 */
.hand .playing-card {
  position: relative;
  top: 0;
  width: var(--hand-w);
  height: var(--hand-h);
  transition: top 120ms ease-out, filter 150ms;
}
/* each card shows 60% of itself, less only when that would overflow the hand's room */
.hand .playing-card + .playing-card {
  margin-left: calc(min(var(--hand-w) * 0.6, (var(--hand-max) - var(--hand-w)) / max(var(--n) - 1, 1)) - var(--hand-w));
}
.hand .playing-card.active { cursor: pointer; }
@media (hover: hover) { .hand .playing-card.active:hover { top: -1.8rem; } }
/* picked (for the exchange): slid up, with a seal on its top edge counting the picks, gold like every selection */
/* the hand's cards are boxes holding the image, so marks can sit over it */
.hand .playing-card > img { display: block; width: 100%; height: 100%; border-radius: inherit; pointer-events: none; }
.hand .playing-card.selected { top: -2.4rem; }
.hand .seal {
  position: absolute;
  left: 50%;
  top: 0;
  translate: -50% -50%;
  width: calc(var(--hand-w) * 0.3);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFD45E, var(--gold) 70%);
  box-shadow: 0 0 0 2px var(--cream), 0 3px 6px rgba(0, 0, 0, 0.45);
  color: var(--ink);
  font-size: calc(var(--hand-w) * 0.15);
  font-weight: 500;
  line-height: 1;
  scale: 0;
  transition: scale 180ms cubic-bezier(0.3, 1.6, 0.5, 1);
  pointer-events: none;
  z-index: 1;
}
.hand .playing-card.selected .seal { scale: 1; }
@media (prefers-reduced-motion: reduce) { .hand .seal { transition: none; } }
.hand .playing-card.dimmed { filter: brightness(0.6) saturate(0.7); }

/* discard piles: each card shows 40% of itself */
.pile { display: flex; align-self: flex-end; min-width: calc(var(--card-w) * 1.2); padding-bottom: 1.2rem; }
.player-left .pile, .player-right .pile, .player-top .pile { align-self: auto; min-width: 0; padding: 0; }
.pile:empty { display: none; }
.pile .playing-card { width: calc(var(--card-w) * 0.5); height: calc(var(--card-h) * 0.5); }
.pile .playing-card + .playing-card { margin-left: calc(var(--card-w) * -0.3); }

/* the middle: the talon while bidding, then the trick */

.talon, .trick { position: absolute; left: 50%; width: 0; height: 0; }
.talon { top: 42%; display: flex; transform: translate(calc(var(--card-w) * -0.65), calc(var(--card-h) * -0.35)); }
/* centred between the top player and the hand */
.trick { top: calc((var(--hdr) + var(--plate-h) + var(--back-h) + 100% - var(--hand-h) - var(--lift)) / 2); }
.talon .playing-card { position: absolute; width: calc(var(--card-w) * 0.7); height: calc(var(--card-h) * 0.7); }
.talon .playing-card:nth-child(2) { left: calc(var(--card-w) * 0.12); }
.talon .playing-card:nth-child(3) { left: calc(var(--card-w) * 0.24); }
.talon .playing-card:nth-child(4) { left: calc(var(--card-w) * 0.36); }
.talon .playing-card:nth-child(5) { left: calc(var(--card-w) * 0.48); }
.talon .playing-card:nth-child(6) { left: calc(var(--card-w) * 0.60); }
.talon-card[class*="fly-to-"] { animation: 320ms ease-in calc(var(--i) * 180ms) forwards; }
.talon-card.fly-to-bottom { animation-name: talon-to-bottom; }
.talon-card.fly-to-top { animation-name: talon-to-top; }
.talon-card.fly-to-left { animation-name: talon-to-left; }
.talon-card.fly-to-right { animation-name: talon-to-right; }
@keyframes talon-to-bottom { to { transform: translate(0, 45vh); opacity: 0; } }
@keyframes talon-to-top { to { transform: translate(0, -40vh); opacity: 0; } }
@keyframes talon-to-left { to { transform: translate(-42vw, 0); opacity: 0; } }
@keyframes talon-to-right { to { transform: translate(42vw, 0); opacity: 0; } }

/* each card comes in from its player's side; the winner of a taken trick is ringed, and the trick stays until
   the next lead, when all go to the taker (--collect: Pacing.trickCollected) */
.trick-card {
  position: absolute;
  --at: translate(-50%, -50%);
  transform: var(--at);
  animation: 260ms cubic-bezier(0.2, 0.7, 0.3, 1);
  transition: box-shadow 150ms;
}
.trick-bottom { --at: translate(-50%, calc(-50% + var(--card-h) * 0.42)); animation-name: from-bottom; }
.trick-top { --at: translate(-50%, calc(-50% - var(--card-h) * 0.42)); animation-name: from-top; }
.trick-left { --at: translate(calc(-50% - var(--card-w) * 0.8), -50%); animation-name: from-left; }
.trick-right { --at: translate(calc(-50% + var(--card-w) * 0.8), -50%); animation-name: from-right; }
@keyframes from-bottom { from { transform: var(--at) translate(0, 40vh); } }
@keyframes from-top { from { transform: var(--at) translate(0, -35vh); } }
@keyframes from-left { from { transform: var(--at) translate(-38vw, 0); } }
@keyframes from-right { from { transform: var(--at) translate(38vw, 0); } }
/* a card seen leaving its hand flies from there instead (GamePage.flyFrom) */
.trick-card.flown { animation: none; }
/* the winner: a gold ring with a thin black line on both of its edges (stacked spreads: the first paints on top) */
.trick-card.winner {
  z-index: 1;
  box-shadow: 0 0 0 1px #111, 0 0 0 4px var(--gold), 0 0 0 5px #111, 0 4px 12px rgba(0, 0, 0, 0.4);
}
/* a taken trick flying to its taker over the next lead coming in (GamePage.trickLeaving); moving from the first
   frame (an ease-in sits still at first, which reads as lag), fading as it lands */
.trick-leaving { position: absolute; inset: 0; pointer-events: none; }
.trick-leaving .trick-card { animation: none; }
.trick-leaving.go .trick-card {
  transition: transform var(--collect) cubic-bezier(0.3, 0.2, 0.6, 1), opacity var(--collect) ease-in;
  opacity: 0;
}
.trick-leaving.go.leaving-bottom .trick-card { transform: translate(-50%, -50%) translate(0, 45vh) scale(0.6); }
.trick-leaving.go.leaving-top .trick-card { transform: translate(-50%, -50%) translate(0, -40vh) scale(0.6); }
.trick-leaving.go.leaving-left .trick-card { transform: translate(-50%, -50%) translate(-42vw, 0) scale(0.6); }
.trick-leaving.go.leaving-right .trick-card { transform: translate(-50%, -50%) translate(42vw, 0) scale(0.6); }

/* this player's turn: what to do, and the buttons for it, just above the hand */

.controls {
  position: absolute;
  left: 50%;
  /* the gaps in pixels at least: on a short screen (a phone held sideways) a rem is only 4px */
  bottom: calc(var(--hand-h) + max(6px, 1.2rem) + var(--lift) + var(--plate-h) + max(12px, 1.2rem));
  z-index: 5;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(110rem, 72vw);
  display: none;
  flex-direction: column;
  align-items: center;
  gap: max(8px, 0.8rem);
}
.controls.open { display: flex; }
.controls .prompt {
  padding: 0.3em 0.9em;
  border-radius: 1em;
  background: var(--cream);
  color: var(--ink);
  font-size: max(12px, 1.9rem);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.controls .button-pane { display: flex; flex-wrap: wrap; justify-content: center; gap: max(6px, 0.9rem); }
.controls .button-pane:empty { display: none; }
.controls .button-row { display: flex; flex-wrap: wrap; justify-content: center; gap: max(6px, 0.9rem); }
.controls .ui-button { min-width: 11rem; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); }
/* the trump to call, and the others in a list behind the triangle */
.split-button { display: inline-flex; border-radius: 999px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); }
.controls .split-button .ui-button { box-shadow: none; }
.controls .split-button .ui-button:first-child { border-radius: 999px 0 0 999px; }
.controls .split-toggle {
  position: relative;
  min-width: 0;
  padding-left: 1.4em;
  padding-right: 1.6em;
  border-left: 1px solid var(--line);
  border-radius: 0 999px 999px 0;
}
/* the select covers the triangle, unseen: tapping it opens the list */
.split-toggle select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; cursor: pointer; }
/*
 * announcements: the figures, then the button that says the chosen ones, in two rows, the first a little longer (the
 * break is placed by announcementControls)
 */
.controls .announce .figures, .controls .announce .actions { display: contents; }
.controls .announce .break { flex-basis: 100%; height: 0; }
.controls .ui-button.mandatory.active { cursor: default; }
.controls .figures-toggle { display: none; }
.figures-toggle .caret { margin-left: 0.4em; }
/* the finished deal: the scores button sits where the hand was */
.controls[data-phase="game-over"] { bottom: calc(var(--hand-h) * 0.5); }

/* phones, upright or sideways: the figures fold away above the say button until asked for */
@media (max-aspect-ratio: 1/1), (max-height: 560px) {
  .controls .figures-toggle { display: inline-block; }
  .controls .announce { flex-direction: column; align-items: center; }
  .controls .announce .actions { display: flex; gap: max(6px, 0.9rem); }
  .controls .announce .break { display: none; }
  .controls .announce .figures {
    display: none;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    max-width: calc(100vw - 2 * var(--gutter));
    padding: 10px;
    border-radius: 14px;
    background: var(--panel-solid);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  }
  .controls .announce.open .figures { display: flex; }
}

/* the log: a corner panel on large screens, behind a button on small ones */

.log-panel {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
}
.log-toggle {
  display: none;
  margin: 0 0 var(--gutter) var(--gutter);
  padding: 0.35em 0.9em;
  border: none;
  border-radius: 1em;
  background: var(--panel);
  color: var(--cream);
  font: inherit;
  font-size: max(12px, 1.7rem);
  cursor: pointer;
}
.action-log {
  width: 30rem;
  max-height: 28rem;
  overflow-y: auto;
  padding: 0.6rem 0;
  border-top-right-radius: 1rem;
  background: var(--panel);
  color: rgba(246, 238, 220, 0.8);
  font-size: max(11px, 1.4rem);
}
.action-log .line { padding: 0.3em 0.9em; }
.action-log .line:last-child { color: var(--cream); }
.action-log .who { color: var(--cream); }
.action-log .who.me { color: var(--gold); }
.action-log .announcement { color: var(--gold); text-align: center; }
@media (max-height: 560px), (max-aspect-ratio: 3/2) {
  .log-toggle { display: block; }
  .action-log { display: none; }
  .log-panel.open .action-log {
    display: block;
    width: min(42rem, 45vw);
    max-height: 60vh;
    margin-left: var(--gutter);
    margin-bottom: 0.8rem;
    border-radius: 1rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  }
  .log-panel.open .log-toggle { background: var(--gold); color: var(--ink); }
}

/*
 * A phone held upright: sized by the width; the contract wraps under the header, the others sit across the top
 * third, the trick in the middle, and the hand runs edge to edge above the bottom, with the name plate over it.
 */
@media (max-aspect-ratio: 1/1) {
  .game {
    --hdr: clamp(36px, 11vw, 52px);
    --gutter: 10px;
    --card-w: min(16vw, 10rem);
    --hand-w: min(15.5vw, 12rem);
    --back-w: min(8.5vw, 6rem);
  }
  .game-header .menu { gap: 1em; }

  .contract { max-width: calc(100% - 2 * var(--gutter) - 7em); font-size: 12px; }

  .table-surface {
    top: calc(var(--hdr) + var(--back-h) + 18rem);
    bottom: calc(var(--hand-h) + 7rem);
    left: 5vw;
    right: 5vw;
  }

  /* a row below the contract, which can take three lines */
  .player-top { top: calc(var(--hdr) + 15rem); }
  .player-top .player-main { flex-direction: column; gap: 0.5rem; }
  .player-left, .player-right { top: calc(var(--hdr) + var(--back-h) + 28rem); transform: none; }
  .backs .playing-card + .playing-card { margin-left: calc(var(--back-w) * -0.78); }
  .player-info { max-width: 44vw; font-size: 13px; }
  /* the side plates end before the talon (in the middle, 0.65 cards to either side) */
  .player-left .player-info, .player-right .player-info { max-width: calc(50vw - var(--gutter) - var(--card-w) * 0.65 - 8px); }
  .player-info { gap: 0.45em; }

  .bubble { max-width: 44vw; font-size: 13px; }
  .player-top .bubble { left: 50%; top: calc(100% + 0.7em); transform: translateX(-50%); }
  .player-top .bubble::before { right: auto; top: auto; bottom: 100%; left: calc(50% - 0.45em); border-color: transparent; border-bottom-color: var(--cream); }
  .player-left .bubble, .player-right .bubble { top: calc(100% + 0.7em); }
  /* the side players' piles (the first one, empty or not, moves both) under the room of a one-line bubble (its
     offset, line and padding, in ems of 13px), less the gap: a fading bubble does not show them through it */
  .player-left .pile-others, .player-right .pile-others { margin-top: calc(13px * (0.7 + 1.25 + 0.9) + 5px - 1.2rem); }
  .player-left .bubble { left: 0; }
  .player-right .bubble { left: auto; right: 0; }
  .player-left .bubble::before, .player-right .bubble::before {
    top: auto;
    bottom: 100%;
    border-color: transparent;
    border-bottom-color: var(--cream);
  }
  .player-left .bubble::before { left: 1em; right: auto; }
  .player-right .bubble::before { right: 1em; left: auto; }

  /* the hand: as wide as the screen, the name plate above its left end, the piles above its right end */
  .game { --hand-max: calc(100vw - 2 * var(--gutter)); }
  /* room for a lifted card under the name plate */
  /* the piles beside the name plate: the declarer's at the left, the others' at the right */
  .player-bottom .pile { left: auto; right: 0; bottom: calc(var(--hand-h) + max(6px, 1.2rem) + var(--lift)); }
  .player-bottom .pile-declarer { left: 0; right: auto; }

  .trick { top: calc((var(--hdr) + 2 * var(--back-h) + 30rem + 100% - var(--hand-h) - 6rem) / 2); }
  /* the talon just under the top player's bubble (a share of the height lands on it on a tall phone), clear of
     the bid buttons on a short one */
  .talon { top: calc(var(--hdr) + 15.5rem + var(--plate-h) + var(--back-h) + 52px + var(--card-h) * 0.35); }

  .controls {
    bottom: calc(var(--hand-h) + max(6px, 1.2rem) + var(--lift) + 30px + 0.8rem);
    max-width: calc(100% - 2 * var(--gutter));
  }
  .controls .ui-button { min-width: 0; padding: 8px 14px; font-size: 14px; }

  /* the log opens from the top right, under the menu */
  .log-panel { top: calc(var(--hdr) + 0.8rem); bottom: auto; left: auto; right: var(--gutter); flex-direction: column; align-items: flex-end; }
  .log-toggle { display: block; margin: 0; font-size: 12px; }
  .action-log { display: none; }
  .log-panel.open .action-log {
    display: block;
    width: min(320px, calc(100vw - 2 * var(--gutter)));
    max-height: 55vh;
    margin: 0.8rem 0 0;
    border-radius: 1rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  }
  .log-panel.open .log-toggle { background: var(--gold); color: var(--ink); }
}

/* overlays and dialogs */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: var(--gutter, 12px);
  background: rgba(8, 30, 18, 0.7);
  color: var(--cream);
  font-size: max(13px, 2rem);
}
/* waiting for players: the table stays visible, dimmed */
.overlay.dim { z-index: 8; background: rgba(8, 30, 18, 0.82); color: rgba(246, 238, 220, 0.8); }
/* matchmaking: the table's four seats, the taken ones gold */
.queue-count { display: flex; flex-direction: column; align-items: center; gap: 1.2rem; }
.queue-count .seats { display: flex; gap: max(8px, 1.4rem); }
.queue-count .seat {
  width: max(10px, 1.8rem);
  height: max(10px, 1.8rem);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(246, 238, 220, 0.45);
}
.queue-count .seat.taken { background: var(--gold); box-shadow: none; }

.modal {
  max-width: min(max(110rem, 640px), 100%);
  max-height: 100%;
  overflow: auto;
  padding: max(12px, 2rem) max(14px, 3rem);
  border-radius: max(8px, 1.2rem);
  background: var(--panel-solid);
  color: var(--cream);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  font-size: max(13px, 1.9rem);
}
.modal h3, .modal h2 { margin: 0 0 0.6em; color: var(--gold); font-weight: 500; }
.modal-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 3rem; }
.modal .close { background: none; border: none; color: var(--cream); font-size: max(22px, 3rem); line-height: 1; cursor: pointer; }
.modal-buttons { display: flex; gap: 1.5rem; justify-content: flex-end; margin-top: 2rem; }
.modal label { display: block; }
.modal textarea { width: min(80rem, 80vw); margin-top: 1rem; padding: 1rem; border-radius: 0.6rem; border: none; font: inherit; }

.invite { color: var(--cream); }
.invite-link { display: flex; flex-wrap: wrap; gap: 1rem; }
.invite-link input { flex: 1; min-width: 20rem; padding: 0.6em; border: none; border-radius: 0.5em; font: inherit; }
.invite-link .ui-button.done { background: var(--gold); color: var(--ink); }

/*
 * The private table's lobby: who sits at the table, as cards dealt onto it (the free seats are their outlines),
 * then the invite link. Sized in em of the dialog, so it scales with the game.
 */
.lobby {
  width: min(100%, max(600px, 104rem));
  padding: max(16px, 2.6rem) max(16px, 3.4rem);
  border: 1px solid rgba(252, 197, 55, 0.22);
  background: linear-gradient(180deg, var(--panel-solid), #163F28);
}
.lobby-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.6em 1.5em; margin-bottom: 1.2em; }
.lobby-title { display: flex; align-items: center; gap: 0.8em; }
.lobby .lobby-title h2 { margin: 0; font-size: 1.45em; }
.lobby-badge {
  padding: 0.2em 0.75em;
  border: 1px solid var(--gold);
  border-radius: 999px;
  color: var(--gold);
  font-size: 0.68em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.lobby-count { display: flex; align-items: center; gap: 0.7em; color: rgba(246, 238, 220, 0.75); font-size: 0.85em; }
.pips { display: flex; gap: 0.35em; }
.pip { width: 0.7em; height: 0.7em; border: 1.5px solid var(--line); border-radius: 50%; transition: background-color 240ms, border-color 240ms; }
.pip.on { border-color: var(--gold); background: var(--gold); }

.lobby-seats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1em; }
.lobby-seat {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  aspect-ratio: 5 / 7;
  min-width: 0;
  padding: 0.8em 0.5em;
  border-radius: 0.7em;
  text-align: center;
}
/* a card face: cream, with a thin frame inside its edge */
.lobby-seat.taken {
  background: var(--cream);
  color: var(--ink);
  box-shadow: 0 0.4em 1em rgba(0, 0, 0, 0.35), inset 0 0 0 0.35em var(--cream), inset 0 0 0 calc(0.35em + 1px) rgba(20, 51, 34, 0.22);
  animation: seat-dealt 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.lobby-seat.taken.me {
  box-shadow: 0 0.4em 1em rgba(0, 0, 0, 0.35), 0 0 0 2px var(--gold), inset 0 0 0 0.35em var(--cream), inset 0 0 0 calc(0.35em + 1px) rgba(20, 51, 34, 0.22);
}
@keyframes seat-dealt { from { opacity: 0; transform: translateY(-1.6em) rotate(-6deg) scale(0.95); } }
.seat-index { position: absolute; color: rgba(20, 51, 34, 0.45); font-size: 0.8em; line-height: 1; }
.seat-index.top { top: 1em; left: 1em; }
.seat-index.bottom { right: 1em; bottom: 1em; transform: rotate(180deg); }
.lobby-seat.free {
  border: 2px dashed var(--line);
  background: repeating-linear-gradient(135deg, rgba(246, 238, 220, 0.035) 0 0.5em, transparent 0.5em 1em);
  color: rgba(246, 238, 220, 0.55);
}
.lobby-seat .avatar {
  display: grid;
  place-items: center;
  width: 2.4em;
  height: 2.4em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--felt-light), var(--felt-deep));
  box-shadow: inset 0 0 0 2px rgba(252, 197, 55, 0.65);
  color: var(--cream);
  font-size: 1.35em;
}
.lobby-seat.free .avatar { border: 2px dashed var(--line); background: none; box-shadow: none; }
.seat-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.95em; }
.seat-tags { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.3em; min-height: 1.3em; }
/* capitals only: centred by their cap height (trimmed where supported, else by a little more padding on top) */
.tag {
  padding: 0.42em 0.65em 0.32em;
  border-radius: 999px;
  font-size: 0.64em;
  line-height: 1;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
@supports (text-box: trim-both cap alphabetic) {
  .tag { padding: 0.45em 0.7em; text-box: trim-both cap alphabetic; }
}
.tag-me { background: var(--gold); color: var(--ink); }
.tag-host { background: var(--ink); color: var(--gold); }
.tag-offline { background: rgba(20, 51, 34, 0.14); color: var(--ink); }
/* a dropped connection: the card greys, its player keeps the seat */
.lobby-seat.taken.offline { background: #D8D1C0; }
.lobby-seat.offline .avatar { filter: grayscale(1); opacity: 0.5; }
.lobby-seat.offline .seat-name { opacity: 0.55; }
.lobby-seat .kick {
  position: absolute;
  top: 0.4em;
  right: 0.4em;
  display: grid;
  place-items: center;
  width: 1.6em;
  height: 1.6em;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(20, 51, 34, 0.09);
  color: var(--ink);
  font: inherit;
  line-height: 1;
  cursor: pointer;
  transition: background-color 120ms, color 120ms;
}
.lobby-seat .kick:hover { background: var(--red); color: var(--cream); }
.lobby-seat .kick:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.lobby-seat .add-bot { margin-top: 0.2em; padding: 0.45em 1em; font-size: 0.8em; white-space: nowrap; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); }

.lobby-error { margin-top: 0.8em; padding: 0.4em 0.8em; border-radius: 6px; background: var(--red); color: var(--white); font-size: 0.85em; text-align: center; }
.lobby-error:empty { display: none; }
.lobby-note { margin: 0.9em 0 1.2em; color: rgba(246, 238, 220, 0.6); font-size: 0.82em; text-align: center; }
.lobby .invite { padding-top: 1.1em; border-top: 1px solid rgba(246, 238, 220, 0.14); }
.lobby .invite h3 { margin: 0 0 0.25em; font-size: 1em; }
.lobby .invite p { margin: 0 0 0.7em; color: rgba(246, 238, 220, 0.7); font-size: 0.85em; }

/* a phone held upright: two rows of seats */
@media (max-width: 560px) {
  .lobby-seats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.7em; }
  .lobby-seat { aspect-ratio: 6 / 5; }
}
/* little height (a phone held sideways): low cards */
@media (max-height: 500px) and (orientation: landscape) {
  .lobby { padding: 12px 16px; }
  .lobby-head { margin-bottom: 0.7em; }
  .lobby-seat { aspect-ratio: auto; min-height: 7.5em; padding: 0.6em 0.4em; gap: 0.3em; }
  .lobby-seat .avatar { width: 2em; height: 2em; font-size: 1.1em; }
  .lobby-note { margin: 0.5em 0 0.7em; }
  .lobby .invite { padding-top: 0.7em; }
  .lobby .invite p { display: none; }
}

.score-table { overflow-x: auto; }
.score-table table { border-collapse: collapse; color: var(--cream); font-variant-numeric: tabular-nums; }
.score-table th, .score-table td { padding: 0.35em 0.8em; text-align: right; white-space: nowrap; }
.score-table th { font-weight: 400; color: rgba(246, 238, 220, 0.7); }
.score-table thead tr:last-child th { color: var(--cream); }
.score-table td.figure { text-align: left; color: var(--cream); padding-left: 0; }
.score-table .me { background: rgba(252, 197, 55, 0.12); }
.score-table thead tr:last-child th.me { color: var(--gold); }
.score-table tr.total td { border-top: 2px solid var(--gold); font-size: 1.15em; color: var(--gold); }
.score-table tr.total td.neg { color: var(--cream); }
@media (max-height: 560px) { .modal.scores { font-size: 12px; } .modal.scores .modal-title h2 { font-size: 16px; } }

@media (prefers-reduced-motion: reduce) {
  .game *, .game *::before { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

/* legal pages and admin */

/* the header is sized like the game's (the --hdr it uses is defined per page) */
.legal-page { --hdr: clamp(36px, 5.5rem, 52px); min-height: 100vh; min-height: 100dvh; font-size: max(14px, 1vh); }
.legal-page .game-header { position: static; font-size: max(9px, 0.8rem); }

.admin-page { max-width: 1100px; margin: 0 auto; padding: 32px 16px; font-size: 16px; color: var(--white); }
.admin-page h1 { color: var(--yellow); text-align: center; }
.admin-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.admin-card { padding: 16px 20px; background: var(--greenThree); border-radius: 6px; }
.admin-card h2 { margin-top: 0; color: var(--yellow); font-size: 20px; }
.admin-card label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.admin-card input, .admin-card select { padding: 8px; font: inherit; }
.admin-page .ui-button { font-size: 15px; }
.bot-list { list-style: none; padding: 0; }
.bot-list li { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; background: var(--greenFour); margin-bottom: 4px; }
.bot-list .remove { background: var(--red); color: var(--white); border: none; border-radius: 4px; padding: 2px 10px; cursor: pointer; }
.admin-message { min-height: 1.5em; }
.issued-token { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.issued-token .hint { flex-basis: 100%; margin: 0; }
.issued-token input { flex: 1; min-width: 0; padding: 8px; font-family: monospace; font-size: 13px; }
.token-list li { gap: 8px; }
.token-list li > span { min-width: 0; overflow-wrap: anywhere; }
.token-list li.revoked { opacity: 0.55; }

/* server errors (e.g. an annotation that was not saved) */
.toast {
  position: fixed;
  top: calc(max(7px, 0.8rem) * 6 + 2rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 1rem 2rem;
  border-radius: 0.4rem;
  background: var(--red);
  color: var(--white);
  font-size: max(12px, 1.8rem);
}
.toast .close { background: none; border: none; color: var(--white); font-size: max(16px, 2.4rem); cursor: pointer; }

/* debug-only post-game annotation, inside the scores dialog */
.annotation { margin-top: 2rem; }
.annotation textarea { display: block; width: 100%; }
.admin-card .hint { font-size: 13px; opacity: 0.8; }

/* the scores on a narrow screen: four columns of numbers must fit without scrolling */
@media (max-width: 600px) {
  .modal.scores { padding: 14px 12px; }
  .score-table table { font-size: 12px; }
  .score-table th, .score-table td { padding: 0.35em 0.4em; }
  .score-table thead tr:last-child th { max-width: 5.5em; overflow: hidden; text-overflow: ellipsis; }
  .score-table td.figure { white-space: normal; }
}

/* the tutorial (/tutorial): the intro's cards, the lesson's bubbles over the table */

.tutorial-intro .intro-stage {
  position: absolute;
  top: calc(var(--hdr) + 1rem);
  left: 0;
  right: 0;
  bottom: min(30vh, 26rem);
}
/* upright, the lesson chip sits under the header, in the middle: the cards start under it */
@media (orientation: portrait) {
  .tutorial-intro .intro-stage { top: calc(clamp(30px, 5.5vh, 52px) + max(34px, 5rem) + max(12px, 1.6rem) * 1.5 + 1.2rem + 8px); bottom: 38vh; }
}
@media (max-width: 480px) { .tutor-actions .dots { display: none; } }
.intro-card {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cw);
  height: calc(var(--cw) * 1.725);
  transition: transform 750ms cubic-bezier(0.2, 0.75, 0.25, 1), opacity 500ms ease;
  transition-delay: var(--d, 0s);
}
/* a flip: the card turns over (3D), and the face shown swaps halfway, when it is edge-on (no backface-visibility,
   which WebKit ignores here) */
.intro-card-inner {
  position: absolute;
  inset: 0;
  transform: perspective(900px) rotateY(0deg);
  transition: transform 600ms ease var(--d, 0s);
}
.intro-card.down .intro-card-inner { transform: perspective(900px) rotateY(180deg); }
.intro-card .face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: calc(var(--cw) * 0.06);
  box-shadow: 0 0.3rem 1rem rgba(0, 0, 0, 0.3);
  transition: opacity 0s linear calc(var(--d, 0s) + 300ms), filter 500ms ease;
}
.intro-card .back { transform: scaleX(-1); opacity: 0; }
.intro-card.down .back { opacity: 1; }
.intro-card.down .front { opacity: 0; }
.intro-card.glow .front { box-shadow: 0 0 0 3px var(--gold), 0 0 2.4rem 0.6rem rgba(252, 197, 55, 0.65); animation: glow 1.6s ease-in-out infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 0 3px var(--gold), 0 0 1rem 0.2rem rgba(252, 197, 55, 0.35); } }
.intro-label {
  position: absolute;
  transform: translate(-50%, -50%);
  color: var(--cream);
  font-size: max(12px, 1.8rem);
  white-space: nowrap;
  animation: fade-in 600ms ease 400ms backwards;
}
.intro-label.big {
  display: grid;
  place-items: center;
  width: max(26px, 4.6rem);
  height: max(26px, 4.6rem);
  border-radius: 50%;
  background: var(--gold);
  color: var(--ink);
  font-size: max(14px, 2.4rem);
}
@keyframes fade-in { from { opacity: 0; } }

/* the tutor's bubble: the text full width, the tutor in its corner */
.intro-caption, .tutor-bubble {
  display: flex;
  padding: max(9px, 1.4rem) max(12px, 2rem);
  border-radius: max(10px, 1.6rem);
  background: var(--panel-solid);
  color: var(--cream);
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.45), 0 0 0 1px var(--line);
  font-size: max(14px, 2rem);
  line-height: 1.45;
}
.intro-caption {
  position: absolute;
  left: 50%;
  bottom: max(10px, 2rem);
  transform: translateX(-50%);
  width: min(92vw, 640px);
  z-index: 60;
}
/* the text and its Next (or hint) side by side when they fit, the Next under the text when not */
.tutor-body { display: flex; flex-wrap: wrap; align-items: flex-end; gap: max(6px, 1rem) max(12px, 2rem); min-width: 0; flex: 1; }
.tutor-text { flex: 1 1 auto; min-width: 0; }
.tutor-body > .tutor-actions { margin-left: auto; }
/* evened-out lines: no lone word on the last one, a less ragged right edge */
.tutor-text { text-wrap: pretty; }
/* long words broken at their syllables (by the page's language), only where that leaves a few letters on each side */
.tutor-text { -webkit-hyphens: auto; hyphens: auto; hyphenate-limit-chars: 5 3 3; }
/* a list beside the tutor: each item a box of its own, so it narrows beside her rather than running under her */
.tutor-list { margin: 0.4em 0 0; padding: 0; list-style: none; }
.tutor-list li { display: flow-root; position: relative; padding-left: 1.1em; margin-top: 0.2em; }
.tutor-list li::before { content: ""; position: absolute; left: 0.25em; top: 0.62em; width: 0.32em; height: 0.32em; border-radius: 50%; background: var(--gold); }
.tutor-bubble.measuring .tutor-body { flex-wrap: nowrap; }
.intro-caption .tutor-actions { flex-basis: 100%; }
/* in a round gold frame in the text's corner, floated, so the text flows beside and under her */
.tutor-badge {
  float: left;
  box-sizing: border-box;
  /* with the space under her, exactly three lines of text tall (the bubble's line-height is 1.45): the fourth line
     starts under her */
  width: calc(3 * 1.45em - 0.4em);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: radial-gradient(circle at 50% 40%, #2f6b47, #173a27);
  box-shadow: 0 0.2rem 0.7rem rgba(0, 0, 0, 0.45);
  margin: 0 max(8px, 1.2rem) 0.4em 0;
}
.tutor-actions { display: flex; align-items: center; justify-content: flex-end; gap: max(8px, 1.4rem); clear: both; }
/* the intro's Skip, Back and Next stay together; only the dots give way */
.tutor-buttons { display: flex; align-items: center; gap: max(8px, 1.4rem); flex: none; white-space: nowrap; margin-left: auto; }
.tutor-actions .dots { display: flex; gap: 6px; margin-right: auto; }
.tutor-actions .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); transition: background 300ms; }
.tutor-actions .dot.on { background: var(--gold); }
.tutor-actions .skip { color: var(--cream); opacity: 0.7; font-size: 0.85em; }
.tutor-hint { color: var(--gold); font-size: 0.9em; animation: pulse-text 1.2s ease-in-out infinite alternate; }
@keyframes pulse-text { to { opacity: 0.55; } }

.tutorial-layer { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.tutorial-layer > * { pointer-events: auto; }
/* one stacking order for the lesson's layer: the shade, the chip above it (it can be clicked), the bubble on top;
   so the spot is absolute (a fixed one would stack as a whole) */
.tutorial-spot { position: absolute; inset: 0; pointer-events: none; }
/* the shade fades in once, with the step: its holes are redrawn as the targets move, and must not fade again */
.tutorial-spot svg.dim { position: absolute; inset: 0; z-index: 1; pointer-events: none; animation: fade-in 300ms ease; }
.tutorial-spot .shade { fill: rgba(6, 24, 14, 0.55); }
.tutorial-spot .ring { fill: none; stroke: var(--gold); stroke-width: 3; animation: ring 1.1s ease-in-out infinite alternate; }
@keyframes ring { to { stroke-opacity: 0.35; } }
.tutor-bubble { position: fixed; z-index: 3; pointer-events: auto; animation: bubble-in 320ms cubic-bezier(0.2, 0.8, 0.3, 1.2); }
@keyframes bubble-in { from { opacity: 0; transform: translateY(1.5rem) scale(0.96); } }
.tutorial-chip {
  position: fixed;
  top: calc(var(--hdr, 44px) + 0.8rem);
  right: max(8px, 1.6rem);
  display: flex;
  gap: 1.4rem;
  align-items: center;
  padding: 0.6rem 1.6rem;
  border-radius: 999px;
  background: var(--panel);
  color: var(--cream);
  font-size: max(12px, 1.6rem);
}
.tutorial-chip .lesson-title { color: var(--gold); }
.tutorial-chip .exit { color: var(--cream); }
.tutorial-nudge {
  position: fixed;
  left: 50%;
  bottom: calc(var(--hand-h, 20vh) + 6rem);
  transform: translateX(-50%);
  max-width: min(90vw, 480px);
  padding: 1rem 2rem;
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink);
  font-size: max(13px, 1.8rem);
  box-shadow: 0 0.6rem 2rem rgba(0, 0, 0, 0.4);
  animation: bubble-in 250ms ease;
}
/* the table set back: a sweep and the rewind sign */
.tutorial-rewind {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(6, 24, 14, 0.5);
  backdrop-filter: blur(3px);
  animation: rewind var(--rewind, 900ms) ease both;
}
.tutorial-rewind .icon { font-size: max(48px, 14rem); color: var(--gold); animation: rewind-spin var(--rewind, 900ms) ease-in-out both; }
@keyframes rewind { 0% { opacity: 0; } 30%, 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes rewind-spin { from { transform: rotate(0deg); } to { transform: rotate(-540deg); } }
.tutorial-done p { max-width: 60ch; }
.tutorial-done .modal-buttons { align-items: center; }
.tutorial-done .modal-buttons .exit { margin-right: auto; color: var(--cream); }
.tutorial-done .modal-buttons .ui-button { white-space: nowrap; }
/* narrow, the two buttons share the row and the way out goes under them */
@media (max-width: 480px) {
  .tutorial-done .modal-buttons { flex-wrap: wrap; gap: 1.2rem; }
  .tutorial-done .modal-buttons .ui-button { flex: 1; }
  .tutorial-done .modal-buttons .exit { order: 1; flex-basis: 100%; margin: 0.4rem 0 0; text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  .intro-card, .intro-card-inner { transition-duration: 1ms; }
  .tutorial-rewind, .tutorial-rewind .icon, .tutor-bubble { animation: none; }
}
.intro-card.dim .face { filter: brightness(0.42) saturate(0.6); }
@media (max-width: 480px) { .tutor-actions .dots { display: none; } }
.btn-big.learn { text-decoration: none; }
/* what can be clicked stays out of the lesson's shade: the header, the lesson's chip */
.tutorial-lesson .game-header { z-index: 46; }
/* In a lesson the layer is no box of its own (a fixed one would stack as a whole), so the game's log can go between
   its parts: the shade, the chip, the log once opened (over the chip), the log's own shade (where a step lights lines
   of it), the bubble, the chip's opened contents over all. */
.tutorial-lesson { position: relative; }
.tutorial-lesson .tutorial-layer { display: contents; }
.tutorial-lesson .tutorial-layer > :not(.tutorial-spot), .tutorial-lesson .tutorial-spot svg.dim { z-index: 41; }
.tutorial-lesson .tutorial-layer > .tutorial-chip { z-index: 42; }
.tutorial-lesson .log-panel.open { z-index: 43; }
/* solid: lines lit in it would show the lit table through it */
.tutorial-lesson .log-panel.open .action-log { background: var(--panel-solid); }
.tutorial-lesson .tutorial-spot svg.log-shade { z-index: 44; }
.tutorial-lesson .tutor-bubble, .tutorial-lesson .tutorial-count { z-index: 45; }
.tutorial-lesson .tutorial-layer > .tutorial-chip.open { z-index: 47; }
.tutorial-chip { z-index: 2; top: calc(clamp(30px, 5.5vh, 52px) + max(10px, 1.6rem)); }
/* the intro's dealt table is the game page's, without its cards (the intro's own fly there) and its chrome */
.intro-ghost { position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity 600ms ease 0.6s; }
.intro-ghost.shown { opacity: 1; }
.intro-ghost .playing-card, .intro-ghost .game-header, .intro-ghost .table-surface, .intro-ghost .controls,
.intro-ghost .log-panel, .intro-ghost .overlay, .intro-ghost .contract, .intro-ghost .toast { visibility: hidden; }
/* the cards stay under the caption */
.tutorial-intro .intro-stage { z-index: 1; }
.intro-caption .tutor-actions { flex-wrap: wrap; }
/* upright, the log's button sits at the top right: the chip goes under the contract, in the middle */
@media (orientation: portrait) {
  .tutorial-chip { right: auto; left: 50%; transform: translateX(-50%); top: calc(clamp(30px, 5.5vh, 52px) + max(34px, 5rem)); }
}
.tutorial-chip .lesson-number { color: var(--gold); margin-right: -0.8rem; }
.tutorial-chip { white-space: nowrap; }
/* winding forward, like a video tape: the table softly blurred and dulled, scan lines, a tracking band rolling down,
   the deck's "▶▶" in the corner */
.tutorial-ff {
  position: fixed;
  inset: 0;
  backdrop-filter: blur(2.5px) saturate(0.6) contrast(1.15);
  -webkit-backdrop-filter: blur(2.5px) saturate(0.6) contrast(1.15);
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.16) 0 2px, transparent 2px 4px);
  animation: fade-in 200ms ease;
  overflow: hidden;
}
.tutorial-ff .tracking {
  position: absolute;
  left: 0;
  right: 0;
  height: 9vh;
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.14) 40%, rgba(255, 255, 255, 0.06) 60%, transparent);
  animation: tracking 1.1s linear infinite;
}
@keyframes tracking { from { top: -10vh; } to { top: 100vh; } }
.tutorial-ff .osd {
  position: absolute;
  top: calc(clamp(30px, 5.5vh, 52px) + 2rem);
  left: max(16px, 3rem);
  color: #fff;
  font-family: 'Courier New', monospace;
  font-size: max(22px, 4.5rem);
  font-weight: bold;
  letter-spacing: -0.15em;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
}
@media (prefers-reduced-motion: reduce) { .tutorial-ff .tracking { animation: none; display: none; } }

/* the course's contents: from the lesson's chip, and on a lesson's end */
.tutorial-chip { padding: 0.4rem; }
.tutorial-chip .chip-toggle {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.3rem 0.9rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.tutorial-chip .chip-toggle:hover, .tutorial-chip.open .chip-toggle { background: rgba(246, 238, 220, 0.1); }
.tutorial-chip .caret { color: var(--gold); transition: transform 150ms; }
.tutorial-chip.open .caret { transform: rotate(180deg); }
.tutorial-chip .lesson-number { margin-right: 0; }
.tutorial-contents-menu {
  position: absolute;
  top: calc(100% + 0.8rem);
  right: 0;
  min-width: max(240px, 34rem);
  padding: 0.8rem;
  border-radius: max(10px, 1.4rem);
  background: var(--panel-solid);
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.45), 0 0 0 1px var(--line);
  animation: bubble-in 200ms ease;
}
.tutorial-contents { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.tutorial-contents button {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  width: 100%;
  padding: max(7px, 0.9rem) max(10px, 1.4rem);
  border: none;
  border-radius: max(8px, 1rem);
  background: transparent;
  color: var(--cream);
  font: inherit;
  font-size: max(13px, 1.8rem);
  text-align: left;
  cursor: pointer;
}
.tutorial-contents button:hover { background: rgba(246, 238, 220, 0.08); }
.tutorial-contents .mark {
  display: grid;
  place-items: center;
  flex: none;
  width: max(22px, 3.4rem);
  height: max(22px, 3.4rem);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--line);
  font-size: 0.85em;
}
.tutorial-contents .done .mark { background: var(--gold); color: var(--ink); box-shadow: none; }
.tutorial-contents .current button { background: rgba(252, 197, 55, 0.14); }
.tutorial-contents .current .name { color: var(--gold); }
.tutorial-done .tutorial-contents { margin: 1.4rem 0 0.4rem; }
.intro-layer { z-index: 70; }

/* the deal counted: both sides' cards and points, and the way to 48 */
.tutorial-count {
  position: fixed;
  left: 50%;
  top: calc(clamp(30px, 5.5vh, 52px) + 4.5rem);
  z-index: 2;
  transform: translateX(-50%);
  width: min(94vw, 760px);
  max-height: calc(100% - clamp(30px, 5.5vh, 52px) - 6rem);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: max(8px, 1.4rem);
  padding: max(10px, 1.8rem) max(12px, 2.2rem);
  border-radius: max(10px, 1.6rem);
  background: var(--panel-solid);
  color: var(--cream);
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.45), 0 0 0 1px var(--line);
  pointer-events: auto;
  animation: bubble-in 320ms cubic-bezier(0.2, 0.8, 0.3, 1.2);
  --cc: clamp(28px, 4.6rem, 52px);
}
.count-side { display: flex; flex-direction: column; gap: 0.6rem; }
.count-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; font-size: max(14px, 2rem); }
.count-side.ours .count-names { color: var(--gold); }
.count-points { font-size: 1.5em; font-variant-numeric: tabular-nums; }
.count-side.ours .count-points { color: var(--gold); }
.count-cards { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end; }
.count-card {
  position: relative;
  display: flex;
  animation: count-in 300ms ease calc(min(var(--i) * 40ms, 640ms) + 200ms) backwards;
}
.count-card .playing-card { width: var(--cc); height: calc(var(--cc) * 1.725); border-radius: calc(var(--cc) * 0.06); }
.count-card.hidden .playing-card + .playing-card { margin-left: calc(var(--cc) * -0.75); }
.count-value {
  position: absolute;
  right: -0.4rem;
  bottom: -0.4rem;
  min-width: max(18px, 2.6rem);
  height: max(18px, 2.6rem);
  display: grid;
  place-items: center;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--gold);
  color: var(--ink);
  font-size: max(11px, 1.4rem);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.count-put-down { display: flex; gap: 0.5rem; align-items: flex-end; margin-left: 0.8rem; padding-left: 1.2rem; border-left: 1px dashed var(--line); }
.count-label { align-self: center; font-size: max(11px, 1.4rem); color: rgba(246, 238, 220, 0.7); writing-mode: vertical-rl; transform: rotate(180deg); }
@keyframes count-in { from { opacity: 0; transform: translateY(-1rem) scale(0.9); } }
.count-bar { position: relative; height: max(10px, 1.4rem); margin: 1.6rem 0 0.4rem; border-radius: 999px; background: rgba(246, 238, 220, 0.18); }
.count-bar-ours {
  height: 100%;
  width: var(--share);
  border-radius: 999px;
  background: var(--gold);
  animation: bar-in 1.2s ease 300ms backwards;
}
@keyframes bar-in { from { width: 0; } }
.count-bar-mark { position: absolute; top: -0.6rem; bottom: -0.6rem; width: 2px; background: var(--cream); }
.count-bar-mark span { position: absolute; bottom: calc(100% + 0.2rem); left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: max(11px, 1.4rem); }
@media (prefers-reduced-motion: reduce) { .count-card, .count-bar-ours, .tutorial-count { animation: none; } }
/* the count on a phone: upright, compact at the top, the bubble below; sideways, on the left, the bubble beside it */
@media (orientation: portrait) and (max-width: 640px) {
  .tutorial-count { --cc: clamp(20px, 6.2vw, 40px); top: calc(clamp(30px, 5.5vh, 52px) + 1rem); max-height: calc(100% - clamp(30px, 5.5vh, 52px) - 1rem - 10px); gap: 0.8rem; padding: 10px 12px; }
  .count-cards { gap: 0.35rem; }
  .count-value { min-width: 14px; height: 14px; font-size: 9px; right: -0.3rem; bottom: -0.3rem; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .tutorial-count { --cc: 20px; top: 40px; max-height: calc(100% - 48px); gap: 6px; padding: 8px 10px; }
  .count-head { font-size: 13px; }
  .count-value { min-width: 13px; height: 13px; font-size: 8px; right: -0.3rem; bottom: -0.3rem; }
  .count-bar { margin-top: 14px; }
}
@media (orientation: portrait) and (max-width: 640px) {
  /* the way to 48 first: the cards below may scroll */
  .tutorial-count .count-bar { order: -1; margin: 1.6rem 0 0.4rem; flex: none; }
}
@media (orientation: portrait) {
  /* the chip is centred upright: so is its menu, popping up in place as on a large screen (its own keyframes keep
     the centring, which the transform does) */
  .tutorial-contents-menu { right: auto; left: 50%; transform: translateX(-50%); min-width: min(90vw, 340px); animation-name: menu-in-centred; }
}
@keyframes menu-in-centred { from { opacity: 0; transform: translateX(-50%) translateY(1.5rem) scale(0.96); } }

/* a count's explanation, in its panel: the step's text and Next, above the count */
.count-say { display: flex; padding-bottom: max(8px, 1.2rem); border-bottom: 1px solid var(--line); font-size: max(14px, 2rem); line-height: 1.45; }
@media (max-height: 500px) and (orientation: landscape) { .count-say { font-size: 13px; } }
@media (orientation: portrait) and (max-width: 640px) { .count-say { font-size: 14px; } }

/* a picked card's seal stands over the edge of the hand: above the player's name plate */
.player-bottom .hand { position: relative; z-index: 4; }
.count-say { order: -2; }

/* the header's sound button: a speaker, with its waves, or struck through */
.sound-toggle {
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  background: none;
  color: var(--cream);
  cursor: pointer;
}
.sound-toggle:hover { color: var(--gold); }
.sound-toggle .icon { width: max(16px, 2.2rem); height: max(16px, 2.2rem); }
.sound-toggle .cross { display: none; }
.sound-toggle.muted .waves { display: none; }
.sound-toggle.muted .cross { display: inline; }
.sound-toggle.muted { opacity: 0.7; }

/* the rules: one readable column; each rule's number hangs in the margin, the sub-rules indented */
.rules-body {
    padding: 32px 16px 64px;
    -webkit-hyphens: auto;
    hyphens: auto;
    hyphenate-limit-chars: 5 3 3;
}
.rules {
  max-width: 760px;
  margin: 0 auto;
  color: var(--cream);
  font-size: 16px;
  line-height: 1.6;
  text-wrap: pretty;
}
.rules h1 { margin: 0 0 24px; color: var(--gold); font-size: 32px; }
.rules h2 { margin: 40px 0 12px; color: var(--gold); font-size: 22px; }
.rules h3 { margin: 28px 0 8px; color: var(--gold); font-size: 17px; }
.rules h1, .rules h2, .rules h3 { line-height: 1.25; }
.rules p { margin: 0 0 10px; }
.rules ul { margin: 0 0 10px; padding-left: 1.2em; }
.rules li { margin-bottom: 6px; }
.rules a { color: var(--gold); }
/*
 * Callouts, as GitHub's: a warning (gold, a triangle) asks the reader to act, an info (cream, an "i") explains. Each has
 * a titled first line with its icon, so they differ by more than their colour.
 */
.rules .callout { margin: 0 0 12px; padding: 12px 16px; border-left: 3px solid var(--callout); border-radius: 4px; background: rgba(0, 0, 0, 0.12); font-size: 15px; }
.rules .callout.warning { --callout: var(--gold); }
.rules .callout.info { --callout: var(--cream); margin-top: 16px; }
.rules .callout p { margin: 0; }
.rules .callout p + p { margin-top: 6px; }
.rules .callout .callout-title { display: flex; align-items: center; gap: 8px; color: var(--callout); font-weight: 600; }
.rules .callout .callout-title::before {
  content: "";
  flex: none;
  width: 18px;
  height: 18px;
  background: var(--callout);
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.rules .callout.warning { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.5 1.5 21h21L12 2.5zm-1.2 7h2.4v6h-2.4v-6zm0 7.8h2.4v2.4h-2.4v-2.4z'/%3E%3C/svg%3E"); }
.rules .callout.info { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 1.5a10.5 10.5 0 1 1 0 21 10.5 10.5 0 0 1 0-21zm-1.2 9v7.5h2.4v-7.5h-2.4zm0-4v2.4h2.4V6.5h-2.4z'/%3E%3C/svg%3E"); }
.rules .rule { padding-left: 3.4em; text-indent: -3.4em; }
.rules .rule b { display: inline-block; min-width: 3.4em; text-indent: 0; color: var(--gold); font-weight: 500; }
.rules .rule.sub { margin-left: 1.6em; }
/* a rule linked to (#rule-10.7): lit up for a moment, a little clear of the top of the screen */
.rules .rule { scroll-margin-top: 24px; }
.rules .rule:target { animation: rule-shown 2.4s ease-out; border-radius: 4px; }
@keyframes rule-shown {
  from, 30% { background: rgba(252, 197, 55, 0.22); box-shadow: 0 0 0 8px rgba(252, 197, 55, 0.22); }
  to { background: transparent; box-shadow: 0 0 0 8px transparent; }
}
.rules .note { margin-left: 5em; font-style: italic; opacity: 0.85; }
/* the tournaments' penalty, wherever a rule incurs it */
.rules .renonsz {
  padding: 0 0.4em;
  border: 1px solid var(--gold);
  border-radius: 4px;
  color: var(--gold);
  font-size: 0.8em;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.rules .closing { margin-top: 32px; color: var(--gold); text-align: center; }
.rules sup { line-height: 0; }
.rules sup a { text-decoration: none; }
.rules .footnotes { margin-top: 40px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; opacity: 0.85; }
.rules .footnotes p + p { margin-top: 6px; }
.rules .footnotes p:target { animation: rule-shown 2.4s ease-out; border-radius: 4px; }
/* the privacy policy and the terms, in the rules' column: their sections numbered in gold before each heading */
.rules.legal > ol { counter-reset: section; margin: 0; padding: 0; list-style: none; }
.rules.legal > ol > li { counter-increment: section; }
.rules.legal h2::before { content: counter(section) ". "; }
.rules.legal ul { list-style: disc; }
.rules.legal h4 { margin: 16px 0 4px; color: var(--gold); font-size: 16px; font-weight: 500; }
.rules.legal b { font-weight: 600; }
.rules.legal table { width: 100%; margin: 8px 0 16px; border-collapse: collapse; font-size: 14px; line-height: 1.45; }
.rules.legal th, .rules.legal td { padding: 8px 10px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.rules.legal th { background: rgba(0, 0, 0, 0.15); color: var(--gold); font-weight: 500; }
/* a wide table scrolls sideways on a phone, rather than squeezing its columns */
@media (max-width: 640px) { .rules.legal table { display: block; overflow-x: auto; } }
@media (max-width: 480px) {
  .rules { font-size: 15px; }
  .rules h1 { font-size: 26px; }
  .rules h2 { font-size: 20px; }
  .rules .rule { padding-left: 2.8em; text-indent: -2.8em; }
  .rules .rule b { min-width: 2.8em; }
  .rules .rule.sub { margin-left: 0.8em; }
  .rules .note { margin-left: 3.6em; }
}

/* a narrow phone: the header's logo and menu (contact, bug report, sound) fit side by side with tighter spacing */
@media (max-width: 420px) {
  .legal-page { --hdr: clamp(36px, 11vw, 52px); }
  .game-header .logo { padding: 0 10px 0 12px; }
  .game-header .menu { padding: 0 10px; gap: 0.8em; }
}
@media (max-width: 380px) {
  .game-header .logo { padding: 0 8px 0 10px; }
  .game-header .menu { padding: 0 8px; gap: 0.6em; }
}

/* a suit's sign in the tutor's text (the intro's suits), as on the cards; inline, so it never parts from its name */
.suit-sign {
  margin-left: 0.15em;
  padding: 0 0.18em;
  border-radius: 0.2em;
  background: var(--cream);
  color: #1a1a1a;
  font-size: 0.85em;
}
.suit-sign.red { color: #c8102e; }
