:root {
  --red: #c62828;
  --black: #1b1b1b;
  --gold: #f2c14e;
  --gold-2: #d49b16;
  --ink: #f6f0e4;
  --panel: rgba(18, 11, 6, 0.72);
  --bg-1: #2b1c12;
  --bg-2: #120b06;
  /* стол по умолчанию */
  --felt-1: #2f8a52;
  --felt-2: #1d6438;
  --felt-3: #123f23;
  --rim-1: #7a4f2c;
  --rim-2: #4a2e17;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Rubik", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(242, 193, 78, 0.08), transparent 40%),
    radial-gradient(ellipse at top, var(--bg-1) 0%, var(--bg-2) 75%) fixed;
  background-color: var(--bg-2);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

button {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 9px 16px;
  border: none;
  border-radius: 10px;
  background: var(--ink);
  color: #3b2a1f;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  transition: transform 0.1s, filter 0.15s;
}
button:hover:not(:disabled) { filter: brightness(1.08); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: linear-gradient(#f7d36b, var(--gold-2)); color: #3b2410; font-weight: 700; }
button.danger { background: linear-gradient(#b23a3a, #7d2222); color: #fff; }
button.ok { background: linear-gradient(#3f9d5f, #276b40); color: #fff; font-weight: 700; }
button.ghost { background: rgba(255, 255, 255, 0.08); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); }
button.small { padding: 6px 12px; font-size: 0.85rem; }

.chip-icon {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold) 0 35%, #b07a10 36% 48%, var(--gold) 49%);
  box-shadow: 0 0 0 1px #6b4a08;
  vertical-align: -2px;
}

/* ===================== Меню ===================== */
.menu { min-height: 100vh; display: flex; justify-content: center; padding: 28px 16px 40px; }
.menu-inner { width: 100%; max-width: 920px; display: flex; flex-direction: column; align-items: center; gap: 22px; }

.logo { text-align: center; }
.logo-suits { font-size: 1.6rem; letter-spacing: 10px; opacity: 0.9; }
.logo-suits .r { color: #e05252; }
.logo h1 {
  margin: 4px 0 0;
  font-size: clamp(3rem, 10vw, 5rem);
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(#ffe7a0, var(--gold) 50%, #b8810f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.6));
}
.logo p { margin: 2px 0 0; opacity: 0.7; letter-spacing: 1px; }

.wallet-box {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border-radius: 30px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px rgba(242, 193, 78, 0.3);
}
.wallet-box b { color: var(--gold); font-size: 1.2rem; }

.pick { display: flex; flex-direction: column; align-items: center; gap: 8px; opacity: 0.95; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.seg button { width: 42px; padding: 8px 0; background: rgba(255, 255, 255, 0.08); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15); }
.seg button.wide { width: auto; padding: 8px 14px; }
.seg button.active { background: linear-gradient(#f7d36b, var(--gold-2)); color: #3b2410; font-weight: 700; }

.menu-h { margin: 6px 0 -8px; font-weight: 500; font-size: 1.1rem; opacity: 0.85; }
.tables { width: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }

.table-card {
  display: flex; flex-direction: column; align-items: stretch; gap: 6px;
  padding: 12px;
  text-align: left;
  border-radius: 16px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 6px 18px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}
.table-card:hover:not(:disabled) { transform: translateY(-4px); box-shadow: inset 0 0 0 2px var(--gold), 0 10px 24px rgba(0, 0, 0, 0.5); filter: none; }
.table-card.locked { opacity: 0.55; }
.mini-felt {
  height: 86px;
  border-radius: 50% / 45%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, var(--felt-1), var(--felt-2) 65%, var(--felt-3));
  border: 6px solid var(--rim-1);
  font-weight: 800; font-size: 1.15rem; color: #fff; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}
.tc-name { font-size: 1.25rem; font-weight: 700; color: var(--gold); margin-top: 4px; }
.tc-desc { font-size: 0.85rem; opacity: 0.75; }
.tc-req { font-size: 0.8rem; opacity: 0.9; }

/* Темы столов */
.theme-green, .felt-green   { --felt-1: #2f8a52; --felt-2: #1d6438; --felt-3: #123f23; --rim-1: #7a4f2c; --rim-2: #4a2e17; }
.theme-blue, .felt-blue     { --felt-1: #2f6fa8; --felt-2: #1c4c7d; --felt-3: #0f2c4c; --rim-1: #6b6f7a; --rim-2: #383b44; }
.theme-red, .felt-red       { --felt-1: #9c2f3c; --felt-2: #6e1d29; --felt-3: #3f0d16; --rim-1: #b8862e; --rim-2: #6b4a12; }
.theme-black, .felt-black   { --felt-1: #34343a; --felt-2: #1f1f24; --felt-3: #0d0d10; --rim-1: #d4a63a; --rim-2: #7a5a12; }
.theme-purple, .felt-purple { --felt-1: #6b3fa0; --felt-2: #4a2873; --felt-3: #2a1544; --rim-1: #a8a8b8; --rim-2: #55556a; }
.theme-teal, .felt-teal     { --felt-1: #1f8f8a; --felt-2: #136661; --felt-3: #093d3a; --rim-1: #8a5a32; --rim-2: #4f3219; }

/* ===================== Игра ===================== */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  max-width: 1240px; margin: 0 auto; padding: 10px 16px;
}
.table-name { font-weight: 700; color: var(--gold); text-align: center; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  grid-template-areas: "table log" "me log";
  gap: 14px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px 24px;
}
.table-wrap { grid-area: table; padding: 26px 34px; }
.me { grid-area: me; }
.log-box { grid-area: log; }

.table {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 50% / 46%;
  background:
    radial-gradient(ellipse at center, rgba(255, 255, 255, 0.08), transparent 60%),
    radial-gradient(ellipse at center, var(--felt-1) 0%, var(--felt-2) 62%, var(--felt-3) 100%);
  border: 16px solid var(--rim-1);
  box-shadow:
    inset 0 0 0 3px rgba(0, 0, 0, 0.25),
    inset 0 0 50px rgba(0, 0, 0, 0.55),
    0 0 0 4px var(--rim-2),
    0 18px 40px rgba(0, 0, 0, 0.6);
}

.center {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 50%;
}
.pot {
  display: flex; align-items: center; gap: 6px;
  background: rgba(0, 0, 0, 0.4);
  padding: 5px 16px; border-radius: 20px; font-size: 1.05rem;
}
.pot b { color: var(--gold); }
.trump-box { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.trump-box .card { --cw: 42px; }
.table-cards { display: flex; gap: 5px; min-height: 70px; align-items: center; flex-wrap: wrap; justify-content: center; }
.table-cards .card { --cw: 44px; }
.played { display: flex; flex-direction: column; align-items: center; font-size: 0.68rem; gap: 2px; opacity: 0.95; }
.message {
  min-height: 1.3em; text-align: center; font-weight: 600; color: var(--gold); font-size: 0.95rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}
.message.big {
  font-size: 1.1rem; padding: 6px 14px; border-radius: 12px; background: rgba(0, 0, 0, 0.45);
  animation: pop 0.4s ease;
}

/* ---------- Места ---------- */
.seat {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  z-index: 2;
  transition: opacity 0.25s;
}
.seat .cards { display: flex; gap: 2px; min-height: 42px; }
.seat .cards .card { --cw: 30px; }
.plate {
  position: relative;
  display: flex; align-items: center; gap: 7px;
  padding: 4px 12px 4px 4px;
  min-width: 112px;
  border-radius: 30px;
  background: var(--panel);
  border: 2px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.avatar {
  position: relative;
  flex: none;
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.95rem; color: #fff;
  background: linear-gradient(135deg, hsl(var(--hue) 60% 55%), hsl(var(--hue) 55% 32%));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
}
.me-seat .avatar { font-size: 0.75rem; }
.dealer-chip {
  position: absolute; right: -4px; bottom: -4px;
  width: 16px; height: 16px; line-height: 16px;
  border-radius: 50%; background: #fff; color: #222;
  font-size: 0.6rem; text-align: center; font-weight: 800;
}
.info { line-height: 1.15; }
.info .name { font-weight: 600; font-size: 0.82rem; }
.info .chips { color: var(--gold); font-size: 0.78rem; }
.status { font-size: 0.72rem; color: #ffe2a0; min-height: 1em; text-shadow: 0 1px 2px #000; display: flex; gap: 4px; align-items: center; }
.bet-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px 1px 3px; border-radius: 10px;
  background: rgba(0, 0, 0, 0.5); color: var(--gold); font-weight: 600;
}
.bet-chip::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: radial-gradient(circle, var(--gold) 0 35%, #b07a10 36% 48%, var(--gold) 49%); }

.seat.turn .plate { border-color: var(--gold); box-shadow: 0 0 16px rgba(242, 193, 78, 0.6); }
.seat.folded, .seat.out, .seat.sitout { opacity: 0.45; }
.seat.winner .plate { border-color: #6be38f; box-shadow: 0 0 18px rgba(107, 227, 143, 0.8); }

/* Таймер хода */
.timer { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, 0.12); }
.timer i {
  display: block; height: 100%;
  background: linear-gradient(90deg, #e05252, var(--gold) 40%, #6be38f);
  background-size: 300% 100%;
  transform-origin: left;
  animation-name: countdown;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}
@keyframes countdown {
  from { transform: scaleX(1); background-position: 100% 0; }
  to { transform: scaleX(0); background-position: 0 0; }
}
.my-timer { height: 6px; margin: 6px 0 0; }
.timer.wide { position: relative; height: 6px; border-radius: 3px; overflow: hidden; }

/* Облачко с объявлением */
.bubble {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 5px 11px;
  border-radius: 12px;
  background: #fffdf8;
  color: #2b1c12;
  font-weight: 700;
  font-size: 0.8rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  animation: bubble 0.25s ease;
  z-index: 5;
  pointer-events: none;
}
.bubble::after {
  content: ""; position: absolute; top: 100%; left: 50%; margin-left: -6px;
  border: 6px solid transparent; border-top-color: #fffdf8;
}
@keyframes bubble { from { opacity: 0; transform: translate(-50%, 6px) scale(0.85); } }

/* ---------- Карты ---------- */
.card {
  --cw: 80px;
  position: relative;
  display: inline-block;
  flex: none;
  width: var(--cw);
  height: calc(var(--cw) * 1.4);
  border-radius: calc(var(--cw) * 0.09);
  background: linear-gradient(160deg, #ffffff, #f3ede0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.card.red { color: var(--red); }
.card.black { color: var(--black); }
.card.back {
  background:
    radial-gradient(circle at center, rgba(242, 193, 78, 0.35) 0 12%, transparent 13%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.12) 0 3px, transparent 3px 6px),
    linear-gradient(135deg, #8e2b2b, #4f1414);
  border: calc(var(--cw) * 0.05) solid #fffdf8;
}
.card.wild { box-shadow: 0 0 0 2px var(--gold), 0 1px 3px rgba(0, 0, 0, 0.5); }
.card .corner {
  position: absolute; top: 5%; left: 8%;
  display: flex; flex-direction: column; align-items: center;
  line-height: 1; font-weight: 700; font-size: calc(var(--cw) * 0.24);
}
.card .pip {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cw) * 0.5);
}
.card .star { position: absolute; right: 6%; bottom: 4%; font-size: calc(var(--cw) * 0.22); color: var(--gold-2); }

/* Раздача: карта летит из центра стола */
.card.deal { animation: deal 0.45s cubic-bezier(0.2, 0.8, 0.3, 1) both; }
@keyframes deal {
  from { transform: translate(var(--fx, 0), var(--fy, 0)) scale(0.5) rotate(-20deg); opacity: 0.2; }
  to { transform: none; opacity: 1; }
}
.card.flip { animation: flip 0.6s ease both; }
@keyframes flip {
  0% { transform: rotateY(90deg) scale(1.3); }
  60% { transform: rotateY(0) scale(1.3); }
  100% { transform: none; }
}
.pop { animation: pop 0.35s ease both; }
@keyframes pop { from { transform: scale(0.5); opacity: 0; } }

/* ---------- Моя панель ---------- */
.me {
  position: relative;
  background: var(--panel);
  border-radius: 16px;
  padding: 12px 16px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transition: box-shadow 0.2s;
}
.me.my-turn { box-shadow: inset 0 0 0 2px var(--gold), 0 0 22px rgba(242, 193, 78, 0.25); }
.me-info { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; font-size: 0.95rem; }
.me-info b { color: var(--gold); }
.combo { margin-left: auto; color: #8ff0ae; font-size: 0.88rem; }
.hand { display: flex; gap: 10px; justify-content: center; min-height: 124px; margin: 10px 0; }
.hand .card { --cw: 86px; transition: transform 0.15s, opacity 0.15s; }
.hand .card.playable { cursor: pointer; box-shadow: 0 0 0 3px #6be38f, 0 6px 14px rgba(0, 0, 0, 0.5); }
.hand .card.playable:hover { transform: translateY(-12px); }
.hand .card.dim { opacity: 0.4; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; min-height: 42px; }
.actions .info { opacity: 0.85; font-size: 0.95rem; }

/* ---------- Журнал ---------- */
.log-box {
  background: var(--panel);
  border-radius: 16px;
  padding: 12px 14px;
  max-height: 720px;
  overflow: auto;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.log-box h3 { margin: 0 0 6px; font-size: 1rem; color: var(--gold); }
#log { margin: 0; padding: 0; list-style: none; font-size: 0.82rem; line-height: 1.5; }
#log li.sep { margin-top: 8px; color: var(--gold); font-weight: 600; }
#log li.win { color: #8ff0ae; font-weight: 600; }

/* ---------- Окна ---------- */
.overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  z-index: 100; padding: 16px;
}
.dialog {
  background: #f6f0e4; color: #3b2a1f;
  border-radius: 18px; padding: 24px 28px;
  max-width: 600px; width: 100%; max-height: 90vh; overflow: auto;
  display: flex; flex-direction: column; gap: 14px;
  animation: pop 0.3s ease;
}
.dialog h2 { margin: 0; }
.rules ul { margin: 0; padding-left: 20px; line-height: 1.5; }
.rules li { margin-bottom: 6px; }

/* ---------- Узкие экраны (телефоны) ---------- */
@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "table" "me" "log"; }
  .table-wrap { padding: 30px 6px 20px; }
  .table { aspect-ratio: 4 / 5; border-width: 10px; border-radius: 44% / 36%; }
  .center { width: 60%; }
  .plate { min-width: 0; padding-right: 8px; }
  .avatar { width: 28px; height: 28px; font-size: 0.8rem; }
  .info .name { font-size: 0.72rem; }
  .info .chips { font-size: 0.7rem; }
  .seat .cards .card { --cw: 22px; }
  .seat .cards { min-height: 31px; }
  .hand .card { --cw: 74px; }
  .combo { margin-left: 0; }
  .bubble { font-size: 0.72rem; padding: 4px 8px; }
  .table-name { font-size: 0.85rem; }
  .topbar button { white-space: nowrap; }
}

/* ===================== Главное меню ===================== */
.main-menu { justify-content: center; min-height: calc(100vh - 68px); }
.menu-buttons { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 340px; margin-top: 10px; }
.menu-btn {
  position: relative;
  padding: 15px 20px;
  font-size: 1.15rem;
  font-weight: 600;
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(242, 193, 78, 0.35), 0 6px 16px rgba(0, 0, 0, 0.4);
  text-align: left;
}
.menu-btn:hover:not(:disabled) { box-shadow: inset 0 0 0 2px var(--gold), 0 8px 20px rgba(0, 0, 0, 0.5); filter: none; }
.menu-btn.primary { background: linear-gradient(#f7d36b, var(--gold-2)); color: #3b2410; text-align: center; font-size: 1.3rem; }
.soon {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  padding: 3px 8px; border-radius: 8px; background: rgba(242, 193, 78, 0.18); color: var(--gold);
}

/* ===================== Экраны настроек ===================== */
.screen-head { width: 100%; display: flex; align-items: center; gap: 14px; }
.screen-head h2 { margin: 0; font-size: 1.6rem; color: var(--gold); }
.panel {
  background: var(--panel);
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 8px 24px rgba(0, 0, 0, 0.4);
}
.form { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.form h3 { margin: 6px 0 -4px; color: var(--gold); font-size: 1.05rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.row.col { flex-direction: column; align-items: flex-start; gap: 8px; }
.row > span { opacity: 0.9; }
.row .seg { justify-content: flex-start; }
button.big { padding: 13px 20px; font-size: 1.1rem; }

/* Переключатель */
.switch { position: relative; flex: none; width: 50px; height: 28px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; border-radius: 14px; background: rgba(255, 255, 255, 0.18); transition: background 0.2s; }
.switch i::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.switch input:checked + i { background: linear-gradient(#3f9d5f, #276b40); }
.switch input:checked + i::after { transform: translateX(22px); }

/* Ползунок громкости */
.range { display: flex; align-items: center; gap: 10px; }
.range input { width: 180px; accent-color: var(--gold); }
.range input:disabled { opacity: 0.4; }
.range b { min-width: 44px; text-align: right; color: var(--gold); }

/* Экран «Новая игра» */
.setup-grid { width: 100%; display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.preview-panel { display: flex; flex-direction: column; gap: 14px; align-items: stretch; position: sticky; top: 16px; }
.preview-table { aspect-ratio: 16 / 10; border-width: 12px; display: flex; align-items: center; justify-content: center; }
.preview-cards { display: flex; gap: 6px; }
.preview-cards .card { --cw: 54px; }
.preview-cards .card:nth-child(1) { transform: rotate(-10deg) translateY(4px); }
.preview-cards .card:nth-child(3) { transform: rotate(10deg) translateY(4px); }
.preview-info { line-height: 1.7; font-size: 0.95rem; }
.preview-info b { color: var(--gold); }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12); font-size: 0.72rem; font-weight: 500;
}
.swatch.active { box-shadow: inset 0 0 0 2px var(--gold), 0 0 12px rgba(242, 193, 78, 0.35); }
.swatch i { display: block; width: 58px; height: 38px; border-radius: 50% / 45%; }
.swatch[class*="felt-"] i { background: radial-gradient(ellipse at center, var(--felt-1), var(--felt-2) 65%, var(--felt-3)); border: 4px solid var(--rim-1); }
.backs .swatch i { width: 34px; height: 48px; border-radius: 4px; border: 2px solid #fffdf8; }

/* ===================== Рубашки карт ===================== */
:root {
  --bk-red:
    radial-gradient(circle at center, rgba(242, 193, 78, 0.35) 0 12%, transparent 13%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.12) 0 3px, transparent 3px 6px),
    linear-gradient(135deg, #8e2b2b, #4f1414);
  --bk-blue:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.3) 0 12%, transparent 13%),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.12) 0 3px, transparent 3px 6px),
    linear-gradient(135deg, #2f5fb8, #142a63);
  --bk-green:
    radial-gradient(circle at center, rgba(242, 193, 78, 0.3) 0 12%, transparent 13%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.1) 0 2px, transparent 2px 5px),
    linear-gradient(135deg, #2f8a52, #123f23);
  --bk-gold:
    radial-gradient(circle at center, #fff3c4 0 10%, transparent 11%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.25) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(-45deg, rgba(120, 80, 10, 0.3) 0 2px, transparent 2px 7px),
    linear-gradient(135deg, #f2c14e, #a8740c);
  --bk-ornament:
    radial-gradient(circle, #f2c14e 0 14%, transparent 15%) 0 0 / 33.3% 23.8%,
    conic-gradient(from 45deg, #7a1f2b 0 25%, #1f3f7a 0 50%, #7a1f2b 0 75%, #1f3f7a 0) 0 0 / 33.3% 23.8%;
  --bk-black:
    linear-gradient(45deg, transparent 42%, rgba(242, 193, 78, 0.55) 43% 57%, transparent 58%),
    linear-gradient(-45deg, transparent 42%, rgba(242, 193, 78, 0.55) 43% 57%, transparent 58%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.05) 0 3px, transparent 3px 6px),
    linear-gradient(135deg, #2b2b30, #0d0d10);
}
.card.back { background: var(--back, var(--bk-red)); }
body[data-back="red"]      { --back: var(--bk-red); }
body[data-back="blue"]     { --back: var(--bk-blue); }
body[data-back="green"]    { --back: var(--bk-green); }
body[data-back="gold"]     { --back: var(--bk-gold); }
body[data-back="ornament"] { --back: var(--bk-ornament); }
body[data-back="black"]    { --back: var(--bk-black); }
.back-red i      { background: var(--bk-red); }
.back-blue i     { background: var(--bk-blue); }
.back-green i    { background: var(--bk-green); }
.back-gold i     { background: var(--bk-gold); }
.back-ornament i { background: var(--bk-ornament); }
.back-black i    { background: var(--bk-black); }

/* Всплывающее сообщение */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #2b1c12; color: var(--ink); padding: 10px 18px; border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), inset 0 0 0 1px var(--gold);
  z-index: 200; animation: pop 0.25s ease; max-width: calc(100% - 32px); text-align: center;
}

@media (max-width: 820px) {
  .setup-grid { grid-template-columns: minmax(0, 1fr); }
  .preview-panel { position: static; }
  .preview-table { width: 100%; max-width: 360px; margin: 0 auto; }
  .range input { width: 130px; }
  .row { align-items: flex-start; }
}

/* ===================== Иконки (Lucide) ===================== */
.ico { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }
button .ico { margin-right: 2px; }
.menu-btn .ico { width: 1.25em; height: 1.25em; margin-right: 8px; color: var(--gold); }
.menu-btn.primary .ico { color: #3b2410; fill: #3b2410; }
.form h3 .ico, .log-box h3 .ico { color: var(--gold); }
.row > span .ico { margin-right: 6px; opacity: 0.85; }
.pot .ico { color: var(--gold); }
.dialog h2 .ico { color: var(--gold-2); }

/* ===================== Слой эффектов (GSAP) ===================== */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 150; overflow: hidden; }
.fx-chip {
  position: fixed;
  width: 18px; height: 18px;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--gold) 0 30%, #fff3c4 31% 38%, var(--gold) 39% 58%, transparent 59%),
    repeating-conic-gradient(#b07a10 0 20deg, #fff3c4 20deg 40deg);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6), inset 0 0 0 1px #6b4a08;
  will-change: transform;
}
.fx-card { position: fixed; will-change: transform; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.55); }

/* =====================================================================
   АДАПТИВНОСТЬ: телефоны (вертикально и горизонтально), планшеты, ПК.
   Идёт последним, поэтому переопределяет правила выше.
   ===================================================================== */
button, .card, .swatch, .switch { touch-action: manipulation; }
.menu { padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }

/* ---------- Игровой экран ---------- */
#game { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
#game .topbar {
  width: 100%;
  padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left));
}
.top-right { display: flex; gap: 6px; }
.table-name { font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.layout {
  --chrome: 420px; /* шапка + моя панель + отступы: столько высоты не достаётся столу */
  flex: 1;
  width: 100%;
  max-width: 1240px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "table" "me";
  gap: 10px;
  padding: 0 max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  align-content: start;
}
.table-wrap { padding: 26px 34px 20px; display: flex; justify-content: center; }
.table {
  aspect-ratio: 16 / 9;
  width: min(100%, calc((100vh - var(--chrome)) * 16 / 9));
  width: min(100%, calc((100dvh - var(--chrome)) * 16 / 9));
  min-width: 280px;
}
.seat { transform: translate(-50%, -50%) scale(var(--ss, 1)); }
.center { transform: translate(-50%, -50%) scale(var(--cs, 1)); }
.me { width: 100%; max-width: 900px; justify-self: center; }
.hand .card { --cw: clamp(60px, 9vw, 88px); }
.hand { min-height: 0; }

/* Кнопки действий: удобные для пальцев */
.actions button { min-height: 42px; }

/* ---------- Журнал: выдвижная панель ---------- */
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(380px, 88vw);
  max-height: none;
  margin: 0;
  border-radius: 18px 0 0 18px;
  background: #1a120b;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: translateX(105%);
  transition: transform 0.28s ease;
  z-index: 120;
  box-shadow: none;
}
.drawer.open { transform: none; box-shadow: -12px 0 32px rgba(0, 0, 0, 0.6); }
.drawer-head {
  position: sticky; top: calc(-1 * max(14px, env(safe-area-inset-top)));
  display: flex; align-items: center; justify-content: space-between;
  background: #1a120b; padding: 4px 0 10px; margin-bottom: 4px; z-index: 1;
}
.drawer-head h3 { margin: 0; }
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  opacity: 0; pointer-events: none; transition: opacity 0.25s; z-index: 110;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
#logBtn { position: relative; }
.badge {
  position: absolute; top: -6px; right: -6px;
  min-width: 18px; height: 18px; padding: 0 5px; line-height: 18px;
  border-radius: 9px; background: #e05252; color: #fff;
  font-size: 0.68rem; font-weight: 700; text-align: center;
}

/* ---------- Планшеты и телефоны вертикально ---------- */
@media (orientation: portrait) and (max-width: 1024px) {
  .layout { --chrome: 430px; }
  .table-wrap { padding: 30px 8px 18px; }
  .table {
    aspect-ratio: 4 / 5;
    width: min(100%, calc((100vh - var(--chrome)) * 4 / 5));
    width: min(100%, calc((100dvh - var(--chrome)) * 4 / 5));
    border-width: 10px;
    border-radius: 44% / 36%;
  }
  .center { width: 62%; }
  .hand .card { --cw: clamp(58px, 17vw, 92px); }
}

/* ---------- Телефоны вертикально ---------- */
@media (max-width: 600px) {
  .layout { --chrome: 320px; gap: 6px; }
  .btn-label { display: none; }
  #game .topbar button.small { padding: 7px 10px; }
  .table-name { font-size: 0.85rem; }
  .me { padding: 8px 10px 10px; border-radius: 14px; }
  .me-info { gap: 10px; font-size: 0.85rem; }
  .combo { font-size: 0.78rem; }
  .hand { gap: 8px; margin: 6px 0; }
  .actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .actions .info { grid-column: 1 / -1; text-align: center; font-size: 0.85rem; }
  .actions button { padding: 8px 4px; font-size: 0.8rem; line-height: 1.15; }
  .table-cards .card { --cw: 36px; }
  .trump-box .card { --cw: 34px; }
  .pot { font-size: 0.9rem; padding: 4px 12px; }
  .message { font-size: 0.82rem; }
  .bubble { font-size: 0.7rem; }
  .menu-btn { font-size: 1.05rem; padding: 13px 16px; }
  .screen-head h2 { font-size: 1.35rem; }
  .panel { padding: 14px; }
}

/* ---------- Очень узкие телефоны (320–360 px) ---------- */
@media (max-width: 360px) {
  .actions button { font-size: 0.72rem; padding: 6px 2px; min-height: 38px; }
  .hand .card { --cw: 52px; }
  .seg button.wide { padding: 7px 10px; }
}

/* ---------- Низкие телефоны вертикально (iPhone SE и подобные) ---------- */
@media (orientation: portrait) and (max-height: 700px) and (max-width: 600px) {
  .layout { --chrome: 350px; }
  .table-wrap { padding: 24px 4px 14px; }
  .table {
    aspect-ratio: 1 / 1;
    min-width: 200px;
    width: min(100%, calc(100vh - var(--chrome)));
    width: min(100%, calc(100dvh - var(--chrome)));
    border-radius: 46% / 44%;
  }
  .hand .card { --cw: 50px; }
  .hand { margin: 4px 0; }
  .me-info { font-size: 0.78rem; }
  .my-timer { margin-top: 3px; }
}

/* ---------- Широкие экраны ПК и ноутбуков: панель справа от стола ---------- */
@media (min-width: 1000px) and (min-aspect-ratio: 3/2) {
  .layout {
    max-width: 1900px;
    grid-template-columns: minmax(0, 1fr) clamp(300px, 24vw, 380px);
    grid-template-areas: "table me";
    align-items: center;
    gap: 16px;
  }
  .table-wrap { padding: 26px 34px; }
  .table {
    width: min(100%, calc((100vh - 120px) * 16 / 9));
    width: min(100%, calc((100dvh - 120px) * 16 / 9));
  }
  .me { padding: 14px 16px; }
  .combo { margin-left: 0; flex-basis: 100%; }
  .hand .card { --cw: clamp(70px, 5.6vw, 96px); }
  .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .actions .info { grid-column: 1 / -1; text-align: center; }
}

/* ---------- Телефоны горизонтально (низкий экран) ---------- */
@media (orientation: landscape) and (max-height: 560px) {
  #game .topbar { padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: 2px; }
  #game .topbar button.small { padding: 5px 10px; }
  .btn-label { display: none; }
  .layout {
    grid-template-columns: minmax(0, 1fr) minmax(230px, 32%);
    grid-template-areas: "table me";
    align-items: center;
    gap: 8px;
  }
  .table-wrap { padding: 18px 26px 12px; }
  .table {
    aspect-ratio: 16 / 9;
    width: min(100%, calc((100vh - 70px) * 16 / 9));
    width: min(100%, calc((100dvh - 70px) * 16 / 9));
    border-width: 8px;
    border-radius: 50% / 46%;
  }
  .me { padding: 8px 10px; max-height: calc(100dvh - 60px); overflow-y: auto; }
  .me-info { font-size: 0.8rem; gap: 8px; }
  .combo { margin-left: 0; font-size: 0.75rem; }
  .hand { gap: 6px; margin: 4px 0; }
  .hand .card { --cw: clamp(48px, 7vw, 64px); }
  .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
  .actions .info { grid-column: 1 / -1; text-align: center; font-size: 0.8rem; }
  .actions button { min-height: 34px; padding: 6px 4px; font-size: 0.75rem; }
  .table-cards { min-height: 0; }
  .table-cards .card { --cw: 32px; }
  .trump-box .card { --cw: 30px; }
  .main-menu { min-height: 0; }
  .logo h1 { font-size: 2.6rem; }
  .menu-buttons { gap: 8px; }
  .menu-btn { padding: 10px 16px; font-size: 1rem; }
}

/* ---------- Большие экраны ---------- */
@media (min-width: 1400px) and (min-height: 900px) {
  .layout { max-width: 1900px; }
  .hand .card { --cw: 96px; }
}

/* На сенсорных экранах нет наведения — убираем «подпрыгивание» карт */
@media (hover: none) {
  .hand .card.playable:hover { transform: none; }
  .table-card:hover:not(:disabled) { transform: none; }
}

/* Окно подтверждения */
.confirm-box { max-width: 380px; text-align: center; align-items: center; z-index: 210; }
.confirm-box p { margin: 0; opacity: 0.8; }
.confirm-actions { display: flex; gap: 10px; width: 100%; }
.confirm-actions button { flex: 1; min-height: 44px; }
button.ghost.dark { background: rgba(59, 42, 31, 0.1); color: #3b2a1f; box-shadow: inset 0 0 0 1px rgba(59, 42, 31, 0.3); }
#confirm { z-index: 220; }
.hint-line { font-size: 0.8rem; opacity: 0.7; line-height: 1.35; }

/* =====================================================================
   ИГРОВОЙ ЭКРАН БЕЗ ПРОКРУТКИ (в т.ч. Safari на iPhone)
   Экран = ровно видимая высота. Панель с картами и кнопками берёт сколько
   нужно, стол занимает остаток — его размер подгоняет fitTable() в script.js.
   ===================================================================== */
body.in-game { overflow: hidden; overscroll-behavior: none; }
#game {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
#game .layout {
  flex: 1 1 auto;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto;
  align-content: stretch;
  align-items: stretch;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}
#game .table-wrap {
  min-height: 0;
  height: 100%;
  align-items: center;
  padding: 24px 28px 16px;
}
#game .table {
  width: var(--tw, 100%);
  height: var(--th, auto);
  aspect-ratio: auto;
  min-width: 0;
}
#game .table.tall { border-radius: 44% / 34%; }
#game .me { align-self: end; }

@media (max-width: 600px) {
  #game .table-wrap { padding: 26px 6px 12px; }
}

/* Панель справа от стола (широкие экраны и телефон горизонтально) */
@media (min-width: 1000px) and (min-aspect-ratio: 3/2) {
  #game .layout { grid-template-rows: minmax(0, 1fr); }
  #game .me { align-self: center; max-height: 100%; overflow-y: auto; }
}
@media (orientation: landscape) and (max-height: 560px) {
  #game .layout { grid-template-rows: minmax(0, 1fr); }
  #game .table-wrap { padding: 16px 22px 10px; }
  #game .me { align-self: center; max-height: 100%; overflow-y: auto; }
}
