/* ====================================================================
   PAINEL DE SORTEIO DAS UNIDADES FEDERATIVAS — PNRA
   Identidade Visual: Instituto Federal Goiano & Ministério da Educação
   Paleta: Botânica Natural (Jacarandá & Pau-Brasil)
   ==================================================================== */

:root {
  /* Tons Orgânicos Quentes de Marfim, Linho e Pergaminho Natural */
  --bg-base: #FDFCF8;
  --bg-mid: #F5F1E8;
  --bg-deep: #EBE5D8;
  
  /* Jacarandá (Roxos e Lilás) */
  --jacaranda-deep: #3A1864;
  --jacaranda-mid: #522588;
  --jacaranda-light: #8B5CF6;
  --jacaranda-lilac: #B084E9;
  
  /* Pau-Brasil (Verdes e Ouro Floral) */
  --paubrasil-forest: #143823;
  --paubrasil-green: #1B4D31;
  --paubrasil-leaf: #3A7D44;
  --paubrasil-gold: #F5BA13;
  --paubrasil-red: #D93829;
  
  /* Estrutura e Superfícies Neutras Quentes */
  --border-sand: #D8CEBC;
  --border-light: #E8E2D5;
  --surface-pearl: rgba(255, 254, 250, 0.95);
  --text-dark: #222B25;
  --text-muted: #5A564A;
  
  /* Cor dinâmica da UF sorteada (definida via JS) */
  --uf-color: #0284C7;
  --uf-color-glow: rgba(2, 132, 199, 0.35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  color: var(--text-dark);
  background: radial-gradient(circle at 50% 15%, var(--bg-base) 0%, var(--bg-mid) 50%, var(--bg-deep) 100%);
  user-select: none;
}

/* ====================================================================
   FLORAS BOTÂNICAS EM SOFT BLUR (3px) E TRANSPARÊNCIA NÍTIDA (0.35)
   ==================================================================== */
.flora-ambient-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.flora-node {
  position: absolute;
  opacity: 0.35;
  filter: blur(3px);
  pointer-events: none;
}

.flora-top-left {
  top: -30px;
  left: -20px;
  width: 390px;
  transform: rotate(-12deg);
}

.flora-top-right {
  top: -25px;
  right: -15px;
  width: 370px;
  transform: rotate(20deg);
}

.flora-bottom-left {
  bottom: -15px;
  left: -30px;
  width: 450px;
  transform: rotate(12deg);
}

.flora-bottom-right {
  bottom: -20px;
  right: -25px;
  width: 430px;
  transform: rotate(-20deg);
}

.flora-mid-left {
  top: 40%;
  left: -70px;
  width: 330px;
  opacity: 0.28;
  filter: blur(4px);
  transform: rotate(40deg);
}

.flora-mid-right {
  top: 36%;
  right: -60px;
  width: 340px;
  opacity: 0.28;
  filter: blur(4px);
  transform: rotate(-30deg);
}

/* Brilhos Ambientais Quentes */
.ambient-glow-1 {
  position: fixed;
  top: -100px;
  left: 15%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(245, 186, 19, 0.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.ambient-glow-2 {
  position: fixed;
  bottom: -120px;
  right: 15%;
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, rgba(20, 56, 35, 0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ====================================================================
   CONTAINER PRINCIPAL FULL-VIEWPORT
   ==================================================================== */
.app-container {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 1820px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

/* ====================================================================
   CABEÇALHO INSTITUCIONAL COMPACTO (WARM PEARL)
   ==================================================================== */
.main-header {
  width: 100%;
  background: var(--surface-pearl);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-sand);
  border-radius: 16px;
  padding: 6px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 16px -2px rgba(45, 35, 20, 0.05);
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo-symbol {
  height: 48px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.08));
}

.brand-divider {
  width: 2px;
  height: 38px;
  background: linear-gradient(180deg, #E5DFD2, #CFC5B2, #E5DFD2);
}

.brand-titles h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 17px;
  font-weight: 800;
  color: #1A2E22;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  line-height: 1.15;
}

.brand-titles p.subtitle {
  font-size: 9.5px;
  font-weight: 700;
  color: #4A463B;
  margin-top: 2px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--paubrasil-green) 0%, var(--paubrasil-forest) 100%);
  color: #FFFFFF;
  border: 1.5px solid rgba(245, 186, 19, 0.45);
  padding: 7px 16px;
  border-radius: 10px;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 3px 10px rgba(20, 56, 35, 0.22);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(20, 56, 35, 0.3);
  border-color: var(--paubrasil-gold);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: #FAF8F2;
  border: 1.5px solid #D6CEBD;
  padding: 6px 13px;
  border-radius: 9px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 12px;
  color: #2D332D;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: #FFFFFF;
  border-color: #B5AB98;
  transform: translateY(-1px);
}

.btn-secondary.active {
  background: #EEF4E8;
  border-color: #88C477;
  color: #1B4D31;
}

.counter-badge {
  background: linear-gradient(135deg, #F9F7EE, #EEF4E8);
  border: 1.5px solid #C4DAB8;
  padding: 4px 12px;
  border-radius: 9px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.counter-badge .count {
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 900;
  color: var(--paubrasil-forest);
  line-height: 1;
}

.counter-badge .label {
  font-size: 8.5px;
  font-weight: 800;
  color: #2F5938;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ====================================================================
   TABULEIRO DE CARTAS: 9 COLUNAS X 3 LINHAS PREENCHENDO TODO O ESPAÇO
   ==================================================================== */
.board-wrapper {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 4px 0;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(3, 1fr);
  column-gap: clamp(10px, 1.3vw, 22px);
  row-gap: clamp(6px, 1vh, 12px);
  width: 100%;
  max-width: 1780px;
  height: 100%;
  max-height: calc(100vh - 142px);
  justify-items: center;
  align-items: center;
}

/* Componente Carta: Proporção 655 : 1024 Sem Nenhum Corte */
.card-item {
  position: relative;
  perspective: 1200px;
  cursor: pointer;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  aspect-ratio: 655 / 1024;
  height: 100%;
  max-height: calc((100vh - 165px) / 3);
  max-width: 165px;
  width: auto;
  margin: 0 auto;
  will-change: transform;
}

/* Hover do Usuário com Prioridade e Elevação Nobre */
.card-item:hover {
  transform: translateY(-9px) scale(1.05) !important;
  z-index: 25 !important;
  animation: none !important;
}

.card-item:hover .card-inner {
  box-shadow: 0 18px 32px -4px rgba(20, 56, 35, 0.38), 0 0 20px rgba(245, 186, 19, 0.28);
}

/* ====================================================================
   DINÂMICA DE MOVIMENTO E ELEVAÇÃO ORGÂNICA DAS CARTAS (PADRÕES)
   ==================================================================== */
@keyframes cardAmbientWave {
  0% {
    transform: translateY(0) scale(1);
  }
  38% {
    transform: translateY(-8px) scale(1.042);
    z-index: 12;
  }
  70% {
    transform: translateY(-2px) scale(1.012);
  }
  100% {
    transform: translateY(0) scale(1);
    z-index: 1;
  }
}

.card-item.ambient-wave {
  animation: cardAmbientWave 1.35s cubic-bezier(0.34, 1.45, 0.64, 1) forwards;
}

.card-item.ambient-wave .card-inner {
  box-shadow: 0 16px 28px -4px rgba(25, 30, 25, 0.32), 0 0 16px rgba(245, 186, 19, 0.22);
}

.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  border-radius: 8px;
  box-shadow: 0 10px 22px -5px rgba(25, 30, 25, 0.25);
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-item.flipped .card-inner {
  transform: rotateY(180deg);
}

/* Verso da Carta: 100% Inteiro com Arte Botânica */
.card-back {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
}

.card-back img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
}

.card-number-badge {
  position: absolute;
  top: 52%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border: 3px solid #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.card-number-badge .num {
  font-family: 'Outfit', sans-serif;
  font-size: 21px;
  font-weight: 900;
  line-height: 1;
  color: #0f274a;
}

.card-item.theme-jacaranda .card-number-badge {
  border-color: #a78bfa;
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.5), 0 6px 14px rgba(0, 0, 0, 0.4);
}

.card-item.theme-paubrasil .card-number-badge {
  border-color: #34d399;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.5), 0 6px 14px rgba(0, 0, 0, 0.4);
}

/* Frente da Carta (Quando Sorteada na Grade) */
.card-front {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  transform: rotateY(180deg);
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(160deg, #FFFFFF 40%, #F9F7F2 100%);
  border: 3px solid var(--card-uf-color, #0284c7);
  box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 8px;
  text-align: center;
}

.card-front .uf-region-pill {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--card-uf-color, #0284c7);
  background: rgba(0, 0, 0, 0.05);
  padding: 3px 8px;
  border-radius: 99px;
  align-self: center;
}

.card-front .uf-map-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.card-front .uf-map-colorized {
  width: 72px;
  height: 72px;
  background-color: var(--card-uf-color, #0284c7);
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.15));
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
}

.card-front .uf-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.card-front .uf-sigla {
  font-family: 'Outfit', sans-serif;
  font-size: 28px;
  font-weight: 900;
  color: var(--card-uf-color, #0284c7);
  line-height: 1;
}

.card-front .uf-nome {
  font-size: 12px;
  font-weight: 800;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-front .uf-badge-drawn {
  background: var(--card-uf-color, #0284c7);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 3px 0;
  border-radius: 4px;
  text-transform: uppercase;
  margin-top: 3px;
  letter-spacing: 0.04em;
}

/* ====================================================================
   CARD VERTICAL GRANDE NO CENTRO (MONUMENTAL SPOTLIGHT - RESPONSIVO)
   ==================================================================== */
.spotlight-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(440px, 92vw);
  height: min(650px, 83vh);
  background: linear-gradient(165deg, #FFFFFF 0%, #FAF8F2 60%, #F5F1E8 100%);
  border-radius: 24px;
  box-shadow: 0 35px 90px -10px rgba(20, 30, 20, 0.55), 0 0 0 3px #FFFFFF, 0 0 100px var(--uf-color-glow);
  border: 4px solid var(--uf-color);
  backdrop-filter: blur(28px);
  z-index: 500;
  padding: clamp(14px, 2.4vh, 22px) clamp(16px, 2vw, 26px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
  animation: modalPopIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.spotlight-overlay.hidden {
  display: none !important;
}

/* Filete interno refinado que ecoa as cartas botânicas originais */
.spotlight-overlay::before {
  content: '';
  position: absolute;
  inset: 10px;
  border: 2px solid rgba(216, 206, 188, 0.9);
  border-radius: 16px;
  pointer-events: none;
}

@keyframes modalPopIn {
  from {
    opacity: 0;
    transform: translate(-50%, -46%) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.spotlight-top-pill {
  background: rgba(2, 132, 199, 0.12);
  color: var(--uf-color);
  font-size: min(10.5px, 1.5vh);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 14px;
  border-radius: 99px;
  border: 1px solid rgba(2, 132, 199, 0.3);
  z-index: 2;
}

.spotlight-map-wrapper {
  width: min(190px, 22vh);
  height: min(190px, 22vh);
  background: #FFFFFF;
  border-radius: 20px;
  border: 2px solid #EAE3D5;
  box-shadow: 0 10px 24px rgba(45, 35, 20, 0.08), inset 0 0 16px rgba(0, 0, 0, 0.02);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  margin: 4px 0;
  z-index: 2;
}

.spotlight-map-fill {
  width: 100%;
  height: 100%;
  background-color: var(--uf-color);
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.22));
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
}

.spotlight-uf-sigla {
  font-family: 'Outfit', sans-serif;
  font-size: min(68px, 8vh);
  font-weight: 900;
  color: var(--uf-color);
  line-height: 0.95;
  letter-spacing: -0.02em;
  z-index: 2;
}

.spotlight-uf-nome {
  font-family: 'Outfit', sans-serif;
  font-size: min(28px, 3.4vh);
  font-weight: 800;
  color: #1A2E22;
  letter-spacing: -0.01em;
  margin-top: 1px;
  z-index: 2;
}

.spotlight-meta-box {
  width: 100%;
  background: #FFFFFF;
  border: 1.5px solid #E8E1D3;
  border-radius: 12px;
  padding: 8px 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 4px 0 8px 0;
  z-index: 2;
}

.spotlight-meta-item .meta-label {
  font-size: 9.5px;
  font-weight: 800;
  color: #8C8270;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.spotlight-meta-item .meta-val {
  font-size: min(15px, 1.9vh);
  font-weight: 800;
  color: #2D332D;
  margin-top: 1px;
}

.spotlight-actions {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 100%;
  z-index: 2;
}

.btn-spotlight-confirm {
  width: 100%;
  background: linear-gradient(135deg, var(--paubrasil-green) 0%, var(--paubrasil-forest) 100%);
  color: #FFFFFF;
  border: 1.5px solid rgba(245, 186, 19, 0.45);
  padding: clamp(9px, 1.4vh, 12px) 18px;
  border-radius: 11px;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: min(14.5px, 1.9vh);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 5px 14px rgba(20, 56, 35, 0.28);
  transition: all 0.2s ease;
}

.btn-spotlight-confirm:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 18px rgba(20, 56, 35, 0.35);
}

.btn-spotlight-undo {
  width: 100%;
  background: #F3EFE6;
  border: 1px solid #D6CCB8;
  color: #5C5446;
  padding: clamp(7px, 1.1vh, 9px) 14px;
  border-radius: 9px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: min(12.5px, 1.6vh);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-spotlight-undo:hover {
  background: #EAE3D5;
  color: #383226;
}

/* ====================================================================
   CONFETTI PARTICLES LAYER
   ==================================================================== */
#confettiCanvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 600;
}

/* ====================================================================
   RODAPÉ INSTITUCIONAL (WARM PEARL COM LOGOS TRANSPARENTES)
   ==================================================================== */
.main-footer {
  width: 100%;
  background: var(--surface-pearl);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-sand);
  border-radius: 16px;
  padding: 6px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: 0 -4px 16px rgba(45, 35, 20, 0.04);
  flex-shrink: 0;
  height: 54px;
  box-sizing: border-box;
}

.footer-history-dock {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  overflow: hidden;
}

.history-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  color: #38423B;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.history-list {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0;
  scrollbar-width: thin;
}

.history-card-pill {
  background: #F8F5EC;
  border: 1.5px solid #D4CBBA;
  border-radius: 8px;
  padding: 3px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  color: #1A2E22;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
  animation: slideInRight 0.3s ease-out;
  cursor: pointer;
  transition: all 0.2s ease;
}

.history-card-pill:hover {
  background: #FFFFFF;
  border-color: #B5AB98;
  transform: translateY(-1px);
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(15px); }
  to { opacity: 1; transform: translateX(0); }
}

.history-card-pill .order-tag {
  background: var(--paubrasil-forest);
  color: #FFFFFF;
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 4px;
  font-weight: 800;
  font-family: 'Outfit', sans-serif;
}

.history-card-pill .uf-tag {
  font-family: 'Outfit', sans-serif;
  font-size: 13.5px;
  font-weight: 900;
}

.empty-history-text {
  font-size: 11px;
  font-weight: 600;
  color: #8C8472;
  font-style: italic;
}

/* Régua Institucional de Logotipos Oficiais - 100% Transparentes */
.footer-logos-ruler {
  display: flex;
  align-items: center;
  gap: 20px;
  padding-left: 20px;
  border-left: 2px solid #E5DFD2;
}

.footer-logo-item {
  display: flex;
  align-items: center;
}

.logo-ifgoiano {
  height: 38px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.06));
}

.logo-pacto-footer {
  height: 40px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.06));
}

.logo-mec {
  height: 36px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.06));
}

.ruler-sep {
  width: 2px;
  height: 30px;
  background: #E5DFD2;
}

/* ====================================================================
   RESPONSIVIDADE MULTIDISPOSITIVOS: TABLETS, NOTEBOOKS E CELULARES
   ==================================================================== */

/* --- TABLETS E NOTEBOOKS MENORES (max-width: 1024px) --- */
@media (max-width: 1024px) {
  .cards-grid {
    column-gap: clamp(8px, 1.1vw, 14px);
    row-gap: clamp(6px, 0.9vh, 10px);
  }
  .main-header {
    padding: 6px 14px;
  }
  .brand-logo-symbol {
    height: 42px;
  }
  .brand-divider {
    height: 32px;
  }
  .brand-titles h1 {
    font-size: 15px;
  }
  .brand-titles p.subtitle {
    font-size: 8.5px;
  }
}

/* --- TABLETS EM MODO RETRATO E TELAS MÉDIAS (max-width: 860px) --- */
@media (max-width: 860px) {
  html, body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-container {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    padding: 10px 14px;
    gap: 12px;
  }

  .main-header {
    padding: 8px 16px;
    border-radius: 14px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .header-brand {
    gap: 12px;
    flex: 1 1 auto;
  }

  .brand-logo-symbol {
    height: 38px;
  }

  .brand-divider {
    height: 30px;
  }

  .brand-titles h1 {
    font-size: 14.5px;
  }

  .brand-titles p.subtitle {
    font-size: 8px;
  }

  .header-controls {
    gap: 8px;
    margin-left: auto;
  }

  .board-wrapper {
    flex: initial;
    height: auto;
    max-height: none;
    overflow: visible;
    padding: 6px 0;
  }

  .cards-grid {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: auto;
    gap: 12px 10px;
    max-height: none;
    height: auto;
    width: 100%;
  }

  .card-item {
    max-height: none;
    max-width: 150px;
    width: 100%;
  }

  .main-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    height: auto;
    padding: 10px 16px;
    border-radius: 14px;
  }

  .footer-logos-ruler {
    border-left: none;
    border-top: 1px solid #E5DFD2;
    padding-left: 0;
    padding-top: 10px;
    justify-content: center;
    gap: 18px;
  }

  .logo-ifgoiano { height: 32px; }
  .logo-pacto-footer { height: 34px; }
  .logo-mec { height: 30px; }
  .ruler-sep { height: 24px; }
}

/* --- CELULARES E SMARTPHONES (max-width: 640px) --- */
@media (max-width: 640px) {
  html, body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .flora-node {
    opacity: 0.20;
    filter: blur(4px);
  }

  .flora-top-left { width: 220px; top: -15px; left: -20px; }
  .flora-top-right { width: 200px; top: -15px; right: -20px; }
  .flora-bottom-left { width: 230px; bottom: -10px; left: -25px; }
  .flora-bottom-right { width: 220px; bottom: -15px; right: -20px; }
  .flora-mid-left, .flora-mid-right { display: none; }

  .app-container {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    padding: 8px 10px 14px 10px;
    gap: 10px;
  }

  /* Cabeçalho Ergonômico em Dispositivos Móveis */
  .main-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 14px;
  }

  .header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .brand-logo-symbol {
    height: 36px;
  }

  .brand-divider {
    height: 28px;
  }

  .brand-titles h1 {
    font-size: 12.5px;
    line-height: 1.15;
  }

  .brand-titles p.subtitle {
    font-size: 7.5px;
    line-height: 1.25;
    margin-top: 1px;
  }

  .header-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding-top: 6px;
    border-top: 1px solid #EAE3D5;
    gap: 6px;
  }

  .btn-primary {
    padding: 6px 12px;
    font-size: 11.5px;
    border-radius: 8px;
    gap: 5px;
  }

  .btn-secondary {
    padding: 5px 10px;
    font-size: 11px;
    border-radius: 8px;
    gap: 5px;
  }

  .counter-badge {
    padding: 3px 8px;
    border-radius: 8px;
  }

  .counter-badge .count {
    font-size: 13px;
  }

  .counter-badge .label {
    font-size: 7.5px;
  }

  /* Tabuleiro 3 Colunas x 9 Linhas: 27 Cartas com Proporção Perfeita no Celular */
  .board-wrapper {
    flex: initial;
    height: auto;
    max-height: none;
    overflow: visible;
    padding: 4px 0 8px 0;
  }

  .cards-grid {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto;
    gap: 10px 8px;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    max-height: none;
    height: auto;
  }

  .card-item {
    max-height: none;
    max-width: 125px;
    width: 100%;
  }

  .card-inner {
    border-radius: 7px;
    box-shadow: 0 6px 14px -3px rgba(25, 30, 25, 0.22);
  }

  .card-number-badge {
    width: 34px;
    height: 34px;
    border-width: 2.5px;
  }

  .card-number-badge .num {
    font-size: 16px;
  }

  .card-front {
    padding: 6px 4px;
    border-width: 2.5px;
  }

  .card-front .uf-region-pill {
    font-size: 7.5px;
    padding: 2px 5px;
  }

  .card-front .uf-map-colorized {
    width: 48px;
    height: 48px;
  }

  .card-front .uf-sigla {
    font-size: 20px;
  }

  .card-front .uf-nome {
    font-size: 10px;
  }

  .card-front .uf-badge-drawn {
    font-size: 7.5px;
    padding: 2px 0;
  }

  /* Rodapé Responsivo */
  .main-footer {
    padding: 8px 12px;
    border-radius: 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    height: auto;
  }

  .footer-history-dock {
    gap: 8px;
    width: 100%;
  }

  .history-title {
    font-size: 10px;
  }

  .history-list {
    gap: 6px;
    padding: 2px 0;
    -webkit-overflow-scrolling: touch;
  }

  .history-card-pill {
    padding: 3px 8px;
    font-size: 11px;
    gap: 5px;
  }

  .history-card-pill .order-tag {
    font-size: 9px;
    padding: 1px 4px;
  }

  .history-card-pill .uf-tag {
    font-size: 12px;
  }

  .footer-logos-ruler {
    border-left: none;
    border-top: 1px solid #E5DFD2;
    padding-left: 0;
    padding-top: 8px;
    justify-content: center;
    gap: 14px;
    width: 100%;
  }

  .logo-ifgoiano { height: 28px; }
  .logo-pacto-footer { height: 30px; }
  .logo-mec { height: 26px; }
  .ruler-sep { height: 20px; }

  /* Card Vertical Central Modal Adaptado para Telas de Celulares */
  .spotlight-overlay {
    width: min(340px, 92vw);
    height: auto;
    max-height: 88dvh;
    padding: 14px 16px;
    border-radius: 18px;
    overflow-y: auto;
  }

  .spotlight-overlay::before {
    inset: 8px;
    border-radius: 12px;
  }

  .spotlight-top-pill {
    font-size: 9.5px;
    padding: 3px 12px;
  }

  .spotlight-map-wrapper {
    width: min(140px, 18vh);
    height: min(140px, 18vh);
    padding: 8px;
    border-radius: 14px;
    margin: 2px 0;
  }

  .spotlight-uf-sigla {
    font-size: 48px;
  }

  .spotlight-uf-nome {
    font-size: 20px;
    margin-top: 0;
  }

  .spotlight-meta-box {
    padding: 6px 10px;
    margin: 3px 0 6px 0;
    gap: 8px;
    border-radius: 10px;
  }

  .spotlight-meta-item .meta-label {
    font-size: 8px;
  }

  .spotlight-meta-item .meta-val {
    font-size: 13px;
  }

  .spotlight-actions {
    gap: 6px;
  }

  .btn-spotlight-confirm {
    padding: 9px 14px;
    font-size: 13.5px;
    border-radius: 9px;
  }

  .btn-spotlight-undo {
    padding: 7px 12px;
    font-size: 11.5px;
    border-radius: 8px;
  }
}

/* --- CELULARES EM MODO PAISAGEM / TELAS ULTRA-BAIXAS (max-height: 520px e landscape) --- */
@media (max-height: 520px) and (orientation: landscape) {
  html, body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-container {
    height: auto;
    min-height: 100%;
    padding: 6px 12px;
    gap: 8px;
  }

  .cards-grid {
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: auto;
    gap: 6px 6px;
    max-height: none;
    height: auto;
  }

  .card-item {
    max-height: 110px;
    max-width: 80px;
  }

  .main-header {
    padding: 4px 12px;
  }

  .brand-logo-symbol {
    height: 30px;
  }

  .brand-titles h1 {
    font-size: 12px;
  }

  .main-footer {
    padding: 4px 12px;
    height: auto;
  }

  .spotlight-overlay {
    height: 94vh;
    width: min(420px, 92vw);
    overflow-y: auto;
    padding: 10px 14px;
  }

  .spotlight-map-wrapper {
    width: 85px;
    height: 85px;
    padding: 6px;
  }

  .spotlight-uf-sigla {
    font-size: 34px;
  }

  .spotlight-uf-nome {
    font-size: 16px;
  }
}
