:root {
  color-scheme: dark;
  --ink: #f6f4ec;
  --muted: #aeb8b3;
  --dark: #09120f;
  --panel: #101d18;
  --line: rgba(255, 255, 255, 0.12);
  --green: #21d07a;
  --green-dark: #0c7542;
  --yellow: #ffd33d;
  --red: #ff4b4b;
  --blue: #64a7ff;
  --card-width: 104px;
  --card-height: 146px;
}

.setup-modal {
  width: min(780px, calc(100% - 28px));
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.setup-rules-link {
  margin-top: 10px;
  padding: 0;
  border: 0;
  color: var(--green);
  background: transparent;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-color: rgba(33, 208, 122, .45);
  text-underline-offset: 4px;
  cursor: pointer;
}

.setup-rules-link:hover {
  color: #7dffb5;
}

.setup-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .035);
}

.setup-card h3 {
  margin-bottom: 8px;
}

.setup-card p {
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.45;
}

.player-count-buttons {
  display: grid;
  gap: 8px;
}

.setup-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
}

.setup-field input,
.setup-field select,
.online-join-row input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: #0a1511;
  font: inherit;
}

.online-create-row,
.online-join-row,
.lobby-actions {
  display: flex;
  align-items: end;
  gap: 8px;
  margin-top: 12px;
}

.online-create-row .setup-field {
  width: 96px;
}

.online-create-row .button,
.online-join-row .button {
  flex: 1;
}

.join-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: .72rem;
}

.join-divider::before,
.join-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.setup-error {
  min-height: 1.25em;
  margin: 10px 0 0;
  color: #ff8787 !important;
}

.lobby-modal {
  width: min(520px, calc(100% - 28px));
}

.room-code {
  padding: 4px 9px;
  border: 1px solid rgba(33, 208, 122, .45);
  border-radius: 8px;
  color: var(--green);
  background: rgba(33, 208, 122, .08);
  font-weight: 900;
  letter-spacing: .14em;
  cursor: pointer;
}

.lobby-status {
  color: var(--muted);
}

.online-players {
  display: grid;
  gap: 8px;
  margin: 18px 0;
}

.online-player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.035);
  font-weight: 800;
}

.online-player.offline {
  opacity: .5;
}

.online-player-seat {
  color: var(--muted);
  font-size: .72rem;
}

.lobby-actions {
  justify-content: flex-end;
}

@media (max-width: 680px) {
  .setup-grid {
    grid-template-columns: 1fr;
  }

  .setup-modal {
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 80% -10%, rgba(33, 208, 122, 0.17), transparent 32rem),
    var(--dark);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar,
.player-heading,
.controls,
.score-strip {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.2rem, 6vw, 4.6rem);
  line-height: 0.8;
  letter-spacing: -0.07em;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.25rem, 2vw, 1.65rem);
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.topbar-actions,
.mode-switch,
.controls {
  display: flex;
  gap: 10px;
}

.mode-switch {
  align-items: center;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
}

.mode-switch > span {
  padding-left: 7px;
}

.mode-button {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.mode-button.active {
  color: #06130d;
  background: var(--green);
}

.button {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  transition: transform 150ms ease, opacity 150ms ease, background 150ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-2px);
}

.button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.button-primary {
  color: #06130d;
  background: var(--green);
}

.button-ghost {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.button-dark {
  background: #26342e;
}

.score-strip {
  gap: 24px;
  margin-bottom: 14px;
  padding: 10px 14px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.score-strip strong {
  color: var(--ink);
}

.winner-banner {
  position: absolute;
  left: 50%;
  bottom: 16px;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 9px 16px;
  border: 1px solid rgba(33, 208, 122, .5);
  border-radius: 999px;
  color: #06130d;
  background: var(--green);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .32);
  font-weight: 900;
  text-align: center;
  transform: translateX(-50%);
}

.winner-replay {
  min-height: 32px;
  padding: 0 13px;
  border-radius: 999px;
  color: var(--ink);
  background: #0b1712;
}

.winner-banner[hidden] {
  display: none;
}

.table {
  position: relative;
  min-height: 480px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  background:
    linear-gradient(90deg, transparent 49.8%, rgba(255,255,255,.11) 50%, transparent 50.2%),
    repeating-linear-gradient(90deg, #0e6b3f 0, #0e6b3f 72px, #0c6239 72px, #0c6239 144px);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.32);
}

.pitch-lines {
  position: absolute;
  inset: 22px;
  border: 2px solid rgba(255,255,255,.13);
  border-radius: 12px;
  pointer-events: none;
}

.pitch-lines::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 128px;
  height: 128px;
  border: 2px solid rgba(255,255,255,.13);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.opponent {
  position: absolute;
  z-index: 2;
  width: min(245px, 24vw);
  min-width: 150px;
  padding: 10px 13px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 14px;
  background: rgba(4, 18, 11, 0.72);
  backdrop-filter: blur(10px);
}

.opponent-top {
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
}

.opponent-left {
  top: 50%;
  left: 22px;
  transform: translateY(-50%);
}

.opponent-right {
  top: 50%;
  right: 22px;
  transform: translateY(-50%);
}

.opponent.active {
  background: rgba(4, 30, 17, .94);
  outline: 4px solid rgba(125, 255, 181, .9);
  outline-offset: 4px;
  box-shadow: 0 0 34px rgba(33, 208, 122, .42);
}

.opponent-top.active {
  transform: translateX(-50%);
}

.game-finished .opponent:not(.winner),
.game-finished .center-zone,
.game-finished .move-toast,
.game-finished .turn-banner,
.game-finished .player-zone:not(.winner) {
  opacity: .28;
  filter: saturate(.45);
  transition: opacity 220ms ease, filter 220ms ease;
}

.opponent.winner,
.player-zone.winner {
  border-color: var(--yellow);
  box-shadow:
    0 0 0 4px rgba(255, 211, 61, .3),
    0 18px 45px rgba(0, 0, 0, .35);
}

.winning-card {
  animation: winning-card-pulse 1.2s ease-in-out infinite alternate;
}

@keyframes winning-card-pulse {
  from {
    filter: brightness(1);
  }
  to {
    filter: brightness(1.22);
    box-shadow: 0 0 0 3px var(--yellow), 0 0 18px rgba(255, 211, 61, .75);
  }
}

.opponent-name {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  font-size: 0.82rem;
  font-weight: 800;
}

.opponent-meta {
  display: grid;
  justify-items: end;
  color: var(--muted);
  font-size: .58rem;
  line-height: 1.05;
}

.opponent-meta strong {
  color: var(--green);
  font-size: .78rem;
}

.opponent-card-pips {
  display: none;
}

.opponent-card-pips.online-card-pips {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.opponent-card-pips.online-card-pips > span {
  width: 12px;
  height: 17px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 3px;
  background: repeating-linear-gradient(45deg, #14251e 0 3px, #1d392d 3px 6px);
}

.mini-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.mini-card-open {
  position: relative;
  width: 31px;
  height: 43px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 5px;
  box-shadow: 0 3px 7px rgba(0,0,0,.22);
}

.mini-card-open .card-face {
  padding: 3px;
}

.mini-card-open .card-league {
  display: none;
}

.mini-card-open .position-icon,
.mini-card-open .club-crest {
  width: 20px;
  height: 20px;
  margin: 1px auto;
}

.mini-card-open .position-icon {
  border-width: 1px;
  border-radius: 6px;
  font-size: .72rem;
}

.mini-card-open .club-crest img {
  width: 17px;
  height: 17px;
}

.mini-card-open .special-symbol {
  font-size: 1rem;
}

.mini-card-open.bot-card-playing {
  z-index: 3;
  animation: bot-card-playing 500ms ease-in-out infinite alternate;
}

@keyframes bot-card-playing {
  from {
    transform: translateY(0) scale(1);
    box-shadow: 0 3px 7px rgba(0,0,0,.22);
  }
  to {
    transform: translateY(-7px) scale(1.12);
    box-shadow: 0 0 0 3px var(--yellow), 0 0 22px rgba(255, 211, 61, .9);
  }
}

.center-zone {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  display: flex;
  gap: 22px;
  transform: translate(-50%, -50%);
}

.pile-block {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 7px;
}

.pile-label {
  color: rgba(255,255,255,.72);
  font-size: .67rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.card {
  position: relative;
  width: var(--card-width);
  height: var(--card-height);
  flex: 0 0 auto;
  overflow: hidden;
  border: 0;
  border-radius: 14px;
  color: #0b1310;
  background: #f5f2e9;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

button.card {
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.card-back {
  display: grid;
  place-items: center;
  border: 5px solid #e8e2d4;
  color: var(--ink);
  font-size: 1.55rem;
  font-weight: 900;
  background:
    radial-gradient(circle at center, #182b23 0 22%, transparent 23%),
    repeating-linear-gradient(45deg, #14251e 0 8px, #1d392d 8px 16px);
}

.card-back::before {
  content: "S";
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 2px solid var(--green);
  border-radius: 50%;
  color: var(--green);
}

.card-back span {
  position: absolute;
  right: 8px;
  bottom: 6px;
  padding: 2px 6px;
  border-radius: 99px;
  color: #07130d;
  background: var(--green);
  font-size: .72rem;
}

.card-face {
  width: 100%;
  height: 100%;
  padding: 10px;
  border: 0;
  background: #f0eee7;
}

.card-league {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  color: #4b5752;
  font-size: .58rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.position-icon {
  display: grid;
  width: 56px;
  height: 56px;
  margin: 5px auto 4px;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 18px;
  background: rgba(255,255,255,.18);
  font-size: 1.75rem;
  line-height: 1;
}

.club-crest {
  display: grid;
  width: 56px;
  height: 56px;
  margin: auto auto 2px;
  place-items: center;
}

.club-crest img {
  display: block;
  width: 46px;
  height: 46px;
  object-fit: contain;
}

.card-club {
  overflow: hidden;
  margin-top: auto;
  font-size: .88rem;
  font-weight: 900;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-face.card-country-ita,
.card-face.card-country-esp,
.card-face.card-country-eng,
.card-face.card-country-ger {
  display: flex;
  flex-direction: column;
}

.card-country-ita {
  color: white;
  background: linear-gradient(145deg, #23945d, #11683e);
}

.card-country-ger {
  color: #17140b;
  background: linear-gradient(145deg, #ffd947, #e7ae13);
}

.card-country-esp {
  color: white;
  background: linear-gradient(145deg, #ef4b45, #b91f2b);
}

.card-country-eng {
  color: #18211d;
  background:
    linear-gradient(135deg, transparent 44%, rgba(190,25,45,.13) 45% 55%, transparent 56%),
    #f4f1e9;
}

.card-country-ita .card-league,
.card-country-esp .card-league {
  color: rgba(255,255,255,.78);
}

.card-country-ger .card-league,
.card-country-eng .card-league {
  color: rgba(0,0,0,.58);
}

.card-special .card-face {
  display: grid;
  align-content: center;
  justify-items: center;
  border-top: 0;
  text-align: center;
}

.card-special .special-symbol {
  font-size: 2.4rem;
  font-weight: 1000;
}

.card-yellow .card-face {
  background: var(--yellow);
}

.card-red .card-face {
  color: white;
  background: var(--red);
}

.card-joker .card-face {
  color: white;
  background: linear-gradient(150deg, #6948ff, #1c122d 74%);
}

.turn-banner {
  position: absolute;
  bottom: 18px;
  left: 50%;
  z-index: 3;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 8px 14px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 99px;
  color: white;
  background: rgba(2, 12, 7, .78);
  font-size: .8rem;
  font-weight: 800;
  text-align: center;
  transform: translateX(-50%);
  backdrop-filter: blur(8px);
}

.move-toast {
  position: absolute;
  top: 18px;
  left: 50%;
  z-index: 4;
  display: none;
  max-width: min(520px, calc(100% - 32px));
  padding: 10px 16px;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 12px;
  color: #07130d;
  background: var(--green);
  box-shadow: 0 12px 28px rgba(0,0,0,.3);
  font-size: .82rem;
  font-weight: 900;
  text-align: center;
  transform: translateX(-50%);
}

.move-toast.visible {
  display: block;
  animation: toast-in 280ms ease-out;
}

.card-flash {
  animation: card-flash 620ms ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -12px) scale(.96); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

@keyframes card-flash {
  0% { transform: scale(.82) rotate(-3deg); filter: brightness(1.8); }
  60% { transform: scale(1.08) rotate(1deg); }
  100% { transform: scale(1); filter: brightness(1); }
}

.player-zone {
  margin-top: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
}

.player-zone.active-turn {
  outline: 4px solid rgba(125, 255, 181, .85);
  outline-offset: 4px;
  box-shadow: 0 0 30px rgba(33, 208, 122, .16);
}

.player-heading {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.selection-hint {
  color: var(--muted);
  font-size: .78rem;
}

.hand {
  display: flex;
  gap: 10px;
  min-height: calc(var(--card-height) + 22px);
  padding: 8px 4px 20px;
  overflow-x: auto;
  scrollbar-color: #426453 transparent;
}

.hand .card {
  overflow: visible;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.hand .card > .card-face {
  overflow: hidden;
  border-radius: inherit;
}

.hand .card.club-grouped::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: -6px;
  padding: 3px;
  border-radius: inherit;
  background: var(--group-ring);
  pointer-events: none;
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

.hand .card.connect-card::after {
  animation: connect-card-pulse 780ms ease-in-out infinite alternate;
}

@keyframes connect-card-pulse {
  from {
    inset: -5px;
    filter: brightness(.9);
  }
  to {
    inset: -11px;
    filter: brightness(1.45);
  }
}

.hand .card:hover {
  transform: translateY(-5px);
}

.hand .card.unplayable {
  opacity: .48;
}

.hand .card.selected {
  transform: translateY(-12px);
  box-shadow: 0 0 0 4px var(--green), 0 16px 28px rgba(0,0,0,.3);
}

.selection-order {
  position: absolute;
  top: 10px;
  right: 8px;
  z-index: 2;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  color: #05120b;
  background: var(--green);
  font-size: .72rem;
  font-weight: 900;
}

.controls {
  justify-content: space-between;
  flex-wrap: wrap;
}

.action-controls,
.sort-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sort-controls {
  color: var(--muted);
  font-size: .74rem;
  font-weight: 800;
}

.sort-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: rgba(255,255,255,.035);
  font-size: .72rem;
  font-weight: 800;
  cursor: pointer;
}

.sort-button.active {
  border-color: var(--green);
  color: #07130d;
  background: var(--green);
}

.player-meta {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.win-chance {
  padding: 6px 10px;
  border: 1px solid rgba(33,208,122,.32);
  border-radius: 99px;
  color: var(--muted);
  background: rgba(33,208,122,.08);
  font-size: .76rem;
  font-weight: 700;
}

.win-chance strong {
  margin-left: 4px;
  color: var(--green);
}

.modal {
  width: min(760px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  padding: 26px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--ink);
  background: #101d18;
  box-shadow: 0 28px 80px rgba(0,0,0,.65);
}

.modal::backdrop {
  background: rgba(0, 0, 0, .75);
  backdrop-filter: blur(5px);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-size: 2rem;
  cursor: pointer;
}

.rules-modal {
  width: min(980px, calc(100% - 32px));
}

.rules-intro {
  max-width: 720px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.rules-guide {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.rule-section {
  display: grid;
  grid-template-columns: minmax(260px, .9fr) minmax(330px, 1.1fr);
  gap: 20px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.025);
}

.rule-copy {
  display: flex;
  gap: 13px;
  align-items: flex-start;
}

.rule-number {
  display: grid;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  color: #07130d;
  background: var(--green);
  font-weight: 900;
}

.rule-copy h3 {
  margin: 3px 0 8px;
  color: var(--green);
}

.rule-copy p,
.rule-copy li,
.rule-note {
  color: var(--muted);
  line-height: 1.5;
}

.rule-copy p {
  margin: 0 0 8px;
}

.rule-copy ul {
  margin: 8px 0 0;
  padding-left: 19px;
}

.rule-copy li + li {
  margin-top: 4px;
}

.rule-visual {
  display: flex;
  min-height: 154px;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  padding: 16px;
  border-radius: 14px;
  background: rgba(0,0,0,.2);
}

.rule-card {
  position: relative;
  display: flex;
  width: 88px;
  height: 124px;
  padding: 9px;
  flex: 0 0 88px;
  flex-direction: column;
  justify-content: space-between;
  overflow: visible;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 12px;
  color: #07130d;
  box-shadow: 0 8px 18px rgba(0,0,0,.24);
}

.rule-card.country-ita,
.mini-rule-card.country-ita {
  background: #218e5d;
}

.rule-card.country-ger,
.mini-rule-card.country-ger {
  background: #ffd23f;
}

.rule-card.country-esp,
.mini-rule-card.country-esp {
  background: #e53c40;
}

.rule-card.country-eng,
.mini-rule-card.country-eng {
  background: linear-gradient(135deg, #f7f4ec 0 64%, #f4dede 64%);
}

.rule-card-country {
  font-size: .62rem;
  font-weight: 900;
  letter-spacing: .08em;
}

.rule-card-icon {
  display: grid;
  width: 42px;
  height: 42px;
  margin: auto;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 12px;
  font-size: 1.35rem;
}

.rule-club-crest {
  display: block;
  width: 42px;
  height: 42px;
  margin: auto;
  object-fit: contain;
}

.rule-card strong {
  overflow: hidden;
  font-size: .78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.anatomy-labels {
  display: grid;
  height: 112px;
  align-content: space-between;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
}

.match-example small {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  text-align: center;
  font-weight: 900;
}

.rule-arrow,
.rule-plus,
.link-chain {
  color: var(--green);
  font-size: 1.25rem;
  font-weight: 900;
}

.legal-options {
  display: flex;
  gap: 10px;
}

.legal-card {
  box-shadow: 0 0 0 3px var(--green), 0 8px 18px rgba(0,0,0,.24);
}

.club-ring-blue {
  box-shadow: 0 0 0 4px #3d7cff, 0 8px 18px rgba(0,0,0,.24);
}

.club-ring-red {
  box-shadow: 0 0 0 4px #ff4f72, 0 8px 18px rgba(0,0,0,.24);
}

.selection-order {
  position: absolute;
  top: -9px;
  right: -9px;
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 50%;
  color: #07130d;
  background: var(--green);
  font-size: .72rem;
  font-weight: 900;
}

.rule-card.special-joker,
.mini-rule-card.special-joker {
  color: white;
  background: linear-gradient(145deg, #6e48e8, #24103e);
}

.rule-card.special-yellow {
  background: #ffd23f;
}

.rule-card.special-red {
  color: white;
  background: #ff4c52;
}

.rule-card-joker {
  margin: auto;
  font-size: 2rem;
  font-weight: 900;
}

.link-example {
  position: relative;
}

.link-chain {
  padding: 6px 9px;
  border: 1px solid rgba(33,208,122,.45);
  border-radius: 99px;
  font-size: .75rem;
}

.skip-badge {
  width: 100%;
  color: var(--green);
  text-align: center;
  font-size: .78rem;
  font-weight: 900;
}

.turn-flow span {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  text-align: center;
  font-size: .8rem;
  font-weight: 800;
}

.winning-section {
  grid-template-columns: 1fr;
}

.winning-examples {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.winning-example {
  display: grid;
  min-height: 135px;
  gap: 8px;
  align-content: center;
  justify-items: center;
  padding: 12px;
  border-radius: 12px;
  color: var(--muted);
  background: rgba(0,0,0,.2);
  text-align: center;
  font-size: .72rem;
}

.winning-example > strong {
  color: var(--ink);
  font-size: .8rem;
}

.empty-hand-icon {
  display: grid;
  width: 48px;
  height: 62px;
  place-items: center;
  border: 2px dashed var(--green);
  border-radius: 9px;
  color: var(--green);
  font-size: 1.25rem;
  font-weight: 900;
}

.mini-combo {
  display: flex;
  gap: 3px;
}

.mini-rule-card {
  display: grid;
  width: 28px;
  height: 40px;
  place-items: center;
  border-radius: 5px;
  color: #07130d;
  font-size: .8rem;
}

.rule-note {
  padding: 14px 16px;
  border: 1px solid rgba(33,208,122,.35);
  border-radius: 14px;
  background: rgba(33,208,122,.08);
}

.rule-note strong {
  color: var(--green);
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.rules-grid article {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.035);
}

.rules-grid h3 {
  margin-bottom: 7px;
  color: var(--green);
}

.rules-grid p,
.result-modal p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.result-modal {
  text-align: center;
}

.result-modal .button {
  margin-top: 24px;
}

.result-icon {
  margin-bottom: 10px;
  font-size: 4rem;
}

@media (max-width: 760px) {
  :root {
    --card-width: 88px;
    --card-height: 124px;
  }

  .app {
    width: min(100% - 20px, 1180px);
    padding-top: 16px;
  }

  .topbar {
    align-items: flex-end;
    flex-wrap: wrap;
  }

  .mode-switch {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .topbar-actions {
    gap: 6px;
  }

  .button {
    min-height: 40px;
    padding: 0 13px;
    font-size: .82rem;
  }

  .table {
    min-height: 430px;
  }

  .opponent {
    min-width: 105px;
  }

  .opponent-left {
    top: 44%;
    left: 10px;
  }

  .opponent-right {
    top: 44%;
    right: 10px;
  }

  .center-zone {
    top: 61%;
    gap: 12px;
  }

  .player-zone {
    padding: 14px 10px;
  }

  .player-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .player-meta {
    width: 100%;
    justify-items: start;
  }

  .controls,
  .action-controls,
  .sort-controls {
    align-items: stretch;
  }

  .controls {
    gap: 12px;
  }

  .action-controls {
    width: 100%;
    flex-wrap: wrap;
  }

  .position-icon,
  .club-crest {
    width: 42px;
    height: 42px;
  }

  .position-icon {
    margin: 4px auto 3px;
    border-radius: 13px;
    font-size: 1.35rem;
  }

  .club-crest {
    margin: auto auto 1px;
  }

  .club-crest img {
    width: 35px;
    height: 35px;
  }

  .rules-grid {
    grid-template-columns: 1fr;
  }

  .rule-section {
    grid-template-columns: 1fr;
  }

  .winning-examples {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .topbar .eyebrow {
    display: none;
  }

  .score-strip {
    gap: 14px;
  }

  .opponent-top {
    top: 12px;
  }

  .mini-card:nth-child(n + 6) {
    display: none;
  }

  .rules-modal {
    width: calc(100% - 16px);
    padding: 18px 14px;
  }

  .rule-section {
    padding: 14px;
  }

  .rule-visual {
    padding: 13px 8px;
  }

  .legal-options {
    gap: 7px;
  }

  .winning-examples {
    grid-template-columns: 1fr;
  }
}

/* На десктопі вся партія вміщується у видиму висоту без прокрутки. */
@media (min-width: 900px) and (min-height: 680px) {
  :root {
    --card-width: 84px;
    --card-height: 118px;
  }

  body {
    overflow: hidden;
  }

  .app {
    display: flex;
    flex-direction: column;
    height: 100svh;
    padding: 10px 0;
  }

  .topbar {
    margin-bottom: 7px;
  }

  .topbar .eyebrow {
    margin-bottom: 4px;
  }

  h1 {
    font-size: clamp(2.4rem, 4vw, 3.4rem);
  }

  .button {
    min-height: 36px;
    padding: 0 14px;
    border-radius: 10px;
    font-size: .78rem;
  }

  .score-strip {
    min-height: 32px;
    margin-bottom: 7px;
    padding: 6px 12px;
  }

  .table {
    min-height: clamp(340px, 42vh, 520px);
    flex: 1 1 auto;
    border-radius: 18px;
  }

  .opponent {
    width: min(320px, 28vw);
    min-width: 180px;
    height: 166px;
    padding: 8px 10px;
  }

  .mini-cards {
    align-content: flex-start;
    max-height: 132px;
    overflow-y: auto;
  }

  .mini-card-open {
    width: 42px;
    height: 58px;
    border-radius: 7px;
  }

  .mini-card-open .position-icon,
  .mini-card-open .club-crest {
    width: 27px;
    height: 27px;
    margin: 1px auto;
  }

  .mini-card-open .position-icon {
    border-radius: 8px;
    font-size: .92rem;
  }

  .mini-card-open .club-crest img {
    width: 23px;
    height: 23px;
  }

  .mini-card-open .special-symbol {
    font-size: 1.35rem;
  }

  .center-zone {
    top: 64%;
    gap: 16px;
  }

  .position-icon,
  .club-crest {
    width: 40px;
    height: 40px;
  }

  .position-icon {
    margin: 3px auto 2px;
    border-radius: 12px;
    font-size: 1.3rem;
  }

  .club-crest {
    margin: auto auto 1px;
  }

  .club-crest img {
    width: 33px;
    height: 33px;

  .player-zone {
    flex: 0 0 auto;
    margin-top: 7px;
    padding: 10px 12px;
    border-radius: 16px;
  }

  .player-heading {
    margin-bottom: 5px;
  }

  .player-heading .eyebrow {
    margin-bottom: 3px;
  }

  .player-heading h2 {
    font-size: 1.12rem;
  }

  .hand {
    min-height: calc(var(--card-height) + 8px);
    padding: 3px 4px 8px;
  }

  .controls {
    margin-top: -2px;
  }

  .sort-controls {
    gap: 5px;
  }

  .sort-button {
    min-height: 28px;
    padding: 0 8px;
    font-size: .67rem;
  }

  .turn-banner {
    bottom: 10px;
  }

  .move-toast {
    top: 14px;
    left: 18px;
    max-width: 340px;
    transform: none;
  }

  .move-toast.visible {
    animation: toast-in-left 280ms ease-out;
  }

  @keyframes toast-in-left {
    from { opacity: 0; transform: translateY(-12px) scale(.96); }
    to { opacity: 1; transform: none; }
  }
}

/* Окреме компактне компонування лише для мобільних екранів. */
@media (max-width: 760px) {
  :root {
    --card-width: 58px;
    --card-height: 82px;
  }

  .app {
    width: calc(100% - 12px);
    min-height: 100svh;
    padding: 8px 0 12px;
  }

  .topbar {
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    margin-bottom: 6px;
  }

  .topbar .eyebrow {
    display: none;
  }

  h1 {
    font-size: 2.2rem;
    line-height: .85;
  }

  .topbar-actions {
    margin-left: auto;
    gap: 4px;
  }

  .topbar-actions .button {
    min-height: 30px;
    padding: 0 7px;
    border-radius: 9px;
    font-size: .66rem;
    white-space: nowrap;
  }

  .score-strip {
    min-height: 28px;
    gap: 12px;
    margin-bottom: 6px;
    padding: 5px 9px;
    border-radius: 10px;
    font-size: .68rem;
  }

  .table {
    height: 280px;
    min-height: 280px;
    border-radius: 18px;
  }

  .pitch-lines {
    inset: 12px;
    border-width: 1px;
  }

  .pitch-lines::after {
    width: 86px;
    height: 86px;
    border-width: 1px;
  }

  .opponent {
    width: 106px;
    min-width: 0;
    height: 52px;
    padding: 6px 8px;
    border-radius: 11px;
  }

  .opponent-top {
    top: 10px;
  }

  .opponent-left {
    top: 76px;
    left: 10px;
    transform: none;
  }

  .opponent-right {
    top: 76px;
    right: 10px;
    transform: none;
  }

  .opponent.active {
    outline-width: 2px;
    outline-offset: 2px;
  }

  .opponent-name {
    align-items: center;
    margin-bottom: 0;
    font-size: .68rem;
    line-height: 1.05;
    white-space: nowrap;
  }

  .opponent-meta {
    display: block;
  }

  .opponent-meta strong {
    font-size: .68rem;
  }

  .opponent-meta > span {
    display: none;
  }

  .opponent-card-pips {
    display: flex;
    gap: 2px;
    width: 100%;
    margin-top: 7px;
  }

  .opponent-card-pips > span {
    width: 7px;
    min-width: 3px;
    max-width: 7px;
    height: 7px;
    flex: 1 1 7px;
    border: 1px solid rgba(255, 255, 255, .42);
    border-radius: 2px;
    background: rgba(33, 208, 122, .72);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  }

  .mini-cards {
    display: none;
  }

  .center-zone {
    top: 45%;
    gap: 9px;
  }

  .pile-block {
    gap: 4px;
  }

  .pile-label {
    font-size: .52rem;
  }

  .card {
    border-radius: 10px;
  }

  .card-back {
    border-width: 4px;
    font-size: 1.1rem;
  }

  .card-back::before {
    width: 34px;
    height: 34px;
  }

  .card-face {
    padding: 6px;
  }

  .card-league {
    font-size: .42rem;
  }

  .position-icon,
  .club-crest {
    width: 26px;
    height: 26px;
  }

  .position-icon {
    margin: 2px auto 1px;
    border-radius: 8px;
    font-size: .82rem;
  }

  .club-crest {
    margin: auto auto 0;
  }

  .club-crest img {
    width: 22px;
    height: 22px;
  }

  .card-special .special-symbol {
    font-size: 1.6rem;
  }

  .turn-banner {
    bottom: 7px;
    max-width: calc(100% - 20px);
    padding: 6px 10px;
    font-size: .65rem;
  }

  .move-toast {
    top: auto;
    bottom: 38px;
    left: 50%;
    max-width: calc(100% - 24px);
    padding: 7px 10px;
    font-size: .66rem;
    transform: translateX(-50%);
  }

  .player-zone {
    margin-top: 6px;
    padding: 8px;
    border-radius: 15px;
  }

  .player-zone.active-turn {
    outline-width: 2px;
    outline-offset: 2px;
  }

  .player-heading {
    align-items: flex-start;
    flex-direction: row;
    gap: 8px;
    margin-bottom: 3px;
  }

  .player-heading .eyebrow {
    margin-bottom: 2px;
    font-size: .55rem;
  }

  .player-heading h2 {
    font-size: .9rem;
  }

  .player-meta {
    width: auto;
    margin-left: auto;
    justify-items: end;
  }

  .selection-hint {
    display: none;
  }

  .win-chance {
    padding: 4px 7px;
    font-size: .6rem;
  }

  .hand {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 4px;
    min-height: 0;
    max-height: 170px;
    padding: 4px 2px 7px;
    overflow-x: visible;
    overflow-y: auto;
  }

  .hand .card {
    width: 100%;
    height: auto;
    aspect-ratio: 104 / 146;
  }

  .hand .card:hover,
  .hand .card.selected {
    transform: none;
  }

  .hand .card.selected {
    box-shadow: 0 0 0 3px var(--green), 0 8px 16px rgba(0,0,0,.3);
  }

  .controls {
    display: grid;
    gap: 6px;
  }

  .sort-controls,
  .action-controls {
    width: 100%;
  }

  .sort-controls {
    display: none;
  }

  .sort-button {
    min-height: 25px;
    padding: 0 7px;
    border-radius: 7px;
    font-size: .59rem;
  }

  .action-controls {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }

  .action-controls .button {
    min-height: 31px;
    padding: 2px 4px;
    border-radius: 8px;
    font-size: .58rem;
    line-height: 1.05;
  }

  .winner-banner {
    bottom: 7px;
    gap: 7px;
    max-width: calc(100% - 18px);
    padding: 6px 8px 6px 11px;
    font-size: .65rem;
  }

  .winner-replay {
    min-height: 27px;
    padding: 0 9px;
    font-size: .61rem;
  }
}
