/**
 * battle-mode.css
 * 
 * Estilos harmoniosos, alegres, responsivos e infantis para o modo Batalha de Cores.
 * Paleta clara e acolhedora integrada ao tema do site (page-colorir-online).
 * Cartões brancos com sombras suaves, badges amigáveis, roleta de lápis 3D fluida.
 * 
 * Versão com melhorias completas de UX (Anel de timer SVG, Timer Flutuante e Banner de Turno).
 */

/* ─── Variáveis Globais de Tema Harmonizado ─── */
:root {
  --battle-primary-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  --battle-accent-gradient: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);

  --battle-p1-primary: #2563eb;
  --battle-p1-accent: #3b82f6;
  --battle-p1-bg: #eff6ff;
  --battle-p1-border: #bfdbfe;
  --battle-p1-glow: rgba(37, 99, 235, 0.25);

  --battle-p2-primary: #ea580c;
  --battle-p2-accent: #f97316;
  --battle-p2-bg: #fff7ed;
  --battle-p2-border: #fed7aa;
  --battle-p2-glow: rgba(234, 88, 12, 0.25);

  --battle-bg-overlay: rgba(15, 23, 42, 0.55);
  --battle-card-bg: #ffffff;
  --battle-card-border: #e2e8f0;
  --battle-card-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.16), 0 0 1px rgba(0, 0, 0, 0.1);

  --battle-text-main: #1e293b;
  --battle-text-muted: #64748b;
  --battle-text-light: #94a3b8;

  --battle-timer-green: #16a34a;
  --battle-timer-yellow: #d97706;
  --battle-timer-red: #dc2626;
}

/* ─── Fundo da Arena e Bloqueio de Overflow durante a Batalha ─── */
html.battle-mode-active,
body.battle-mode-active {
  max-width: 100vw !important;
  width: 100% !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
  background-color: #eef4fb !important;
  background-image: radial-gradient(#cbd5e1 1.5px, transparent 1.5px), radial-gradient(#bfdbfe 1.5px, #eef4fb 1.5px) !important;
  background-size: 28px 28px !important;
  background-position: 0 0, 14px 14px !important;
  transition: background-color 0.4s ease;
}

body.battle-mode-active * {
  box-sizing: border-box;
}

body.battle-mode-active .app-container {
  max-width: 100vw !important;
  width: 100% !important;
  overflow-x: hidden !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* ─── Botão de Entrada na Toolbar Principal ─── */
.btn-battle-entry {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, #c50000 0%, #a70000 50%, #ffcc14 100%);
  color: #ffffff !important;
  border: 2px solid #ffffff;
  padding: 8px 15px;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
  max-width: 150px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(255, 107, 107, 0.35);
  transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-decoration: none;
  user-select: none;
  font-family: inherit;
}

.btn-battle-entry:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 6px 20px rgba(255, 107, 107, 0.5);
  background: linear-gradient(135deg, #fa5252 0%, #fd7e14 50%, #ff922b 100%);
}

.btn-battle-entry:active {
  transform: translateY(0) scale(0.97);
}

.btn-battle-entry:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ─── Supressão Estrita de Ferramentas Normais, Toolbar Desktop e Pinte e Vista na Batalha ─── */
body.battle-mode-active .header-container,
body.battle-mode-active .controls,
body.battle-mode-active .color-palette,
body.battle-mode-active #colorPickerDiv,
body.battle-mode-active #colorPicker,
body.battle-mode-active #flags-mode,
body.battle-mode-active #toggleDrawMode,
body.battle-mode-active #toggleSoundButton,
body.battle-mode-active #toggleMusicModalButton,
body.battle-mode-active #toggleAchievementsButton,
body.battle-mode-active #toggleFullscreen,
body.battle-mode-active #desfazer,
body.battle-mode-active #limparCanvas,
body.battle-mode-active .pdf-dropdown-wrapper,
body.battle-mode-active #imprimirCanvas,
body.battle-mode-active #assinarRosto,
body.battle-mode-active #floating-color-bar,
body.battle-mode-active .tools-drawer,
body.battle-mode-active .mode-selection-overlay,
body.battle-mode-active #modeSelectionOverlay,
body.battle-mode-active .drawing-actions-overlay,
body.battle-mode-active .published-art-hero,
body.battle-mode-active .mobile-sheet-backdrop,
body.battle-mode-active #mobile-sheet-menu,
body.battle-mode-active #stickerModal,
body.battle-mode-active #adesivos-container,
body.battle-mode-active #pinte-e-vista-actions,
body.battle-mode-active #btn-pinte-e-vista-mockup,
body.battle-mode-active #btn-colorir-tudo,
body.battle-mode-active #mood-selector-container,
body.battle-mode-active #mockupModal,
body.battle-mode-active .caracteristicas-camisa,
body.battle-mode-active #fliperamaStandaloneBtn,
body.battle-mode-active #finalPublishBtn,
body.battle-mode-active #conditionalActionButton,
body.battle-mode-active #conditionalActionButton.mobile-below-canvas,
body.battle-mode-active #spacesCounterWrapper,
body.battle-mode-active #spacesCounterContainer,
body.battle-mode-active #progressBarContainer,
body.battle-mode-active #spacesCountValue,
body.battle-mode-active #difficultyLabel {
  display: none !important;
  pointer-events: none !important;
}

/* ─── Elementos Internos de Miniaturas (Idêntico ao Modo Normal) ─── */
.battle-tile-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  border-radius: inherit;
}

.battle-glitter-star {
  font-size: 1.3rem;
  color: #ffd700;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  line-height: 1;
  display: block;
}

/* ─── Item do Modo Batalha no Mobile Sheet Menu ─── */
.sheet-item--battle .sheet-item-icon {
  background: linear-gradient(135deg, #3b82f6 0%, #ea580c 100%) !important;
  color: #ffffff !important;
  font-size: 1.2rem;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.sheet-item--battle:hover {
  background: #f0f9ff;
}

.tile-lock {
  font-size: 1.2rem;
  color: #475569;
  pointer-events: none;
}

.tile-check {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #ffffff;
  font-weight: 900;
  font-size: 1.4rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.95), 0 0 8px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  z-index: 10;
  line-height: 1;
}

.pen-active-check {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #ffffff;
  font-weight: 900;
  font-size: 1.4rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.95), 0 0 8px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  z-index: 10;
  line-height: 1;
}

/* ─── Container Raiz da Batalha (battle-root) ─── */
.battle-root {
  position: relative;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  font-family: inherit;
  color: var(--battle-text-main);
  box-sizing: border-box;
  z-index: 100;
}

/* ─── Overlays e Modais da Batalha ─── */
.battle-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--battle-bg-overlay);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  box-sizing: border-box;
  animation: battleModalFadeIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.battle-overlay.battle-modal-fadeout {
  animation: battleModalFadeOut 0.25s ease-out forwards;
}

.battle-modal-card {
  background: var(--battle-card-bg);
  border: 1px solid var(--battle-card-border);
  border-radius: 24px;
  padding: 28px 24px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--battle-card-shadow);
  text-align: center;
  box-sizing: border-box;
  color: var(--battle-text-main);
}

.battle-card-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  color: #475569;
  padding: 4px 14px;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.battle-title {
  font-size: 1.85rem;
  font-weight: 900;
  color: #0f172a;
  margin: 0 0 6px 0;
  line-height: 1.25;
}

.battle-subtitle {
  color: var(--battle-text-muted);
  font-size: 1rem;
  margin: 0 0 20px 0;
  line-height: 1.5;
}

/* ─── Regras no Modal Intro ─── */
.battle-intro-rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
  text-align: left;
}

.battle-intro-rule-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 16px;
  border-radius: 16px;
}

.battle-intro-rule-card .rule-icon {
  font-size: 1.6rem;
  margin-bottom: 6px;
}

.battle-intro-rule-card.rule-p1 {
  border-left: 4px solid #2563eb;
}

.battle-intro-rule-card.rule-timer {
  border-left: 4px solid #f59e0b;
}

.battle-intro-rule-card.rule-win {
  border-left: 4px solid #16a34a;
}

.battle-intro-rule-card .rule-title {
  display: block;
  font-weight: 800;
  font-size: 0.95rem;
  color: #0f172a;
  margin-bottom: 4px;
}

.battle-intro-rule-card .rule-desc {
  font-size: 0.85rem;
  color: #64748b;
  line-height: 1.4;
}

/* ─── Botões Principais Harmonizados ─── */
.battle-btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff !important;
  border: none;
  padding: 13px 30px;
  border-radius: 9999px;
  font-size: 1.08rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  font-family: inherit;
}

.battle-btn-primary:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.45);
}

.battle-btn-primary:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.battle-btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.battle-btn-secondary {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  padding: 12px 22px;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.battle-btn-secondary:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.battle-btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: none;
  padding: 12px 24px;
  border-radius: 9999px;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
  transition: all 0.2s ease;
  font-family: inherit;
}

.battle-btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.4);
}

.battle-btn-outline {
  background: transparent;
  color: #64748b;
  border: 1px solid #cbd5e1;
  padding: 12px 22px;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.battle-btn-outline:hover {
  background: #f8fafc;
  color: #334155;
  border-color: #94a3b8;
}

/* ─── Modal de Escolha de Cores (Cardápio) ─── */
.battle-selection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 14px 18px;
  border-radius: 16px;
  transition: all 0.3s ease;
}

.battle-selection-header.p1 {
  background: var(--battle-p1-bg);
  border: 2px solid var(--battle-p1-border);
  color: var(--battle-p1-primary);
}

.battle-selection-header.p2 {
  background: var(--battle-p2-bg);
  border: 2px solid var(--battle-p2-border);
  color: var(--battle-p2-primary);
}

.battle-player-badge {
  font-size: 1.15rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 8px;
}

.battle-counter-badge {
  background: #ffffff;
  padding: 5px 14px;
  border-radius: 9999px;
  font-size: 0.9rem;
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.battle-selection-tip {
  font-size: 0.92rem;
  color: var(--battle-text-muted);
  margin-bottom: 14px;
}

.battle-color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 10px;
  max-height: 46vh;
  overflow-y: auto;
  padding: 8px 4px;
  margin-bottom: 20px;
}

.battle-color-tile {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  border: 2.5px solid #e2e8f0;
  cursor: pointer;
  position: relative;
  transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.06);
}

.battle-color-tile:hover:not(.reserved):not(.selected) {
  transform: scale(1.12);
  border-color: #0f172a;
  z-index: 5;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

.battle-color-tile.selected {
  border-color: #0f172a;
  box-shadow: 0 0 0 3px #ffffff, 0 6px 18px rgba(0, 0, 0, 0.3);
  transform: scale(1.08);
  z-index: 6;
}

.battle-color-tile.reserved {
  opacity: 0.32;
  cursor: not-allowed;
  filter: grayscale(85%);
  border-color: #cbd5e1;
}

.battle-color-tile.reserved::after {
  content: '🔒';
  font-size: 0.95rem;
}

/* ─── Roleta do Sorteio com Lápis 3D Realista ─── */
.battle-roulette-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 0;
}

.battle-roulette-target {
  padding: 6px 16px;
  border-radius: 9999px;
  font-weight: 800;
  font-size: 1.05rem;
  transition: all 0.3s ease;
}

.battle-roulette-target.target-p1 {
  background: var(--battle-p1-bg);
  color: var(--battle-p1-primary);
  border: 2px solid var(--battle-p1-border);
}

.battle-roulette-target.target-p2 {
  background: var(--battle-p2-bg);
  color: var(--battle-p2-primary);
  border: 2px solid var(--battle-p2-border);
}

.battle-roulette-target.is-winner-target {
  transform: scale(1.12);
  box-shadow: 0 0 18px currentColor;
}

.battle-roulette-stage {
  position: relative;
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 16px 0;
}

.battle-roulette-wheel-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 4px dashed #e2e8f0;
  background: radial-gradient(circle, #f8fafc 0%, #f1f5f9 100%);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.06), 0 4px 14px rgba(0, 0, 0, 0.05);
  box-sizing: border-box;
}

.battle-roulette-center-dot {
  position: absolute;
  width: 22px;
  height: 22px;
  background: linear-gradient(135deg, #fcd34d 0%, #f59e0b 100%);
  border: 3px solid #ffffff;
  border-radius: 50%;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* ─── Lápis 3D em Pivô Central ─── */
.battle-roulette-pencil {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 160px;
  margin-top: -80px;
  margin-left: -13px;
  transform-origin: 13px 80px;
  z-index: 5;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.25));
  will-change: transform;
}

/* Ponta de Grafite */
.pencil-tip-graphite {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 12px solid #1e293b;
  margin: 0 auto;
}

/* Madeira Apontada */
.pencil-wood-bevel {
  width: 0;
  height: 0;
  border-left: 13px solid transparent;
  border-right: 13px solid transparent;
  border-bottom: 24px solid #fed7aa;
  margin: -1px auto 0 auto;
}

/* Corpo Sextavado */
.pencil-body-hex {
  width: 26px;
  height: 90px;
  background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 35%, #fef08a 50%, #f59e0b 80%, #d97706 100%);
  border-radius: 2px;
  position: relative;
  margin: 0 auto;
  box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.15);
}

.pencil-stripe {
  position: absolute;
  top: 0;
  left: 35%;
  width: 30%;
  height: 100%;
  background: rgba(255, 255, 255, 0.35);
}

/* Virola Metálica */
.pencil-metal-ferrule {
  width: 26px;
  height: 14px;
  background: linear-gradient(90deg, #94a3b8 0%, #e2e8f0 40%, #f8fafc 60%, #64748b 100%);
  border-top: 1px solid #475569;
  border-bottom: 1px solid #475569;
  margin: 0 auto;
}

/* Borracha Rosa */
.pencil-eraser-cap {
  width: 26px;
  height: 20px;
  background: linear-gradient(90deg, #fb7185 0%, #fda4af 40%, #f43f5e 100%);
  border-radius: 0 0 8px 8px;
  margin: 0 auto;
}

.battle-roulette-announcement {
  font-size: 1.25rem;
  font-weight: 800;
  min-height: 36px;
  margin-top: 12px;
  color: var(--battle-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.battle-roulette-announcement.p1-won {
  color: var(--battle-p1-primary);
  animation: battleBounce 0.5s ease;
}

.battle-roulette-announcement.p2-won {
  color: var(--battle-p2-primary);
  animation: battleBounce 0.5s ease;
}

/* ─── HUD Superior durante a Partida ─── */
.battle-hud-wrapper {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  margin-bottom: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.battle-hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 10px 16px 8px 16px;
}

.battle-player-hud {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-radius: 14px;
  transition: all 0.25s ease;
  border: 2px solid transparent;
}

.battle-player-hud.p1 {
  justify-content: flex-start;
  background: #f8fafc;
}

.battle-player-hud.p2 {
  justify-content: flex-end;
  background: #f8fafc;
}

.battle-player-hud.p1.active {
  background: var(--battle-p1-bg);
  border-color: var(--battle-p1-primary);
  box-shadow: 0 0 14px var(--battle-p1-glow);
}

.battle-player-hud.p2.active {
  background: var(--battle-p2-bg);
  border-color: var(--battle-p2-primary);
  box-shadow: 0 0 14px var(--battle-p2-glow);
}

.battle-hud-avatar {
  font-size: 1.5rem;
  line-height: 1;
}

.battle-hud-name {
  font-weight: 800;
  font-size: 1rem;
  color: #0f172a;
}

.battle-hud-stats {
  font-size: 0.8rem;
  color: var(--battle-text-muted);
  font-weight: 600;
}

.battle-hud-score {
  font-size: 1.45rem;
  font-weight: 900;
  color: #0f172a;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.battle-hud-score span {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--battle-text-light);
}

/* ─── Timer com Anel Circular SVG ─── */
.battle-timer-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 90px;
}

.battle-timer-ring-wrap {
  position: relative;
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.battle-timer-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-ring-bg {
  fill: none;
  stroke: #f1f5f9;
  stroke-width: 4.5;
}

.timer-ring-fill {
  fill: none;
  stroke: var(--battle-timer-green);
  stroke-width: 4.5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.15s linear, stroke 0.3s ease;
}

.battle-timer-display {
  font-size: 1.6rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #0f172a;
  line-height: 1;
  z-index: 2;
  transition: color 0.3s ease;
}

.battle-timer-display.warning {
  color: var(--battle-timer-yellow);
}

.battle-timer-display.critical {
  color: var(--battle-timer-red);
  animation: battleTimerPulse 0.45s infinite alternate;
}

.battle-remaining-badge {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--battle-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 3px;
}

/* ─── Barra Linear de Progresso do Turno ─── */
.battle-turn-bar-container {
  width: 100%;
  height: 5px;
  background: #f1f5f9;
  position: relative;
}

.battle-turn-progress-bar {
  height: 100%;
  width: 100%;
  background-color: var(--battle-timer-green);
  transition: width 0.12s linear, background-color 0.3s ease;
}

/* ─── Paleta de Canetas Ativas com Cor do Jogador Corrente ─── */
.battle-pens-palette {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  margin: 12px 0;
  border-radius: 20px;
  transition: background 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
}

.battle-pens-palette.p1 {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 50%, #3b82f6 100%);
  border: 2.5px solid #93c5fd;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
}

.battle-pens-palette.p2 {
  background: linear-gradient(135deg, #c2410c 0%, #ea580c 50%, #f97316 100%);
  border: 2.5px solid #fdba74;
  box-shadow: 0 8px 24px rgba(234, 88, 12, 0.35);
}

.battle-pens-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 900;
  color: #ffffff !important;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.4px;
}

.battle-pens-items {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.battle-pen-item {
  width: 48px;
  height: 56px;
  border-radius: 14px;
  border: 3px solid #ffffff;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  outline: none;
  overflow: hidden;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
  padding: 0;
}

.battle-pen-item:hover:not(.active) {
  transform: translateY(-4px) scale(1.08);
  border-color: #ffffff;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.battle-pen-item.active {
  transform: translateY(-8px) scale(1.12);
  border-color: #ffffff;
  box-shadow: 0 0 0 3px #ffffff, 0 8px 22px rgba(0, 0, 0, 0.45);
  z-index: 4;
}

.battle-btn-abandon {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff !important;
  border: 1.5px solid rgba(255, 255, 255, 0.65);
  border-radius: 9999px;
  padding: 7px 16px;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  backdrop-filter: blur(4px);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.battle-btn-abandon:hover {
  background: #ffffff;
  color: #dc2626 !important;
  border-color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  text-shadow: none;
}

/* ─── Bloqueio e Congelamento Visual de Interação durante Transição ─── */
body.battle-transition-locked #paintCanvas,
body.battle-transition-locked #canvasContainer,
body.battle-transition-locked #battle-pens-container,
body.battle-transition-locked .battle-pen-item {
  pointer-events: none !important;
  cursor: wait !important;
}

.battle-transition-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: battleModalFadeIn 0.22s ease-out forwards;
  pointer-events: all;
  cursor: wait;
}

.battle-transition-overlay.fade-out {
  animation: battleModalFadeOut 0.25s ease-out forwards;
}

.battle-transition-card {
  background: #ffffff;
  padding: 24px 32px;
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25), 0 0 0 3px rgba(255, 255, 255, 0.8);
  border: 3px solid #e2e8f0;
  max-width: 90vw;
  width: 380px;
  animation: battleBounce 0.4s ease;
}

.battle-transition-card.p1 {
  border-color: var(--battle-p1-primary);
  background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%);
  box-shadow: 0 20px 50px rgba(37, 99, 235, 0.25);
}

.battle-transition-card.p2 {
  border-color: var(--battle-p2-primary);
  background: linear-gradient(180deg, #fff7ed 0%, #ffffff 100%);
  box-shadow: 0 20px 50px rgba(234, 88, 12, 0.25);
}

.battle-transition-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 4px 12px;
  border-radius: 9999px;
  margin-bottom: 10px;
  background: #0f172a;
  color: #ffffff;
}

.battle-transition-title {
  font-size: 1.45rem;
  font-weight: 900;
  color: #0f172a;
  margin-bottom: 6px;
}

.battle-transition-player {
  font-size: 1.2rem;
  font-weight: 900;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.battle-transition-player.p1 {
  color: var(--battle-p1-primary);
}

.battle-transition-player.p2 {
  color: var(--battle-p2-primary);
}

.battle-transition-countdown {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--battle-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.85);
  padding: 6px 14px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.battle-transition-spinner {
  width: 16px;
  height: 16px;
  border: 2.5px solid #cbd5e1;
  border-top-color: #0f172a;
  border-radius: 50%;
  animation: battleSpin 0.8s linear infinite;
}

@keyframes battleSpin {
  to {
    transform: rotate(360deg);
  }
}

/* ─── Toast / Banner de Troca de Turno ─── */
.battle-turn-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  background: #ffffff;
  padding: 12px 24px;
  border-radius: 9999px;
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.18), 0 0 0 3px rgba(255, 255, 255, 0.8);
  z-index: 999999;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 2px solid #e2e8f0;
  animation: turnToastIn 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  pointer-events: none;
}

.battle-turn-toast.p1 {
  border-color: var(--battle-p1-primary);
  box-shadow: 0 14px 35px rgba(37, 99, 235, 0.25);
}

.battle-turn-toast.p2 {
  border-color: var(--battle-p2-primary);
  box-shadow: 0 14px 35px rgba(234, 88, 12, 0.25);
}

.battle-turn-toast.fade-out {
  animation: turnToastOut 0.25s ease-out forwards;
}

.turn-toast-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.turn-toast-icon {
  font-size: 1.6rem;
}

.turn-toast-text {
  text-align: left;
}

.turn-toast-title {
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: var(--battle-text-muted);
}

.turn-toast-player {
  font-size: 1.1rem;
  font-weight: 800;
  color: #0f172a;
}

/* ─── Timer Flutuante / Sticky Pill (Ao rolar a página) ─── */
.battle-sticky-timer-pill {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #ffffff;
  border: 2px solid #0f172a;
  border-radius: 9999px;
  padding: 8px 18px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  z-index: 99998;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.battle-sticky-timer-pill.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.battle-sticky-timer-pill:hover {
  transform: scale(1.05);
}

.sticky-pbadge {
  font-weight: 800;
  font-size: 0.95rem;
  padding: 2px 8px;
  border-radius: 8px;
}

.sticky-pbadge.p1 {
  background: var(--battle-p1-bg);
  color: var(--battle-p1-primary);
}

.sticky-pbadge.p2 {
  background: var(--battle-p2-bg);
  color: var(--battle-p2-primary);
}

.sticky-time {
  font-size: 1.15rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #0f172a;
}

.sticky-scroll-btn {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--battle-text-muted);
}

/* ─── Feedback de Rejeição de Área Bloqueada ─── */
.battle-rejected-feedback {
  animation: battleShake 0.4s ease-in-out;
}

/* ─── Keyframe Animations ─── */
@keyframes battleModalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes battleModalFadeOut {
  from {
    opacity: 1;
    transform: scale(1);
  }

  to {
    opacity: 0;
    transform: scale(0.96);
  }
}

@keyframes turnToastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px) scale(0.85);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

@keyframes turnToastOut {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }

  to {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px) scale(0.9);
  }
}

@keyframes battleBounce {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.12);
  }
}

@keyframes battleTimerPulse {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.14);
  }
}

@keyframes battleShake {

  0%,
  100% {
    transform: translateX(0);
  }

  20%,
  60% {
    transform: translateX(-6px);
  }

  40%,
  80% {
    transform: translateX(6px);
  }
}

/* ─── Acessibilidade: prefers-reduced-motion ─── */
@media (prefers-reduced-motion: reduce) {

  .battle-overlay,
  .battle-roulette-pencil,
  .battle-timer-display.critical,
  .battle-rejected-feedback,
  .battle-turn-toast {
    animation: none !important;
    transition: none !important;
  }
}

/* ─── Responsividade Mobile e Telas Estreitas (320px - 768px) ─── */
@media (max-width: 768px) {
  .battle-root {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 4px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
  }

  .battle-hud-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 6px;
    border-radius: 14px;
  }

  .battle-hud {
    grid-template-columns: 1fr auto 1fr;
    gap: 4px;
    padding: 6px 6px;
    width: 100%;
    box-sizing: border-box;
  }

  .battle-player-hud {
    flex-direction: column;
    padding: 4px 6px;
    gap: 4px;
    min-width: 0;
    overflow: hidden;
    border-radius: 10px;
  }

  .battle-hud-avatar {
    font-size: 1.15rem;
  }

  .battle-hud-info {
    min-width: 0;
    overflow: hidden;
  }

  .battle-hud-name {
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70px;
  }

  .battle-hud-stats {
    font-size: 0.65rem;
    white-space: nowrap;
    overflow: hidden;
  }

  .battle-hud-score {
    font-size: 1.05rem;
  }

  .battle-timer-box {
    min-width: 50px;
  }

  .battle-timer-ring-wrap {
    width: 44px;
    height: 44px;
  }

  .battle-timer-display {
    font-size: 1.2rem;
  }

  .battle-remaining-badge {
    font-size: 0.6rem;
  }

  #battle-pens-container {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .battle-pens-palette {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 8px 10px;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 14px;
    box-sizing: border-box !important;
  }

  .battle-pens-label {
    justify-content: center;
    font-size: 0.85rem;
  }

  .battle-pens-items {
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    width: 100%;
  }

  .battle-pen-item {
    width: 38px;
    height: 46px;
    flex-shrink: 0;
  }

  .battle-btn-abandon {
    align-self: center;
    padding: 5px 12px;
    font-size: 0.78rem;
  }

  .battle-modal-card {
    padding: 16px 12px;
    max-width: calc(100vw - 16px);
    width: 100%;
    box-sizing: border-box;
    border-radius: 18px;
  }

  .battle-title {
    font-size: 1.45rem;
  }

  .battle-subtitle {
    font-size: 0.88rem;
    margin-bottom: 12px;
  }

  .battle-intro-rules-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 16px;
  }

  .battle-intro-rule-card {
    padding: 10px 12px;
  }

  .battle-selection-header {
    padding: 8px 10px;
  }

  .battle-color-grid {
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 6px;
    padding: 2px;
  }

  .battle-transition-card {
    padding: 16px 14px;
    max-width: calc(100vw - 20px);
    width: 330px;
    box-sizing: border-box;
  }

  .battle-turn-toast {
    max-width: calc(100vw - 24px);
    padding: 8px 14px;
  }

  .battle-sticky-timer-pill {
    bottom: 12px;
    right: 12px;
    padding: 6px 12px;
    max-width: calc(100vw - 24px);
  }
}