/* ============================================================
   BOARD — structure of the game screen: the ornate frame, the
   board grid, the hero panels, and the turn seal. Cards
   (minion-card / hand-card) live in cards.css.
   ============================================================ */

#screen-game {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 0;
  overflow: hidden;
}

.board-frame {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 3px;
  background: linear-gradient(135deg, var(--gold), #6b4b1c 45%, var(--gold) 100%);
  border-radius: 0;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.62), 0 0 0 1px rgba(255, 230, 162, 0.12);
}

.corner {
  position: absolute;
  width: 26px;
  height: 26px;
  z-index: 2;
  pointer-events: none;
}
.corner::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid var(--gold);
}
.corner-tl { top: -3px; left: -3px; }
.corner-tl::before { border-right: none; border-bottom: none; }
.corner-tr { top: -3px; right: -3px; }
.corner-tr::before { border-left: none; border-bottom: none; }
.corner-bl { bottom: -3px; left: -3px; }
.corner-bl::before { border-right: none; border-top: none; }
.corner-br { bottom: -3px; right: -3px; }
.corner-br::before { border-left: none; border-top: none; }

.board {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(150px, 1fr) auto minmax(150px, 1fr) auto;
  gap: 12px;
  padding: 24px 30px 18px;
  border-radius: 6px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 219, 135, 0.14), rgba(232, 179, 79, 0.055) 18%, transparent 42%),
    linear-gradient(90deg, rgba(232, 179, 79, 0.05), transparent 18%, transparent 82%, rgba(232, 179, 79, 0.05)),
    radial-gradient(ellipse at 50% 8%, rgba(79, 195, 232, 0.13), transparent 38%),
    radial-gradient(ellipse at 50% 54%, rgba(232, 179, 79, 0.11), transparent 42%),
    radial-gradient(ellipse at bottom, #221824 0%, var(--bg) 70%);
  overflow: visible;
}

.board::before {
  content: "";
  position: absolute;
  inset: 24% 18%;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(circle, rgba(232, 179, 79, 0.16), rgba(232, 179, 79, 0.06) 34%, transparent 68%);
  filter: blur(22px);
  opacity: 0.72;
}

.board > * {
  position: relative;
  z-index: 1;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 22px;
  min-height: 0;
  padding: 8px 0;
}
.opponent-row {
  display: grid;
  grid-template-columns: clamp(176px, 16vw, 230px) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "hero board"
    "hand board";
  align-items: center;
  column-gap: 22px;
  row-gap: 8px;
}
.self-row { flex-direction: row-reverse; }

#oppHero {
  grid-area: hero;
  width: 100%;
  min-width: 0;
}

#oppBoard {
  grid-area: board;
  min-width: 0;
  align-self: stretch;
}

#oppHandBack {
  grid-area: hand;
  align-self: start;
  max-width: 100%;
  padding: 5px 7px;
  border-radius: 7px;
  background: rgba(8, 6, 15, 0.24);
}

#oppHandBack .minion-card {
  flex: 0 0 auto;
}

.hero-panel {
  background:
    linear-gradient(160deg, rgba(49, 39, 70, 0.9), rgba(20, 16, 29, 0.92)),
    radial-gradient(circle at 25% 20%, rgba(232, 179, 79, 0.18), transparent 55%);
  border: 1px solid rgba(232, 179, 79, 0.24);
  border-radius: 6px;
  padding: 12px 14px;
  width: clamp(176px, 16vw, 230px);
  min-width: 176px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  grid-template-areas:
    "avatar name"
    "avatar stats";
  align-items: center;
  justify-content: center;
  column-gap: 12px;
  row-gap: 4px;
  align-self: center;
  box-shadow: inset 0 0 0 1px rgba(232, 179, 79, 0.08), 0 10px 24px rgba(0, 0, 0, 0.28);
}
.hero-avatar {
  grid-area: avatar;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background-color: rgba(8, 6, 12, 0.72);
  background-position: center;
  background-size: cover;
  border: 1px solid rgba(232, 179, 79, 0.62);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Cinzel", serif;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.42);
}
.hero-name {
  grid-area: name;
  min-width: 0;
  font-family: "Cinzel", serif;
  font-size: 17px;
  color: var(--cream);
  letter-spacing: 0.4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hero-stats {
  grid-area: stats;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 14px;
  line-height: 1.1;
}
.stat.hp { color: var(--hp); font-weight: 700; }
.stat.mana { color: var(--mana); font-weight: 700; }
.stat.deck { color: var(--cream-dim); }

.hero-panel.targetable { cursor: crosshair; box-shadow: 0 0 0 2px var(--hp); }
.hero-panel.active-turn { box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(232, 179, 79, 0.35); }

.btn-end-turn {
  background: linear-gradient(180deg, var(--gold), #a5762e);
  color: #241800;
  font-size: 15px;
  padding: 12px 22px;
  min-width: 140px;
}
.btn-end-turn:disabled { opacity: 0.35; cursor: not-allowed; filter: none; }

.btn-surrender {
  background: transparent;
  border: 1px solid var(--hp);
  color: var(--hp);
  padding: 5px 14px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.btn-surrender:hover { background: rgba(214, 69, 69, 0.16); filter: none; }

.minion-row {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, clamp(72px, 9.2vw, 150px)));
  gap: 14px;
  width: 100%;
  min-height: 0;
  align-items: center;
  align-content: center;
  justify-content: center;
  justify-items: center;
  padding: 8px 10px;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  direction: ltr;
}

.minion-row > .minion-card {
  width: 100%;
}

.hand-back {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
}

.center-strip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0;
  position: relative;
}

.turn-actions {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.manuscript-rule {
  width: 100%;
  max-width: 640px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--gold);
  font-size: 11px;
  opacity: 0.8;
}
.manuscript-rule::before,
.manuscript-rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.turn-seal {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f4d488, #a5762e 65%, #5c3f16 100%);
  border: 2px solid #3a2a10;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Cinzel", serif;
  font-weight: 700;
  color: #241800;
  font-size: 12px;
  line-height: 1.15;
  text-align: center;
  box-shadow: 0 0 16px rgba(232, 179, 79, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.45);
  flex-shrink: 0;
}

.turn-label {
  font-family: "Cinzel", serif;
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold);
  white-space: nowrap;
}

.game-log {
  max-width: 560px;
  max-height: 44px;
  overflow-y: auto;
  font-size: 11px;
  color: var(--cream-dim);
  text-align: center;
  line-height: 1.5;
  font-style: italic;
}

@media (max-width: 720px) {
  .board-frame { padding: 2px; }
  .board {
    grid-template-rows: minmax(116px, 1fr) auto minmax(116px, 1fr) auto;
    padding: 12px 10px 10px;
    gap: 7px;
  }
  .corner { width: 18px; height: 18px; }
  .hero-panel {
    width: clamp(118px, 28vw, 148px);
    min-width: 118px;
    grid-template-columns: 30px minmax(0, 1fr);
    padding: 7px 8px;
    column-gap: 7px;
  }
  .hero-avatar { width: 28px; height: 28px; font-size: 12px; }
  .hero-name { font-size: 12px; }
  .hero-stats { font-size: 10.5px; gap: 4px 7px; }
  .center-strip { gap: 12px; }
  .turn-actions { position: static; transform: none; margin-top: 4px; }
  .btn-end-turn { font-size: 12px; padding: 8px 14px; min-width: 0; }
  .btn-surrender { font-size: 9px; padding: 4px 10px; }
  .player-row { gap: 7px; padding: 3px 0; }
  .minion-row {
    grid-template-columns: repeat(5, minmax(0, clamp(44px, 16vw, 104px)));
    gap: 7px;
    padding: 5px;
    border-radius: 7px;
  }
  .opponent-row {
    grid-template-columns: minmax(108px, 128px) minmax(0, 1fr);
    column-gap: 7px;
    row-gap: 5px;
  }
  #oppHandBack {
    padding: 2px 4px;
    border-radius: 6px;
  }
  .turn-seal { width: 40px; height: 40px; font-size: 9px; }
  .game-log { font-size: 9.5px; max-width: 90vw; }
}

@media (max-width: 720px) and (orientation: portrait) {
  .board {
    grid-template-rows: minmax(112px, 1fr) auto minmax(112px, 1fr) auto;
    gap: 6px;
  }

  .center-strip {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "seal label actions";
    align-items: center;
    column-gap: 8px;
    padding: 2px 4px;
  }

  .turn-seal {
    grid-area: seal;
    width: 34px;
    height: 34px;
    font-size: 8px;
  }

  .turn-label {
    grid-area: label;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 10px;
    letter-spacing: 0.8px;
    text-align: left;
  }

  .manuscript-rule,
  .game-log {
    display: none;
  }

  .turn-actions {
    grid-area: actions;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin: 0;
  }

  .btn-end-turn,
  .btn-surrender {
    min-width: 0;
    min-height: 34px;
    padding: 7px 9px;
    font-size: 9px;
    line-height: 1;
    white-space: nowrap;
  }

  .self-row {
    display: grid;
    grid-template-columns: minmax(108px, 128px) minmax(0, 1fr);
    grid-template-areas: "hero board";
    align-items: center;
    column-gap: 7px;
  }

  #selfHero {
    grid-area: hero;
    width: 100%;
    min-width: 0;
  }

  #selfBoard {
    grid-area: board;
    min-width: 0;
    align-self: stretch;
  }
}
