:root {
  --gold: #f3c969;
  --gold-deep: #b7832c;
  --purple: #2a1245;
  --purple-deep: #160828;
  --ink: #f6ead2;
  --glow-blue: #6ab0ff;
  --glow-purple: #c27bff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--purple-deep) url("assets/background.webp") center / cover no-repeat;
  color: var(--ink);
  font-family: "Cinzel", Georgia, serif;
  user-select: none;
  -webkit-user-select: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(10, 4, 20, 0.05) 30%, rgba(10, 4, 20, 0.7) 100%);
  pointer-events: none;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
}
.screen.active { display: flex; }

/* ---------- Menu ---------- */
#menu {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2vh;
  padding: 16px;
}
.logo {
  width: min(88vw, 620px, 62vh);
  filter: drop-shadow(0 0 30px rgba(194, 123, 255, 0.45));
  animation: float 6s ease-in-out infinite;
}
@keyframes float {
  50% { transform: translateY(-10px); }
}
.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(80vw, 300px);
}
.hint {
  font-size: 14px;
  opacity: 0.75;
  letter-spacing: 0.06em;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.08em;
  color: var(--gold);
  text-shadow: 0 2px 2px rgba(0, 0, 0, 0.6);
  padding: 14px 22px;
  border-radius: 14px;
  border: 2px solid var(--gold-deep);
  background: linear-gradient(180deg, #4a2275 0%, var(--purple) 55%, var(--purple-deep) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 220, 150, 0.35), 0 6px 18px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.2s, border-color 0.2s;
}
.btn:hover {
  border-color: var(--gold);
  box-shadow: inset 0 1px 0 rgba(255, 220, 150, 0.45), 0 0 22px rgba(194, 123, 255, 0.55);
  transform: translateY(-2px);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn.small { font-size: 15px; padding: 10px 14px; border-radius: 10px; }

/* ---------- Game layout ---------- */
#game {
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 16px;
}
.panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(360px, 34vw);
}
.board-area {
  display: flex;
  align-items: center;
  justify-content: center;
}
#board {
  position: relative;
  aspect-ratio: 1302 / 1208;
  width: min(calc(100vw - min(360px, 34vw) - 72px), calc((100vh - 32px) * 1.078), 900px);
  touch-action: none;
  cursor: pointer;
}
.board-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.6));
  pointer-events: none;
}
#hl-layer, #piece-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

@media (orientation: portrait) {
  #game { flex-direction: column; gap: 8px; padding: 10px 8px; }
  .panel { width: min(96vw, 560px); }
  .scoreboard { width: min(64vw, 300px); }
  #board { width: min(96vw, calc((100vh - 330px) * 1.078)); }
}

/* ---------- Scoreboard ---------- */
.scoreboard {
  position: relative;
  width: 100%;
}
.scoreboard img { width: 100%; display: block; }
.score {
  position: absolute;
  top: 70%;
  transform: translate(-50%, -50%);
  font-weight: 900;
  font-size: clamp(22px, 3.4vw, 40px);
  color: var(--gold);
  text-shadow: 0 2px 0 #6b3d0d, 0 0 14px rgba(255, 200, 90, 0.5);
}
#score-wizards { left: 30.3%; }
#score-witches { left: 71.1%; }
.turn-glow {
  position: absolute;
  top: 24%;
  width: 22%;
  height: 22%;
  border-radius: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  transition: left 0.4s, background 0.4s;
  mix-blend-mode: screen;
  animation: pulse 1.8s ease-in-out infinite;
}
.turn-glow.w { left: 30.3%; background: radial-gradient(circle, rgba(106, 176, 255, 0.55), transparent 70%); }
.turn-glow.b { left: 71.1%; background: radial-gradient(circle, rgba(194, 123, 255, 0.55), transparent 70%); }
@keyframes pulse { 50% { opacity: 0.45; } }

.status {
  font-weight: 700;
  font-size: 18px;
  text-align: center;
  min-height: 1.4em;
  color: var(--gold);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}
.status.check { color: #ff8a8a; }

.tray {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 34px;
  width: 100%;
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(22, 8, 40, 0.55);
  border: 1px solid rgba(243, 201, 105, 0.25);
}
.tray img { height: 30px; margin: 0 -3px; }
@media (orientation: portrait) {
  .tray { min-height: 26px; }
  .tray img { height: 22px; }
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}
@media (orientation: portrait) {
  .controls { grid-template-columns: repeat(4, 1fr); }
  .btn.small { font-size: 13px; padding: 8px 4px; }
}

/* ---------- Board overlays ---------- */
.hl {
  position: absolute;
  border-radius: 6%;
}
.hl.last { background: rgba(243, 201, 105, 0.32); }
.hl.sel { box-shadow: inset 0 0 0 3px var(--glow-blue), inset 0 0 22px rgba(106, 176, 255, 0.8); }
.hl.check { background: radial-gradient(circle, rgba(255, 60, 60, 0.85), rgba(255, 60, 60, 0) 72%); }
.hl.move::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 28%; height: 30%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(150, 230, 140, 0.85);
  box-shadow: 0 0 12px rgba(120, 255, 140, 0.9);
}
.hl.capture { box-shadow: inset 0 0 0 4px rgba(120, 255, 140, 0.85), inset 0 0 18px rgba(120, 255, 140, 0.6); }

.piece {
  position: absolute;
  height: 14.5%;
  transform: translate(-50%, -100%);
  transition: left 0.28s ease, top 0.28s ease;
  filter: drop-shadow(0 6px 5px rgba(0, 0, 0, 0.55));
  pointer-events: none;
}
.piece.dragging {
  transition: none;
  z-index: 999 !important;
  filter: drop-shadow(0 16px 10px rgba(0, 0, 0, 0.6)) brightness(1.12);
}
.piece.instant { transition: none; }

/* ---------- Modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 2, 16, 0.6);
  backdrop-filter: blur(3px);
  z-index: 100;
  padding: 16px;
}
.modal.open { display: flex; }
.card {
  width: min(440px, 100%);
  padding: 22px 26px 24px;
  border-radius: 18px;
  border: 2px solid var(--gold-deep);
  background: linear-gradient(180deg, #3a1960, var(--purple-deep));
  box-shadow: 0 0 40px rgba(194, 123, 255, 0.35), 0 20px 50px rgba(0, 0, 0, 0.6);
  text-align: center;
}
.card h2 {
  margin: 0 0 14px;
  color: var(--gold);
  font-weight: 900;
  letter-spacing: 0.08em;
}
.card p { font-size: 17px; }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  font-size: 16px;
  border-bottom: 1px solid rgba(243, 201, 105, 0.15);
  text-align: left;
}
.row input[type="range"] { width: 48%; accent-color: var(--gold); }
.row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--gold); }
.row select {
  width: 48%;
  font-family: inherit;
  font-size: 14px;
  padding: 6px;
  color: var(--ink);
  background: var(--purple-deep);
  border: 1px solid var(--gold-deep);
  border-radius: 8px;
}
.note { font-size: 13px !important; opacity: 0.7; margin: 12px 0 0; }
.card-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
}
.promo-choices {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.promo-choices button {
  width: 76px;
  height: 120px;
  padding: 6px;
  border-radius: 12px;
  border: 2px solid var(--gold-deep);
  background: rgba(22, 8, 40, 0.8);
  cursor: pointer;
}
.promo-choices button:hover { border-color: var(--gold); box-shadow: 0 0 16px rgba(194, 123, 255, 0.6); }
.promo-choices img { height: 100%; }
