:root {
  color-scheme: dark;
  --ink: #f7f9fb;
  --muted: rgba(247, 249, 251, 0.68);
  --line: rgba(255, 255, 255, 0.13);
  --frame: #061827;
  --frame-2: #0b2234;
  --table-a: #0d4056;
  --table-b: #082b3b;
  --table-c: #051d2b;
  --green: #327a3e;
  --green-2: #245d31;
  --gold: #c9a35a;
  --danger: #c95858;
  --tg-vh: 100vh;
  --tg-stable-vh: 100vh;
  --bar-h: clamp(62px, 10vh, 92px);
  --hud-h: clamp(70px, 10vh, 92px);
  --hand-card-w: clamp(48px, 9vw, 102px);
  --hand-card-h: calc(var(--hand-card-w) * 1.42);
  --battle-card-w: clamp(64px, 9vw, 96px);
  --battle-card-h: calc(var(--battle-card-w) * 1.44);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 8%, rgba(49, 76, 99, 0.4), transparent 26%),
    linear-gradient(180deg, #172636, #06101a 72%);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  font-weight: 800;
}

button:disabled {
  opacity: 0.48;
  cursor: default;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(10px, 2vh, 13px);
  background: rgba(4, 14, 24, 0.78);
  color: var(--ink);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: clamp(13px, 1.8vh, 15px);
}

.hidden {
  display: none !important;
}

.app {
  width: 100vw;
  height: min(var(--tg-stable-vh), 100vh);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.screen {
  width: min(460px, calc(100vw - 28px));
  max-height: calc(var(--tg-stable-vh) - 24px);
  overflow: auto;
}

.menu {
  width: 100%;
  height: min(var(--tg-stable-vh), 100vh);
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  justify-items: center;
  align-items: center;
  padding: clamp(18px, 4vh, 34px);
  background:
    radial-gradient(circle at 50% 18%, rgba(201, 163, 90, 0.22), transparent 28%),
    linear-gradient(155deg, #17344a, #0e1721 72%);
}

.brand {
  grid-row: 1 / 3;
  display: grid;
  justify-items: center;
  gap: clamp(8px, 1.5vh, 14px);
  text-align: center;
}

.brand span {
  width: clamp(72px, 13vh, 104px);
  height: clamp(72px, 13vh, 104px);
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(145deg, #fffdf4, #dfe8f7);
  color: #1b2632;
  font-size: clamp(18px, 3vh, 24px);
  font-weight: 900;
  transform: rotate(-5deg);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
}

.brand strong {
  font-size: clamp(28px, 6vh, 42px);
}

.primary,
.secondary,
.ghost,
.hud-btn,
.actions button {
  min-height: clamp(40px, 6vh, 54px);
  border-radius: 8px;
  padding: 10px 16px;
}

.primary {
  background: linear-gradient(#dcb75e, #a77c2c);
  color: #160f05;
  box-shadow: 0 4px 0 #6f501c, 0 14px 24px rgba(0, 0, 0, 0.24);
}

.primary.big {
  grid-row: 3;
  width: min(320px, 82vw);
  font-size: clamp(20px, 3.6vh, 25px);
}

.secondary {
  background: linear-gradient(#f1d27a, #c69739);
  color: #2d1f08;
}

.ghost,
.hud-btn {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
  border: 1px solid var(--line);
}

.panel {
  padding: clamp(16px, 3vh, 22px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(9, 22, 35, 0.94);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
}

.panel h1 {
  margin: 0 0 18px;
  font-size: clamp(23px, 4vh, 30px);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mode-panel {
  width: min(560px, calc(100vw - 28px));
  padding: clamp(18px, 3.4vh, 26px);
  overflow: hidden;
  background:
    repeating-radial-gradient(ellipse at 50% 62%, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 7px),
    radial-gradient(circle at 18% 0%, rgba(201, 163, 90, 0.14), transparent 30%),
    linear-gradient(145deg, rgba(9, 29, 43, 0.98), rgba(4, 16, 26, 0.98));
}

.mode-panel .panel-head {
  align-items: center;
  margin-bottom: clamp(16px, 2.6vh, 24px);
}

.mode-panel .ghost {
  min-height: 42px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  font-size: clamp(14px, 2vh, 16px);
}

.mode-heading {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.mode-heading h1 {
  margin: 0;
  font-size: clamp(26px, 4.4vh, 34px);
  line-height: 1.05;
}

.mode-heading p {
  margin: 0;
  color: rgba(220, 236, 248, 0.64);
  font-size: clamp(13px, 2vh, 15px);
  font-weight: 700;
}

.mode-grid,
.settings {
  display: grid;
  gap: clamp(10px, 1.8vh, 14px);
}

.player-picker {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.player-picker legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: clamp(13px, 1.8vh, 15px);
}

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

.player-options label {
  position: relative;
  display: block;
  cursor: pointer;
}

.player-options input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.player-options span {
  min-height: 58px;
  display: grid;
  place-content: center;
  gap: 1px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(5, 21, 33, 0.72));
  color: rgba(231, 241, 248, 0.7);
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.player-options strong {
  font-size: 21px;
  line-height: 1;
}

.player-options small {
  font-size: 10px;
  font-weight: 700;
}

.player-options input:checked + span {
  transform: translateY(-2px);
  border-color: rgba(239, 200, 111, 0.92);
  background: linear-gradient(180deg, #e2bd64, #ad7e2d);
  color: #211706;
  box-shadow: 0 4px 0 #72511a, 0 12px 24px rgba(0, 0, 0, 0.25);
}

.player-options input:focus-visible + span {
  outline: 3px solid rgba(78, 169, 231, 0.72);
  outline-offset: 2px;
}

.mode-panel .mode-grid {
  gap: clamp(14px, 2.2vh, 18px);
}

.mode-card {
  min-height: clamp(104px, 20vh, 134px);
  padding: clamp(14px, 2.8vh, 19px);
  display: grid;
  justify-items: start;
  gap: 8px;
  text-align: left;
  color: var(--ink);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.045));
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mode-panel .mode-card {
  position: relative;
  min-height: clamp(132px, 20vh, 156px);
  grid-template-columns: minmax(0, 1fr) auto;
  align-content: center;
  gap: 8px 16px;
  padding: clamp(18px, 3vh, 24px);
  overflow: hidden;
  background:
    radial-gradient(circle at 85% 18%, var(--mode-glow), transparent 28%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.045));
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 14px 36px rgba(0, 0, 0, 0.22);
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.mode-panel .mode-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(201, 163, 90, 0.24), transparent 34%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 10px);
  opacity: 0.5;
  pointer-events: none;
}

.mode-panel .mode-card:hover,
.mode-panel .mode-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(243, 211, 137, 0.62);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 20px 48px rgba(0, 0, 0, 0.34), 0 0 0 1px rgba(243, 211, 137, 0.12);
}

.mode-panel .mode-card:active {
  transform: translateY(0);
}

.mode-panel .mode-card.online {
  --mode-glow: rgba(67, 148, 214, 0.34);
}

.mode-panel .mode-card.bot {
  --mode-glow: rgba(76, 177, 113, 0.3);
}

.mode-card span {
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(201, 163, 90, 0.18);
  color: #f3d389;
  font-size: 13px;
  letter-spacing: 1px;
}

.mode-panel .mode-card span,
.mode-panel .mode-card strong,
.mode-panel .mode-card small,
.mode-panel .mode-card i {
  position: relative;
  z-index: 1;
}

.mode-panel .mode-card span {
  width: fit-content;
}

.mode-panel .mode-card i {
  grid-column: 2;
  grid-row: 1 / span 3;
  width: clamp(54px, 9vw, 74px);
  height: clamp(70px, 11vw, 92px);
  display: grid;
  place-items: center;
  align-self: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: linear-gradient(160deg, #fffdf6, #dfe8f0);
  color: #132130;
  font-style: normal;
  font-size: clamp(18px, 3vh, 24px);
  font-weight: 900;
  transform: rotate(5deg);
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.28);
}

.mode-panel .mode-card.bot i {
  transform: rotate(-5deg);
}

.mode-card strong {
  font-size: clamp(18px, 3vh, 21px);
}

.mode-panel .mode-card strong {
  font-size: clamp(21px, 3.2vh, 26px);
}

.mode-card small {
  color: var(--muted);
  font-weight: 500;
}

.mode-panel .mode-card small {
  max-width: 34ch;
  color: rgba(221, 235, 244, 0.72);
  font-size: clamp(13px, 2vh, 15px);
  line-height: 1.35;
}

.setting-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.game {
  position: relative;
  width: min(100vw, 1180px);
  height: min(var(--tg-stable-vh), 920px);
  max-height: 100vh;
  display: grid;
  grid-template-rows: clamp(0px, 3.8vh, 34px) var(--hud-h) minmax(0, 1fr);
  background:
    radial-gradient(circle at 50% 20%, rgba(32, 75, 101, 0.24), transparent 30%),
    linear-gradient(180deg, var(--frame-2), var(--frame));
  overflow: hidden;
  border: 1px solid rgba(121, 161, 185, 0.22);
  border-radius: clamp(0px, 1.2vw, 14px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

.window-bar {
  grid-row: 1;
  position: relative;
  min-height: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  color: rgba(255, 255, 255, 0.62);
  font-size: clamp(11px, 1.7vh, 15px);
}

.window-bar span {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.window-bar span:nth-child(1) { background: #f45c5c; }
.window-bar span:nth-child(2) { background: #f0c34a; }
.window-bar span:nth-child(3) { background: #59c55d; }

.window-bar strong {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-weight: 800;
}

.hud {
  grid-row: 2;
  z-index: 8;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: clamp(10px, 1.5vw, 18px);
  padding: clamp(10px, 1.8vh, 18px) clamp(18px, 3vw, 30px);
  background:
    linear-gradient(180deg, rgba(2, 13, 22, 0.86), rgba(3, 18, 30, 0.58));
}

.hud-title {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: clamp(14px, 2vw, 24px);
}

.hud-title strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(18px, 2.5vh, 26px);
  font-weight: 900;
}

.hud-title em {
  color: rgba(255, 255, 255, 0.44);
  font-style: normal;
  font-size: clamp(12px, 1.8vh, 15px);
  font-weight: 800;
  letter-spacing: 6px;
}

.cash {
  min-width: clamp(72px, 8vw, 104px);
  text-align: center;
  font-size: clamp(24px, 3.6vh, 34px);
  font-weight: 900;
  text-shadow: 0 2px 9px rgba(0, 0, 0, 0.38);
}

.hud-btn,
.menu-exit,
.hud-icons button {
  min-height: clamp(44px, 6vh, 56px);
  color: #fff;
  background: linear-gradient(180deg, rgba(43, 67, 85, 0.9), rgba(24, 43, 58, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 8px 20px rgba(0, 0, 0, 0.24);
}

.hud-btn {
  min-width: clamp(94px, 12vw, 140px);
}

.menu-exit {
  min-width: clamp(86px, 10vw, 124px);
  color: #fff;
  border-radius: 10px;
}

.hud-icons {
  display: flex;
  gap: clamp(8px, 1vw, 12px);
}

.hud-icons button {
  width: clamp(44px, 6vh, 56px);
  padding: 0;
  border-radius: 10px;
  font-size: clamp(20px, 3vh, 24px);
}

.table {
  position: relative;
  grid-row: 3;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  margin: 0 clamp(10px, 1.5vw, 14px);
  border-radius: clamp(8px, 1.2vw, 12px);
  background:
    repeating-radial-gradient(ellipse at 50% 52%, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 5px),
    radial-gradient(ellipse at 50% 48%, rgba(255, 255, 255, 0.08), transparent 48%),
    linear-gradient(135deg, var(--table-a), var(--table-b) 55%, var(--table-c));
}

.table::before,
.table::after,
.table-oval {
  content: "";
  position: absolute;
  pointer-events: none;
  border-radius: 50%;
}

.table::before {
  inset: clamp(58px, 10vh, 86px) clamp(28px, 5vw, 70px) clamp(58px, 10vh, 88px);
  border: clamp(5px, 0.8vw, 9px) solid rgba(180, 216, 228, 0.18);
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.32),
    0 34px 42px rgba(0, 0, 0, 0.26);
}

.table::after {
  left: 5%;
  right: 5%;
  bottom: clamp(-62px, -7vh, -36px);
  height: clamp(130px, 20vh, 190px);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 54%);
  opacity: 0.55;
}

.table-oval {
  inset: clamp(82px, 13vh, 120px) clamp(54px, 8vw, 108px) clamp(82px, 13vh, 124px);
  background: radial-gradient(ellipse at 50% 45%, rgba(255, 255, 255, 0.055), rgba(0, 0, 0, 0.08) 74%);
}

.players {
  position: absolute;
  z-index: 3;
  top: clamp(20px, 4vh, 38px);
  left: clamp(20px, 4vw, 58px);
  right: clamp(20px, 4vw, 58px);
  height: clamp(130px, 24vh, 220px);
  pointer-events: none;
}

.seat {
  position: absolute;
  left: var(--seat-x);
  top: var(--seat-y);
  width: clamp(82px, 13vw, 160px);
  display: grid;
  justify-items: center;
  gap: 5px;
  color: white;
  transform: translateX(-50%);
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.7);
}

.opponent-cards {
  position: relative;
  width: clamp(80px, 13vw, 150px);
  height: clamp(54px, 10vh, 98px);
}

.opponent-cards span {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: clamp(34px, 5.2vw, 62px);
  height: clamp(52px, 8vw, 88px);
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background:
    repeating-linear-gradient(45deg, #dff9ee 0 7px, #79b394 7px 12px);
  transform-origin: 50% 100%;
  transform: translateX(-50%) rotate(calc((var(--b) - var(--mid)) * 7deg));
  box-shadow: 0 9px 18px rgba(0, 0, 0, 0.22);
}

.opponent-cards em {
  position: absolute;
  right: -8px;
  bottom: 18%;
  min-width: clamp(24px, 3vh, 32px);
  height: clamp(24px, 3vh, 32px);
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(4, 14, 24, 0.94);
  color: #fff;
  font-size: clamp(12px, 1.8vh, 15px);
  font-style: normal;
  font-weight: 900;
}

.seat .avatar {
  display: none;
}

.seat strong {
  order: -1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(14px, 2vh, 20px);
  font-weight: 900;
}

.seat small {
  display: none;
}

.seat.defender strong {
  color: #f0cb7a;
}

.seat.empty {
  opacity: 0.52;
}

.deck {
  position: absolute;
  z-index: 4;
  left: clamp(126px, 20vw, 300px);
  top: 48%;
  transform: translateY(-50%);
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: clamp(12px, 2vw, 22px);
}

.deck-stack {
  grid-row: 1 / 3;
  position: relative;
  width: calc(var(--hand-card-w) * 0.86);
  height: calc(var(--hand-card-h) * 0.9);
}

.deck-stack::before,
.deck-stack::after {
  content: "";
  position: absolute;
  inset: 8px 0 -8px;
  border-radius: 8px;
  background: linear-gradient(#e5e3df, #b9b7b3);
  box-shadow: 0 9px 0 rgba(255, 255, 255, 0.5), 0 14px 18px rgba(0, 0, 0, 0.25);
}

.deck-stack .card {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
}

.deck-badge {
  min-width: clamp(76px, 9vw, 108px);
  padding: clamp(10px, 1.8vh, 15px);
  display: grid;
  gap: 4px;
  justify-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(8, 22, 34, 0.66);
  color: rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.deck-badge span {
  font-size: clamp(10px, 1.5vh, 13px);
  font-weight: 900;
}

.deck-badge strong {
  color: #fff;
  font-size: clamp(17px, 2.5vh, 24px);
}

.trump {
  width: clamp(54px, 8vw, 84px);
  height: clamp(40px, 6vw, 64px);
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #fffdf6;
  color: #151515;
  font-size: clamp(20px, 3vh, 32px);
  transform: rotate(-14deg);
  box-shadow: 0 9px 20px rgba(0, 0, 0, 0.28);
}

.trump.red {
  color: #dd1f3a;
}

.trump.black {
  color: #101418;
}

.battle {
  position: absolute;
  z-index: 5;
  left: 40%;
  right: 26%;
  top: 41%;
  min-height: clamp(88px, 15vh, 140px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 2vw, 28px);
}

.empty-table {
  color: rgba(255, 255, 255, 0.68);
  font-size: clamp(13px, 2vh, 16px);
  text-shadow: 0 2px 7px rgba(0, 0, 0, 0.3);
}

.slot {
  width: var(--battle-card-w);
  height: var(--battle-card-h);
  position: relative;
}

.slot .cover {
  position: absolute;
  left: 28%;
  top: 14%;
  transform: rotate(10deg);
}

.table-status {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: calc(var(--hand-card-h) + clamp(70px, 12vh, 108px));
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.84);
  font-size: clamp(13px, 2vh, 17px);
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.table-status::before {
  content: "";
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 4px dotted rgba(255, 255, 255, 0.72);
  opacity: 0;
  animation: spin 1.1s linear infinite;
}

.table-status.thinking::before {
  opacity: 0.9;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.actions {
  position: absolute;
  z-index: 8;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  width: clamp(104px, 29vw, 142px);
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr;
}

.actions button {
  min-width: 0;
  min-height: clamp(42px, 6vh, 52px);
  color: #fff;
  background: linear-gradient(180deg, rgba(35, 58, 76, 0.92), rgba(18, 34, 49, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 12px 22px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
  font-size: clamp(14px, 2vh, 18px);
}

.actions button[hidden] {
  display: none;
}

.actions button:not(:disabled) {
  background: linear-gradient(180deg, #4e9a55, #2d713a);
}

.game-result {
  position: absolute;
  z-index: 12;
  left: 50%;
  top: 50%;
  width: min(360px, calc(100% - 32px));
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: clamp(18px, 4vh, 28px);
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(15, 36, 51, 0.96), rgba(7, 18, 29, 0.98));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  text-align: center;
}

.game-result::before {
  content: "";
  width: 54px;
  height: 6px;
  border-radius: 999px;
  background: #c9a35a;
}

.game-result.win::before {
  background: #48b66b;
}

.game-result.lose::before {
  background: #d94b5f;
}

.game-result strong {
  color: #fff;
  font-size: clamp(20px, 3.5vh, 28px);
  line-height: 1.1;
}

.game-result span {
  color: rgba(221, 235, 244, 0.78);
  font-size: clamp(14px, 2.2vh, 17px);
  line-height: 1.35;
}

.game-result button {
  width: min(180px, 100%);
  min-height: 44px;
  color: #fff;
  background: linear-gradient(180deg, rgba(50, 82, 105, 0.98), rgba(25, 48, 66, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.24);
}

.you-label {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: calc(var(--hand-card-h) + clamp(58px, 9vh, 78px));
  transform: translateX(-50%);
  font-size: clamp(15px, 2.2vh, 20px);
  font-weight: 900;
  text-shadow: 0 2px 7px rgba(0, 0, 0, 0.45);
}

.hand {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: clamp(58px, 9vh, 78px);
  width: min(76%, 780px);
  height: calc(var(--hand-card-h) + clamp(18px, 4vh, 34px));
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0;
  overflow: visible;
  transform: translateX(-50%);
  touch-action: pan-y;
}

.card {
  width: var(--hand-card-w);
  height: var(--hand-card-h);
  flex: 0 0 var(--hand-card-w);
  margin-left: calc(var(--hand-card-w) * -1 * var(--hand-overlap, 0.34));
  border: 1px solid #e4e0d8;
  border-radius: clamp(7px, 1.2vh, 10px);
  background: linear-gradient(160deg, #fff, #edf1f2);
  color: #111;
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: center;
  justify-items: center;
  padding: clamp(7px, 1.5vh, 13px);
  font-size: calc(var(--hand-card-w) * 0.46);
  font-weight: 900;
  box-shadow: 0 13px 24px rgba(0, 0, 0, 0.34);
  transform:
    translateY(var(--fan-y, 0px))
    rotate(calc((var(--i) - var(--mid)) * 3.2deg));
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.hand .card:first-child {
  margin-left: 0;
}

.card small {
  font-size: calc(var(--hand-card-w) * 0.34);
}

.card.red {
  color: #d82036;
}

.card.small {
  width: var(--battle-card-w);
  height: var(--battle-card-h);
  margin-left: 0;
  padding: 6px;
  font-size: calc(var(--battle-card-w) * 0.34);
}

.card.small small {
  font-size: calc(var(--battle-card-w) * 0.26);
}

.card.back {
  background:
    repeating-linear-gradient(45deg, #dff9ee 0 7px, #79b394 7px 12px);
  border-color: #e0fff1;
}

.selected {
  outline: 3px solid var(--gold);
  transform:
    translateY(calc(-1 * clamp(14px, 3vh, 26px)))
    rotate(calc((var(--i) - var(--mid)) * 3.2deg));
}

.target {
  outline: 3px solid var(--danger);
}

@media (min-width: 760px) {
  .app {
    padding: clamp(8px, 1.5vh, 16px);
  }

  .game {
    width: min(96vw, 1160px);
    height: min(calc(var(--tg-stable-vh) - 16px), 900px);
  }
}

@media (max-width: 720px) {
  :root {
    --bar-h: clamp(58px, 10vh, 74px);
    --hud-h: clamp(56px, 9vh, 70px);
  }

  .window-bar {
    display: none;
  }

  .game {
    width: 100vw;
    height: min(var(--tg-stable-vh), 100vh);
    grid-template-rows: var(--hud-h) minmax(0, 1fr);
    border-radius: 0;
    border: 0;
  }

  .hud {
    grid-row: 1;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    padding: 8px 10px;
  }

  .hud-title {
    display: grid;
    gap: 2px;
  }

  .hud-title em {
    font-size: 10px;
    letter-spacing: 4px;
  }

  .cash {
    min-width: 54px;
    font-size: 22px;
  }

  .hud-btn {
    min-width: 78px;
    padding-inline: 10px;
  }

  .menu-exit {
    min-width: 74px;
    padding-inline: 9px;
  }

  .mode-panel {
    width: min(100vw - 20px, 560px);
    padding: 14px;
  }

  .mode-panel .panel-head {
    gap: 10px;
  }

  .mode-panel .ghost {
    min-height: 38px;
    padding: 7px 12px;
  }

  .mode-heading h1 {
    font-size: clamp(23px, 6vw, 30px);
  }

  .mode-panel .mode-card {
    min-height: 126px;
    padding: 16px;
    gap: 8px 12px;
  }

  .mode-panel .mode-card i {
    width: 50px;
    height: 68px;
    font-size: 18px;
  }

  .table {
    grid-row: 2;
    margin: 0;
    border-radius: 0;
  }

  .table::before {
    inset: clamp(58px, 11vh, 84px) -18% clamp(58px, 11vh, 84px);
  }

  .table-oval {
    inset: clamp(88px, 15vh, 112px) 6% clamp(88px, 15vh, 112px);
  }

  .players {
    top: 16px;
    left: 10px;
    right: 10px;
    height: 120px;
  }

  .seat {
    width: clamp(68px, 21vw, 90px);
  }

  .opponent-cards {
    width: clamp(68px, 21vw, 90px);
    height: 74px;
  }

  .opponent-cards span {
    width: clamp(34px, 10vw, 44px);
    height: clamp(52px, 15vw, 66px);
  }

  .seat strong {
    font-size: 13px;
  }

  .players[data-count="5"] .seat {
    width: clamp(62px, 19vw, 78px);
  }

  .players[data-count="5"] .seat strong {
    font-size: 11px;
  }

  .players[data-count="5"] .opponent-cards {
    width: clamp(60px, 18vw, 76px);
  }

  .deck {
    left: clamp(22px, 7vw, 44px);
    top: 45%;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .deck-badge {
    min-width: 62px;
    padding: 8px;
  }

  .trump {
    width: 52px;
    height: 40px;
  }

  .battle {
    left: 28%;
    right: 4%;
    top: 25%;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(3, var(--battle-card-w));
    justify-content: center;
    align-content: start;
    gap: 9px 8px;
  }

  .actions {
    right: 10px;
    bottom: 10px;
    width: clamp(104px, 31vw, 132px);
  }

  .table-status {
    top: 124px;
    bottom: auto;
    max-width: calc(100% - 32px);
    font-size: 13px;
    white-space: normal;
  }

  .you-label {
    display: none;
  }

  .hand {
    left: 50%;
    width: calc(100% - 20px);
    bottom: 72px;
  }
}

@media (max-height: 640px) {
  :root {
    --bar-h: 56px;
  }

  .seat .avatar,
  .seat small {
    display: none;
  }

  .players {
    top: 10px;
    height: 110px;
  }

  .actions {
    bottom: 8px;
    width: 108px;
  }

  .table-status {
    display: none;
  }

  .you-label {
    display: none;
  }

  .hand {
    bottom: 64px;
  }

}
