:root {
  --gold: #d6a24a;
  --gold-light: #ffe3a3;
  --gold-dark: #7b4618;
  --black: #050504;
  --panel: rgba(10, 9, 8, 0.78);
  --panel-strong: rgba(10, 7, 5, 0.92);
  --text: #f3e5c9;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 40%, rgba(93, 54, 18, 0.38), transparent 45%),
    linear-gradient(180deg, #110d08 0%, #050504 55%, #090604 100%);
  font-family: Georgia, "Times New Roman", serif;
}

button {
  font: inherit;
}

.game-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: clamp(8px, 1.2vh, 14px);
  width: 100vw;
  height: 100vh;
  min-height: 620px;
  padding: clamp(10px, 1.5vh, 16px) clamp(14px, 2vw, 28px) clamp(8px, 1vh, 12px);
  overflow: hidden;
  background: #060403;
}

.map-frame {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  min-height: 0;
}

.map-stage {
  position: relative;
  width: min(100%, calc((100vh - 210px) * 1.5));
  max-height: 100%;
  aspect-ratio: 3 / 2;
  isolation: isolate;
  overflow: hidden;
  background: #0b0907;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.58);
}

.valeth-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: brightness(0.8) contrast(1.1) saturate(0.93);
}

.vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(0, 0, 0, 0.18) 0%, rgba(0, 0, 0, 0.04) 24%, rgba(0, 0, 0, 0.06) 72%, rgba(0, 0, 0, 0.28) 100%),
    radial-gradient(circle at center, transparent 58%, rgba(0, 0, 0, 0.38) 100%);
}

.map-stage::before,
.map-stage::after {
  content: "";
  position: absolute;
  inset: 10px;
  z-index: 4;
  pointer-events: none;
  border: 1px solid rgba(224, 162, 70, 0.7);
  box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.85), 0 0 20px rgba(214, 162, 74, 0.18);
}

.map-stage::after {
  inset: 18px;
  border-color: rgba(255, 224, 157, 0.24);
}

.ornament {
  position: absolute;
  z-index: 5;
  width: clamp(72px, 8vw, 128px);
  aspect-ratio: 1;
  pointer-events: none;
  opacity: 0.74;
  border-color: var(--gold);
}

.ornament::before,
.ornament::after {
  content: "";
  position: absolute;
  border-color: inherit;
}

.ornament::before {
  inset: 0;
  border-top: 2px solid;
  border-left: 2px solid;
  border-radius: 18px 0 0 0;
}

.ornament::after {
  width: 54%;
  height: 54%;
  top: 12%;
  left: 12%;
  border-top: 1px solid;
  border-left: 1px solid;
  border-radius: 100% 0 0 0;
  transform: rotate(8deg);
}

.ornament-top-left {
  top: 18px;
  left: 18px;
}

.ornament-top-right {
  top: 18px;
  right: 18px;
  transform: scaleX(-1);
}

.ornament-bottom-left {
  bottom: 18px;
  left: 18px;
  transform: scaleY(-1);
}

.ornament-bottom-right {
  right: 18px;
  bottom: 18px;
  transform: scale(-1);
}

.hero-header {
  position: relative;
  z-index: 8;
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  padding-top: 2px;
  text-align: center;
  pointer-events: none;
}

.hero-header h1 {
  margin: 0;
  font-size: clamp(1.65rem, 4.2vw, 4rem);
  line-height: 0.95;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--gold-light);
  text-shadow:
    0 2px 0 #5b2e10,
    0 4px 14px rgba(0, 0, 0, 0.95),
    0 0 28px rgba(214, 162, 74, 0.5);
}

.hero-header::after {
  content: "";
  display: block;
  width: min(680px, 76%);
  height: 2px;
  margin: 10px auto 0;
  background: linear-gradient(90deg, transparent, var(--gold-dark), var(--gold-light), var(--gold-dark), transparent);
  box-shadow: 0 0 16px rgba(214, 162, 74, 0.6);
}

.region-layer {
  position: absolute;
  inset: 0;
  z-index: 7;
}

.region-hotspot {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  aspect-ratio: 1;
  padding: 0;
  cursor: pointer;
  background: radial-gradient(circle, rgba(255, 219, 139, 0.24), rgba(214, 162, 74, 0.05) 42%, transparent 68%);
  border: 1px solid transparent;
  border-radius: 999px;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.84);
  transition: opacity 220ms ease, transform 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}

.region-hotspot:hover,
.region-hotspot:focus-visible {
  opacity: 1;
  outline: none;
  border-color: rgba(255, 224, 157, 0.78);
  box-shadow: 0 0 22px rgba(214, 162, 74, 0.5), inset 0 0 18px rgba(255, 224, 157, 0.2);
  transform: translate(-50%, -50%) scale(1);
}

.tooltip {
  position: fixed;
  z-index: 20;
  max-width: min(320px, calc(100vw - 32px));
  padding: 14px 16px;
  color: #f8e6bf;
  background: linear-gradient(145deg, rgba(15, 10, 7, 0.96), rgba(39, 25, 13, 0.92));
  border: 1px solid rgba(255, 216, 139, 0.78);
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.64), inset 0 0 16px rgba(214, 162, 74, 0.1);
  opacity: 0;
  pointer-events: none;
  transform: translate(14px, 14px) scale(0.96);
  transition: opacity 150ms ease, transform 150ms ease;
}

.tooltip.is-visible {
  opacity: 1;
  transform: translate(14px, 14px) scale(1);
}

.tooltip h2 {
  margin: 0 0 6px;
  color: var(--gold-light);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tooltip p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.35;
}

.tooltip strong {
  display: block;
  margin-top: 8px;
  color: var(--gold);
  font-weight: normal;
}

.main-menu {
  position: relative;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(10px, 1.4vw, 22px);
  width: min(1280px, 100%);
  margin: 0 auto;
}

.menu-button {
  min-height: clamp(50px, 7vh, 74px);
  padding: 8px 8px;
  cursor: pointer;
  color: var(--gold-light);
  background:
    linear-gradient(145deg, rgba(33, 25, 18, 0.96), rgba(6, 5, 5, 0.94)),
    radial-gradient(circle at top, rgba(255, 226, 160, 0.16), transparent 55%);
  border: 1px solid rgba(197, 127, 43, 0.86);
  clip-path: polygon(9px 0, calc(100% - 9px) 0, 100% 9px, 100% calc(100% - 9px), calc(100% - 9px) 100%, 9px 100%, 0 calc(100% - 9px), 0 9px);
  box-shadow: inset 0 0 0 2px rgba(255, 225, 152, 0.1), 0 10px 24px rgba(0, 0, 0, 0.54);
  font-size: clamp(0.68rem, 1vw, 0.95rem);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: transform 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.menu-button span {
  display: block;
  margin-bottom: 3px;
  font-size: clamp(1rem, 1.8vw, 1.45rem);
  filter: drop-shadow(0 2px 3px #000);
}

.menu-button:hover,
.menu-button:focus-visible {
  color: #fff4d4;
  outline: none;
  transform: translateY(-4px);
  border-color: var(--gold-light);
  background:
    linear-gradient(145deg, rgba(53, 35, 17, 0.98), rgba(12, 8, 5, 0.96)),
    radial-gradient(circle at top, rgba(255, 226, 160, 0.26), transparent 58%);
  box-shadow: inset 0 0 0 2px rgba(255, 225, 152, 0.18), 0 0 28px rgba(214, 162, 74, 0.38), 0 12px 30px rgba(0, 0, 0, 0.66);
}

.credit {
  position: relative;
  justify-self: end;
  z-index: 9;
  color: rgba(255, 226, 166, 0.74);
  font-size: clamp(0.72rem, 1vw, 0.95rem);
  letter-spacing: 0.03em;
  text-shadow: 0 2px 4px #000;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.62);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  position: relative;
  width: min(480px, 100%);
  padding: 34px 30px 28px;
  text-align: center;
  color: var(--text);
  background:
    linear-gradient(145deg, rgba(31, 20, 12, 0.98), rgba(6, 5, 4, 0.98)),
    radial-gradient(circle at top, rgba(214, 162, 74, 0.22), transparent 58%);
  border: 1px solid rgba(255, 225, 152, 0.72);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.72), inset 0 0 28px rgba(214, 162, 74, 0.12);
  transform: translateY(18px) scale(0.96);
  transition: transform 180ms ease;
}

.modal-backdrop.is-open .modal {
  transform: translateY(0) scale(1);
}

.modal::before {
  content: "";
  position: absolute;
  inset: 10px;
  pointer-events: none;
  border: 1px solid rgba(214, 162, 74, 0.3);
}

.modal-sigil {
  margin-bottom: 8px;
  color: var(--gold-light);
  font-size: 2rem;
  text-shadow: 0 0 18px rgba(214, 162, 74, 0.75);
}

.modal h2 {
  margin: 0 0 10px;
  color: var(--gold-light);
  font-size: clamp(1.35rem, 3vw, 2rem);
  letter-spacing: 0.04em;
}

.modal p {
  margin: 0 0 24px;
  color: rgba(243, 229, 201, 0.82);
}

.modal-close {
  min-width: 132px;
  padding: 10px 18px;
  cursor: pointer;
  color: var(--black);
  background: linear-gradient(180deg, #ffe5a8, #c38432);
  border: 1px solid #ffe7ad;
  box-shadow: 0 0 20px rgba(214, 162, 74, 0.32);
  font-weight: bold;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.modal-close:hover,
.modal-close:focus-visible {
  outline: none;
  filter: brightness(1.12);
}

@media (max-width: 1020px) {
  body {
    overflow: auto;
  }

  .game-shell {
    height: auto;
    min-height: 100vh;
  }

  .map-stage {
    width: min(100%, calc((100vh - 270px) * 1.5));
  }

  .main-menu {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
  }
}

@media (max-width: 680px) {
  .game-shell {
    gap: 10px;
    padding: 12px;
  }

  .map-stage {
    width: min(100%, calc((100vh - 220px) * 1.5));
  }

  .hero-header h1 {
    font-size: clamp(1.45rem, 7vw, 2.35rem);
  }

  .main-menu {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
  }

  .menu-button {
    min-height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 7px 4px;
    line-height: 1.05;
  }

  .menu-button span {
    display: block;
    margin: 0;
    font-size: 1.1rem;
  }

  .credit {
    justify-self: center;
    text-align: center;
  }
}

@media (max-width: 430px) {
  .main-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.battlefield {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) 170px;
  gap: 12px;
  padding: 14px;
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 36%, rgba(88, 38, 20, 0.62), transparent 38%),
    radial-gradient(circle at 20% 80%, rgba(33, 79, 71, 0.28), transparent 28%),
    linear-gradient(145deg, #080604, #17100a 42%, #060404);
}

/* battle-main: players grid + decks column side by side */
.battle-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 12px;
  min-height: 0;
  overflow: hidden;
}

.battlefield[hidden] {
  display: none;
}

.battle-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 14px;
  border: 1px solid rgba(214, 162, 74, 0.5);
  background: rgba(8, 6, 5, 0.78);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.38);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--gold);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.battle-topbar h2 {
  margin: 0;
  color: var(--gold-light);
  font-size: clamp(1.35rem, 2.5vw, 2.25rem);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-shadow: 0 2px 12px #000;
}

.battle-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.socket-status {
  padding: 7px 10px;
  color: rgba(255, 230, 184, 0.86);
  border: 1px solid rgba(214, 162, 74, 0.28);
  background: rgba(0, 0, 0, 0.28);
  font-size: 0.82rem;
}

.battle-small-button {
  min-height: 34px;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--gold-light);
  background: linear-gradient(180deg, rgba(61, 38, 18, 0.98), rgba(11, 8, 6, 0.98));
  border: 1px solid rgba(214, 162, 74, 0.72);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.battle-small-button:hover,
.battle-small-button:focus-visible {
  outline: none;
  border-color: var(--gold-light);
  box-shadow: 0 0 18px rgba(214, 162, 74, 0.3);
}

.room-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(260px, 1.2fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid rgba(119, 82, 35, 0.7);
  background: rgba(12, 10, 8, 0.72);
}

.room-panel[hidden] {
  display: none;
}

.room-panel strong {
  display: block;
  color: var(--gold-light);
  text-transform: uppercase;
}

.room-panel p {
  margin: 3px 0 0;
  color: rgba(243, 229, 201, 0.78);
  font-size: 0.88rem;
}

.room-panel input {
  width: 100%;
  padding: 9px 10px;
  color: #ffe9b7;
  background: rgba(0, 0, 0, 0.46);
  border: 1px solid rgba(214, 162, 74, 0.45);
}

.battle-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  overflow: auto;
  padding-right: 4px;
}

.player-board {
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(214, 162, 74, 0.48);
  background:
    radial-gradient(circle at 50% 0%, rgba(214, 162, 74, 0.16), transparent 42%),
    linear-gradient(145deg, rgba(18, 14, 10, 0.96), rgba(5, 5, 5, 0.9));
  box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.55), 0 18px 34px rgba(0, 0, 0, 0.36);
}

.player-board.is-defeated {
  opacity: 0.48;
  filter: grayscale(0.8);
}

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.player-header strong {
  display: block;
  color: var(--gold-light);
  font-size: 1.05rem;
  text-transform: uppercase;
}

.player-header span {
  display: block;
  color: rgba(243, 229, 201, 0.68);
  font-size: 0.78rem;
}

.life-badge {
  flex: 0 0 auto;
  padding: 6px 8px;
  color: #ffe5e5 !important;
  border: 1px solid rgba(215, 74, 74, 0.65);
  background: rgba(91, 13, 13, 0.5);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 9px;
}

.stats-row span {
  padding: 5px 6px;
  text-align: center;
  color: rgba(255, 237, 200, 0.9);
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(214, 162, 74, 0.2);
  font-size: 0.78rem;
}

.deck-slots {
  display: grid;
  grid-template-columns: repeat(5, minmax(112px, 1fr));
  gap: 8px;
}

.card-slot {
  min-height: 188px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.4);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.58);
}

.card-slot.blue {
  border-color: rgba(85, 154, 255, 0.75);
}

.card-slot.green {
  border-color: rgba(86, 194, 106, 0.75);
}

.card-slot.red {
  border-color: rgba(220, 65, 55, 0.75);
}

.card-slot.purple {
  border-color: rgba(174, 95, 255, 0.75);
}

.card-slot.gray {
  border-color: rgba(165, 165, 165, 0.72);
}

.card-slot img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: #110d08;
}

.card-info,
.empty-card {
  display: grid;
  gap: 2px;
  padding: 7px;
  font-size: 0.72rem;
  line-height: 1.18;
}

.card-info strong,
.empty-card strong {
  color: var(--gold-light);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.card-info span,
.empty-card span {
  color: rgba(243, 229, 201, 0.78);
}

.empty-card {
  min-height: 188px;
  place-content: center;
  text-align: center;
  background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0 2px, transparent 2px 9px);
}

.battle-log {
  min-height: 0;
  padding: 10px;
  border: 1px solid rgba(214, 162, 74, 0.42);
  background: rgba(8, 6, 5, 0.84);
  overflow: hidden;
}

.battle-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.battle-log-header strong {
  color: var(--gold-light);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

#combatLog {
  height: 110px;
  overflow: auto;
}

#combatLog p {
  margin: 0 0 5px;
  color: rgba(243, 229, 201, 0.78);
  font-size: 0.88rem;
}

.combat-modal {
  width: min(720px, 100%);
}

.combat-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0;
}

.combat-choice {
  min-height: 106px;
  padding: 16px;
  cursor: pointer;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(214, 162, 74, 0.18), transparent 58%),
    linear-gradient(145deg, rgba(28, 18, 11, 0.98), rgba(7, 6, 5, 0.98));
  border: 1px solid rgba(214, 162, 74, 0.62);
  text-align: left;
}

.combat-choice strong {
  display: block;
  margin-bottom: 8px;
  color: var(--gold-light);
  font-size: 1.1rem;
  text-transform: uppercase;
}

.combat-choice span {
  color: rgba(243, 229, 201, 0.76);
}

.combat-choice:hover,
.combat-choice:focus-visible {
  outline: none;
  transform: translateY(-2px);
  border-color: var(--gold-light);
  box-shadow: 0 0 24px rgba(214, 162, 74, 0.3);
}

@media (max-width: 1180px) {
  .battle-grid {
    grid-template-columns: 1fr;
  }

  .deck-slots {
    grid-template-columns: repeat(5, minmax(98px, 1fr));
  }
}

@media (max-width: 760px) {
  .battlefield {
    position: absolute;
    min-height: 100vh;
    height: auto;
    overflow: auto;
    grid-template-rows: auto auto auto auto;
  }

  .battle-topbar,
  .room-panel {
    grid-template-columns: 1fr;
    display: grid;
  }

  .battle-actions {
    justify-content: start;
  }

  .deck-slots {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .combat-choice-grid {
    grid-template-columns: 1fr;
  }
}

.battlefield[hidden],
.room-panel[hidden] {
  display: none;
}

/* ── Initiative Inline Panel ──────────────────────────── */

.initiative-panel {
  padding: 10px 14px;
  border: 1px solid rgba(214, 162, 74, 0.6);
  background:
    radial-gradient(circle at 50% 0%, rgba(214, 162, 74, 0.1), transparent 55%),
    rgba(8, 6, 4, 0.88);
  box-shadow: 0 4px 18px rgba(0,0,0,0.4);
}

.initiative-panel[hidden] {
  display: none;
}

.initiative-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.initiative-panel-title {
  color: var(--gold-light);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.initiative-start-btn {
  background: linear-gradient(180deg, rgba(214,162,74,0.9), rgba(120,70,18,0.95)) !important;
  color: #0a0704 !important;
  font-weight: bold !important;
  border-color: var(--gold-light) !important;
  opacity: 1 !important;
}

.initiative-start-btn:disabled {
  opacity: 0.35 !important;
  cursor: default;
}

/* Grid of player D20 cards */
.initiative-inline-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.initiative-card {
  flex: 1 1 120px;
  max-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px;
  border: 1px solid rgba(214, 162, 74, 0.45);
  background: rgba(0,0,0,0.3);
}

.initiative-card.is-human {
  border-color: rgba(100, 180, 255, 0.65);
}

.initiative-card .player-label {
  color: var(--gold-light);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
}

.initiative-card .player-label.human-label {
  color: #82c8ff;
}

/* D20 die */
.d20-container {
  position: relative;
  width: 58px;
  height: 58px;
  cursor: pointer;
  flex-shrink: 0;
}

.d20-svg {
  width: 100%;
  height: 100%;
  transition: transform 0.15s ease, filter 0.15s ease;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.7));
}

.d20-container:not(.is-rolled):hover .d20-svg {
  transform: scale(1.1) rotate(-5deg);
  filter: drop-shadow(0 5px 14px rgba(214, 162, 74, 0.55));
}

.d20-container.is-rolling .d20-svg {
  animation: diceRoll 0.55s ease-in-out;
}

.d20-container.is-rolled .d20-svg {
  cursor: default;
}

@keyframes diceRoll {
  0%   { transform: rotate(0deg) scale(1); }
  20%  { transform: rotate(-32deg) scale(1.15); }
  45%  { transform: rotate(20deg) scale(0.9); }
  65%  { transform: rotate(-12deg) scale(1.07); }
  82%  { transform: rotate(6deg) scale(0.97); }
  100% { transform: rotate(0deg) scale(1); }
}

.d20-result {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Georgia, serif;
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--gold-light);
  text-shadow: 0 0 8px rgba(214, 162, 74, 0.9), 0 2px 4px #000;
  opacity: 0;
  transition: opacity 0.3s ease 0.45s;
  pointer-events: none;
}

.d20-container.is-rolled .d20-result {
  opacity: 1;
}

.d20-container.nat20 .d20-result {
  color: #ffd700;
  text-shadow: 0 0 14px rgba(255, 215, 0, 0.95), 0 2px 4px #000;
}

.d20-hint {
  font-size: 0.66rem;
  color: rgba(243, 229, 201, 0.5);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
}

.roll-btn {
  padding: 5px 10px;
  cursor: pointer;
  color: var(--black);
  background: linear-gradient(180deg, #ffe5a8, #c38432);
  border: 1px solid #ffe7ad;
  font-weight: bold;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 0 10px rgba(214, 162, 74, 0.3);
  transition: filter 0.15s ease, transform 0.1s ease;
}

.roll-btn:hover:not(:disabled) {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

.roll-btn:disabled {
  opacity: 0.38;
  cursor: default;
}

.ai-auto-badge {
  padding: 4px 8px;
  font-size: 0.68rem;
  color: rgba(243, 229, 201, 0.55);
  border: 1px solid rgba(214, 162, 74, 0.22);
  background: rgba(0, 0, 0, 0.22);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Inline order list */
.initiative-order-inline {
  margin-top: 8px;
  padding: 7px 12px;
  border: 1px solid rgba(214, 162, 74, 0.3);
  background: rgba(0,0,0,0.28);
}

.initiative-order-inline ol {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 20px;
}

.initiative-order-inline li {
  color: rgba(243, 229, 201, 0.82);
  font-size: 0.8rem;
  line-height: 1.6;
}

.initiative-order-inline li .order-score {
  color: var(--gold);
  font-weight: bold;
}

.initiative-order-inline li.is-first {
  color: var(--gold-light);
}

/* Active turn highlight on player boards */
.player-board.is-active-turn {
  border-color: rgba(255, 225, 100, 0.9);
  box-shadow: inset 0 0 22px rgba(0,0,0,0.55), 0 0 28px rgba(214, 162, 74, 0.42);
}

.player-board .turn-badge {
  display: none;
  padding: 3px 8px;
  color: var(--black);
  background: linear-gradient(90deg, #d6a24a, #ffe5a8);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: bold;
}

.player-board.is-active-turn .turn-badge {
  display: inline-block;
}

@media (max-width: 560px) {
  .initiative-inline-grid {
    gap: 8px;
  }
  .initiative-card {
    flex-basis: calc(50% - 4px);
    max-width: none;
  }
}

/* ── Battle layout: players + decks ──────────────────── */

.battle-grid {
  min-height: 0;
  overflow: auto;
}

.decks-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}

/* ── Deck stacks (Monte Valeth & Cemitério) ──────────── */
.deck-stack {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(214, 162, 74, 0.6);
  background:
    radial-gradient(circle at 50% 30%, rgba(214,162,74,0.18), transparent 60%),
    linear-gradient(160deg, rgba(28,18,6,0.98), rgba(8,6,4,0.98));
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  position: relative;
  overflow: hidden;
}

.deck-stack::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px dashed rgba(214,162,74,0.22);
  pointer-events: none;
}

.deck-stack:hover:not(.is-empty) {
  border-color: var(--gold-light);
  box-shadow: 0 0 22px rgba(214,162,74,0.45);
  transform: translateY(-2px);
}

.deck-stack.is-empty {
  opacity: 0.4;
  cursor: default;
  border-color: rgba(214,162,74,0.22);
}

.cemetery-deck {
  cursor: default;
  border-color: rgba(130, 60, 60, 0.65);
  background:
    radial-gradient(circle at 50% 30%, rgba(130,30,30,0.22), transparent 60%),
    linear-gradient(160deg, rgba(20,8,8,0.98), rgba(8,4,4,0.98));
}

.cemetery-deck::before {
  border-color: rgba(180,60,60,0.2);
}

.deck-stack-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  text-align: center;
}

.deck-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.deck-name {
  color: var(--gold-light);
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  display: block;
}

.cemetery-deck .deck-name { color: #d46060; }

.deck-count {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(214,162,74,0.55);
  background: rgba(0,0,0,0.45);
  color: var(--gold-light);
  font-size: 0.85rem;
  font-weight: bold;
  font-family: Georgia, serif;
}

.cemetery-deck .deck-count {
  border-color: rgba(180,60,60,0.55);
  color: #e88;
}

.deck-hint {
  color: rgba(243,229,201,0.45);
  font-size: 0.6rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.cemetery-preview {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 2px;
}

.cem-thumb {
  font-size: 0.9rem;
  opacity: 0.75;
}

/* ── Attack Total Row ────────────────────────────────── */
.attack-total-row {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 2px 8px;
  align-items: baseline;
  padding: 5px 8px;
  margin-bottom: 8px;
  border: 1px solid rgba(214,162,74,0.3);
  background: rgba(0,0,0,0.28);
}

.atk-label {
  color: rgba(243,229,201,0.6);
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  grid-column: 1;
  grid-row: 1;
}

.atk-value {
  color: var(--gold-light);
  font-size: 1.15rem;
  font-weight: bold;
  font-family: Georgia, serif;
  grid-column: 2;
  grid-row: 1;
  text-align: right;
}

.atk-breakdown {
  grid-column: 1 / -1;
  grid-row: 2;
  color: rgba(243,229,201,0.42);
  font-size: 0.64rem;
  letter-spacing: 0.04em;
}

/* ── Player badges ───────────────────────────────────── */
.player-badges {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.attack-badge {
  padding: 4px 7px;
  color: #ffe9a0;
  border: 1px solid rgba(214,162,74,0.55);
  background: rgba(60,38,8,0.6);
  font-size: 0.75rem;
  font-weight: bold;
}

/* ── Card Action Modal ───────────────────────────────── */
.card-action-modal {
  max-width: 680px;
  width: 100%;
  padding: 0;
  overflow: hidden;
}

.card-action-body {
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: 280px;
}

.card-action-img {
  width: 200px;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-action-info {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-action-category {
  color: var(--gold);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.card-action-info h2 {
  margin: 0;
  color: var(--gold-light);
  font-size: 1.3rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-action-info p {
  margin: 0;
  color: rgba(243,229,201,0.72);
  font-size: 0.85rem;
  line-height: 1.5;
}

.card-action-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0;
}

.card-action-stats span {
  padding: 4px 9px;
  border: 1px solid rgba(214,162,74,0.35);
  background: rgba(0,0,0,0.3);
  color: rgba(243,229,201,0.85);
  font-size: 0.78rem;
}

.card-action-stats strong {
  color: var(--gold-light);
}

.card-action-btns {
  display: flex;
  gap: 8px;
  margin-top: auto;
  flex-wrap: wrap;
}

.card-action-btn {
  flex: 1 1 auto;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: bold;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: filter 0.15s, transform 0.1s;
}

.card-action-btn.confirm {
  color: #0a0704;
  background: linear-gradient(180deg, #ffe5a8, #c38432);
  border: 1px solid #ffe7ad;
}

.card-action-btn.discard {
  color: rgba(243,229,201,0.75);
  background: rgba(60,10,10,0.7);
  border: 1px solid rgba(180,60,60,0.55);
}

.card-action-btn:hover { filter: brightness(1.12); transform: translateY(-1px); }

@media (max-width: 560px) {
  .card-action-body { grid-template-columns: 1fr; }
  .card-action-img  { width: 100%; height: 160px; }
  .battle-main { grid-template-columns: minmax(0,1fr) 90px; }
  .deck-count  { width: 28px; height: 28px; font-size: 0.75rem; }
  .deck-name   { font-size: 0.58rem; }
}
