/* ============================================================
   BOARD ARENA - tabletop surface, player zones, and controls.
   Card anatomy stays in cards.css; hand presentation is isolated
   in board-hand.css.
   ============================================================ */

#screen-game {
  background: #120904;
}

.board-frame {
  padding: 7px;
  background:
    linear-gradient(90deg, rgba(255, 229, 143, 0.9), rgba(105, 67, 22, 0.94) 14%, rgba(62, 35, 14, 0.96) 50%, rgba(105, 67, 22, 0.94) 86%, rgba(255, 229, 143, 0.9));
  box-shadow: inset 0 0 0 1px rgba(20, 8, 2, 0.92), 0 18px 48px rgba(0, 0, 0, 0.52);
}

.board-frame::before {
  content: "";
  position: absolute;
  inset: 12px;
  z-index: 3;
  border: 1px solid rgba(242, 202, 80, 0.32);
  box-shadow: inset 0 0 0 1px rgba(35, 16, 5, 0.72);
  pointer-events: none;
}

.corner {
  width: 34px;
  height: 34px;
  z-index: 4;
}

.corner::before {
  border-color: rgba(242, 202, 80, 0.86);
  box-shadow: 0 0 10px rgba(242, 202, 80, 0.22);
}

.board {
  isolation: isolate;
  overflow: hidden;
  grid-template-rows: minmax(180px, 1fr) auto minmax(180px, 1fr) auto;
  gap: 9px;
  padding: 22px clamp(22px, 4vw, 68px) 0;
  border-radius: 2px;
  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%);
}

.board::before {
  inset: 18% 8%;
  background: radial-gradient(ellipse, rgba(242, 202, 80, 0.1), rgba(113, 63, 14, 0.05) 44%, transparent 70%);
  filter: blur(30px);
  opacity: 0.9;
}

.board::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 44%, rgba(0, 0, 0, 0.48) 100%);
}

.player-row {
  position: relative;
  display: grid;
  min-height: 0;
  padding: 0;
}

.opponent-row {
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "hero"
    "board";
  gap: 8px;
}

.self-row {
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas:
    "board"
    "hero";
  gap: 8px;
}

#oppHero,
#selfHero {
  width: clamp(126px, 12.5vw, 150px);
  min-width: 126px;
  min-height: 98px;
  margin-bottom: 17px;
  justify-self: center;
}

#oppHero { grid-area: hero; }
#selfHero { grid-area: hero; justify-self: start; }

/* The player's hero stays compact so the friendly board has more room to read. */
#selfHero {
  width: clamp(108px, 10.5vw, 128px);
  min-width: 108px;
  min-height: 84px;
  margin-bottom: 14px;
}
#selfHero .hero-avatar { top: 7px; width: 52px; height: 52px; }
#selfHero .hero-name { width: calc(100% + 16px); font-size: 10px; }
#selfHero .hero-stats .hp { left: -16px; bottom: -16px; width: 42px; height: 42px; font-size: 10px; }
#selfHero .hero-stats .mana { right: -16px; bottom: -14px; width: 41px; height: 41px; font-size: 8px; }
#selfHero .hero-stats .deck { top: 6px; right: 7px; font-size: 7px; }
#oppBoard,
#selfBoard { grid-area: board; min-width: 0; align-self: stretch; }

#oppHandBack {
  position: absolute;
  top: 4px;
  left: clamp(4px, 6vw, 84px);
  z-index: 2;
  grid-area: unset;
  max-width: min(22vw, 180px);
  padding: 4px 6px;
  border: 1px solid rgba(242, 202, 80, 0.18);
  border-radius: 5px;
  background: rgba(15, 6, 2, 0.4);
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.3);
}

#oppHandBack .minion-card {
  margin-left: -10px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.55);
}

#oppHandBack .minion-card:first-child { margin-left: 0; }

.hero-panel {
  position: relative;
  display: block;
  overflow: visible;
  touch-action: none;
  padding: 0;
  border: 2px solid rgba(242, 202, 80, 0.76);
  border-radius: 12px 12px 26px 26px;
  background:
    linear-gradient(145deg, rgba(91, 51, 18, 0.96), rgba(22, 10, 4, 0.98) 68%),
    radial-gradient(circle at 50% 24%, rgba(255, 227, 146, 0.2), transparent 56%);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.48), inset 0 1px 0 rgba(255, 230, 158, 0.25);
}

.hero-panel::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(255, 221, 132, 0.26);
  border-radius: 8px 8px 21px 21px;
  pointer-events: none;
}

.hero-avatar {
  position: absolute;
  top: 8px;
  left: 50%;
  width: 61px;
  height: 61px;
  transform: translateX(-50%);
  border: 2px solid #f6cf67;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(52, 23, 4, 0.96), 0 7px 13px rgba(0, 0, 0, 0.55), inset 0 0 12px rgba(255, 227, 153, 0.22);
}

.hero-name {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  width: calc(100% + 22px);
  transform: translateX(-50%);
  font-family: "Cinzel", serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.7px;
  color: #ffe9bd;
  text-align: center;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.95);
}

.hero-stats {
  display: block;
  font-size: 10px;
}

.hero-stats .stat {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  font-family: "Cinzel", serif;
  font-weight: 700;
  line-height: 1;
}

.hero-stats .hp {
  left: -18px;
  bottom: -18px;
  width: 47px;
  height: 47px;
  color: #fff5f1;
  font-size: 12px;
  text-shadow: 0 1px 2px rgba(57, 2, 10, 0.95);
}

.hero-stats .hp::before {
  content: "";
  position: absolute;
  inset: 4px;
  z-index: -1;
  border: 2px solid #ffb6bd;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 25%, #ffe8e9, #ff8793 30%, #bf3148 68%, #671124);
  box-shadow: 0 3px 0 #5d1020, 0 5px 10px rgba(0, 0, 0, 0.65), 0 0 12px rgba(255, 86, 108, 0.62);
}

.hero-stats .mana {
  right: -18px;
  bottom: -15px;
  width: 46px;
  height: 46px;
  color: #eefcff;
  font-size: 9px;
  text-shadow: 0 1px 2px rgba(3, 21, 52, 0.95);
}

.hero-stats .mana::before {
  content: "";
  position: absolute;
  inset: 5px;
  z-index: -1;
  border: 2px solid #b9f2ff;
  border-radius: 7px;
  background: radial-gradient(circle at 32% 25%, #e8fcff, #62d5ff 28%, #257bcc 67%, #142b72);
  box-shadow: 0 3px 0 #10235c, 0 5px 10px rgba(0, 0, 0, 0.65), 0 0 12px rgba(92, 213, 255, 0.44);
  transform: rotate(45deg);
}

.hero-stats .deck {
  top: 7px;
  right: 8px;
  min-width: 19px;
  color: #f8dfa1;
  font-size: 8px;
}

.hero-stats .deck::before {
  content: "";
  position: absolute;
  inset: -4px -5px;
  z-index: -1;
  border: 1px solid rgba(255, 226, 143, 0.46);
  border-radius: 3px;
  background: rgba(19, 8, 3, 0.78);
  box-shadow: -2px 2px 0 rgba(91, 53, 19, 0.92), -4px 4px 0 rgba(35, 15, 4, 0.9);
}

.hero-panel.active-turn {
  border-color: #ffdf78;
  box-shadow: 0 0 0 2px rgba(242, 202, 80, 0.52), 0 0 24px rgba(242, 202, 80, 0.42), inset 0 1px 0 rgba(255, 236, 176, 0.3);
}

.minion-row {
  grid-template-columns: repeat(5, minmax(0, clamp(82px, 10.4vw, 156px)));
  gap: clamp(8px, 1.35vw, 22px);
  padding: 13px clamp(8px, 2vw, 26px);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#oppBoard,
#selfBoard { background: transparent; }

#screen-game .minion-card,
#screen-game .hand-card.unaffordable {
  opacity: 1;
}

#screen-game .minion-card.exhausted,
#screen-game .hand-card.unaffordable {
  filter: grayscale(0.56) brightness(0.72);
}

.center-strip {
  min-height: 52px;
  gap: 3px;
  padding: 2px 180px;
}

.turn-seal {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 226, 143, 0.88);
  background: linear-gradient(145deg, #ffdc6d, #9b651c 74%);
  box-shadow: 0 0 0 2px rgba(42, 18, 4, 0.82), 0 0 16px rgba(242, 202, 80, 0.22);
  font-size: 9px;
}

.turn-label {
  font-size: 10px;
  letter-spacing: 1.4px;
  color: #f7d778;
}

.turn-timer {
  color: rgba(226, 231, 255, 0.76);
  font-family: "Cinzel", serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.7px;
  line-height: 1;
  text-transform: uppercase;
}

.turn-timer-warning {
  color: #ff8d87;
  text-shadow: 0 0 10px rgba(255, 76, 69, 0.7);
}

.manuscript-rule { max-width: 760px; opacity: 0.64; }
.game-log { display: none; }

.turn-actions {
  right: clamp(10px, 2vw, 32px);
  gap: 7px;
}

.btn-end-turn {
  min-width: 142px;
  min-height: 58px;
  padding: 10px 18px;
  border: 2px solid #ffe088;
  border-radius: 8px;
  background: linear-gradient(180deg, #f4cf57, #b78326);
  box-shadow: 0 5px 0 #654015, 0 12px 22px rgba(0, 0, 0, 0.44), inset 0 1px 0 rgba(255, 248, 191, 0.64);
  font-family: "Cinzel", serif;
  font-size: 12px;
  letter-spacing: 0.9px;
  text-transform: uppercase;
}

.btn-end-turn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #654015, 0 6px 12px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 248, 191, 0.52);
}

.btn-surrender {
  border-color: rgba(255, 180, 160, 0.44);
  color: rgba(255, 202, 192, 0.86);
  background: rgba(32, 7, 4, 0.38);
}

@media (max-width: 900px) and (orientation: landscape) {
  .board { grid-template-rows: minmax(112px, 1fr) auto minmax(112px, 1fr) auto; padding: 14px 18px 0; }
  .board-frame { padding: 4px; }
  .minion-row { grid-template-columns: repeat(5, minmax(0, clamp(48px, 11.8vw, 88px))); gap: 8px; padding: 7px; }
  #oppHero, #selfHero { width: 90px; min-width: 90px; min-height: 68px; margin-bottom: 13px; }
  #selfHero { width: 80px; min-width: 80px; min-height: 61px; margin-bottom: 11px; }
  #selfHero .hero-avatar { top: 5px; width: 36px; height: 36px; }
  #selfHero .hero-name { width: calc(100% + 10px); font-size: 7px; }
  #selfHero .hero-stats .hp { left: -12px; bottom: -13px; width: 32px; height: 32px; font-size: 8px; }
  #selfHero .hero-stats .mana { right: -12px; bottom: -12px; width: 31px; height: 31px; font-size: 6px; }
  .hero-panel { padding: 0; }
  .hero-avatar { top: 5px; width: 40px; height: 40px; border-width: 1px; box-shadow: 0 0 0 2px rgba(52, 23, 4, 0.96), 0 4px 8px rgba(0, 0, 0, 0.52); }
  .hero-name { top: calc(100% + 3px); width: calc(100% + 12px); font-size: 8px; letter-spacing: 0.35px; }
  .hero-stats .stat { min-height: 0; padding: 0; }
  .hero-stats .hp { left: -14px; bottom: -15px; width: 36px; height: 36px; font-size: 9px; }
  .hero-stats .hp::before { inset: 4px; }
  .hero-stats .mana { right: -14px; bottom: -13px; width: 35px; height: 35px; font-size: 7px; }
  .hero-stats .mana::before { inset: 4px; border-width: 1px; }
  .hero-stats .deck { top: 5px; right: 6px; font-size: 6px; }
  #oppHandBack { top: 0; left: 2px; transform: scale(0.78); transform-origin: top left; }
  .center-strip { min-height: 38px; padding: 0 124px; }
  .turn-seal { width: 27px; height: 27px; font-size: 7px; }
  .turn-label { font-size: 8px; }
  .turn-timer { font-size: 7px; }
  .btn-end-turn { min-width: 104px; min-height: 42px; font-size: 9px; }
  .btn-surrender { font-size: 8px; padding: 3px 8px; }
}

@media (max-width: 720px) and (orientation: portrait) {
  .board { grid-template-rows: minmax(202px, 1fr) auto minmax(202px, 1fr) auto; gap: 6px; padding: 12px 10px 0; }
  .opponent-row { grid-template-rows: auto minmax(0, 1fr); gap: 6px; }
  .self-row { grid-template-rows: minmax(0, 1fr) auto; gap: 6px; }
  #selfHero { justify-self: start; }
  #oppHandBack { top: 0; left: 0; transform: scale(0.72); transform-origin: top left; }
  .minion-row {
    width: min(100%, 328px);
    justify-self: center;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-auto-rows: min-content;
    column-gap: clamp(6px, 2vw, 10px);
    row-gap: 6px;
    align-content: center;
    justify-content: center;
    padding: 6px 0;
  }
  .minion-row > .minion-card { grid-column: span 2; }
  .minion-row > .minion-card:only-child { grid-column: 3 / span 2; }
  .minion-row > .minion-card:first-child:nth-last-child(2) { grid-column: 2 / span 2; }
  .minion-row > .minion-card:nth-child(4):last-child { grid-column: 3 / span 2; }
  .minion-row > .minion-card:nth-child(4):nth-last-child(2) { grid-column: 2 / span 2; }
  .minion-row .card-name { font-size: 9.5px; }
  .minion-row .card-stat { font-size: 14px; }
  /* The row nearest the centre of the table sits slightly forward. */
  #oppBoard .minion-card:nth-child(n + 4) { margin-top: -8px; z-index: 2; }
  #selfBoard .minion-card:nth-child(n + 4) { margin-top: 8px; z-index: 1; }
  #oppHero, #selfHero { width: 106px; min-width: 106px; min-height: 79px; margin-bottom: 14px; }
  #selfHero { width: 94px; min-width: 94px; min-height: 71px; margin-bottom: 12px; }
  #selfHero .hero-avatar { top: 5px; width: 40px; height: 40px; }
  #selfHero .hero-name { width: calc(100% + 12px); font-size: 8px; }
  #selfHero .hero-stats .hp { left: -13px; bottom: -14px; width: 35px; height: 35px; font-size: 8px; }
  #selfHero .hero-stats .mana { right: -13px; bottom: -12px; width: 34px; height: 34px; font-size: 7px; }
  .hero-panel { padding: 0; }
  .hero-avatar { top: 6px; width: 46px; height: 46px; }
  .hero-name { top: calc(100% + 3px); width: calc(100% + 16px); font-size: 9px; letter-spacing: 0.45px; }
  .hero-stats .stat { min-height: 0; padding: 0; }
  .hero-stats .hp { left: -14px; bottom: -15px; width: 38px; height: 38px; font-size: 9px; }
  .hero-stats .hp::before { inset: 4px; }
  .hero-stats .mana { right: -14px; bottom: -13px; width: 37px; height: 37px; font-size: 7px; }
  .hero-stats .mana::before { inset: 4px; }
  .hero-stats .deck { top: 6px; right: 7px; font-size: 7px; }
  .center-strip { min-height: 36px; padding: 0 116px 0 0; }
  .turn-seal { width: 26px; height: 26px; font-size: 7px; }
  .turn-label { font-size: 8px; letter-spacing: 0.7px; }
  .turn-timer { font-size: 7px; letter-spacing: 0.45px; }
  .manuscript-rule { display: none; }
  .turn-actions { right: 6px; flex-direction: row; gap: 4px; }
  .btn-end-turn { min-width: 84px; min-height: 38px; padding: 6px 7px; border-radius: 6px; font-size: 8px; }
  .btn-surrender { min-height: 27px; padding: 3px 6px; font-size: 7px; }
}

/* Phones use the full display for play space; the ornate outer frame is a
   desktop flourish and costs too much room on a narrow viewport. */
@media (max-width: 720px) {
  .board-frame {
    padding: 0;
    background: transparent;
    box-shadow: none;
  }
  .board-frame::before,
  .corner { display: none; }
  .board { border-radius: 0; }
}
