:root {
  color-scheme: dark;
  --felt: #102820;
  --felt-deep: #081511;
  --felt-soft: #173d30;
  --rail: #35594b;
  --app-background: linear-gradient(160deg, #102820 0%, #173d30 42%, #081511 100%);
  --control-border: #668d7c;
  --control-surface: #0f211c;
  --control-hover: #245541;
  --panel-border: #73917f;
  --panel-surface: rgba(8, 21, 17, 0.86);
  --online-surface: rgba(7, 24, 20, 0.52);
  --online-input: #0c241d;
  --soft-border: #456858;
  --soft-surface: rgba(16, 37, 31, 0.72);
  --track-surface: #29483c;
  --button-ink: #172119;
  --secondary-border: #719282;
  --secondary-surface: #143128;
  --secondary-hover: #214b3a;
  --inner-border: #315442;
  --inner-surface: rgba(15, 37, 29, 0.72);
  --inner-active: rgba(31, 67, 48, 0.82);
  --divider: #436554;
  --table-surface: rgba(17, 54, 42, 0.46);
  --panel-inset: rgba(8, 21, 17, 0.58);
  --overlay-surface: rgba(2, 10, 7, 0.68);
  --hand-count-border: #597868;
  --scroll-thumb: #5a7c6a;
  --empty-border: #5a7869;
  --empty-text: #86a092;
  --winner-glow: rgba(65, 211, 126, 0.67);
  --winner-glow-soft: rgba(65, 211, 126, 0.39);
  --gold: #e0c35a;
  --gold-strong: #f1d77a;
  --cream: #f7f1dd;
  --muted: #abc2b7;
  --red: #cf3d46;
  --ink: #191713;
  --shadow: rgba(0, 0, 0, 0.34);
  font-family: "Bura Georgian UI", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--felt-deep);
  color: var(--cream);
}

@font-face {
  font-family: "Bura Georgian Display";
  src: url("assets/fonts/BPG%20Classic%20Black%20Caps.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Bura Georgian UI";
  src: url("assets/fonts/BPG%20SF%20DG.ttf") format("truetype");
  font-display: swap;
}

.label-font-display {
  font-family: "Bura Georgian Display", Georgia, "Times New Roman", serif;
}

.label-font-ui {
  font-family: "Bura Georgian UI", Inter, ui-sans-serif, system-ui, sans-serif;
}

.label-font-regular {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@font-face {
  font-family: "Bura Georgian Square";
  src: url("assets/fonts/BPG%20Square%2038.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Bura Georgian Square Caps";
  src: url("assets/fonts/BPG%20Square%2038%20Caps.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Bura Georgian Glaho Bold";
  src: url("assets/fonts/bpg-glaho-bold-webfont.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Bura Georgian Glaho Web";
  src: url("assets/fonts/bpg-glaho-web-webfont.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Bura Georgian Arial";
  src: url("assets/fonts/arial-geo-webfont.ttf") format("truetype");
  font-display: swap;
}

.label-font-square {
  font-family: "Bura Georgian Square", Inter, ui-sans-serif, system-ui, sans-serif;
}

.label-font-squareCaps {
  font-family: "Bura Georgian Square Caps", Inter, ui-sans-serif, system-ui, sans-serif;
}

.label-font-glahoBold {
  font-family: "Bura Georgian Glaho Bold", Inter, ui-sans-serif, system-ui, sans-serif;
}

.label-font-glahoWeb {
  font-family: "Bura Georgian Glaho Web", Inter, ui-sans-serif, system-ui, sans-serif;
}

.label-font-arialGeo {
  font-family: "Bura Georgian Arial", Arial, sans-serif;
}

@font-face {
  font-family: "Bura Georgian ALK Sanet";
  src: url("assets/fonts/alk-sanet-webfont.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Bura Georgian ALK Dots";
  src: url("assets/fonts/alkdots-webfont.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Bura Georgian Archy EDT Bold";
  src: url("assets/fonts/archyedt-bold-webfont.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Bura Georgian Web 002 Caps";
  src: url("assets/fonts/bpg-web-002-caps-webfont.ttf") format("truetype");
  font-display: swap;
}

.label-font-alkSanet {
  font-family: "Bura Georgian ALK Sanet", Inter, ui-sans-serif, system-ui, sans-serif;
}

.label-font-alkDots {
  font-family: "Bura Georgian ALK Dots", Inter, ui-sans-serif, system-ui, sans-serif;
}

.label-font-archyEdtBold {
  font-family: "Bura Georgian Archy EDT Bold", Inter, ui-sans-serif, system-ui, sans-serif;
}

.label-font-bpgWeb002Caps {
  font-family: "Bura Georgian Web 002 Caps", Inter, ui-sans-serif, system-ui, sans-serif;
}

:root[data-theme="red"] {
  --felt: #321718;
  --felt-deep: #17090b;
  --felt-soft: #57292b;
  --rail: #7f484b;
  --app-background: linear-gradient(160deg, #321718 0%, #57292b 42%, #17090b 100%);
  --control-border: #a86b6d;
  --control-surface: #2b1214;
  --control-hover: #673034;
  --panel-border: #a06c6e;
  --panel-surface: rgba(23, 9, 11, 0.88);
  --online-surface: rgba(42, 14, 17, 0.58);
  --online-input: #2b1114;
  --soft-border: #754146;
  --soft-surface: rgba(48, 20, 23, 0.74);
  --track-surface: #5b3034;
  --button-ink: #241113;
  --secondary-border: #aa7578;
  --secondary-surface: #421d21;
  --secondary-hover: #6b3035;
  --inner-border: #703b40;
  --inner-surface: rgba(43, 17, 20, 0.76);
  --inner-active: rgba(86, 32, 38, 0.86);
  --divider: #754248;
  --table-surface: rgba(76, 28, 33, 0.52);
  --panel-inset: rgba(23, 9, 11, 0.7);
  --overlay-surface: rgba(20, 5, 8, 0.7);
  --hand-count-border: #95595d;
  --scroll-thumb: #9b6064;
  --empty-border: #90575b;
  --empty-text: #bc8a8d;
  --winner-glow: rgba(238, 116, 123, 0.68);
  --winner-glow-soft: rgba(238, 116, 123, 0.4);
}

:root[data-theme="blue"] {
  --felt: #142844;
  --felt-deep: #080f22;
  --felt-soft: #213c67;
  --rail: #4d6f9c;
  --app-background: linear-gradient(160deg, #142844 0%, #213c67 42%, #080f22 100%);
  --control-border: #7397c8;
  --control-surface: #0d1c34;
  --control-hover: #244f85;
  --panel-border: #7395c3;
  --panel-surface: rgba(8, 15, 34, 0.88);
  --online-surface: rgba(10, 24, 47, 0.58);
  --online-input: #0c1b33;
  --soft-border: #405f8d;
  --soft-surface: rgba(18, 38, 70, 0.76);
  --track-surface: #2c4d7d;
  --button-ink: #101c31;
  --secondary-border: #7a9ac9;
  --secondary-surface: #18355e;
  --secondary-hover: #28558c;
  --inner-border: #375a8a;
  --inner-surface: rgba(11, 28, 53, 0.78);
  --inner-active: rgba(25, 58, 102, 0.86);
  --divider: #456895;
  --table-surface: rgba(24, 55, 97, 0.54);
  --panel-inset: rgba(8, 15, 34, 0.7);
  --overlay-surface: rgba(4, 8, 22, 0.72);
  --hand-count-border: #6487b7;
  --scroll-thumb: #668ab9;
  --empty-border: #6384b1;
  --empty-text: #94acd0;
  --winner-glow: rgba(112, 176, 255, 0.7);
  --winner-glow-soft: rgba(112, 176, 255, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.02) 0 1px, transparent 1px 12px),
    var(--app-background);
}

button,
input {
  font: inherit;
}

select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: var(--control-surface);
  color: var(--cream);
  padding: 0 12px;
}

select:focus {
  border-color: var(--gold);
  outline: 2px solid transparent;
}

.match-target {
  display: block;
  max-width: 240px;
  margin: 0 0 20px;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 24px 18px 36px;
}

.topbar,
.score-heading,
.lane-heading,
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 18px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.eyebrow,
.section-kicker,
.mini-label {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 3rem;
  font-weight: 400;
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  line-height: 1.15;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--control-border);
  border-radius: 50%;
  background: var(--soft-surface);
  color: var(--cream);
  cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--gold);
  outline: 2px solid transparent;
  background: var(--control-hover);
}

.icon-button[hidden],
.reconnect-button[hidden] {
  display: none;
}

.setup-panel,
.game-panel,
.result-panel {
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel-surface);
  box-shadow: 0 18px 55px var(--shadow);
  overflow: hidden;
}

.setup-panel,
.result-panel {
  padding: 24px;
}

.setup-copy {
  margin-bottom: 22px;
}

.brand-heading,
.brand-meta {
  display: flex;
  align-items: baseline;
}

.brand-heading {
  flex-wrap: wrap;
  gap: 12px;
}

.brand-heading h1 {
  margin: 0;
}

.brand-meta {
  gap: 8px;
}

.brand-meta .eyebrow,
.brand-meta .build-version {
  margin: 0;
}

.build-version {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.name-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.setup-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.online-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 1rem;
  color: var(--text);
  font-weight: 700;
}

.online-mode-toggle {
  margin-top: 0;
}

.online-toggle input {
  accent-color: var(--gold);
}

.online-fields {
  display: grid;
  gap: 0.8rem;
  margin-top: 0.9rem;
  padding: 1rem;
  border: 1px solid rgba(203, 168, 78, 0.32);
  background: var(--online-surface);
}

.setup-online-grid .online-fields {
  height: 100%;
  margin-top: 0;
}

.online-fields label {
  display: grid;
  gap: 0.35rem;
}

.online-fields input {
  min-height: 2.6rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(203, 168, 78, 0.38);
  border-radius: 4px;
  background: var(--online-input);
  color: var(--text);
}

.created-code {
  display: grid;
  gap: 0.25rem;
  padding-top: 0.35rem;
  text-align: center;
}

.created-code span {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.created-code strong {
  color: var(--gold);
  font-size: clamp(2rem, 7vw, 3.5rem);
  letter-spacing: 0.2em;
  line-height: 1;
}

.online-status {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
}

.online-status[data-tone="error"] { color: #e88f8f; }
.online-status[data-tone="success"] { color: #d5b65b; }

.reconnect-button {
  justify-self: center;
  min-height: 40px;
}

.lobby-panel {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--rail);
}

.lobby-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.lobby-heading .mini-label,
.lobby-heading h2 {
  margin: 0;
}

.lobby-controls,
.lobby-filter {
  display: flex;
  align-items: center;
}

.lobby-controls {
  gap: 8px;
}

.lobby-filter {
  overflow: hidden;
  border: 1px solid var(--secondary-border);
  border-radius: 7px;
}

.lobby-filter-button {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-right: 1px solid var(--secondary-border);
  border-radius: 0;
  background: var(--secondary-surface);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  cursor: pointer;
}

.lobby-filter-button:last-child {
  border-right: 0;
}

.lobby-filter-button:hover,
.lobby-filter-button:focus-visible {
  background: var(--secondary-hover);
  color: var(--cream);
  outline: 0;
}

.lobby-filter-button.is-active {
  background: var(--gold);
  color: var(--button-ink);
}

.lobby-refresh-button {
  width: 38px;
  height: 38px;
}

.sync-icon {
  display: block;
  width: 18px;
  height: 18px;
}

.lobby-list {
  display: grid;
  margin-top: 12px;
}

.lobby-empty {
  margin: 0;
  padding: 14px 0 2px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.lobby-room {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--divider);
}

.lobby-room:first-child {
  border-top: 0;
}

.lobby-room-info {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.lobby-room-info strong {
  overflow: hidden;
  color: var(--cream);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lobby-room-players {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.lobby-room-players strong {
  min-width: 0;
}

.lobby-room-players span {
  flex: 0 0 auto;
  color: var(--gold);
  font-size: 0.88rem;
  font-weight: 900;
}

.lobby-room-info span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.lobby-join-button {
  min-height: 38px;
  padding: 0 13px;
}

.lobby-room-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lobby-room-code {
  border: 0;
  background: transparent;
  color: var(--gold);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  line-height: 1;
  cursor: pointer;
}

.lobby-room-code:hover,
.lobby-room-code:focus-visible {
  color: var(--gold-strong);
  outline: 0;
  text-shadow: 0 0 9px rgba(224, 195, 90, 0.45);
}

.lobby-cancel-button {
  min-height: 34px;
  padding: 0 11px;
}

.lobby-room-status {
  color: var(--gold-strong);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: var(--control-surface);
  color: var(--cream);
  padding: 0 12px;
}

input:focus {
  border-color: var(--gold);
  outline: 2px solid transparent;
}

.dev-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.mode-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 16px 0 20px;
  padding: 0;
  border: 0;
}

.mode-picker legend {
  width: 100%;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mode-picker label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--cream);
  font-size: 0.9rem;
  font-weight: 800;
}

.dev-toggle input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--gold);
}

.mode-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 4px 0 20px;
  padding: 12px 14px;
  border: 1px solid var(--soft-border);
  border-radius: 8px;
  background: var(--soft-surface);
}

.mode-toggle > span:first-child {
  display: grid;
  gap: 3px;
  margin: 0;
}

.mode-toggle strong {
  color: var(--cream);
}

.mode-toggle small {
  color: var(--muted);
  font-size: 0.76rem;
}

.mode-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle-track {
  display: block;
  position: relative;
  flex: 0 0 48px;
  width: 48px;
  height: 28px;
  margin: 0;
  border-radius: 999px;
  background: var(--track-surface);
  cursor: pointer;
  transition: background 180ms ease;
}

.toggle-track span {
  display: block;
  width: 20px;
  height: 20px;
  margin: 4px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 180ms ease, background 180ms ease;
}

.mode-toggle input:checked + .toggle-track {
  background: var(--gold);
}

.mode-toggle input:checked + .toggle-track span {
  background: var(--button-ink);
  transform: translateX(20px);
}

.mode-toggle input:focus-visible + .toggle-track {
  outline: 2px solid var(--gold-strong);
  outline-offset: 3px;
}

.setup-control-grid .mode-toggle {
  min-height: 86px;
  margin: 0;
}

.match-target-picker {
  display: grid;
  gap: 10px;
  margin: 0;
}

.match-target-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
}

.match-target-heading strong {
  color: var(--cream);
}

.match-target-heading output {
  display: grid;
  place-items: center;
  min-width: 42px;
  min-height: 34px;
  border: 1px solid var(--gold);
  border-radius: 6px;
  color: var(--gold-strong);
  font-weight: 100;
}

.match-target-picker input[type="range"] {
  width: 100%;
  min-height: 24px;
  margin: 0;
  padding: 0;
  accent-color: var(--gold);
  cursor: pointer;
}

.range-ends {
  display: flex;
  justify-content: space-between;
  margin: -4px 2px 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 100;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  border-radius: 6px;
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  border: 0;
  background: var(--gold);
  color: var(--button-ink);
}

.primary-button:hover,
.primary-button:focus-visible {
  outline: 2px solid transparent;
  background: var(--gold-strong);
}

.secondary-button {
  border: 1px solid var(--secondary-border);
  background: var(--secondary-surface);
  color: var(--cream);
}

.secondary-button:hover,
.secondary-button:focus-visible {
  border-color: var(--gold);
  outline: 2px solid transparent;
  background: var(--secondary-hover);
}

.secondary-button.gold {
  border-color: var(--gold);
  color: var(--gold-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--rail);
}

.score-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--soft-border);
  border-radius: 8px;
  background: var(--soft-surface);
}

.score-card.active {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(224, 195, 90, 0.28);
}

.score-heading span {
  min-width: 0;
  overflow: hidden;
  color: var(--cream);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-heading strong {
  color: var(--gold-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.8rem;
  line-height: 1;
}

.score-track {
  height: 7px;
  margin: 10px 0 8px;
  border-radius: 99px;
  background: var(--track-surface);
  overflow: hidden;
}

.score-value {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), #ef6b61);
  transition: width 180ms ease;
}

.score-card small,
.turn-detail,
.stock-count,
#event-log {
  color: var(--muted);
  font-size: 0.86rem;
}

.stock-count {
  text-align: left;
}

.player-lane {
  min-height: 190px;
  padding: 16px;
}

.game-panel {
  overflow: visible;
}

.opponent-lane {
  min-height: auto;
  border-bottom: 1px solid var(--rail);
}

.current-lane {
  min-height: 260px;
  overflow: visible;
  border-top: 1px solid var(--rail);
}

.current-lane .hand-row {
  overflow: visible;
  padding-top: 28px;
}

.lane-heading {
  position: relative;
}

.theme-picker {
  position: absolute;
  z-index: 1;
  top: 50%;
  right: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  transform: translateY(-50%);
}

.theme-swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid rgba(247, 241, 221, 0.62);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.16);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.theme-swatch[data-theme-choice="green"] {
  background: #255b45;
}

.theme-swatch[data-theme-choice="red"] {
  background: #8d3f44;
}

.theme-swatch[data-theme-choice="blue"] {
  background: #315d98;
}

.theme-swatch:hover,
.theme-swatch:focus-visible {
  border-color: var(--gold-strong);
  outline: 2px solid transparent;
  transform: scale(1.12);
}

.theme-swatch.selected {
  border: 2px solid var(--gold-strong);
  box-shadow: 0 0 0 2px var(--felt-deep), 0 0 9px rgba(224, 195, 90, 0.7);
}

.opponent-lane .lane-heading-main {
  padding-left: 0;
}

.lane-heading-main {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
  padding-right: 302px;
}

.lane-heading-main h2,
.lane-heading-main .mini-label {
  margin: 0;
}

.captured-count {
  position: absolute;
  top: 50%;
  right: 260px;
  display: flex;
  min-width: 112px;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--inner-border);
  border-radius: 6px;
  background: var(--inner-surface);
  transform: translateY(-50%);
}

.captured-count span {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.captured-count strong {
  color: var(--gold-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.turn-ornaments {
  display: flex;
  position: absolute;
  left: calc(50% - 49px);
  top: 50%;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin: 0;
  transform: translate(-50%, -50%);
  opacity: 0.92;
  transition: opacity 240ms ease;
}

.turn-ornaments img {
  width: 24px;
  height: 29px;
  object-fit: contain;
  filter: sepia(1) saturate(4) hue-rotate(355deg) brightness(1.2)
    drop-shadow(0 0 3px rgba(224, 195, 90, 0.9))
    drop-shadow(0 0 8px rgba(224, 195, 90, 0.45));
}

.turn-ornaments.active {
  opacity: 1;
}

.turn-ornaments.active img {
  filter: brightness(0) saturate(100%) invert(86%) sepia(78%) saturate(1120%) hue-rotate(351deg) brightness(106%) contrast(106%)
    drop-shadow(0 0 5px rgba(245, 210, 65, 1))
    drop-shadow(0 0 13px rgba(245, 210, 65, 0.82));
}

.turn-ornaments.opening-turn-signal img {
  animation: opening-turn-pulse 450ms ease-in-out 2;
}

.turn-ornaments.reserve-entry img {
  filter: brightness(0) saturate(100%) invert(17%) sepia(78%) saturate(3866%) hue-rotate(346deg) brightness(96%) contrast(105%)
    drop-shadow(0 0 5px rgba(229, 70, 72, 0.92));
  animation: reserve-entry-blink 360ms ease-in-out 2;
}

.turn-ornaments.turn-critical img {
  filter: brightness(0) saturate(100%) invert(17%) sepia(78%) saturate(3866%) hue-rotate(346deg) brightness(96%) contrast(105%)
    drop-shadow(0 0 5px rgba(229, 70, 72, 0.92))
    drop-shadow(0 0 12px rgba(229, 70, 72, 0.58));
  animation: reserve-critical-blink 650ms ease-in-out infinite;
}

@keyframes reserve-entry-blink {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.16;
    transform: scale(0.88);
  }
}

@keyframes reserve-critical-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.26;
  }
}

.turn-timer {
  position: absolute;
  top: 50%;
  left: calc(50% + 60px);
  z-index: 1;
  min-width: 24px;
  color: var(--gold-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  transform: translate(-50%, -50%);
  text-shadow: 0 0 8px rgba(224, 195, 90, 0.38);
}

.turn-timer.is-reserve,
.turn-timer.is-critical {
  color: #e54648;
  text-shadow: 0 0 8px rgba(229, 70, 72, 0.58);
}

.turn-timer.is-critical {
  animation: reserve-critical-blink 650ms ease-in-out infinite;
}

@keyframes opening-turn-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.22;
    transform: scale(0.88);
  }
}

.hand-controls-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  min-width: 0;
}

.hand-controls-row .hand-row {
  min-width: 0;
}

.lane-actions {
  display: flex;
  flex: 0 0 172px;
  flex-wrap: wrap;
  align-content: flex-start;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 28px;
  margin-right: 37px;
}

.lane-actions .primary-button,
.lane-actions .secondary-button {
  width: 100%;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hand-count {
  flex: 0 0 auto;
  border: 1px solid var(--hand-count-border);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.lane-stats {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.lane-score {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  white-space: nowrap;
}

.hand-row,
.played-row {
  display: flex;
  min-height: 0;
  align-items: center;
  flex: 1 1 auto;
  gap: 10px;
  padding-top: 12px;
  overflow: visible;
  scrollbar-color: var(--scroll-thumb) transparent;
}

.table-zone {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr) 246px;
  gap: 14px;
  padding: 16px;
  background: var(--table-surface);
}

.played-row.winner-glow .playing-card {
  filter: drop-shadow(0 0 4px var(--winner-glow)) drop-shadow(0 0 11px var(--winner-glow-soft));
}

.played-row {
  justify-content: center;
}

.played-row .playing-card {
  filter: none;
  transition: filter 360ms ease-in-out;
  transition-delay: 100ms;
}

.stock-panel,
.trick-panel,
.log-panel,
.match-panel {
  min-width: 0;
  border: 1px solid var(--divider);
  border-radius: 8px;
  background: var(--panel-inset);
  padding: 12px;
}

.match-panel {
  display: grid;
  align-content: stretch;
}

.match-panel-heading {
  display: grid;
  gap: 5px;
}

.match-panel-heading strong {
  color: var(--cream);
  font-size: 0.92rem;
}

.deal-weight-value {
  color: var(--gold-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
  line-height: 1;
}

.match-score-stack {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100%;
  gap: 14px;
}

.match-score-south {
  position: relative;
  display: grid;
  align-content: end;
  gap: 10px;
  min-height: 0;
}

.match-score-north {
  display: grid;
  gap: 8px;
}

.match-score-middle {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 0;
}

.match-captured-score {
  position: absolute;
  top: calc(25% - 18px);
  right: 0;
  left: 0;
  margin: 0;
  color: var(--cream);
  font-size: 2.24rem;
  line-height: 1;
  pointer-events: none;
  text-align: center;
  transform: translateY(-50%);
}

.match-deal-result {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  left: 0;
  margin: 0;
  color: var(--gold-strong);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}

.match-deal-info {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 9px 4px;
  border-top: 1px solid var(--divider);
  border-bottom: 1px solid var(--divider);
  align-self: center;
}

.match-deal-info div {
  display: grid;
  justify-items: center;
  gap: 3px;
}

.match-deal-info span {
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.match-deal-info strong {
  color: var(--gold-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  line-height: 1;
}

.match-deal-info strong.is-resetting {
  animation: deal-weight-reset 520ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes deal-weight-reset {
  0% { color: var(--gold-strong); text-shadow: 0 0 0 rgba(241, 215, 122, 0); transform: scale(1); }
  42% { color: #fff4b8; text-shadow: 0 0 18px rgba(241, 215, 122, 0.9); transform: scale(1.35); }
  100% { color: var(--gold-strong); text-shadow: 0 0 0 rgba(241, 215, 122, 0); transform: scale(1); }
}

.match-score-player {
  position: relative;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 12px 10px;
  border: 1px solid var(--inner-border);
  border-radius: 6px;
  background: var(--inner-surface);
  transition: border-color 180ms ease, background 180ms ease;
}

.match-score-player.active {
  border-color: var(--gold);
  background: var(--inner-active);
}

.match-score-player.is-awarding {
  border-color: var(--gold-strong);
  background: rgba(87, 76, 27, 0.34);
  box-shadow: 0 0 16px rgba(224, 195, 90, 0.32);
}

.match-score-player.is-awarding .match-score-value {
  animation: deal-score-point 360ms ease-out both;
}

@keyframes deal-score-point {
  0% { color: var(--gold-strong); text-shadow: 0 0 0 rgba(241, 215, 122, 0); }
  44% { color: #fff4b8; text-shadow: 0 0 18px rgba(241, 215, 122, 0.95); }
  100% { color: var(--gold-strong); text-shadow: 0 0 0 rgba(241, 215, 122, 0); }
}

.match-score-award {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  display: grid;
  justify-items: center;
  gap: 3px;
  min-width: 118px;
  padding: 9px 12px;
  border: 1px solid var(--gold-strong);
  border-radius: 6px;
  background: var(--felt-soft);
  box-shadow: 0 0 22px rgba(241, 215, 122, 0.66);
  transform: translate(-50%, -50%);
  animation: deal-score-award-pop 1050ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.match-score-award span {
  color: var(--cream);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-align: center;
}

.match-score-award strong {
  color: var(--gold-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.6rem;
  line-height: 1;
}

@keyframes deal-score-award-pop {
  0% { opacity: 0; transform: translate(-50%, -38%) scale(0.7); }
  20% { opacity: 1; transform: translate(-50%, -54%) scale(1.08); }
  72% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.88); }
}

.match-score-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.match-score-heading strong {
  color: var(--cream);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-seat {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.match-seat:empty {
  display: none;
}

.match-score-value {
  color: var(--gold-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  line-height: 1;
}

.match-score-value span {
  color: var(--muted);
  font-family: inherit;
  font-size: 0.92rem;
}

.match-score-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--track-surface);
}

.match-score-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), #ef6b61);
  transition: width 300ms ease;
}

.match-score-divider {
  height: 1px;
  background: var(--divider);
}

.stock-panel {
  display: grid;
  align-content: center;
  gap: 8px;
}

.trick-panel {
  display: grid;
  height: 430px;
  min-height: 430px;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
}

.trick-slot {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.trick-slot > .mini-label {
  margin-left: auto;
  text-align: right;
}

.trick-slot:nth-child(2) > .mini-label {
  order: 2;
  margin-top: 8px;
}

.log-panel {
  max-height: 210px;
  overflow: hidden;
}

#event-log {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
  line-height: 1.35;
}

.playing-card {
  position: relative;
  flex: 0 0 114px;
  width: 114px;
  aspect-ratio: 180 / 252;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  color: var(--ink);
  transform: translateY(0);
  transition: transform 140ms ease, filter 140ms ease;
}

.playing-card.compact-card {
  flex-basis: 79px;
  width: 79px;
}

.opponent-lane .playing-card.compact-card {
  flex-basis: 36px;
  width: 36px;
}

.opponent-lane .playing-card {
  flex-basis: 79px;
  width: 79px;
}

.playing-card.table-card {
  flex-basis: 88px;
  width: 88px;
}

.playing-card.trump-display-card {
  flex-basis: 114px;
  width: 114px;
}

.playing-card.entering-card {
  animation: card-land 1200ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes card-land {
  from {
    opacity: 0.72;
    transform: translateY(64px) scale(0.82);
  }
  72% {
    opacity: 1;
    transform: translateY(-6px) scale(1.03);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.playing-card.interactive-card {
  cursor: pointer;
}

.playing-card.interactive-card:hover,
.playing-card.interactive-card:focus-visible {
  outline: 2px solid transparent;
  transform: translateY(-6px);
  filter: drop-shadow(0 14px 14px rgba(0, 0, 0, 0.34));
}

.playing-card.selected {
  transform: translateY(-14px);
  filter: drop-shadow(0 0 0 var(--gold)) drop-shadow(0 12px 16px rgba(224, 195, 90, 0.36));
}

.playing-card.selected::after {
  position: absolute;
  pointer-events: none;
  content: "";
}

.playing-card.selected::after {
  inset: -4px;
  border: 3px solid var(--gold);
  border-radius: 12px;
}

.card-image {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  object-fit: fill;
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.28);
}

.point-chip {
  position: absolute;
  left: 7px;
  bottom: 7px;
  z-index: 2;
  min-width: 22px;
  height: 22px;
  border: 1px solid rgba(25, 23, 19, 0.15);
  border-radius: 999px;
  background: rgba(247, 241, 221, 0.86);
  color: #172119;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 900;
}

.card-back .card-image {
  border: 1px solid #d0b45a;
}

.playing-card.card-back {
  transition: none;
}

.empty-slot {
  display: grid;
  flex: 1 1 auto;
  min-height: 106px;
  place-items: center;
  border: 1px dashed var(--empty-border);
  border-radius: 8px;
  color: var(--empty-text);
  font-size: 0.86rem;
  font-weight: 800;
}

.action-bar {
  padding: 16px;
  border-top: 1px solid var(--rail);
  background: var(--panel-inset);
}

.action-bar > div:first-child {
  min-width: 0;
}

.turn-detail {
  min-height: 1.3em;
  margin: 8px 0 0;
}

.action-buttons {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.deal-score-dimmer {
  position: fixed;
  z-index: 20;
  inset: 0;
  background: rgba(2, 10, 7, 0.78);
  backdrop-filter: blur(2px);
  transition: opacity 220ms ease;
}

.deal-score-dimmer[hidden] {
  display: none;
}

.app-shell.is-deal-score-summary .match-panel {
  position: relative;
  z-index: 21;
  border-color: var(--gold);
  background: var(--panel-surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.58);
}

.result-overlay {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--overlay-surface);
}

.result-overlay[hidden] {
  display: none;
}

.result-overlay .result-panel {
  position: relative;
  width: min(100%, 500px);
  margin: 0;
  border-color: var(--panel-border);
  background: var(--panel-surface);
}

.result-exit-button {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  font-size: 1.55rem;
  line-height: 1;
}

.result-panel p:last-of-type {
  color: var(--muted);
  line-height: 1.45;
}

.result-panel .match-timeout-detail {
  color: #e54648;
  font-weight: 700;
  text-align: center;
}

.result-countdown {
  margin: 14px 0 0;
  color: var(--gold-strong);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.result-panel .primary-button {
  width: 100%;
  margin-top: 10px;
}

.result-scores {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.result-score {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 12px 10px;
  border: 1px solid var(--inner-border);
  border-radius: 6px;
  background: var(--inner-surface);
}

.result-score.winner {
  border-color: var(--gold);
}

.result-score span {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: calc(0.68rem + 2px);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.result-score strong {
  color: var(--gold-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.1rem;
  line-height: 1;
}

@media (max-width: 900px) {
  h1 {
    font-size: 2.35rem;
  }

  .table-zone {
    grid-template-columns: 126px minmax(0, 1fr);
  }

  .turn-ornaments {
    left: calc(50% + 70px);
  }

  .lane-heading-main {
    padding-right: 94px;
  }

  .opponent-lane .lane-heading-main {
    padding-left: 0;
  }

  .captured-count {
    right: 0;
  }


  .log-panel {
    grid-column: 1 / -1;
    max-height: none;
  }

  .match-panel {
    grid-column: 1 / -1;
  }

  .playing-card {
    flex-basis: 114px;
    width: 114px;
  }

  .playing-card.compact-card {
    flex-basis: 84px;
    width: 84px;
  }

  .opponent-lane .playing-card.compact-card {
    flex-basis: 32px;
    width: 32px;
  }

  .opponent-lane .playing-card {
    flex-basis: 70px;
    width: 70px;
  }

  .playing-card.trump-display-card {
    flex-basis: 114px;
    width: 114px;
  }

  .trick-panel {
    height: 400px;
    min-height: 400px;
  }
}

@media (max-width: 660px) {
  .app-shell {
    padding: 18px 10px 28px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand-heading {
    gap: 8px;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.22rem;
  }

  .setup-panel,
  .result-panel {
    padding: 18px;
  }

  .lobby-room {
    gap: 10px;
  }

  .result-overlay {
    padding: 16px;
  }

  .name-grid,
  .scoreboard,
  .table-zone,
  .setup-control-grid {
    grid-template-columns: 1fr;
  }

  .turn-ornaments {
    left: 50%;
  }


  .scoreboard,
  .player-lane,
  .table-zone,
  .action-bar {
    padding: 12px;
  }

  .player-lane {
    min-height: 160px;
  }

  .current-lane {
    min-height: 220px;
  }

  .hand-row,
  .played-row {
    min-height: 112px;
    gap: 8px;
  }

  .playing-card {
    flex-basis: 90px;
    width: 90px;
  }

  .playing-card.table-card,
  .playing-card.compact-card {
    flex-basis: 79px;
    width: 79px;
  }

  .playing-card.trump-display-card {
    flex-basis: 90px;
    width: 90px;
  }

  .trick-panel {
    height: 370px;
    min-height: 370px;
  }

  .opponent-lane .playing-card.compact-card {
    flex-basis: 28px;
    width: 28px;
  }

  .opponent-lane .playing-card {
    flex-basis: 62px;
    width: 62px;
  }

  .action-bar {
    display: grid;
  }

  .action-buttons {
    justify-content: stretch;
  }

  .hand-controls-row {
    flex-direction: column;
  }

  .action-buttons button {
    flex: 1 1 140px;
  }

  .lane-actions {
    flex: 0 0 auto;
    width: 100%;
    justify-content: stretch;
    margin-top: 12px;
    margin-right: 0;
  }

  .lane-actions button {
    flex: 1 1 140px;
  }
}
