/* Star Wars Hearthstone - Hearthstone-style, colorful cards */

:root {
  --space: #0d1219;
  --space-light: #141b26;
  --cyan: #00d4ff;
  --cyan-dim: #00a8cc;
  --amber: #ffb347;
  --amber-bright: #ffcc00;
  --red: #e63946;
  --green: #2ed573;
  --gold: #d4a84b;
  --gold-dark: #8b6914;
  --felt: #1a2f1a;
  --felt-dark: #0f1f0f;
  --card-border-gold: #c9a227;
  --card-inner: #2d2a22;
  --rebellion: #4a90d9;
  --rebellion-dark: #2d5a8a;
  --empire: #c41e3a;
  --empire-dark: #8b1530;
  --neutral: #8b7355;
  --neutral-dark: #5c4a38;
  --defense: #6b46c1;
  --defense-dark: #4c1d95;
  --font-display: 'Orbitron', sans-serif;
  --font-body: 'Rajdhani', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: var(--font-body);
  background: var(--space);
  color: #e2e8f0;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-overflow-scrolling: touch;
}

#app {
  position: relative;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Static starfield - no animation */
#stars, #stars2, #stars3 {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 0;
}
#stars {
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='2'%3E%3Ccircle fill='%2300d4ff' fill-opacity='0.35' cx='1' cy='1' r='0.5'/%3E%3C/svg%3E") repeat;
}
#stars2 {
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='3' height='3'%3E%3Ccircle fill='%23fff' fill-opacity='0.15' cx='1.5' cy='1.5' r='0.5'/%3E%3C/svg%3E") repeat;
}
#stars3 {
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Ccircle fill='%23ffb347' fill-opacity='0.12' cx='2' cy='2' r='0.5'/%3E%3C/svg%3E") repeat;
}

.screen {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.screen.hidden {
  display: none;
}

/* Lobby */
.lobby-card {
  position: relative;
  background: linear-gradient(145deg, #1a1f2e 0%, #0d1117 100%);
  border: 1px solid rgba(201, 162, 39, 0.4);
  border-radius: 16px;
  padding: 2.5rem;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 60px rgba(201, 162, 39, 0.08);
  animation: cardIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes cardIn {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.logo { text-align: center; margin-bottom: 0.5rem; font-family: var(--font-display); font-weight: 800; letter-spacing: 0.08em; line-height: 1.2; }
.logo .logo-icon { display: block; margin-bottom: 0.35rem; color: var(--cyan); filter: drop-shadow(0 0 12px rgba(0, 212, 255, 0.6)); }
.logo-sw { display: block; font-size: 1.4rem; color: var(--cyan); text-shadow: 0 0 20px rgba(0, 212, 255, 0.5); }
.logo-hs { display: block; font-size: 1.1rem; color: var(--amber); text-shadow: 0 0 15px rgba(255, 179, 71, 0.4); }
.subtitle { text-align: center; color: #94a3b8; font-size: 0.9rem; margin-bottom: 1.5rem; }
.btn-instructions-lobby, .btn-settings-lobby {
  position: absolute;
  top: 1rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(0,180,255,0.5);
  background: rgba(0,30,50,0.6);
  color: #00d4ff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-instructions-lobby {
  right: 1rem;
}
.btn-instructions-lobby[title="Галерея карт"] {
  right: 3.5rem;
}
.btn-settings-lobby {
  right: 6rem;
}
.btn-instructions-lobby:hover, .btn-settings-lobby:hover {
  background: rgba(0,180,255,0.2);
  transform: scale(1.1);
}

.lobby-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.tab {
  flex: 1;
  padding: 0.6rem 1rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: #94a3b8;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.tab:hover { background: rgba(255,255,255,0.08); color: #e2e8f0; }
.tab.active { background: rgba(0,212,255,0.15); border-color: var(--cyan); color: var(--cyan); }

.panel { display: none; }
.panel.active { display: block; animation: fadeIn 0.3s ease; }
.panel.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.panel label { display: block; margin-bottom: 0.35rem; font-size: 0.9rem; color: #94a3b8; }
.panel input {
  width: 100%;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: #e2e8f0;
  font-family: var(--font-body);
  font-size: 1rem;
  transition: border-color 0.2s;
}
.panel input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0,212,255,0.15);
}
.panel input::placeholder { color: #64748b; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--cyan) 0%, var(--cyan-dim) 100%);
  color: var(--space);
  width: 100%;
  margin-top: 0.5rem;
  box-shadow: 0 4px 20px rgba(0,212,255,0.3);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(0,212,255,0.4); }
.btn-ghost {
  background: transparent;
  color: #94a3b8;
  border: 1px solid rgba(255,255,255,0.2);
  width: 100%;
  margin-top: 0.75rem;
}
.btn-ghost:hover { background: rgba(255,255,255,0.05); color: #e2e8f0; }

.error {
  margin-top: 1rem;
  padding: 0.75rem;
  background: rgba(255,71,87,0.15);
  border: 1px solid rgba(255,71,87,0.4);
  border-radius: 8px;
  color: var(--red);
  font-size: 0.9rem;
}
.error.hidden { display: none !important; }
.hint { font-size: 0.9rem; color: #94a3b8; margin-bottom: 1rem; }

#player-list, #connect-player-list { list-style: none; margin-bottom: 1rem; }
#player-list li, #connect-player-list li {
  padding: 0.5rem 1rem;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
#player-list li::before, #connect-player-list li::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}
#room-panel h3, #connect-panel h3 { margin-bottom: 0.75rem; font-family: var(--font-display); color: var(--cyan); }
#room-panel label { display: block; margin-bottom: 0.35rem; font-size: 0.9rem; color: #94a3b8; }
#room-code-display {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  background: rgba(0,180,255,0.15);
  border: 2px solid var(--cyan);
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  letter-spacing: 0.15em;
  user-select: all;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
#room-code-display:hover {
  background: rgba(0,180,255,0.25);
  transform: scale(1.05);
}
#room-connect-info {
  display: inline-block;
  padding: 0.3rem 0.6rem;
  background: rgba(255,204,0,0.1);
  border: 1px solid var(--amber);
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  user-select: all;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
#room-connect-info:hover {
  background: rgba(255,204,0,0.2);
  transform: scale(1.03);
}
#room-faction {
  display: block;
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.5rem;
  background: rgba(0,0,0,0.3);
  border: 2px solid rgba(0,180,255,0.35);
  border-radius: 8px;
  color: #f8fafc;
  font-size: 0.95rem;
}

/* Game layout - Hearthstone-style felt board */
#game {
  flex-direction: column;
  align-items: stretch;
  padding: 0.5rem;
  gap: 0.5rem;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: linear-gradient(180deg, rgba(10,25,45,0.95) 0%, rgba(5,18,35,0.98) 100%);
  border: 2px solid rgba(0,180,255,0.35);
  border-radius: 12px;
  flex-wrap: wrap;
  gap: 0.75rem;
  box-shadow: inset 0 1px 0 rgba(0,180,255,0.1), 0 4px 16px rgba(0,0,0,0.4);
}

.header-left, .header-center, .header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.mana-display, .health-display, .armor-display {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
}
.mana-display, .health-display {
  font-size: 1.15rem;
}

.mana-icon {
  width: 24px;
  height: 24px;
  background: radial-gradient(circle at 30% 30%, #5eb3e8, #2d7ab8);
  border-radius: 50%;
  border: 2px solid #1a4d6e;
  box-shadow: 0 0 12px rgba(94,179,232,0.6), inset 0 1px 0 rgba(255,255,255,0.3);
}
.mana-display .swg.mana-icon {
  background: none; border: none; box-shadow: none;
  width: auto; height: auto; font-size: 1.35rem;
  color: #5eb3e8; display: inline-flex; align-items: center;
}

.heart-icon {
  width: 22px;
  height: 22px;
  background: radial-gradient(circle at 30% 30%, #ff6b6b, #c92a2a);
  border-radius: 50%;
  border: 2px solid #8b1530;
  box-shadow: 0 0 10px rgba(230,57,70,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
}
.health-display .swg.health-icon {
  background: none; border: none; box-shadow: none;
  width: auto; height: auto; font-size: 1.2rem;
  color: #ff6b6b; display: inline-flex; align-items: center;
}

.health-display #your-health.health-changed {
  animation: healthChange 0.5s ease-out;
  display: inline-block;
}

@keyframes healthChange {
  0% {
    transform: scale(1);
    color: var(--red);
  }
  50% {
    transform: scale(1.3);
    color: var(--amber-bright);
  }
  100% {
    transform: scale(1);
    color: var(--red);
  }
}

.deck-count { font-size: 0.9rem; color: #94a3b8; }
.deck-count .swg.deck-icon { font-size: 1rem; margin-right: 0.2rem; color: var(--gold); }

.turn-badge {
  background: linear-gradient(135deg, var(--amber) 0%, #e67e22 100%);
  color: #1a0f00;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  border: 2px solid var(--gold-dark);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: all 0.3s ease;
}
.turn-badge.your-turn {
  background: linear-gradient(135deg, #5eb3e8 0%, #2d7ab8 100%);
  color: #fff;
  border-color: #1a4d6e;
  animation: yourTurnGlow 1.5s ease-in-out infinite;
}
.turn-timer {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(148,163,184,0.3);
  color: #94a3b8;
  font-size: 0.95rem;
}
.turn-timer.timer-warn { color: var(--amber); border-color: var(--amber); animation: timerPulse 1s ease-in-out infinite; }
.turn-timer.timer-ended { color: var(--red); }
@keyframes timerPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }
/* Chat */
.chat-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 320px;
  max-width: calc(100vw - 40px);
  background: linear-gradient(145deg, rgba(13,18,25,0.95) 0%, rgba(5,10,18,0.98) 100%);
  border: 2px solid rgba(0,180,255,0.3);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  z-index: 150;
  display: flex;
  flex-direction: column;
  max-height: 400px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.chat-container.collapsed {
  max-height: 50px;
  overflow: hidden;
}

.chat-container.collapsed .chat-content {
  display: none;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: rgba(0,0,0,0.3);
  border-bottom: 1px solid rgba(0,180,255,0.2);
  border-radius: 12px 12px 0 0;
  cursor: pointer;
  user-select: none;
}

.chat-title {
  font-weight: 600;
  color: var(--cyan);
  font-size: 0.95rem;
}

.btn-chat-toggle {
  background: transparent;
  border: none;
  color: var(--cyan);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  transition: transform 0.2s;
}

.chat-container.collapsed .btn-chat-toggle {
  transform: rotate(-90deg);
}

.chat-content {
  display: flex;
  flex-direction: column;
  height: 350px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  font-size: 0.85rem;
  line-height: 1.4;
  -webkit-overflow-scrolling: touch;
}

.chat-message {
  margin-bottom: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  background: rgba(0,0,0,0.3);
  word-wrap: break-word;
}

.chat-message.system {
  color: #94a3b8;
  font-style: italic;
  background: rgba(148,163,184,0.1);
}

.chat-message.user {
  color: var(--cyan);
  background: rgba(0,180,255,0.1);
}

.chat-message .chat-username {
  font-weight: 600;
  margin-right: 0.5rem;
}

.chat-message .chat-time {
  font-size: 0.7rem;
  color: #64748b;
  margin-left: 0.5rem;
}

.chat-input-container {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid rgba(0,180,255,0.2);
  background: rgba(0,0,0,0.2);
}

.chat-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(0,180,255,0.3);
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 0.85rem;
  font-family: var(--font-body);
}

.chat-input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 8px rgba(0,180,255,0.3);
}

.btn-chat-send {
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, var(--cyan) 0%, var(--cyan-dim) 100%);
  border: none;
  border-radius: 6px;
  color: #0d1219;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-chat-send:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--cyan-dim) 0%, var(--cyan) 100%);
  transform: scale(1.05);
}

.btn-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  .chat-container {
    width: calc(100vw - 20px);
    right: 10px;
    bottom: 10px;
    max-height: 300px;
  }
  
  .chat-content {
    height: 250px;
  }
  
  .chat-input-container {
    flex-direction: column;
  }
  
  .btn-chat-send {
    width: 100%;
  }
}
@keyframes yourTurnGlow {
  0%, 100% { box-shadow: 0 0 12px rgba(94,179,232,0.5); transform: scale(1); }
  50% { box-shadow: 0 0 24px rgba(94,179,232,0.8); transform: scale(1.04); }
}

.btn-end-turn {
  background: linear-gradient(180deg, #f0c14b 0%, #d4a84b 50%, #b8860b 100%);
  color: #1a0f00;
  padding: 0.55rem 1.4rem;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid var(--gold-dark);
  font-family: var(--font-body);
  transition: all 0.2s;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.3);
}
.btn-end-turn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(240,193,75,0.4);
}
.btn-end-turn:disabled { opacity: 0.5; cursor: not-allowed; }

#game-log {
  font-size: 0.85rem;
  color: #94a3b8;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-instructions, .btn-settings {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: linear-gradient(180deg, #2d2a22 0%, #1a1814 100%);
  color: var(--gold);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  margin-left: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-instructions:hover, .btn-settings:hover {
  background: rgba(212,168,75,0.2);
  transform: scale(1.08);
}
/* Иконки внутри кнопок не должны перехватывать клики */
.btn-instructions svg,
.btn-instructions i[data-lucide],
.btn-settings svg,
.btn-settings i[data-lucide],
.btn-instructions-lobby svg,
.btn-instructions-lobby i[data-lucide],
.btn-settings-lobby svg,
.btn-settings-lobby i[data-lucide] {
  pointer-events: none;
}

/* Board – Star Wars style (trench/hangar, space) */
.board {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 180px;
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(0,20,40,0.97) 0%, rgba(5,15,30,0.98) 50%, rgba(10,8,20,0.99) 100%),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 40px,
      rgba(0,180,255,0.04) 40px,
      rgba(0,180,255,0.04) 41px
    ),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 40px,
      rgba(0,180,255,0.03) 40px,
      rgba(0,180,255,0.03) 41px
    );
  border: 2px solid rgba(0,180,255,0.35);
  border-radius: 12px;
  padding: 0.75rem;
  box-shadow:
    inset 0 0 120px rgba(0,80,120,0.15),
    inset 0 0 0 1px rgba(0,180,255,0.1),
    0 4px 24px rgba(0,0,0,0.5);
  position: relative;
}
.board::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: radial-gradient(ellipse 80% 40% at 50% 30%, rgba(255,140,0,0.06) 0%, transparent 50%);
  pointer-events: none;
}
.board::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40%;
  background: linear-gradient(to top, rgba(0,0,0,0.4) 0%, transparent 100%);
  border-radius: 0 0 10px 10px;
  pointer-events: none;
}

.opponents { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; position: relative; z-index: 1; }
.opponent-block {
  background: linear-gradient(180deg, rgba(10,25,45,0.9) 0%, rgba(5,15,30,0.95) 100%);
  border: 1px solid rgba(0,180,255,0.3);
  border-radius: 10px;
  padding: 0.75rem;
  min-width: 180px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.05);
}
.opponent-block.current-turn {
  border-color: rgba(255,180,0,0.6);
  box-shadow: 0 0 24px rgba(255,180,0,0.2);
}
.opponent-block.steal-target {
  border-color: rgba(255,204,0,0.6);
  box-shadow: 0 0 20px rgba(255,204,0,0.4);
  cursor: pointer;
  animation: stealTargetPulse 1.5s ease-in-out infinite;
}
.opponent-block.steal-target:hover {
  border-color: rgba(255,204,0,0.9);
  box-shadow: 0 0 30px rgba(255,204,0,0.6);
  transform: scale(1.02);
}
@keyframes stealTargetPulse {
  0%, 100% { box-shadow: 0 0 20px rgba(255,204,0,0.4); }
  50% { box-shadow: 0 0 30px rgba(255,204,0,0.7); }
}
.opponent-block.defeated {
  opacity: 0.5;
  position: relative;
}
.opponent-block.defeated::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, transparent 45%, rgba(255,70,70,0.3) 48%, rgba(255,70,70,0.3) 52%, transparent 55%);
  pointer-events: none;
  z-index: 10;
}
.opponent-block.defeated::after {
  content: '';
  position: absolute;
  top: 50%;
  left: -10px;
  right: -10px;
  height: 3px;
  background: rgba(255,70,70,0.8);
  transform: translateY(-50%) rotate(-5deg);
  box-shadow: 0 0 10px rgba(255,70,70,0.6);
  pointer-events: none;
  z-index: 11;
}
.opponent-name { font-weight: 700; color: var(--cyan); margin-bottom: 0.35rem; font-size: 0.95rem; }
.opponent-armor { color: #5eb3e8; font-weight: 600; display: inline-flex; align-items: center; gap: 0.2rem; }
.armor-display { color: #5eb3e8; font-weight: 600; margin-left: 0.5rem; display: inline-flex; align-items: center; gap: 0.3rem; }
.armor-icon { color: #5eb3e8; }
.opponent-health, .opponent-stats span { display: inline-flex; align-items: center; gap: 0.2rem; }
.opponent-name { display: flex; align-items: center; gap: 0.3rem; }

/* Lucide Icons стилизация */
[data-lucide] {
  stroke-width: 2;
  vertical-align: middle;
}
.opponent-name [data-lucide="bot"] {
  color: var(--cyan);
  filter: drop-shadow(0 0 4px rgba(0, 212, 255, 0.5));
}
.opponent-name.defeated-name {
  text-decoration: line-through;
  color: #666;
  opacity: 0.6;
}
.defeated-badge {
  color: var(--red);
  font-size: 1.2em;
  margin-left: 0.3rem;
}
.opponent-stats { display: flex; gap: 0.75rem; font-size: 0.85rem; color: #94a3b8; margin-bottom: 0.5rem; }
.opponent-stats.defeated-stats {
  opacity: 0.5;
  text-decoration: line-through;
}
.opponent-board { display: flex; flex-wrap: wrap; gap: 0.5rem; min-height: 80px; }

.battlefield { flex: 1; display: flex; flex-direction: column; justify-content: center; position: relative; z-index: 1; }
.your-board {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  min-height: 130px;
  padding: 0.5rem;
}

/* Cards - larger, Hearthstone-style frames */
.card-wrap {
  position: relative;
  width: 180px;
  height: 252px;
  perspective: 1000px;
  cursor: pointer;
  flex-shrink: 0;
}
.card-wrap.disabled { cursor: not-allowed; opacity: 0.6; }
.card-wrap.not-enough-mana {
  cursor: not-allowed;
  opacity: 0.5;
  filter: grayscale(0.3) brightness(0.7);
  pointer-events: none;
}
.card-wrap.in-hand {
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform: rotate(var(--hand-rotate, 0deg));
}
.card-wrap.in-hand:hover:not(.disabled):not(.not-enough-mana) {
  transform: rotate(var(--hand-rotate, 0deg)) translateY(-20px) scale(1.08);
  z-index: 20;
}

/* Touch feedback for mobile */
.card-wrap.touch-active {
  transform: rotate(var(--hand-rotate, 0deg)) translateY(-15px) scale(1.05);
  z-index: 20;
  transition: transform 0.1s ease;
}

.card-wrap.swiping {
  opacity: 0.8;
  transform: rotate(var(--hand-rotate, 0deg)) translateY(-10px) scale(1.02);
}

.card-wrap.long-pressed {
  transform: rotate(var(--hand-rotate, 0deg)) translateY(-25px) scale(1.12);
  z-index: 25;
  box-shadow: 0 0 30px rgba(0,212,255,0.6);
}

/* Prevent text selection on touch devices */
.card-wrap, .btn, .tab, .deck-fan {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Better touch targets */
@media (hover: none) and (pointer: coarse) {
  .card-wrap.in-hand:active:not(.disabled) {
    transform: rotate(var(--hand-rotate, 0deg)) translateY(-15px) scale(1.05);
    z-index: 20;
  }
  
  .btn:active {
    transform: scale(0.95);
  }
  
  .card-wrap.attackable:active {
    transform: scale(1.1);
  }
}

.card {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  transform-style: preserve-3d;
  border-radius: 12px;
  overflow: hidden;
  border: 3px solid var(--card-border-gold);
  box-shadow:
    0 8px 24px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.15),
    inset 0 -1px 0 rgba(0,0,0,0.3);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.card::before {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 9px;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.4);
}

/* Faction colors */
.card.faction-rebellion {
  background: linear-gradient(165deg, #2d4a6a 0%, #1a2d44 45%, #0f1a28 100%);
  border-color: var(--rebellion);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 20px rgba(74,144,217,0.15), inset 0 1px 0 rgba(255,255,255,0.12);
}
.card.faction-empire {
  background: linear-gradient(165deg, #4a2028 0%, #2d1519 45%, #1a0d10 100%);
  border-color: var(--empire);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 20px rgba(196,30,58,0.15), inset 0 1px 0 rgba(255,255,255,0.1);
}
.card.faction-neutral {
  background: linear-gradient(165deg, #3d3528 0%, #2d2720 45%, #1a1612 100%);
  border-color: var(--neutral);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 16px rgba(139,115,85,0.12), inset 0 1px 0 rgba(255,255,255,0.1);
}
.card.faction-pirates {
  background: linear-gradient(165deg, #2d4a2d 0%, #1a2f1a 45%, #0f1f0f 100%);
  border-color: #2ed573;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 20px rgba(46,213,115,0.2), inset 0 1px 0 rgba(255,255,255,0.1);
}
.card.faction-animal {
  background: linear-gradient(165deg, #4a3d28 0%, #3d2f1a 45%, #2a1f0f 100%);
  border-color: #8b6914;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 20px rgba(139,105,20,0.15), inset 0 1px 0 rgba(255,255,255,0.1);
}
.card.faction-defense {
  background: linear-gradient(165deg, #4a2d6a 0%, #2d1a4a 45%, #1a0f2d 100%);
  border-color: var(--defense);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 20px rgba(107,70,193,0.25), inset 0 1px 0 rgba(255,255,255,0.12);
}

.card-wrap.playable:not(.disabled) .card {
  border-color: var(--amber-bright);
  box-shadow: 0 0 24px rgba(255,204,0,0.4), 0 8px 24px rgba(0,0,0,0.5);
}

.card-art {
  height: 38%;
  min-height: 70px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  border-bottom: 3px solid rgba(0,0,0,0.4);
  position: relative;
}
.card.faction-rebellion .card-art {
  background: linear-gradient(180deg, rgba(74,144,217,0.25) 0%, rgba(15,26,40,0.9) 100%);
  color: #7eb8f0;
  text-shadow: 0 0 20px rgba(126,184,240,0.6);
}
.card.faction-empire .card-art {
  background: linear-gradient(180deg, rgba(196,30,58,0.2) 0%, rgba(26,13,16,0.95) 100%);
  color: #e86a7a;
  text-shadow: 0 0 20px rgba(232,106,122,0.6);
}
.card.faction-neutral .card-art {
  background: linear-gradient(180deg, rgba(139,115,85,0.2) 0%, rgba(26,22,18,0.95) 100%);
  color: #c4a574;
  text-shadow: 0 0 16px rgba(196,165,116,0.5);
}
.card.faction-pirates .card-art {
  background: linear-gradient(180deg, rgba(46,213,115,0.25) 0%, rgba(15,47,26,0.9) 100%);
  color: #5ef5a0;
  text-shadow: 0 0 20px rgba(94,245,160,0.6);
}
.card.faction-animal .card-art {
  background: linear-gradient(180deg, rgba(139,105,20,0.25) 0%, rgba(42,31,15,0.9) 100%);
  color: #d4a84b;
  text-shadow: 0 0 20px rgba(212,168,75,0.6);
}
.card.faction-defense .card-art {
  background: linear-gradient(180deg, rgba(107,70,193,0.3) 0%, rgba(26,15,45,0.95) 100%);
  color: #8b5cf6;
  text-shadow: 0 0 20px rgba(139,92,246,0.7);
}
.card-art .card-art-swg { font-size: 1.5em; }
.card-art .card-art-fallback { font-size: 1.1rem; opacity: 0.9; }
.card-art .card-art-image {
  width: 80%;
  height: 80%;
  max-width: 120px;
  max-height: 120px;
  object-fit: contain;
  object-position: center;
  margin: auto;
  display: block;
}

.card-info {
  padding: 0.5rem 0.6rem;
  font-size: 0.8rem;
  background: rgba(0,0,0,0.3);
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.card-name {
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 0.25rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.card-text {
  font-size: 0.72rem;
  color: #94a3b8;
  line-height: 1.3;
  margin-bottom: 0.35rem;
  flex: 0 1 auto;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-wrap: break-word;
}
.card-stats {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
}
.card-cost-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05rem;
}
.card-cost-wrap .card-stat-label { font-size: 0.55rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.03em; }
.card-cost {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5eb3e8 0%, #2d7ab8 100%);
  color: #0a1520;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8rem;
  border: 2px solid #1a4d6e;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 2px 4px rgba(0,0,0,0.3);
}
.card-atk-wrap, .card-hp-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05rem;
}
.card-atk-wrap .card-stat-label, .card-hp-wrap .card-stat-label { font-size: 0.55rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.03em; }
.card-atk-hp {
  display: flex;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1rem;
}
.card-atk-hp .atk, .card-atk-wrap .atk { color: #ff6b6b; text-shadow: 0 0 8px rgba(255,107,107,0.5); font-weight: 800; font-size: 1rem; }
.card-atk-hp .hp, .card-hp-wrap .hp { color: #51cf66; text-shadow: 0 0 8px rgba(81,207,102,0.5); font-weight: 800; font-size: 1rem; }
.card-abilities {
  font-size: 0.68rem;
  color: var(--amber);
  margin-top: 0.2rem;
  line-height: 1.35;
  flex: 0 1 auto;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-wrap: break-word;
}
.card-abilities .ability-tag { color: #94a3b8; margin-right: 0.2rem; }
.card-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.25rem;
  flex-shrink: 0;
}
.card-btn-info {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(148,163,184,0.5);
  background: rgba(0,0,0,0.3);
  color: #94a3b8;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}
.card-btn-info:hover { background: rgba(100,116,139,0.4); color: #fff; }

.card.play-anim {
  animation: cardPlay 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes cardPlay {
  0% { transform: scale(1) translateY(0); filter: brightness(1); }
  40% { transform: scale(1.15) translateY(-50px); filter: brightness(1.35); }
  100% { transform: scale(1) translateY(0); filter: brightness(1); }
}

.card.summon-anim {
  animation: summon 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes summon {
  0% { opacity: 0; transform: scale(0.2); filter: blur(6px); }
  65% { opacity: 1; transform: scale(1.06); filter: blur(0); }
  100% { opacity: 1; transform: scale(1); filter: blur(0); }
}

.card.damage-anim {
  animation: damageFlash 0.4s ease;
}
@keyframes damageFlash {
  0%, 100% { filter: brightness(1); transform: scale(1); }
  30% { filter: brightness(2.2); transform: scale(1.04); }
  60% { filter: brightness(1.1); transform: scale(0.98); }
}

/* Draw from deck – card flies in from left */
.card-wrap.draw-from-deck {
  animation: drawFromDeck 0.55s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
}
@keyframes drawFromDeck {
  0% {
    opacity: 0;
    transform: rotate(var(--hand-rotate, 0deg)) translate(-180px, 60px) scale(0.5);
  }
  70% {
    opacity: 1;
    transform: rotate(var(--hand-rotate, 0deg)) translate(0, -8px) scale(1.05);
  }
  100% {
    opacity: 1;
    transform: rotate(var(--hand-rotate, 0deg)) translate(0, 0) scale(1);
  }
}

/* Combat: attacker lunges, target hit, death */
.card-wrap.combat-lunge .card {
  animation: combatLunge 0.4s ease-out forwards;
}
@keyframes combatLunge {
  0% { transform: translate(0, 0) scale(1); }
  35% { transform: translate(var(--lunge-dx, 30px), var(--lunge-dy, -20px)) scale(1.15); filter: brightness(1.4); }
  100% { transform: translate(0, 0) scale(1); filter: brightness(1); }
}

/* Новая анимация: карта накладывается на цель */
.card-wrap.combat-lunge-overlay {
  animation: combatLungeOverlay 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
}

.card-wrap.combat-lunge-overlay .card {
  box-shadow: 0 0 40px rgba(255, 200, 0, 0.6), 0 0 80px rgba(255, 100, 0, 0.4);
}

@keyframes combatLungeOverlay {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    filter: brightness(1);
    opacity: 1;
  }
  25% {
    transform: translate(calc(var(--attack-dx, 0) * 0.6), calc(var(--attack-dy, 0) * 0.6)) scale(1.15) rotate(-3deg);
    filter: brightness(1.4) drop-shadow(0 0 25px rgba(255, 200, 0, 0.7));
  }
  45% {
    transform: translate(var(--attack-dx, 0), var(--attack-dy, 0)) scale(1.3) rotate(0deg);
    filter: brightness(2) drop-shadow(0 0 40px rgba(255, 100, 0, 1));
    z-index: 1001;
  }
  50% {
    transform: translate(var(--attack-dx, 0), var(--attack-dy, 0)) scale(1.28) rotate(1deg);
    filter: brightness(1.9) drop-shadow(0 0 35px rgba(255, 150, 0, 0.95));
  }
  55% {
    transform: translate(var(--attack-dx, 0), var(--attack-dy, 0)) scale(1.25) rotate(-1deg);
    filter: brightness(1.7) drop-shadow(0 0 30px rgba(255, 120, 0, 0.9));
  }
  100% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    filter: brightness(1);
    z-index: auto;
    opacity: 1;
  }
}

.card-wrap.combat-hit .card {
  animation: combatHit 0.45s ease-out forwards;
}
@keyframes combatHit {
  0% { transform: scale(1); filter: brightness(1); }
  20% { filter: brightness(2.5); transform: scale(1.08); }
  40% { transform: scale(0.95); filter: brightness(1.2); }
  100% { transform: scale(1); filter: brightness(1); }
}

/* Эффект удара - карта трясётся и подсвечивается */
.card-wrap.combat-hit-impact {
  animation: combatHitImpact 0.35s ease-out forwards;
}

.card-wrap.combat-hit-impact .card {
  box-shadow: 0 0 30px rgba(255, 50, 50, 0.8), 0 0 60px rgba(255, 100, 100, 0.5);
}

@keyframes combatHitImpact {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    filter: brightness(1);
  }
  8% {
    transform: translate(-4px, -3px) scale(1.08) rotate(-3deg);
    filter: brightness(2.8) saturate(1.3);
  }
  16% {
    transform: translate(4px, 3px) scale(1.08) rotate(3deg);
    filter: brightness(3) saturate(1.4);
  }
  24% {
    transform: translate(-3px, 2px) scale(1.05) rotate(-2deg);
    filter: brightness(2.5) saturate(1.2);
  }
  32% {
    transform: translate(3px, -2px) scale(1.05) rotate(2deg);
    filter: brightness(2.7) saturate(1.3);
  }
  40% {
    transform: translate(-2px, 1px) scale(1.03) rotate(-1deg);
    filter: brightness(2.2) saturate(1.1);
  }
  48% {
    transform: translate(2px, -1px) scale(1.03) rotate(1deg);
    filter: brightness(2.4) saturate(1.2);
  }
  56% {
    transform: translate(-1px, 0) scale(1.02) rotate(-0.5deg);
    filter: brightness(2) saturate(1.05);
  }
  64% {
    transform: translate(1px, 0) scale(1.02) rotate(0.5deg);
    filter: brightness(1.8) saturate(1.1);
  }
  72% {
    transform: translate(0, 0) scale(1.01) rotate(0deg);
    filter: brightness(1.5) saturate(1.05);
  }
  80% {
    transform: translate(0, 0) scale(1.005) rotate(0deg);
    filter: brightness(1.2) saturate(1.02);
  }
  100% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    filter: brightness(1) saturate(1);
  }
}
.card-wrap.combat-death .card {
  animation: combatDeath 0.4s ease-in forwards;
}
@keyframes combatDeath {
  0% { opacity: 1; transform: scale(1); filter: brightness(1); }
  100% { opacity: 0; transform: scale(0.3); filter: brightness(2); pointer-events: none; }
}

/* Board minions - larger */
.board .card-wrap {
  width: 115px;
  height: 160px;
}
/* Opponent cards - larger and more visible */
.opponents .card-wrap {
  width: 140px;
  height: 195px;
  transform: scale(1);
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4), 0 0 20px rgba(0,180,255,0.3);
  border: 2px solid rgba(0,180,255,0.4);
  border-radius: 12px;
  background: rgba(0,0,0,0.2);
}
.opponents .card-wrap:hover {
  transform: scale(1.08) translateY(-5px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.6), 0 0 30px rgba(0,180,255,0.5);
  z-index: 10;
}
.opponents .card-wrap .card {
  border-width: 2px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(0,180,255,0.2);
}
.board .card-wrap.attackable .card {
  border-color: var(--red);
  box-shadow: 0 0 20px rgba(230,57,70,0.5);
  animation: attackablePulse 1s ease-in-out infinite;
}
@keyframes attackablePulse {
  0%, 100% { box-shadow: 0 0 20px rgba(230,57,70,0.5); }
  50% { box-shadow: 0 0 30px rgba(230,57,70,0.75); }
}

/* Hand + deck – Star Wars hangar style */
.hand-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(180deg, rgba(8,18,35,0.98) 0%, rgba(5,12,25,0.99) 100%);
  border: 2px solid rgba(0,180,255,0.3);
  border-radius: 12px 12px 0 0;
  box-shadow: inset 0 0 80px rgba(0,60,100,0.12), 0 -4px 20px rgba(0,0,0,0.4);
  min-height: 220px;
}

/* Deck fan */
.deck-fan {
  position: relative;
  width: 110px;
  height: 155px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}
.deck-fan .deck-fan-icon {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.5rem;
  color: rgba(212,168,75,0.3);
  z-index: 0;
}
.deck-fan .deck-stack { z-index: 1; }
.deck-fan.deck-just-drew {
  animation: deckDrawPulse 0.4s ease-out;
}
.deck-fan.deck-drawable {
  cursor: pointer;
}
.deck-fan.deck-drawable:hover {
  filter: brightness(1.15);
}
.deck-fan.deck-drawable:hover .deck-stack .deck-card {
  filter: brightness(1.1);
}
@keyframes deckDrawPulse {
  0% { filter: brightness(1); }
  50% { filter: brightness(1.25); }
  100% { filter: brightness(1); }
}
.deck-stack {
  position: absolute;
  width: 100px;
  height: 140px;
  perspective: 600px;
}
.deck-stack .deck-card {
  position: absolute;
  width: 100px;
  height: 140px;
  left: 50%;
  top: 50%;
  margin-left: -50px;
  margin-top: -70px;
  border-radius: 10px;
  background: linear-gradient(145deg, #1a1520 0%, #0d0a12 100%);
  border: 2px solid var(--gold-dark);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(212,168,75,0.3);
  transform-origin: center bottom;
}
.deck-stack .deck-card:nth-child(1) { z-index: 5; transform: translate(-50%, -50%) rotate(-10deg) translateY(0); animation: deckFloat 2.5s ease-in-out 0s infinite; }
.deck-stack .deck-card:nth-child(2) { z-index: 4; transform: translate(-50%, -50%) rotate(-5deg) translateY(3px); animation: deckFloat 2.5s ease-in-out 0.15s infinite; }
.deck-stack .deck-card:nth-child(3) { z-index: 3; transform: translate(-50%, -50%) rotate(0deg) translateY(6px); animation: deckFloat 2.5s ease-in-out 0.3s infinite; }
.deck-stack .deck-card:nth-child(4) { z-index: 2; transform: translate(-50%, -50%) rotate(5deg) translateY(9px); animation: deckFloat 2.5s ease-in-out 0.45s infinite; }
.deck-stack .deck-card:nth-child(5) { z-index: 1; transform: translate(-50%, -50%) rotate(10deg) translateY(12px); animation: deckFloat 2.5s ease-in-out 0.6s infinite; }
@keyframes deckFloat {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.08); }
}
.deck-stack .deck-card::after {
  content: '✦';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: rgba(212,168,75,0.5);
}

.deck-count-badge {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #2d2a22 0%, #1a1814 100%);
  border: 2px solid var(--gold);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--gold);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  z-index: 10;
}

/* Drop targets (drag minion to attack) */
.drop-target {
  transition: box-shadow 0.2s, transform 0.2s;
}
.drop-target.drop-over {
  box-shadow: 0 0 20px rgba(255,180,0,0.6);
  transform: scale(1.05);
}
.your-board.drop-target {
  min-height: 180px;
  border: 2px dashed rgba(0,180,255,0.3);
  border-radius: 12px;
  padding: 0.5rem;
  transition: border-color 0.2s, background 0.2s;
}
.your-board.drop-target.drop-over {
  border-color: rgba(0,180,255,0.7);
  background: rgba(0,180,255,0.1);
  box-shadow: 0 0 30px rgba(0,180,255,0.4);
}
.drop-target-hero {
  min-width: 70px;
  min-height: 50px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  background: rgba(196,30,58,0.2);
  border: 2px dashed rgba(230,57,70,0.5);
  border-radius: 10px;
  margin-right: 0.35rem;
  margin-bottom: 0.35rem;
}
.drop-target-hero .drop-hero-icon { font-size: 1.2rem; color: #ff6b6b; }
.drop-target-hero .drop-hero-name { font-size: 0.7rem; color: #94a3b8; }
.drop-target-hero.drop-over {
  background: rgba(196,30,58,0.35);
  border-color: #e63946;
}

.card-wrap.dragging {
  opacity: 0.6;
}

/* Effects layer */
#effects-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}
.effect {
  position: fixed;
  width: 80px;
  height: 80px;
  margin-left: -40px;
  margin-top: -40px;
  pointer-events: none;
}
.effect-draw {
  animation: effectDraw 0.8s ease-out forwards;
}
.effect-draw::before,
.effect-draw::after {
  content: '';
  position: absolute;
  inset: -20px;
  border-radius: 50%;
  border: 2px solid rgba(0,212,255,0.6);
  animation: effectRing 0.8s ease-out forwards;
}
.effect-draw::after { animation-delay: 0.1s; }
@keyframes effectDraw {
  0% { opacity: 1; transform: scale(0.3); }
  100% { opacity: 0; transform: scale(1.5); }
}
@keyframes effectRing {
  0% { transform: scale(0.2); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}
.effect-attack {
  animation: effectAttack 0.8s ease-out forwards;
}
.effect-attack::before {
  content: '';
  position: absolute;
  inset: -30px;
  background: radial-gradient(circle, rgba(255,70,70,0.5) 0%, transparent 70%);
  border-radius: 50%;
  animation: effectBurst 0.6s ease-out forwards;
}
@keyframes effectAttack {
  0% { opacity: 1; transform: scale(0.2); }
  70% { opacity: 1; transform: scale(1.2); }
  100% { opacity: 0; transform: scale(1.5); }
}
@keyframes effectBurst {
  0% { transform: scale(0.1); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}
.effect-play {
  animation: effectPlay 0.8s ease-out forwards;
}
.effect-play::before {
  content: '✦';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: rgba(255,204,0,0.8);
  animation: effectSparkle 0.7s ease-out forwards;
}
@keyframes effectPlay {
  0% { opacity: 1; transform: scale(0.5); }
  100% { opacity: 0; transform: scale(1.8); }
}
@keyframes effectSparkle {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* Hand - fanned */
.hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 0;
  flex-wrap: nowrap;
  min-height: 200px;
  flex: 1;
  max-width: 100%;
  overflow: visible;
}
.hand .card-wrap {
  margin-left: -36px;
  transition: margin 0.2s ease, transform 0.25s ease;
}
.hand .card-wrap:first-child { margin-left: 0; }
.hand .card-wrap:hover {
  margin-left: -12px;
}
.hand .card-wrap:hover + .card-wrap { margin-left: -24px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.3s ease;
}
.modal-overlay.hidden { display: none !important; }

/* Auth Modal */
.auth-modal {
  max-width: 400px;
}
.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid rgba(212,168,75,0.2);
}
.auth-tab {
  flex: 1;
  padding: 0.75rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #94a3b8;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.auth-tab.active {
  color: var(--cyan);
  border-bottom-color: var(--cyan);
}
.auth-tab:hover {
  color: var(--cyan);
}
.auth-panel {
  display: none;
}
.auth-panel.active {
  display: block;
}
.auth-panel label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: #94a3b8;
}
.auth-panel input {
  width: 100%;
  padding: 0.75rem;
  background: rgba(0,0,0,0.3);
  border: 2px solid rgba(0,180,255,0.35);
  border-radius: 8px;
  color: #f8fafc;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}
.auth-panel input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 10px rgba(0,212,255,0.3);
}

/* Leaderboard Modal */
.leaderboard-modal {
  max-width: 700px;
  max-height: 80vh;
}
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}
.leaderboard-table th,
.leaderboard-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.leaderboard-table th {
  background: rgba(0,0,0,0.3);
  color: var(--cyan);
  font-weight: 700;
  position: sticky;
  top: 0;
}
.leaderboard-table tr:hover {
  background: rgba(0,212,255,0.1);
}
.leaderboard-table .rank {
  font-weight: 700;
  color: var(--gold);
  width: 50px;
  text-align: center;
}
.leaderboard-table .username {
  font-weight: 600;
  color: var(--cyan);
}
.leaderboard-table .stats {
  text-align: center;
}

.modal {
  background: linear-gradient(145deg, #2d2a22 0%, #1a1814 100%);
  border: 3px solid var(--gold);
  border-radius: 20px;
  padding: 2.5rem;
  max-width: 420px;
  text-align: center;
  animation: cardIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 40px rgba(212,168,75,0.2), 0 12px 40px rgba(0,0,0,0.5);
}
.modal h2 { font-family: var(--font-display); margin-bottom: 1rem; }
.modal p { margin-bottom: 1.5rem; color: #94a3b8; }

.instructions-modal { 
  max-width: 520px; 
  max-height: 85vh;
  text-align: left;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.instructions-body {
  overflow-y: auto;
  flex: 1;
  padding-right: 0.5rem;
  margin-right: -0.5rem;
}
.instructions-body::-webkit-scrollbar {
  width: 8px;
}
.instructions-body::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.2);
  border-radius: 4px;
}
.instructions-body::-webkit-scrollbar-thumb {
  background: rgba(0,180,255,0.5);
  border-radius: 4px;
}
.instructions-body::-webkit-scrollbar-thumb:hover {
  background: rgba(0,180,255,0.7);
}
.card-info-modal { max-width: 420px; text-align: left; }
.card-info-modal h2 { font-size: 1.2rem; color: var(--cyan); margin-bottom: 0.5rem; }
.card-info-modal .card-info-meta { font-size: 0.85rem; color: #94a3b8; margin-bottom: 0.5rem; }
.card-info-modal .card-info-text { font-size: 0.9rem; color: #c4a574; margin-bottom: 0.5rem; }
.card-info-modal .card-info-abilities { font-size: 0.85rem; color: var(--amber); margin-bottom: 0.5rem; }
.card-info-modal .card-info-bio { font-size: 0.8rem; color: #94a3b8; line-height: 1.4; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid rgba(148,163,184,0.3); }
.card-info-modal .hidden { display: none !important; }
/* Forge Sidebar - Новая версия */
.forge-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 90vw;
  max-width: 1200px;
  height: 100vh;
  background: linear-gradient(145deg, #1a1814 0%, #0d0a08 100%);
  border-left: 3px solid var(--gold);
  box-shadow: -5px 0 40px rgba(0,0,0,0.9);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
.forge-sidebar:not(.hidden) {
  transform: translateX(0);
}
.forge-sidebar.hidden {
  display: none;
}
.forge-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 2px solid var(--gold);
  background: rgba(0,0,0,0.4);
  flex-shrink: 0;
}
.forge-sidebar-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(212,168,75,0.5);
}
.btn-forge-close {
  background: transparent;
  border: 2px solid var(--gold);
  color: var(--gold);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.btn-forge-close:hover {
  background: var(--gold);
  color: #1a1814;
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(212,168,75,0.6);
}

.forge-main-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

.forge-columns {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 1rem;
  height: 100%;
  overflow: hidden;
}

.forge-columns.forge-two-cols {
  grid-template-columns: 1fr 1.2fr;
}

.forge-hint-inline {
  font-size: 0.85rem;
  color: #94a3b8;
  margin: 0 0 0.5rem 0;
  padding: 0 1rem;
}

.forge-column {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  border: 1px solid rgba(212,168,75,0.2);
}

.forge-column-title {
  font-size: 0.95rem;
  color: var(--gold);
  margin: 0;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(212,168,75,0.2);
  background: rgba(0,0,0,0.3);
  font-family: var(--font-display);
  font-weight: 600;
  flex-shrink: 0;
}

.forge-cards-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.75rem;
  -webkit-overflow-scrolling: touch;
}

.forge-cards-list .card-wrap {
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.forge-cards-list .card-wrap:hover {
  transform: translateY(-5px) scale(1.05);
  border-color: var(--cyan);
  box-shadow: 0 0 20px rgba(0,180,255,0.5);
  z-index: 10;
}

.forge-cards-list .card-wrap.selected {
  border-color: var(--cyan);
  box-shadow: 0 0 25px rgba(0,180,255,0.7);
  transform: scale(1.05);
}

.forge-selected-column {
  background: rgba(0,180,255,0.05);
  border-color: rgba(0,180,255,0.3);
}

.forge-selected {
  flex: 1;
  padding: 1rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: flex-start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.forge-selected-empty {
  width: 100%;
  color: #94a3b8;
  font-size: 0.9rem;
  text-align: center;
  padding: 3rem 1rem;
  font-style: italic;
}

.forge-selected-card {
  position: relative;
  cursor: pointer;
  transition: all 0.2s;
}

.forge-selected-card:hover {
  transform: scale(1.1);
  z-index: 5;
}

.forge-selected-card::before {
  content: '×';
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  background: rgba(255,70,70,0.9);
  border: 2px solid #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
  font-weight: 800;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.forge-selected-card:hover::before {
  opacity: 1;
  pointer-events: auto;
}

.forge-actions {
  padding: 1rem 1.5rem;
  border-top: 2px solid var(--gold);
  background: rgba(0,0,0,0.4);
  display: flex;
  gap: 1rem;
  flex-shrink: 0;
}

.forge-actions .btn {
  flex: 1;
}

.forge-actions .btn-primary {
  background: linear-gradient(135deg, var(--gold) 0%, #b8860b 100%);
  color: #1a0f00;
  font-weight: 700;
}

.forge-actions .btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #b8860b 0%, var(--gold) 100%);
  box-shadow: 0 0 20px rgba(212,168,75,0.6);
}

.forge-actions .btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Forge preview (предпросмотр результата крафта) */
.forge-preview {
  padding: 1rem;
  border-top: 1px solid rgba(212,168,75,0.2);
  background: rgba(0,0,0,0.25);
  flex-shrink: 0;
}

.forge-preview.hidden {
  display: none !important;
}

.forge-preview-title {
  margin: 0 0 0.75rem 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gold);
}

.forge-preview-card-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  margin-bottom: 0.75rem;
}

.forge-preview-loading {
  margin: 0;
  color: #94a3b8;
  font-size: 0.9rem;
}

.forge-preview-card {
  flex-shrink: 0;
}

.forge-preview-card .card {
  border-radius: 8px;
  border: 2px solid rgba(212,168,75,0.5);
  box-shadow: 0 0 20px rgba(212,168,75,0.3);
}

.forge-preview-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

@media (max-width: 768px) {
  .forge-sidebar {
    width: 100vw;
    max-width: 100vw;
  }
}
.cards-gallery-modal {
  max-width: 90vw;
  max-height: 90vh;
  width: 1200px;
  text-align: left;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.gallery-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.gallery-filter, .gallery-search {
  padding: 0.5rem;
  background: rgba(0,0,0,0.4);
  border: 2px solid rgba(0,180,255,0.3);
  border-radius: 8px;
  color: #f8fafc;
  font-size: 0.9rem;
}
.gallery-search {
  flex: 1;
  min-width: 200px;
}
.cards-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  overflow-y: auto;
  max-height: 60vh;
  padding: 0.5rem;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
}
.gallery-card {
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.gallery-card:hover {
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(0,180,255,0.6);
  z-index: 10;
  position: relative;
}
.gallery-card.fictional {
  border: 2px solid rgba(255,204,0,0.6);
  box-shadow: 0 0 10px rgba(255,204,0,0.3);
}
.gallery-card.fictional::before {
  content: '⚡ ВЫМЫШЛЕННЫЙ';
  position: absolute;
  top: -8px;
  right: -8px;
  background: rgba(255,204,0,0.9);
  color: #000;
  font-size: 0.6rem;
  font-weight: 800;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  z-index: 20;
  white-space: nowrap;
}
.settings-modal { max-width: 400px; text-align: left; }
.steal-cards-modal {
  max-width: 800px;
  max-height: 90vh;
  text-align: left;
  overflow-y: auto;
}
.steal-target-select {
  margin-bottom: 1rem;
}
.steal-target-option {
  pointer-events: auto !important;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.steal-target-option:hover {
  background: rgba(0,180,255,0.2) !important;
  border-color: var(--cyan) !important;
  transform: scale(1.02);
}
.steal-target-option:active {
  transform: scale(0.98);
}
.steal-deck-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
}
.steal-deck-card {
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 2px solid transparent;
  position: relative;
  z-index: 10;
  pointer-events: auto !important;
  user-select: none;
  -webkit-user-select: none;
}
.steal-deck-card:hover {
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(0,180,255,0.5);
  z-index: 15;
}
.steal-deck-card.selected {
  border-color: var(--cyan);
  box-shadow: 0 0 20px rgba(0,180,255,0.7);
  transform: scale(1.05);
}
.steal-deck-card:active {
  transform: scale(0.95);
}
.steal-selected {
  min-height: 80px;
  padding: 0.5rem;
  background: rgba(255,204,0,0.1);
  border: 2px dashed rgba(255,204,0,0.3);
  border-radius: 8px;
  margin-bottom: 1rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.steal-selected-empty {
  color: #94a3b8;
  font-size: 0.9rem;
  width: 100%;
  text-align: center;
}
.steal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}
.settings-content { margin: 1.5rem 0; }
.setting-group {
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.setting-group label {
  font-size: 0.9rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.setting-group label span {
  color: var(--cyan);
  font-weight: 600;
}
#music-volume-slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(0,0,0,0.4);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
#music-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cyan);
  cursor: pointer;
  border: 2px solid rgba(0,180,255,0.5);
  box-shadow: 0 0 8px rgba(0,180,255,0.5);
}
#music-volume-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cyan);
  cursor: pointer;
  border: 2px solid rgba(0,180,255,0.5);
  box-shadow: 0 0 8px rgba(0,180,255,0.5);
}
#music-toggle.active {
  background: rgba(0,180,255,0.2);
  border-color: var(--cyan);
  color: var(--cyan);
}
.instructions-body { margin-bottom: 1.5rem; }
.instructions-body h3 { font-size: 1rem; color: var(--cyan); margin: 1rem 0 0.5rem; }
.instructions-body ul { margin: 0.5rem 0; padding-left: 1.25rem; color: #94a3b8; }
.instructions-body li { margin-bottom: 0.35rem; }
.instructions-body .atk { color: #ff6b6b; }
.instructions-body .hp { color: #51cf66; }
.instructions-body .faction-r { color: #7eb8f0; }
.instructions-body .faction-e { color: #e86a7a; }
.instructions-body .faction-n { color: #c4a574; }
.instructions-body .instructions-icon { font-size: 1.1em; vertical-align: middle; margin: 0 0.15em; opacity: 0.9; }

/* Rooms list (Лобби) */
.rooms-list {
  margin-top: 1rem;
}

.room-item {
  transition: all 0.2s;
}

.room-item:hover {
  border-color: rgba(212,168,75,0.4) !important;
  background: rgba(0,0,0,0.4) !important;
}

.room-item button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#spectator-badge {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Attack mode bar */
.attack-mode {
  position: fixed;
  bottom: 240px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(196,30,58,0.3) 0%, rgba(139,21,48,0.4) 100%);
  border: 2px solid var(--red);
  border-radius: 14px;
  padding: 0.85rem 1.75rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 50;
  animation: fadeIn 0.2s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.attack-mode.hidden { display: none !important; }
.attack-mode p { color: #f8fafc; font-weight: 600; }
.spell-mode p { color: var(--amber); }
.spell-target { box-shadow: 0 0 16px rgba(255,204,0,0.5); cursor: pointer; }
.spell-target:hover { box-shadow: 0 0 24px rgba(255,204,0,0.7); }
.hero-ability-target { box-shadow: 0 0 14px rgba(0,212,255,0.5); cursor: pointer; }
.hero-ability-target:hover { box-shadow: 0 0 22px rgba(0,212,255,0.7); }

/* Frozen effect */
.frozen, .frozen-card {
  position: relative;
  filter: brightness(0.75) saturate(0.6);
  border: 3px solid rgba(135,206,250,0.8) !important;
  box-shadow: 0 0 20px rgba(135,206,250,0.6), 
              0 0 40px rgba(135,206,250,0.4),
              inset 0 0 30px rgba(135,206,250,0.3) !important;
  animation: frozenShimmer 2s ease-in-out infinite;
}

@keyframes frozenShimmer {
  0%, 100% {
    filter: brightness(0.75) saturate(0.6);
    box-shadow: 0 0 20px rgba(135,206,250,0.6), 
                0 0 40px rgba(135,206,250,0.4),
                inset 0 0 30px rgba(135,206,250,0.3);
  }
  50% {
    filter: brightness(0.85) saturate(0.7);
    box-shadow: 0 0 30px rgba(135,206,250,0.8), 
                0 0 60px rgba(135,206,250,0.6),
                inset 0 0 40px rgba(135,206,250,0.4);
  }
}

.frozen-icon {
  position: absolute;
  top: 5px;
  right: 5px;
  font-size: 1.8rem;
  z-index: 10;
  animation: frozenPulse 2s ease-in-out infinite;
  text-shadow: 0 0 10px rgba(135,206,250,0.8),
               0 0 20px rgba(135,206,250,0.6);
}
@keyframes frozenPulse {
  0%, 100% { opacity: 0.9; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.3); }
}
.frozen-card::before {
  content: '';
  position: absolute;
  inset: -3px;
  background: linear-gradient(135deg, 
    rgba(135,206,250,0.2) 0%, 
    rgba(70,130,180,0.3) 25%,
    rgba(135,206,250,0.2) 50%,
    rgba(70,130,180,0.3) 75%,
    rgba(135,206,250,0.2) 100%);
  background-size: 200% 200%;
  border-radius: 12px;
  animation: frozenGradient 3s linear infinite;
  z-index: -1;
  pointer-events: none;
}

@keyframes frozenGradient {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: 200% 200%;
  }
}

/* Synergy bonuses */
.has-synergy {
  position: relative;
}

.has-synergy::after {
  content: '✨';
  position: absolute;
  top: -5px;
  left: -5px;
  font-size: 1.2rem;
  z-index: 15;
  animation: synergyGlow 2s ease-in-out infinite;
  filter: drop-shadow(0 0 5px rgba(255, 204, 0, 0.8));
}

@keyframes synergyGlow {
  0%, 100% {
    opacity: 0.7;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

.synergy-bonus {
  color: var(--amber-bright);
  font-size: 0.7em;
  font-weight: bold;
  margin-left: 2px;
  text-shadow: 0 0 5px rgba(255, 204, 0, 0.8);
}

/* Fictional card marker */
.fictional-card {
  border: 2px solid rgba(255,204,0,0.6) !important;
  box-shadow: 0 0 15px rgba(255,204,0,0.4) !important;
  position: relative;
}
.fictional-card::after {
  content: '⚡';
  position: absolute;
  top: 5px;
  left: 5px;
  font-size: 1.2rem;
  z-index: 15;
  text-shadow: 0 0 8px rgba(255,204,0,0.8);
  animation: fictionalPulse 2s ease-in-out infinite;
}
@keyframes fictionalPulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* Damage indicators */
.damage-indicator {
  font-size: 2rem;
  font-weight: 900;
  color: #ff6b6b;
  text-shadow: 0 0 10px rgba(255,107,107,0.8), 0 2px 4px rgba(0,0,0,0.5);
  pointer-events: none;
  user-select: none;
  animation: damageFloat 1.5s ease-out forwards;
}
@keyframes damageFloat {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  50% {
    opacity: 1;
    transform: translateY(-40px) scale(1.3);
  }
  100% {
    opacity: 0;
    transform: translateY(-80px) scale(0.8);
  }
}

/* Hero damage flash */
.hero-damage-flash {
  animation: heroDamageFlash 0.5s ease;
}
@keyframes heroDamageFlash {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.5) contrast(1.2); box-shadow: 0 0 30px rgba(255,107,107,0.8); }
}

/* Spell hit effect */
.spell-hit {
  animation: spellHit 0.5s ease;
}
@keyframes spellHit {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.1) rotate(5deg); }
  75% { transform: scale(0.95) rotate(-5deg); }
}

/* Attack announcement - крупный текст на экране */
.attack-announcement {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 500;
  background: linear-gradient(135deg, rgba(196,30,58,0.98) 0%, rgba(139,21,48,0.98) 100%);
  border: 5px solid var(--red);
  border-radius: 25px;
  padding: 2.5rem 5rem;
  font-size: 3rem;
  font-weight: 900;
  color: #ffffff;
  text-align: center;
  text-shadow: 
    0 0 30px rgba(255,255,255,1),
    0 0 60px rgba(255,107,107,0.8),
    0 4px 12px rgba(0,0,0,0.9),
    0 0 0 4px rgba(0,0,0,0.3);
  box-shadow: 
    0 0 80px rgba(255,71,87,1),
    0 0 120px rgba(255,107,107,0.6),
    0 12px 48px rgba(0,0,0,0.8),
    inset 0 2px 10px rgba(255,255,255,0.2);
  animation: attackAnnouncementIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), attackAnnouncementPulse 0.5s ease-in-out 0.5s infinite, attackAnnouncementOut 0.4s ease-in 3.1s forwards;
  pointer-events: none;
  white-space: nowrap;
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  line-height: 1.3;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attack-announcement.hidden {
  display: none;
}
@keyframes attackAnnouncementIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2) rotate(-15deg);
    filter: blur(10px);
  }
  60% {
    transform: translate(-50%, -50%) scale(1.1) rotate(2deg);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
    filter: blur(0);
  }
}
@keyframes attackAnnouncementPulse {
  0%, 100% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 
      0 0 80px rgba(255,71,87,1),
      0 0 120px rgba(255,107,107,0.6),
      0 12px 48px rgba(0,0,0,0.8);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.03);
    box-shadow: 
      0 0 100px rgba(255,71,87,1),
      0 0 150px rgba(255,107,107,0.8),
      0 14px 52px rgba(0,0,0,0.9);
  }
}
@keyframes attackAnnouncementOut {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
    filter: blur(5px);
  }
}

/* Mobile optimizations */
@media (max-width: 900px) {
  .hand .card-wrap { margin-left: -48px; }
  .card-wrap { width: 154px; height: 214px; }
  .board .card-wrap { width: 128px; height: 178px; }
  .opponents .card-wrap { width: 120px; height: 167px; }
  .attack-announcement {
    font-size: 2rem;
    padding: 1.8rem 3rem;
    white-space: normal;
    max-width: 95vw;
    line-height: 1.4;
  }
}

/* Touch device optimizations */
@media (max-width: 768px) {
  html, body {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
  }
  
  .screen {
    padding: 0.5rem;
    min-height: 100vh;
    overflow-x: hidden;
  }
  
  .lobby-card {
    padding: 1.5rem;
    max-width: 100%;
    margin: 0 auto;
  }
  
  .game-header {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--space);
    border-bottom: 1px solid rgba(0,180,255,0.2);
  }
  
  .header-left, .header-center, .header-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.4rem;
    gap: 0.5rem;
  }
  
  .header-center {
    order: -1;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .btn {
    min-height: 40px;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    touch-action: manipulation;
  }
  
  .btn-end-turn {
    min-height: 40px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    flex: 1;
    min-width: 100px;
  }
  
  .btn-forge, .btn-hero-ability, .btn-draw-card {
    min-height: 38px;
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
    min-width: 70px;
  }
  
  .btn-instructions, .btn-settings {
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
    min-width: 44px;
    min-height: 44px;
  }
  
  .card-wrap {
    width: 120px;
    height: 168px;
    touch-action: manipulation;
  }
  
  .board .card-wrap {
    width: 85px;
    height: 119px;
  }
  
  .opponents .card-wrap {
    width: 85px;
    height: 119px;
  }
  
  /* Уменьшаем текст на картах для средних мобильных */
  .card-name {
    font-size: 0.7rem !important;
  }
  
  .card-cost {
    font-size: 0.8rem !important;
    width: 20px !important;
    height: 20px !important;
  }
  
  .card-stats {
    font-size: 0.75rem !important;
  }
  
  .card-stats .atk, .card-stats .hp {
    font-size: 0.75rem !important;
  }
  
  .card-text {
    font-size: 0.65rem !important;
    -webkit-line-clamp: 3 !important;
  }
  
  .opponents {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  
  .opponent-block {
    min-width: auto;
    width: 100%;
    padding: 0.5rem;
  }
  
  .hand {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding: 0.5rem;
    gap: 0.3rem;
  }
  
  .hand .card-wrap {
    margin-left: -25px;
    scroll-snap-align: start;
    flex-shrink: 0;
  }
  
  .hand .card-wrap:first-child {
    margin-left: 0;
  }
  
  .hand .card-wrap:last-child {
    margin-right: 0.5rem;
  }
  
  .hand-container {
    min-height: 200px;
    padding: 0.5rem;
    position: relative;
  }
  
  .deck-fan {
    width: 80px;
    height: 112px;
    flex-shrink: 0;
  }
  
  .deck-stack {
    width: 75px;
    height: 105px;
  }
  
  .deck-stack .deck-card {
    width: 75px;
    height: 105px;
  }
  
  .board {
    min-height: 150px;
    padding: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .your-board {
    min-height: 110px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  
  .your-board .card-wrap {
    scroll-snap-align: start;
    flex-shrink: 0;
  }
  
  .attack-mode {
    bottom: 200px;
    padding: 0.7rem 1.2rem;
    font-size: 0.9rem;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 2rem);
    max-width: 400px;
  }
  
  .attack-mode p {
    font-size: 0.85rem;
  }
  
  .modal {
    max-width: 95vw;
    padding: 1.5rem;
    margin: 1rem;
    max-height: 90vh;
    overflow-y: auto;
  }
  
  .cards-gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
  }
  
  .gallery-card {
    width: 100px !important;
    height: 140px !important;
  }
  
  .forge-sidebar {
    width: 100vw;
    max-width: 100vw;
    right: 0;
    left: 0;
    border-radius: 0;
  }
  
  .forge-columns {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 0.75rem;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .forge-column {
    max-height: 300px;
  }
  
  .forge-cards-list {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.5rem;
    max-height: 250px;
  }
  
  .forge-selected {
    max-height: 200px;
  }
  
  .forge-actions {
    flex-direction: column;
  }
  
  .forge-actions .btn {
    width: 100%;
  }
  
  .mana-display, .health-display {
    font-size: 1rem;
  }
  
  .turn-badge {
    font-size: 0.85rem;
    padding: 0.35rem 0.7rem;
  }
  
  .turn-timer {
    font-size: 0.85rem;
  }
  
  .chat-container {
    width: calc(100vw - 20px);
    right: 10px;
    bottom: 10px;
    max-height: 300px;
  }
  
  .chat-content {
    height: 250px;
  }
  
  .chat-input-container {
    flex-direction: column;
  }
  
  .btn-chat-send {
    width: 100%;
  }
  
  .card-name {
    font-size: 0.8rem;
  }
  
  .card-text {
    font-size: 0.68rem;
    line-height: 1.3;
  }
  
  .card-cost, .card-atk-hp {
    font-size: 0.9rem;
  }
  
  .card-btn-info {
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
    min-width: 28px;
    min-height: 28px;
  }
  
  /* Touch feedback */
  .card-wrap.touch-active {
    transform: scale(1.05);
    transition: transform 0.1s;
  }
  
  .card-wrap.swiping {
    opacity: 0.7;
  }
  
  /* Prevent text selection on touch */
  .card-wrap, .btn, .tab, .deck-fan {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }
  
  /* Улучшенная поддержка touch для интерактивных элементов */
  .btn:active {
    transform: scale(0.95);
    transition: transform 0.1s;
  }
  
  .card-wrap:active:not(.disabled) {
    transform: scale(0.98);
  }
}

/* Small mobile devices */
@media (max-width: 480px) {
  .lobby-card {
    padding: 1rem;
  }
  
  /* Уменьшаем карты */
  .card-wrap {
    width: 100px;
    height: 140px;
  }
  
  .board .card-wrap {
    width: 70px;
    height: 98px;
  }
  
  .opponents .card-wrap {
    width: 70px;
    height: 98px;
  }
  
  .hand .card-wrap {
    margin-left: -25px;
  }
  
  .hand-container {
    min-height: 140px;
    padding: 0.25rem;
  }
  
  .hand {
    gap: 0.2rem;
    padding: 0.25rem;
  }
  
  /* Уменьшаем колоду */
  .deck-fan {
    width: 70px;
    height: 98px;
  }
  
  .deck-stack {
    width: 65px;
    height: 91px;
  }
  
  .deck-stack .deck-card {
    width: 65px;
    height: 91px;
  }
  
  /* Уменьшаем заголовок игры */
  .game-header {
    padding: 0.4rem;
    font-size: 0.75rem;
    gap: 0.3rem;
  }
  
  .header-left, .header-center, .header-right {
    gap: 0.3rem;
  }
  
  /* Маленькие кнопки */
  .btn {
    padding: 0.4rem 0.7rem;
    font-size: 0.75rem;
    min-height: 36px;
    border-radius: 6px;
  }
  
  .btn-end-turn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    min-height: 36px;
    min-width: 80px;
  }
  
  .btn-forge, .btn-hero-ability, .btn-draw-card {
    padding: 0.35rem 0.6rem;
    font-size: 0.7rem;
    min-height: 32px;
    min-width: 60px;
  }
  
  .btn-instructions, .btn-settings {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
    min-width: 32px;
    min-height: 32px;
  }
  
  /* Уменьшаем текст на картах */
  .card-name {
    font-size: 0.6rem !important;
    line-height: 1.1 !important;
  }
  
  .card-cost {
    font-size: 0.75rem !important;
    width: 18px !important;
    height: 18px !important;
  }
  
  .card-stats {
    font-size: 0.7rem !important;
    gap: 0.3rem !important;
  }
  
  .card-stats .atk, .card-stats .hp {
    font-size: 0.7rem !important;
  }
  
  .card-text {
    font-size: 0.55rem !important;
    line-height: 1.2 !important;
    -webkit-line-clamp: 3 !important;
    margin-bottom: 0.2rem !important;
  }
  
  .card-info {
    padding: 0.3rem !important;
  }
  
  /* Уменьшаем доски */
  .board {
    min-height: 100px;
    padding: 0.3rem;
  }
  
  .your-board {
    min-height: 90px;
    padding: 0.3rem;
  }
  
  .opponent-block {
    padding: 0.3rem;
  }
  
  .opponent-name {
    font-size: 0.75rem;
  }
  
  .opponent-stats {
    font-size: 0.7rem;
  }
  
  /* Уменьшаем статистику игрока */
  #your-mana, #your-max-mana, #your-health {
    font-size: 1rem;
  }
  
  #your-name {
    font-size: 0.85rem;
  }
  
  /* Уменьшаем анонсы */
  .attack-announcement {
    font-size: 1.2rem;
    padding: 1rem 1.5rem;
  }
  
  /* Уменьшаем модальные окна */
  .modal {
    padding: 0.75rem;
    max-width: 95vw;
  }
  
  .modal h2 {
    font-size: 1.1rem;
  }
  
  .modal p {
    font-size: 0.85rem;
  }
  
  /* Галерея карт */
  .cards-gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 0.5rem;
  }
  
  .gallery-card {
    width: 70px !important;
    height: 98px !important;
  }
  
  /* Уменьшаем чат */
  .chat-container {
    width: calc(100vw - 10px);
    right: 5px;
    bottom: 5px;
    max-height: 250px;
  }
  
  .chat-content {
    height: 200px;
  }
  
  .chat-messages {
    font-size: 0.75rem;
    padding: 0.5rem;
  }
  
  /* Уменьшаем кузницу */
  .forge-sidebar {
    padding: 0.5rem;
  }
  
  .forge-cards-list .card-wrap {
    width: 80px;
    height: 112px;
  }
  
  /* Уменьшаем лог игры */
  #game-log {
    font-size: 0.7rem;
    max-width: 150px;
  }
  
  /* Уменьшаем таймер */
  .turn-timer {
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
  }
}
