/* ============================================================
   DAMAS HELENA — styles.css
   Visual "big tech", mobile-first, colorido e alegre.
   A4 (UI/UX) + A5 (cores) + A7 (2D/3D) — fábrica da Helena.
   ============================================================ */

/* ---------- Tokens (sobrescritos em runtime pelo JS) ---------- */
:root {
  --p1: #ff5fa2;          /* peça jogador 1 (rosa)  */
  --p2: #3aa0ff;          /* peça jogador 2 (azul)  */
  --board-light: #f3e7d3; /* casa clara             */
  --board-dark: #7a4f9e;  /* casa escura            */
  --bg: #150a22;          /* fundo                  */
  --accent: #ff5fa2;      /* destaque               */

  /* derivados de acabamento */
  --glass: rgba(255, 255, 255, .07);
  --glass-strong: rgba(255, 255, 255, .12);
  --stroke: rgba(255, 255, 255, .16);
  --radius: 18px;
  --radius-lg: 26px;
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-pop: 0 18px 50px rgba(0, 0, 0, .5);
  --ink: #f6f2ff;
  --ink-dim: rgba(246, 242, 255, .62);
}

/* ---------- Reset / base ---------- */
* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  /* fundo vibrante e escuro derivado de var(--bg) e var(--accent) */
  background:
    radial-gradient(1200px 700px at 15% -10%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 60%),
    radial-gradient(1000px 800px at 110% 20%, color-mix(in srgb, var(--p2) 22%, transparent), transparent 55%),
    radial-gradient(900px 900px at 50% 120%, color-mix(in srgb, var(--board-dark) 30%, transparent), transparent 60%),
    linear-gradient(160deg, var(--bg), color-mix(in srgb, var(--bg) 70%, #000));
  background-attachment: fixed;
}

/* ---------- Header / título ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  text-align: center;
  padding: 14px 12px 10px;
  backdrop-filter: blur(10px);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 65%, transparent), transparent);
}

#title { margin: 0; line-height: 1.05; }

.title-main {
  display: block;
  font-size: clamp(28px, 7vw, 46px);
  font-weight: 900;
  letter-spacing: .5px;
  background: linear-gradient(90deg, var(--p1), var(--p2) 55%, var(--board-dark));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 26px color-mix(in srgb, var(--accent) 45%, transparent);
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .4));
}

.title-sub {
  display: block;
  margin-top: 2px;
  font-size: clamp(12px, 3.4vw, 16px);
  font-style: italic;
  font-weight: 500;
  color: var(--ink-dim);
  text-shadow: 0 0 14px color-mix(in srgb, var(--p2) 40%, transparent);
}

/* ---------- Layout responsivo ---------- */
.layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 18px 14px 40px;
  max-width: 1100px;
  margin: 0 auto;
}

@media (min-width: 900px) {
  .layout {
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 28px;
  }
}

/* ---------- Board wrap + HUD ---------- */
.board-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.hud {
  display: flex;
  gap: 10px;
  width: min(94vw, 560px);
  justify-content: space-between;
}

.hud-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 8px;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-soft);
}

.hud-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--ink-dim);
}

.hud-val {
  font-size: clamp(14px, 3.6vw, 18px);
  font-weight: 800;
}

#turn-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  vertical-align: middle;
  box-shadow: 0 0 10px currentColor;
}

/* ---------- Stage / tabuleiro ---------- */
.stage {
  position: relative;
  transition: transform .4s ease;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: min(94vw, 70vh, 560px);
  aspect-ratio: 1 / 1;
  overflow: hidden;                 /* cantos arredondados do tabuleiro */
  border-radius: 16px;
  border: 3px solid color-mix(in srgb, var(--board-dark) 60%, #000);
  box-shadow: var(--shadow-pop), inset 0 0 0 2px rgba(255, 255, 255, .06);
  touch-action: manipulation;
  transition: transform .4s ease, box-shadow .4s ease;
}

/* ---------- Células ---------- */
.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.cell.light { background: var(--board-light); }
.cell.dark  { background: var(--board-dark); }

/* casa da peça selecionada — anel/brilho de destaque */
.cell.selected {
  box-shadow:
    inset 0 0 0 4px var(--accent),
    inset 0 0 22px color-mix(in srgb, var(--accent) 60%, transparent);
  z-index: 2;
}

/* casa de destino legal — marcador pulsante central */
.cell.target::before {
  content: "";
  position: absolute;
  width: 34%;
  height: 34%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%,
              color-mix(in srgb, var(--accent) 90%, #fff),
              var(--accent));
  box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 80%, transparent);
  animation: target-pulse 1.1s ease-in-out infinite;
}

@keyframes target-pulse {
  0%, 100% { transform: scale(.7); opacity: .55; }
  50%      { transform: scale(1.05); opacity: 1; }
}

/* ---------- Peças ---------- */
.piece {
  width: 78%;
  height: 78%;
  border-radius: 50%;
  position: relative;
  border: 2px solid rgba(0, 0, 0, .22);
  box-shadow:
    0 6px 12px rgba(0, 0, 0, .4),
    inset 0 2px 4px rgba(255, 255, 255, .55),
    inset 0 -6px 10px rgba(0, 0, 0, .35);
  transition: transform .2s ease, box-shadow .25s ease, filter .2s ease;
  will-change: transform;
}

/* relevo: claro no topo-esquerda, escuro embaixo */
.piece.p1 {
  background: radial-gradient(circle at 32% 28%,
              color-mix(in srgb, var(--p1) 55%, #fff),
              var(--p1) 55%,
              color-mix(in srgb, var(--p1) 60%, #000));
}

.piece.p2 {
  background: radial-gradient(circle at 32% 28%,
              color-mix(in srgb, var(--p2) 55%, #fff),
              var(--p2) 55%,
              color-mix(in srgb, var(--p2) 60%, #000));
}

.piece:hover { transform: scale(1.05); }

/* peça selecionada — leve elevação */
.piece.sel {
  transform: scale(1.08);
  box-shadow:
    0 12px 22px rgba(0, 0, 0, .5),
    inset 0 2px 4px rgba(255, 255, 255, .6),
    0 0 18px color-mix(in srgb, var(--accent) 70%, transparent);
}

/* dama — emblema de coroa dourada */
.piece.king::after {
  content: "★";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 52%;
  color: #ffd76a;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .55), 0 0 10px rgba(255, 200, 70, .8);
}

.piece.king {
  border-color: #ffd76a;
  box-shadow:
    0 6px 14px rgba(0, 0, 0, .45),
    inset 0 2px 4px rgba(255, 255, 255, .55),
    inset 0 0 0 3px rgba(255, 215, 106, .8),
    0 0 16px rgba(255, 200, 70, .5);
}

/* ============================================================
   2D vs 3D
   ============================================================ */

/* --- 2D: visão de cima, plano --- */
.mode-2d #board { transform: none; }

/* --- 3D: tabuleiro inclinado com profundidade --- */
.mode-3d.stage,
.mode-3d #stage { perspective: 1100px; }

.mode-3d #board {
  transform: rotateX(52deg) rotateZ(0deg);
  transform-style: preserve-3d;
  box-shadow:
    0 60px 80px rgba(0, 0, 0, .6),
    var(--shadow-pop);
}

/* peças "em pé" e flutuando no 3D */
.mode-3d .piece {
  transform: rotateX(-52deg) translateZ(10px);
  box-shadow:
    0 16px 22px rgba(0, 0, 0, .6),
    inset 0 2px 4px rgba(255, 255, 255, .55),
    inset 0 -6px 10px rgba(0, 0, 0, .35);
}

.mode-3d .piece.sel { transform: rotateX(-52deg) translateZ(20px) scale(1.05); }
.mode-3d .piece:hover { transform: rotateX(-52deg) translateZ(16px) scale(1.04); }

/* ============================================================
   Panel (glassmorphism)
   ============================================================ */
.panel {
  width: min(94vw, 420px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--glass);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-pop);
}

@media (min-width: 900px) {
  .panel { position: sticky; top: 92px; }
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--glass-strong);
  border: 1px solid var(--stroke);
}

.group-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  font-weight: 700;
  color: var(--ink-dim);
}

/* ---------- Segmented control ---------- */
.seg {
  display: flex;
  gap: 6px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .25);
  border: 1px solid var(--stroke);
}

.seg-btn {
  flex: 1;
  border: none;
  cursor: pointer;
  padding: 9px 10px;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: transparent;
  transition: transform .15s ease, background .2s ease, box-shadow .2s ease;
}

.seg-btn small {
  display: block;
  font-size: .7em;
  font-weight: 500;
  opacity: .8;
}

.seg-btn.active {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 50%, var(--p2)));
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 45%, transparent);
}

.seg-btn:active { transform: scale(.96); }

/* ---------- Linha nível da IA ---------- */
.ai-level-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}

#ai-level {
  font-weight: 900;
  font-size: 1.1em;
  padding: 4px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--p2), var(--accent));
  box-shadow: 0 4px 12px rgba(0, 0, 0, .35);
}

/* ---------- Linha de cor ---------- */
.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}

input[type=color] {
  width: 44px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35), inset 0 0 0 2px var(--stroke);
}
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: none; border-radius: 6px; }

/* ---------- Botões ---------- */
.btn {
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--glass-strong);
  border: 1px solid var(--stroke);
  transition: transform .15s ease, box-shadow .2s ease, filter .2s ease;
}

.btn:hover { transform: scale(1.03); filter: brightness(1.08); }
.btn:active { transform: scale(.97); }

.btn.primary {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 45%, var(--p2)));
  border-color: transparent;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 45%, transparent);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--stroke);
}

.btn.toggle.active {
  background: linear-gradient(135deg, var(--p2), var(--accent));
  border-color: transparent;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--p2) 40%, transparent);
}

.btn.big {
  padding: 16px 20px;
  font-size: 1.08em;
  border-radius: 16px;
}

/* ---------- Scoreboard ---------- */
.scoreboard {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--glass-strong);
  border: 1px solid var(--stroke);
  font-weight: 700;
}

.dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  box-shadow: 0 0 10px currentColor;
}
.dot.d1 { background: var(--p1); color: var(--p1); }
.dot.d2 { background: var(--p2); color: var(--p2); }

.score-num {
  font-size: 1.5em;
  font-weight: 900;
}

/* ---------- Balão da Helena ---------- */
.helena-bubble {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 40;
  max-width: min(86vw, 360px);
  padding: 12px 16px;
  border-radius: 18px;
  font-weight: 600;
  color: var(--ink);
  background: linear-gradient(135deg,
              color-mix(in srgb, var(--accent) 30%, var(--bg)),
              color-mix(in srgb, var(--p2) 30%, var(--bg)));
  border: 1px solid var(--stroke);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-pop);
  animation: bubble-in .35s ease;
}

/* cantinho do balão */
.helena-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  transform: translateX(-50%) rotate(45deg);
  width: 16px;
  height: 16px;
  background: inherit;
  border-right: 1px solid var(--stroke);
  border-bottom: 1px solid var(--stroke);
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(.95); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

[hidden] { display: none !important; }

/* ============================================================
   Overlay de vitória
   ============================================================ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 4, 20, .6);
  backdrop-filter: blur(14px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .35s ease, visibility .35s ease;
}

.overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.overlay-card {
  text-align: center;
  padding: 34px 30px;
  border-radius: var(--radius-lg);
  background: var(--glass);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-pop);
  transform: scale(.7);
  transition: transform .4s cubic-bezier(.18, 1.25, .4, 1);
}

.overlay.show .overlay-card { transform: scale(1); animation: card-zoom .5s ease; }

@keyframes card-zoom {
  0%   { transform: scale(.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.overlay-text {
  margin: 0;
  font-size: clamp(34px, 10vw, 72px);
  font-weight: 900;
  letter-spacing: 1px;
  background: linear-gradient(90deg, var(--p1), var(--accent) 50%, var(--p2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 30px color-mix(in srgb, var(--accent) 50%, transparent);
  animation: text-pop 1.4s ease-in-out infinite;
}

@keyframes text-pop {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25%      { transform: scale(1.06) rotate(-1.5deg); }
  75%      { transform: scale(1.06) rotate(1.5deg); }
}

#overlay-sub {
  margin-top: 12px;
  font-size: clamp(14px, 4vw, 20px);
  color: var(--ink-dim);
}

/* ============================================================
   Balões (confete de comemoração)
   ============================================================ */
.balloons {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  overflow: hidden;
}

.balloon {
  position: absolute;
  bottom: -120px;
  width: 42px;
  height: 54px;
  border-radius: 50% 50% 48% 48%;
  background: radial-gradient(circle at 35% 28%,
              color-mix(in srgb, var(--c, var(--accent)) 40%, #fff),
              var(--c, var(--accent)) 60%,
              color-mix(in srgb, var(--c, var(--accent)) 70%, #000));
  box-shadow: inset -4px -6px 10px rgba(0, 0, 0, .25), 0 6px 14px rgba(0, 0, 0, .3);
  animation: balloon-rise var(--d, 4s) ease-in var(--delay, 0s) forwards;
}

/* nó embaixo */
.balloon::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 8px solid var(--c, var(--accent));
}

/* fiozinho + estouro (raios/confete) */
.balloon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  width: 1px;
  height: 40px;
  background: rgba(255, 255, 255, .4);
}

/* subida com leve oscilação X */
@keyframes balloon-rise {
  0%   { transform: translateY(0) translateX(0); opacity: 0; }
  10%  { opacity: 1; }
  50%  { transform: translateY(-55vh) translateX(18px); }
  90%  { opacity: 1; }
  100% { transform: translateY(-110vh) translateX(-10px); opacity: 0; }
}

/* estouro disparado pelo JS (classe .pop) */
.balloon.pop {
  animation: balloon-pop .35s ease forwards;
}

@keyframes balloon-pop {
  0%   { transform: scale(1); opacity: 1; }
  40%  { transform: scale(1.4); opacity: .9; filter: brightness(1.6); }
  100% { transform: scale(0); opacity: 0; }
}

/* raios de confete no estouro */
.balloon.pop::after {
  content: "";
  height: 0;
  width: 0;
  box-shadow:
    14px -4px 0 2px var(--c, var(--accent)),
    -14px -4px 0 2px var(--c, var(--accent)),
    0 -16px 0 2px var(--c, var(--accent)),
    10px 10px 0 2px var(--c, var(--accent)),
    -10px 10px 0 2px var(--c, var(--accent));
  animation: confetti-burst .35s ease forwards;
}

@keyframes confetti-burst {
  from { opacity: 1; transform: translateX(-50%) scale(.4); }
  to   { opacity: 0; transform: translateX(-50%) scale(1.6); }
}

/* ============================================================
   Acessibilidade — reduzir movimento
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .board, .stage { transition: none; }
}
