:root {
  --bg-1: #0d1020;
  --bg-2: #171b33;
  --panel: rgba(24, 28, 52, 0.9);
  --gold: #d9a441;
  --gold-2: #f2cd73;
  --blue: #3f7fd6;
  --green: #3fb26b;
  --red: #d94f4f;
  --text: #e8ecff;
  --muted: #97a0c4;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 10%, #1f2a4d 0%, var(--bg-1) 45%, #070912 100%);
  min-height: 100vh;
  user-select: none;
}

.hidden {
  display: none !important;
}

#app {
  min-height: 100vh;
}

.screen {
  min-height: 100vh;
}

/* ---------------- Lobby ---------------- */
#lobby {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lobby-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid rgba(217, 164, 65, 0.35);
  border-radius: 18px;
  padding: 32px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

.lobby-card h1 {
  margin: 0 0 6px;
  font-size: 30px;
  color: var(--gold-2);
  letter-spacing: 0.5px;
}

.subtitle {
  margin: 0 0 24px;
  color: var(--muted);
}

.field {
  display: block;
  text-align: left;
  margin-bottom: 20px;
}

.field span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.field input:focus {
  border-color: var(--gold);
}

.lobby-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 18px;
  color: #14182c;
  transition: transform 0.08s ease, filter 0.15s ease;
}

button:hover:not(:disabled) {
  filter: brightness(1.08);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.primary {
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
}

.secondary {
  background: linear-gradient(180deg, #6f8fd8, #3f63b6);
  color: #fff;
}

.ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.small {
  padding: 8px 12px;
  font-size: 13px;
}

.status {
  margin-top: 18px;
  min-height: 20px;
  color: var(--gold-2);
  font-size: 14px;
}

/* ---------------- Game ---------------- */
#game {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 10px 16px 14px;
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.turn-indicator {
  font-size: 14px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.3);
  padding: 6px 14px;
  border-radius: 20px;
}

.turn-indicator.your-turn {
  color: #0d1020;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  font-weight: 700;
}

.battlefield {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  min-height: 0;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.opponent-side {
  align-items: flex-start;
}

.self-side {
  align-items: flex-end;
}

.board {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  min-height: 118px;
  padding: 6px 8px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  width: 100%;
}

.self-side .board {
  justify-content: flex-end;
}

/* Hero */
.hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(63, 127, 214, 0.25), rgba(0, 0, 0, 0.3));
  border: 2px solid rgba(217, 164, 65, 0.3);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.hero .hero-name {
  font-weight: 700;
  font-size: 15px;
}

.hero .hero-hp {
  font-size: 22px;
  font-weight: 800;
  color: var(--green);
  min-width: 42px;
  text-align: center;
}

.hero .deck-info {
  font-size: 12px;
  color: var(--muted);
}

.hero.targetable {
  border-color: var(--red);
  box-shadow: 0 0 20px rgba(217, 79, 79, 0.7);
  cursor: crosshair;
}

/* Minions */
.minion {
  position: relative;
  width: 86px;
  height: 108px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #2c3358, #1a1f3a);
  border: 2px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px;
  transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.minion .art {
  font-size: 34px;
  line-height: 1;
}

.minion .name {
  font-size: 11px;
  text-align: center;
  margin-top: 4px;
  line-height: 1.1;
}

.minion .stat {
  position: absolute;
  bottom: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: #14182c;
}

.minion .atk {
  left: 4px;
  background: linear-gradient(180deg, #ffe08a, #d9a441);
}

.minion .hp {
  right: 4px;
  background: linear-gradient(180deg, #8ff0aa, #3fb26b);
}

.minion .hp.damaged {
  background: linear-gradient(180deg, #ff9a9a, #d94f4f);
}

.minion.taunt {
  border-color: #c9a24d;
  box-shadow: inset 0 0 0 2px rgba(201, 162, 77, 0.4);
}

.minion.charge::after,
.minion.rush::after {
  content: '⚡';
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 12px;
}

.minion.shield {
  border-color: #8fdcff;
  box-shadow: 0 0 12px rgba(143, 220, 255, 0.6);
}

.minion.ready {
  box-shadow: 0 0 0 2px var(--green), 0 0 14px rgba(63, 178, 107, 0.6);
}

.minion.exhausted {
  filter: grayscale(0.5) brightness(0.8);
}

.minion.selectable {
  cursor: pointer;
}

.minion.targetable {
  cursor: crosshair;
  border-color: var(--red);
  box-shadow: 0 0 18px rgba(217, 79, 79, 0.75);
}

.minion.selected {
  transform: translateY(-8px);
  box-shadow: 0 0 0 2px var(--gold), 0 10px 24px rgba(0, 0, 0, 0.6);
}

/* Hand */
.hand-row {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  padding-top: 10px;
}

.mana {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  width: 120px;
  align-content: flex-end;
  justify-content: center;
}

.mana .pip {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(63, 127, 214, 0.25);
  border: 1px solid rgba(63, 127, 214, 0.6);
}

.mana .pip.full {
  background: linear-gradient(180deg, #7fb2ff, #3f7fd6);
  box-shadow: 0 0 8px rgba(63, 127, 214, 0.9);
}

.mana .label {
  width: 100%;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}

.hand {
  flex: 1;
  display: flex;
  gap: 8px;
  justify-content: center;
  min-height: 150px;
  align-items: flex-end;
}

.card {
  position: relative;
  width: 104px;
  height: 146px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #33406e, #1c2340);
  border: 2px solid rgba(217, 164, 65, 0.35);
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.card.playable {
  cursor: pointer;
  border-color: var(--gold);
}

.card.playable:hover {
  transform: translateY(-14px);
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.55);
}

.card.unplayable {
  filter: grayscale(0.6) brightness(0.7);
}

.card .cost {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(180deg, #7fb2ff, #2f66b8);
  color: #fff;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.card .art {
  font-size: 36px;
  margin-top: 6px;
}

.card .name {
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  margin: 4px 0;
  line-height: 1.1;
}

.card .text {
  font-size: 10px;
  text-align: center;
  color: #cdd6f5;
  line-height: 1.2;
  flex: 1;
  overflow: hidden;
}

.card .stats {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-weight: 800;
  font-size: 14px;
}

.card .stats .a {
  color: var(--gold-2);
}

.card .stats .h {
  color: #8ff0aa;
}

.card.picked {
  transform: translateY(-18px);
  box-shadow: 0 0 0 2px var(--red), 0 16px 30px rgba(0, 0, 0, 0.6);
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  width: 170px;
}

.hero-power {
  background: linear-gradient(180deg, #8b5cf6, #6d28d9);
  color: #fff;
  position: relative;
}

.hero-power:disabled {
  filter: grayscale(0.7);
}

.hero-power .hp-art {
  font-size: 18px;
  margin-right: 6px;
}

.hero-power.picking {
  box-shadow: 0 0 0 2px var(--red);
}

.end-turn {
  background: linear-gradient(180deg, #f2cd73, #d9a441);
  padding: 14px;
}

.end-turn:disabled {
  filter: grayscale(0.6);
}

/* Log & hints */
.log-panel {
  position: absolute;
  right: 14px;
  top: 46px;
  width: 220px;
  max-height: 34vh;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  pointer-events: none;
}

.log-panel div:last-child {
  color: var(--text);
}

.hint {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(217, 79, 79, 0.92);
  color: #fff;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 40;
}

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 24, 44, 0.95);
  border: 1px solid var(--gold);
  color: var(--gold-2);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 60;
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 16, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(4px);
}

.overlay-card {
  background: var(--panel);
  border: 1px solid rgba(217, 164, 65, 0.4);
  border-radius: 18px;
  padding: 36px 44px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
}

.overlay-card h2 {
  margin: 0 0 10px;
  font-size: 28px;
  color: var(--gold-2);
}

.overlay-card p {
  color: var(--muted);
  margin: 0 0 22px;
}

.overlay-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

@media (max-width: 720px) {
  .log-panel {
    display: none;
  }
  .mana {
    width: 90px;
  }
  .actions {
    width: 130px;
  }
  .card {
    width: 86px;
    height: 124px;
  }
}
