* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: radial-gradient(ellipse at center, #1b1230 0%, #0a0614 100%);
  font-family: 'Segoe UI', Tahoma, sans-serif;
  color: #f1e9ff;
  overflow: hidden;
  user-select: none;
}

.hidden { display: none !important; }

.screen {
  width: 100vw; height: 100vh;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- ЛОГИН ---------- */
.login-box {
  text-align: center;
  background: rgba(20, 10, 40, 0.6);
  padding: 40px 50px;
  border-radius: 16px;
  border: 1px solid #6a3fb5;
  box-shadow: 0 0 40px rgba(150, 80, 255, 0.35);
}
.login-box h1 { font-size: 2.4em; margin-bottom: 4px; letter-spacing: 1px; }
.login-box h1 span { color: #ffb347; text-shadow: 0 0 12px #ffb347; }
.subtitle { color: #b8a4e0; margin-bottom: 24px; }
#name-input {
  display: block; width: 260px; margin: 0 auto 16px; padding: 12px 14px;
  border-radius: 8px; border: 1px solid #6a3fb5; background: #14092b; color: #fff;
  font-size: 1em; text-align: center;
}
.btn-primary {
  background: linear-gradient(180deg, #ffcf6b, #d99b2b);
  border: none; color: #2b1600; font-weight: bold; padding: 12px 28px;
  border-radius: 10px; cursor: pointer; font-size: 1.05em;
  box-shadow: 0 4px 0 #a6741a; transition: transform .1s;
}
.btn-primary:hover { transform: translateY(-2px); }
.btn-primary:active { transform: translateY(2px); box-shadow: 0 1px 0 #a6741a; }
.btn-secondary {
  margin-top: 14px; background: transparent; color: #cbb8ef; border: 1px solid #6a3fb5;
  padding: 8px 18px; border-radius: 8px; cursor: pointer;
}
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 4px solid #6a3fb5; border-top-color: #ffcf6b;
  margin: 18px auto 8px; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- ИГРОВОЕ ПОЛЕ ---------- */
.board {
  width: 100vw; height: 100vh;
  display: flex; flex-direction: column;
  background:
    linear-gradient(180deg, rgba(90,40,140,.25), transparent 20%, transparent 80%, rgba(40,20,80,.35)),
    #170c2e;
  padding: 12px 16px 8px;
}

.hero-row { display: flex; align-items: center; gap: 16px; }
.opponent-row { justify-content: flex-start; }
.my-row { justify-content: flex-start; }

.hero-portrait {
  width: 70px; height: 70px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #5b2fa8, #2a1350);
  border: 3px solid #c79bff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 0 14px rgba(180, 120, 255, .5);
  position: relative; flex-shrink: 0;
}
.hero-name { font-size: 0.65em; color: #e3d4ff; position: absolute; top: -18px; white-space: nowrap; }
/* Портрет соперника сдвинут на 5px ниже, чтобы имя не обрезалось верхним краем экрана */
#opp-hero { margin-top: 5px; }
.hero-health {
  font-size: 1.3em; font-weight: bold; color: #ff5c5c;
  text-shadow: 0 0 6px rgba(255,60,60,.8);
}

.mana { font-size: 1.1em; color: #7fd4ff; font-weight: bold; min-width: 70px; text-align: center; }
.deck-count { font-size: .8em; color: #a894cf; }

.hero-power {
  width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle, #ffb347, #a5590a);
  border: 2px solid #ffdca0; cursor: pointer; font-size: 1.2em; color: #2a1200;
  box-shadow: 0 0 10px rgba(255,180,60,.6);
}
.hero-power.active-glow { animation: pulse 1s infinite; }
.hero-power:disabled, .hero-power.used { filter: grayscale(0.8); opacity: .5; cursor: default; }

.btn-endturn {
  margin-left: auto; background: linear-gradient(180deg,#7f4fe0,#4b2591);
  border: 2px solid #c79bff; color: #fff; font-weight: bold;
  padding: 10px 20px; border-radius: 10px; cursor: pointer;
}
.btn-endturn:disabled { opacity: .4; cursor: default; }
.btn-endturn.glow { animation: pulse 1.1s infinite; }

@keyframes pulse {
  0%,100% { box-shadow: 0 0 6px rgba(199,155,255,.6); }
  50% { box-shadow: 0 0 20px rgba(199,155,255,1); }
}

/* Игровые поля (боевые зоны) */
.battlefield {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 130px;
  border-top: 1px dashed rgba(180,140,255,.15);
  border-bottom: 1px dashed rgba(180,140,255,.15);
}
.center-log {
  height: 26px; font-size: .75em; color: #9c86c9; text-align: center; overflow: hidden;
}

/* Руки */
.hand { display: flex; gap: 6px; }
.opponent-hand { height: 70px; align-items: center; }
.my-hand {
  display: flex; justify-content: center; gap: 8px; padding: 8px 0 4px;
  min-height: 150px;
}

/* ---------- КАРТЫ ---------- */
.card {
  width: 100px; height: 140px; border-radius: 10px; position: relative; cursor: pointer;
  background: linear-gradient(160deg, #3a2166, #1c0f38);
  border: 2px solid #8a5cd6;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 6px; box-shadow: 0 4px 10px rgba(0,0,0,.5);
  transition: transform .15s ease;
  flex-shrink: 0;
}
.card:hover { transform: translateY(-14px) scale(1.05); z-index: 5; }
.card.playable { border-color: #ffcf6b; box-shadow: 0 0 10px rgba(255,207,107,.7); }
.card.selected { border-color: #ff5c5c; box-shadow: 0 0 16px rgba(255,60,60,.9); transform: translateY(-14px); }
.card .cost {
  position: absolute; top: -6px; left: -6px; width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle, #4fc3f7, #0d6ea8); border: 2px solid #bfe9ff;
  display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: .85em;
}
.card .name { font-size: .68em; text-align: center; line-height: 1.15; margin-top: 12px; }
.card .stats {
  display: flex; justify-content: space-between; font-weight: bold; font-size: .95em;
}
.card .atk { color: #ffe27a; }
.card .hp { color: #ff7a7a; }
.card .taunt-badge {
  position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  font-size: .6em; background: #4b2591; border: 1px solid #c79bff; border-radius: 6px;
  padding: 1px 6px; color: #e3d4ff;
}

.card-back {
  background: repeating-linear-gradient(45deg, #2a1350, #2a1350 6px, #3a1e66 6px, #3a1e66 12px);
  border: 2px solid #6a3fb5;
}

/* Существа на столе */
.minion {
  width: 86px; height: 100px; border-radius: 10px; position: relative; cursor: pointer;
  background: linear-gradient(160deg, #402873, #1e1140);
  border: 2px solid #8a5cd6;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  padding: 4px; transition: transform .15s, box-shadow .15s;
}
.minion .name { font-size: .62em; text-align: center; margin-bottom: 20px; padding: 0 2px; }
.minion .stats { position: absolute; bottom: 4px; left: 0; right: 0; display: flex; justify-content: space-between; padding: 0 6px; font-weight: bold; }
.minion .atk { color: #ffe27a; }
.minion .hp { color: #ff7a7a; }
.minion.sick { filter: grayscale(0.6) brightness(0.75); }
.minion.can-attack { border-color: #7fffa0; box-shadow: 0 0 10px rgba(120,255,160,.6); cursor: pointer; }
.minion.taunt { border-color: #ffb347; box-shadow: 0 0 8px rgba(255,179,71,.5); }
.minion.selected-attacker { border-color: #ff5c5c; box-shadow: 0 0 16px rgba(255,60,60,1); transform: translateY(-8px); }
.minion.valid-target { box-shadow: 0 0 14px rgba(255,60,60,.9); border-color: #ff5c5c; cursor: crosshair; }
.hero-portrait.valid-target { box-shadow: 0 0 20px rgba(255,60,60,1); border-color: #ff5c5c; cursor: crosshair; }

/* ---------- АНИМАЦИИ ---------- */
@keyframes cardPlayed {
  0% { transform: translateY(60px) scale(0.7); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
.anim-played { animation: cardPlayed .35s ease-out; }

@keyframes attackLungeRight {
  0% { transform: translate(0,0); }
  50% { transform: translate(40px,-6px) scale(1.08); }
  100% { transform: translate(0,0); }
}
@keyframes attackLungeLeft {
  0% { transform: translate(0,0); }
  50% { transform: translate(-40px,-6px) scale(1.08); }
  100% { transform: translate(0,0); }
}
.anim-attack-right { animation: attackLungeRight .35s ease-in-out; }
.anim-attack-left { animation: attackLungeLeft .35s ease-in-out; }

@keyframes shake {
  0%,100% { transform: translate(0,0); }
  20% { transform: translate(-6px,2px); }
  40% { transform: translate(6px,-2px); }
  60% { transform: translate(-4px,2px); }
  80% { transform: translate(4px,-2px); }
}
.anim-hit { animation: shake .4s; }

@keyframes deathFade {
  0% { transform: scale(1) rotate(0); opacity: 1; }
  100% { transform: scale(0.2) rotate(25deg); opacity: 0; }
}
.anim-death { animation: deathFade .4s ease-in forwards; }

@keyframes floatUp {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-50px); opacity: 0; }
}
.dmg-popup {
  position: fixed; font-size: 1.6em; font-weight: bold; color: #ff5c5c;
  text-shadow: 0 0 8px #000, 0 0 4px #ff0000;
  pointer-events: none; z-index: 50;
  animation: floatUp .8s ease-out forwards;
}
.dmg-popup.heal { color: #7fffa0; }

@keyframes coinFlip {
  0% { transform: rotateY(0deg) scale(1); }
  50% { transform: rotateY(360deg) scale(1.3); }
  100% { transform: rotateY(720deg) scale(1); }
}
.anim-coin { animation: coinFlip .8s ease-in-out; }

.turn-banner {
  position: fixed; top: 40%; left: 50%; transform: translate(-50%,-50%);
  font-size: 2.4em; font-weight: bold; color: #ffcf6b;
  text-shadow: 0 0 20px rgba(255,207,107,.8);
  z-index: 60; animation: bannerPop 1.4s ease-out forwards;
  pointer-events: none;
}
@keyframes bannerPop {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%,-50%) scale(1.1); }
  25% { transform: translate(-50%,-50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

#fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 100; }

/* ---------- ЭКРАН ОКОНЧАНИЯ ---------- */
.over-box {
  text-align: center; background: rgba(20,10,40,.8); padding: 50px 70px;
  border-radius: 16px; border: 1px solid #6a3fb5; box-shadow: 0 0 50px rgba(150,80,255,.5);
}
#over-title { font-size: 2.6em; margin-bottom: 24px; }
