/* ═══════════════════════════════════════════
   Дурак — Mini App Styles
   ═══════════════════════════════════════════ */

:root {
  --tg-bg: var(--tg-theme-bg-color, #1a1a2e);
  --tg-text: var(--tg-theme-text-color, #ffffff);
  --tg-hint: var(--tg-theme-hint-color, #aaaaaa);
  --tg-button: var(--tg-theme-button-color, #4a90d9);
  --tg-button-text: var(--tg-theme-button-text-color, #ffffff);

  --felt-green: #2d6a4f;
  --felt-dark: #1b4332;
  --card-red: #e63946;
  --card-black: #1d3557;
  --card-bg: #fff8f0;
  --gold: #ffd700;

  --radius: 10px;
  --card-w: 52px;
  --card-h: 74px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--tg-bg);
  color: var(--tg-text);
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.screen {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 12px;
}

/* ═══════ ЛОББИ ═══════ */
.lobby-header {
  text-align: center;
  padding: 24px 0 16px;
}
.logo { font-size: 56px; line-height: 1; }
.lobby-header h1 { font-size: 28px; font-weight: 700; margin-top: 8px; }

.mode-badge {
  display: inline-block;
  background: var(--tg-button);
  color: var(--tg-button-text);
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 13px;
  margin-top: 6px;
}

.lobby-players {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 0;
  overflow-y: auto;
}

.lobby-player {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.lobby-player .avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--tg-button);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700;
  flex-shrink: 0;
}
.lobby-player .pname { font-weight: 600; font-size: 16px; }
.lobby-player .phost { font-size: 12px; color: var(--gold); margin-top: 2px; }

.lobby-info {
  text-align: center;
  color: var(--tg-hint);
  font-size: 14px;
  line-height: 1.6;
  padding: 8px 0;
}
.hint { font-size: 12px; opacity: 0.7; margin-top: 4px; }

/* ═══════ КНОПКИ ═══════ */
.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  letter-spacing: 0.3px;
}
.btn:active { transform: scale(0.97); opacity: 0.85; }

.btn-primary {
  background: var(--tg-button);
  color: var(--tg-button-text);
  margin-top: 12px;
}
.btn-secondary {
  background: rgba(255,255,255,0.12);
  color: var(--tg-text);
  margin-top: 8px;
}
.btn-danger {
  background: #e63946;
  color: #fff;
  margin-top: 8px;
}

/* ═══════ ИГРОВОЙ ЭКРАН ═══════ */
#screen-game {
  padding: 0;
  gap: 0;
}

/* Верхняя панель */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(0,0,0,0.3);
  flex-shrink: 0;
}

.deck-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
}
.deck-icon { font-size: 22px; }

.trump-info {
  display: flex;
  align-items: center;
  gap: 6px;
}
.trump-suit {
  font-size: 24px;
  font-weight: 700;
}
.trump-card-mini {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
}

.phase-info {
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
  text-align: right;
  max-width: 90px;
}

/* Противники */
.opponents-area {
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding: 8px 12px;
  flex-shrink: 0;
  gap: 8px;
  flex-wrap: wrap;
}

.opponent {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 60px;
}
.opponent .oname {
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.opponent .orole {
  font-size: 10px;
  color: var(--gold);
}
.opponent .ocard-stack {
  display: flex;
  position: relative;
  height: 44px;
  width: 36px;
}
.opponent .ocard-back {
  width: 28px;
  height: 40px;
  background: linear-gradient(135deg, #1565c0, #0d47a1);
  border-radius: 5px;
  border: 1.5px solid rgba(255,255,255,0.3);
  position: absolute;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.opponent .ocard-back:nth-child(1) { top: 0; left: 0; transform: rotate(-6deg); }
.opponent .ocard-back:nth-child(2) { top: 2px; left: 4px; transform: rotate(0deg); }
.opponent .ocard-back:nth-child(3) { top: 0; left: 8px; transform: rotate(5deg); }
.opponent.done .ocard-stack { opacity: 0.3; }
.opponent .ocount {
  font-size: 11px;
  color: var(--tg-hint);
}

/* Стол (стол) */
.table-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  min-height: 0;
}

.felt {
  width: 100%;
  max-width: 380px;
  min-height: 110px;
  background: radial-gradient(ellipse at center, var(--felt-green), var(--felt-dark));
  border-radius: 20px;
  border: 2px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 10px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.3);
}

.table-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: center;
}

.table-pair {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.table-hint {
  color: rgba(255,255,255,0.4);
  font-size: 13px;
  text-align: center;
  font-style: italic;
}

/* ═══════ КАРТЫ ═══════ */
.card {
  width: var(--card-w);
  height: var(--card-h);
  background: var(--card-bg);
  border-radius: 7px;
  border: 1.5px solid rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  flex-shrink: 0;
}
.card.red { color: var(--card-red); }
.card.black { color: var(--card-black); }

.card .rank {
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
}
.card .suit {
  font-size: 20px;
  line-height: 1;
  margin-top: 2px;
}
.card .rank-corner {
  position: absolute;
  top: 4px; left: 5px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
}
.card .rank-corner-bot {
  position: absolute;
  bottom: 4px; right: 5px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  transform: rotate(180deg);
}

.card.trump-card {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.card.selected {
  transform: translateY(-10px);
  box-shadow: 0 8px 20px rgba(74,144,217,0.6);
  outline: 2px solid var(--tg-button);
}

.card.selectable:hover,
.card.selectable:active {
  transform: translateY(-6px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

.card.dimmed { opacity: 0.4; }

/* Оборотная сторона карты на столе */
.card-defense-slot {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 7px;
  border: 2px dashed rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: rgba(255,255,255,0.4);
}
.card-defense-slot.clickable {
  cursor: pointer;
  border-color: rgba(255,255,200,0.6);
}
.card-defense-slot.clickable:active { opacity: 0.7; }

/* ═══════ МОЯ ЗОНА ═══════ */
.my-area {
  background: rgba(0,0,0,0.25);
  padding: 10px 12px 12px;
  flex-shrink: 0;
}

.my-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.my-name { font-size: 14px; font-weight: 700; }
.role-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}
.role-badge.attacker { background: #e63946; color: #fff; }
.role-badge.defender { background: #2a9d8f; color: #fff; }

.my-cards {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  align-items: flex-end;
  min-height: calc(var(--card-h) + 10px);
}
.my-cards::-webkit-scrollbar { display: none; }

/* Панель кнопок */
.action-bar {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.action-bar .btn {
  flex: 1;
  padding: 10px;
  font-size: 14px;
}

/* ═══════ КОНЕЦ ИГРЫ ═══════ */
#screen-gameover {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0;
}

.gameover-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px;
}

.gameover-emoji { font-size: 80px; }
#gameover-title { font-size: 28px; font-weight: 700; }
.gameover-sub { color: var(--tg-hint); font-size: 16px; }

.winners-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  margin-top: 8px;
}

.winner-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.winner-item .place { font-size: 24px; }
.winner-item .wname { font-size: 16px; font-weight: 600; }
.winner-item .wlabel { font-size: 12px; color: var(--tg-hint); }

/* ═══════ УВЕДОМЛЕНИЯ ═══════ */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30,30,50,0.95);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  pointer-events: none;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

/* ═══════ ОВЕРЛЕЙ ВЫБОРА ═══════ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.overlay-box {
  background: var(--tg-bg);
  border-radius: 16px;
  padding: 20px;
  max-width: 320px;
  width: 90%;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.1);
}
.overlay-box p {
  margin-bottom: 16px;
  font-size: 15px;
  color: var(--tg-hint);
}

.select-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}

/* ═══════ УТИЛИТЫ ═══════ */
.highlight-attacker { border: 2px solid #e63946 !important; }
.highlight-defender { border: 2px solid #2a9d8f !important; }
