:root {
  /* Cores principais - apenas as utilizadas */
  --primary: #2BD9E2;
  --primary-light: #4FE3EA;
  --primary-dark: #1FA8B0;
  --tertiary: #FFE066;
  --tertiary-dark: #E6C94D;
  --tertiary-light: #FFF499;
  /* --neutral-100: #F8F9FA;
  --neutral-200: #E9ECEF;
  --neutral-300: #DEE2E6;
  --neutral-400: #CED4DA;
  --neutral-500: #ADB5BD;
  --neutral-600: #6C757D;
  --neutral-700: #495057;
  --neutral-800: #343A40; */
  
  /* Variáveis para acessibilidade */
  --focus-color: #0066CC;
  --focus-outline: 3px solid var(--focus-color);
  --focus-outline-offset: 2px;
  --error-color: #D32F2F;
  --success-color: #2E7D32;
  --text-high-contrast: #000000;
  --bg-high-contrast: #FFFFFF;
  --min-touch-target: 40px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

#main{
  @media only screen and (max-width: 768px) {
    height: calc(100vh - 40px);
  }
}

section {
  overflow: hidden;
  padding: 10px 0;
}


/* Estilos de foco unificados */
*:focus {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
  border-radius: 4px;
}

*:focus:not(:focus-visible) {
  outline: none;
}

*:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
  z-index: 1000;
}

/* Foco para elementos interativos - consolidado */
button:focus,
[role="button"]:focus,
[tabindex]:focus,
.peca:focus,
lac:focus {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
  box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);
}

.peca:focus,
lac:focus {
  border-color: var(--focus-color);
  background-color: var(--primary);
  color: rgb(0, 0, 0);
  transform: scale(1.05);
}

.btn-limpar:focus {
  border-color: var(--focus-color);
  transform: translateY(-2px);
  background-color: var(--neutral-300);
  color: white;
}

.btn-conferir:focus {
  border-color: var(--focus-color);
  transform: translateY(-2px);
  background-color: var(--primary-dark);
  color: white;
}

/* Classe para conteúdo apenas para leitores de tela */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sr-only:focus {
  position: static;
  width: auto;
  height: auto;
  padding: 8px;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  background-color: var(--focus-color);
  color: white;
  border-radius: 4px;
  z-index: 10000;
}

/* Animações */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInLeft {
  from { transform: translateX(-20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

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

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(43, 217, 226, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(43, 217, 226, 0); }
  100% { box-shadow: 0 0 0 0 rgba(43, 217, 226, 0); }
}

@keyframes successPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes errorShake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-5px); }
  100% { transform: translateX(0); }
}

@keyframes feedbackAppear {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

@keyframes zoomIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes ripple {
  to {
    transform: scale(2.5);
    opacity: 0;
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@keyframes checking {
  0% { transform: scale(1); }
  50% { transform: scale(1.1) translateY(-5px); }
  100% { transform: scale(1); }
}

/* Container principal do jogo */
.game-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
  height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.5s ease-in-out;
}

/* Layout principal */
#maincomplete {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  border-radius: 12px;
  /* gap: 8px; */
}

/* Areas principais - definições base consolidadas */
#area-superior {
  width: 100%;
  height: 60%;
  overflow-y: auto;
  padding: 20px 20px 100px 20px;
  position: relative;
  border-bottom: 1px solid var(--neutral-300);
  animation: fadeInLeft 0.5s ease-out;
  display: flex;
  flex-direction: column;
  background: var(--neutral-100);

  @media only screen and (max-width: 480px) {
    padding: 10px;
  }
}

#area-inferior {
  width: 100%;
  height: 40%;
  padding: 12px;
  background-color: var(--neutral-200);
  display: flex;
  flex-direction: column;
  animation: fadeInRight 0.5s ease-out;
  min-height: 0;
  overflow-y: auto;
}

/* Área do enunciado */
#enunciado {
  font-size: 18px;
  color: var(--neutral-800);
  margin-bottom: 20px;
  line-height: 1.6;
  padding: 0;
  flex-shrink: 0;
  font-weight: 400;
}

#enunciado_texto {
  font-weight: 500;
  margin-bottom: 12px;
  padding: 12px;
  background-color: var(--neutral-200);
  border-radius: 12px;
  display: flex;
  font-size: 17px;
  line-height: 1.5;
  align-items: center;
}

.img-container {
  margin: 12px 0;
  text-align: center;
  flex-shrink: 0;
}

.img-container img {
  max-width: 100%;
  max-height: 250px;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
  cursor: pointer;
}

.img-container img:hover {
  transform: scale(1.03);
}

.img-legend {
  font-size: 13px;
  color: var(--neutral-600);
  margin-top: 8px;
  font-style: italic;
}

/* Área do texto com lacunas */
.text-area {
  font-size: 18px;
  line-height: 1.7;
  color: var(--neutral-800);
  margin-bottom: 0;
  padding: 0;
  border-radius: 12px;
  flex: 1;
  min-height: 0;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.text-area p {
  margin-bottom: 12px;
  padding-bottom: 6px;
  /* border-bottom: 1px dotted var(--neutral-300); */
}

/* ===== FORMATAÇÕES DE TEXTO DO TINYMCE ===== */

/* Formatações básicas */
.text-area strong,
.text-area b {
  font-weight: 700;
  color: var(--neutral-800);
}

.text-area em,
.text-area i {
  font-style: italic;
  color: var(--neutral-800);
}

.text-area u {
  text-decoration: underline;
  color: var(--neutral-800);
}

.text-area s,
.text-area strike,
.text-area del {
  text-decoration: line-through;
  color: var(--neutral-600);
}

/* Subscript e Superscript */
.text-area sub {
  font-size: 0.75em;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
  bottom: -0.25em;
}

.text-area sup {
  font-size: 0.75em;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
  top: -0.5em;
}

/* Blockquote */
.text-area blockquote {
  margin: 16px 0;
  padding: 12px 20px;
  border-left: 4px solid var(--neutral-300);
  background-color: white;
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: var(--neutral-700);
}

.text-area blockquote p {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* Listas */
.text-area ul,
.text-area ol {
  margin: 12px 0;
  padding-left: 30px;
}

.text-area ul {
  list-style-type: disc;
}

.text-area ol {
  list-style-type: decimal;
}

.text-area li {
  margin-bottom: 8px;
  line-height: 1.6;
  color: var(--neutral-800);
}

.text-area ul ul,
.text-area ol ul {
  list-style-type: circle;
  margin-top: 8px;
}

.text-area ol ol,
.text-area ul ol {
  list-style-type: lower-alpha;
  margin-top: 8px;
}

/* Alinhamentos de texto */
.text-area [style*="text-align: left"],
.text-area .align-left {
  text-align: left;
}

.text-area [style*="text-align: center"],
.text-area .align-center {
  text-align: center;
}

.text-area [style*="text-align: right"],
.text-area .align-right {
  text-align: right;
}

.text-area [style*="text-align: justify"],
.text-area .align-justify {
  text-align: justify;
}

/* Lacunas - definições base consolidadas */
lac {
  background-color: var(--neutral-200);
  border-radius: 8px;
  padding: 6px 12px;
  margin: 0 3px;
  color: var(--neutral-800);
  display: inline-flex;
  min-width: 50px;
  min-height: var(--min-touch-target);
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  position: relative;
  transition: all 0.3s ease;
  /* box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1); */
  margin-bottom: 8px;
  font-size: 16px;
  line-height: 1.3;
  font-weight: 500;
  letter-spacing: 0.01em;
  border: 2px solid transparent;
  align-items: center;
  justify-content: center;
}

/* Lacunas dentro de elementos formatados */
.text-area p lac,
.text-area div lac,
.text-area li lac,
.text-area blockquote lac {
  vertical-align: middle;
  margin-bottom: 0;
}

.text-area strong lac,
.text-area b lac,
.text-area em lac,
.text-area i lac {
  font-weight: 500;
  font-style: normal;
}

/* Lacunas em listas */
.text-area li lac {
  margin: 0 3px;
}

/* Lacunas em blockquotes */
.text-area blockquote lac {
  background-color: var(--neutral-300);
}

/* Lacunas em alinhamentos */
.text-area [style*="text-align: center"] lac,
.text-area .align-center lac {
  margin: 0 auto;
}

.text-area [style*="text-align: right"] lac,
.text-area .align-right lac {
  margin-left: auto;
}

lac:hover {
  background-color: var(--neutral-400);
  transform: translateY(-1px);
}

.davez {
  background-color: rgba(43, 217, 226, 0.2);
  border: 2px solid var(--primary);
  transform: scale(1.05);
  box-shadow: 0 0 12px rgba(43, 217, 226, 0.4);
  animation: pulse 1.5s infinite;
  min-width: 55px;
}

.laccerto {
  background-color: var(--feedback-positivo) !important;
  border: 2px solid var(--feedback-positivo) !important;
  color: white !important;
  animation: successPulse 1s ease;
  font-weight: 600 !important;
}

.lacerrado {
  background-color: var(--feedback-negativo) !important;
  border: 2px solid var(--feedback-negativo) !important;
  color: white !important;
  animation: errorShake 0.5s ease;
  font-weight: 600 !important;
}

.laccerto::after,
.lacerrado::after {
  content: '';
  width: 20px;
  height: 20px;
  position: absolute;
  top: -8px;
  right: -8px;
  border-radius: 50%;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 10px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.laccerto::after {
  background-color: var(--feedback-positivo);
  background-image: url(../imgs/icon_certo.svg);
}

.lacerrado::after {
  background-color: var(--feedback-negativo);
  background-image: url(../imgs/icon_errado.svg);
}

/* Área de peças */
.words-title {
  font-size: 16px;
  color: var(--neutral-700);
  margin-bottom: 10px;
  font-weight: 600;
  text-align: center;
  flex-shrink: 0;
}

.words-container {
  /* flex: 1; */
  /* overflow-y: auto; */
  min-height: 200px;
  padding: 2px;

  @media only screen and (max-width: 768px) {
    min-height: unset;
  }
}

#ul_pecas {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
  align-content: flex-start;
  margin: 0;
  padding: 0;
  max-height: 100%;
}

/* Peças - definições base consolidadas */
.peca {
  background-color: var(--tertiary);
  color: var(--neutral-800);
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 3px 0 var(--tertiary-dark);
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--min-touch-target);
  line-height: 1.3;
  flex-shrink: 0;
  word-break: break-word;
  text-align: center;
  letter-spacing: 0.01em;
  border: 2px solid transparent;
  max-width: 100%;
}

.peca:hover {
  background-color: var(--tertiary-light);
  transform: translateY(-2px);
  box-shadow: 0 5px 0 var(--tertiary-dark);
}

.peca:active {
  transform: translateY(1px);
  box-shadow: 0 2px 0 var(--tertiary-dark);
}

.peca.selecionada {
  background-color: var(--primary);
  color: white;
  box-shadow: 0 3px 0 var(--primary-dark);
  transform: scale(1.05);
}

.peca.selecionada:hover {
  background-color: var(--primary-light);
  box-shadow: 0 5px 0 var(--primary-dark);
}

.peca.usada {
  background-color: var(--neutral-400);
  color: var(--neutral-600);
  cursor: not-allowed;
  opacity: 0.6;
  transform: none !important;
  box-shadow: 0 2px 0 var(--neutral-500);
}

/* Controles - definições base consolidadas */
.controls {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-shrink: 0;
}

.btn-limpar, .btn-conferir {
  flex: 1;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--min-touch-target);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.btn-limpar {
  background-color: var(--neutral-100);
  color: var(--neutral-700);
  box-shadow: 0 3px 0 var(--neutral-300);
}

.btn-limpar:hover {
  background-color: var(--neutral-300);
  transform: translateY(-2px);
  box-shadow: 0 5px 0 var(--neutral-400);
}

.btn-limpar:active {
  transform: translateY(1px);
  box-shadow: 0 2px 0 var(--neutral-500);
}

.btn-conferir {
  background-color: var(--primary);
  color: white;
  box-shadow: 0 3px 0 var(--primary-dark);
}

.btn-conferir:hover {
  background-color: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: 0 5px 0 var(--primary-dark);
}

.btn-conferir:active {
  transform: translateY(1px);
  box-shadow: 0 2px 0 var(--primary-dark);
}

/* Feedback - agora usa o sistema global padronizado */

/* Elementos especiais */
#zoomImg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  animation: fadeIn 0.3s ease;
  backdrop-filter: blur(5px);
}

#zoomImg::after {
  content: '×';
  position: fixed;
  top: 20px;
  right: 30px;
  font-size: 48px;
  color: white;
  cursor: pointer;
  opacity: 0.8;
  transition: all 0.3s ease;
}

#zoomImg:hover::after {
  opacity: 1;
  transform: scale(1.1);
}

#zoomImg img {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1001;
  display: none;
}



#tooltip {
  position: fixed;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  max-width: 300px;
  z-index: 1002;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  backdrop-filter: blur(4px);
}

#tooltip.show {
  opacity: 1;
}

#loading-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  pointer-events: none;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--neutral-300);
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-state {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
}

.loading-state::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: shimmer 1.5s infinite;
}

/* Classes dinâmicas */
.touch-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transform: scale(0);
  animation: ripple 0.5s linear;
  pointer-events: none;
}

.success-overlay,
.error-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
}

.success-overlay {
  background: radial-gradient(circle, rgba(93, 213, 97, 0.2) 0%, rgba(93, 213, 97, 0) 70%);
}

.error-overlay {
  background: radial-gradient(circle, rgba(255, 107, 107, 0.15) 0%, rgba(255, 107, 107, 0) 70%);
}

.close-hint {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
}

.checking {
  animation: checking 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

/* Otimizações de performance para dispositivos touch - consolidadas */
.peca, lac, .btn-limpar, .btn-conferir {
  will-change: transform, opacity;
  transform: translateZ(0);
  backface-visibility: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  max-width: 100%;

}

.peca:active, lac:active, .btn-limpar:active, .btn-conferir:active {
  transform: scale(0.98) translateZ(0);
  transition: transform 0.1s ease-out;
}

/* Classes de dispositivo */
.touch-device .peca:hover,
.touch-device lac:hover,
.touch-device .btn-limpar:hover,
.touch-device .btn-conferir:hover {
  transform: none;
}



.low-memory-device * {
  animation-duration: 0.1s !important;
  transition-duration: 0.1s !important;
}

/* ========================================
   BREAKPOINTS RESPONSIVOS (MOBILE-FIRST)
   ======================================== */

/* Small mobile (480px+) */
@media only screen and (min-width: 480px) {
  .game-container {
    /* padding: 10px; */
    height: calc(100vh - 70px);
  }
  
  .text-area { font-size: 17px; }
  
  lac {
    font-size: 16px;
    /* padding: 10px 14px; */
    min-width: 55px;
  }
  
  .peca {
    font-size: 16px;
    padding: 14px 18px;
    margin: 5px;
  }
  
  .btn-limpar, .btn-conferir {
    font-size: 15px;
    padding: 14px 18px;
  }
}

/* Tablet portrait (600px+) */
@media only screen and (min-width: 600px) {
  .game-container {
    /* padding: 12px; */
    /* max-width: 600px; */
  }
  
  #area-superior {
    height: 60%;
    padding: 16px;
  }
  
  #area-inferior {
    height: 40%;
    padding: 16px;
  }
  
  .text-area {
    font-size: 18px;
    line-height: 1.6;
  }
  
  lac {
    font-size: 17px;
    /* padding: 10px 16px; */
    margin: 5px;
  }
  
  .peca {
    font-size: 17px;
    padding: 14px 20px;
    margin: 6px;
    border-radius: 18px;
  }
  
  .controls {
    flex-direction: row;
    gap: 12px;
  }
  
  .btn-limpar, .btn-conferir {
    width: auto;
    flex: 1;
    font-size: 15px;
  }
}

/* Tablet landscape (768px+) */
@media only screen and (min-width: 768px) {
  .game-container {
    /* max-width: 800px; */
    /* padding: 15px; */
    height: calc(100vh - 80px);
  }
  
  #maincomplete {
    flex-direction: row;
    gap: 12px;
  }
  
  #area-superior {
    width: 65%;
    height: calc(100% - 56px);
    /* border-right: 1px solid var(--neutral-300); */
    border-bottom: none;
  }
  
  #area-inferior {
    width: 35%;
    height: 100%;
  }
}

/* Desktop small (992px+) */
@media only screen and (min-width: 992px) {
  .game-container {
    /* max-width: 1000px; */
    /* padding: 20px; */
  }
  
  #area-superior {
    width: 68%;
  }
  
  #area-inferior {
    width: 32%;
    padding: 18px;
  }
  
  .text-area {
    font-size: 19px;
    line-height: 1.5;
  }
  
  #enunciado_texto { font-size: 18px; }
  
  lac {
    font-size: 18px;
    /* padding: 8px 16px; */
    margin: 4px;
    min-width: 60px;
  }
  
  .peca {
    font-size: 17px;
    padding: 12px 20px;
    margin: 4px;
  }
}

/* Desktop large (1200px+) */
@media only screen and (min-width: 1200px) {
  .game-container {
    /* max-width: 1200px; */
    /* padding: 25px; */
  }
  
  #area-superior {
    width: 70%;
  }
  
  #area-inferior {
    width: 30%;
    padding: 20px;
  }
  
  .text-area {
    font-size: 20px;
    line-height: 2.4;
  }
  
  #enunciado_texto { font-size: 19px; }
  
  lac {
    font-size: 19px;
    /* padding: 10px 18px; */
    margin: 0 5px;
  }
  
  .peca {
    font-size: 20px;
    padding: 8px 16px;
  }
  
  .btn-limpar, .btn-conferir {
    font-size: 16px;
    padding: 14px 24px;
  }
}

/* Telas muito pequenas */
@media only screen and (max-width: 360px) {
  .game-container { height: calc(100vh - 50px); }
  
  .text-area {
    font-size: 15px;
    line-height: 1.8;
  }
  
  lac {
    min-width: 38px;
    font-size: 13px;
    min-height: 32px;
    padding: 4px 6px;
  }
  
  .peca {
    font-size: 14px;
    padding: 8px 10px;
    min-height: 40px;
    min-width: 60px;
    margin: 3px;
  }
  
  .words-title { font-size: 13px; }
  
  .btn-limpar, .btn-conferir {
    font-size: 13px;
    padding: 10px 14px;
  }
  
  /* Formatações de texto em telas pequenas */
  .text-area blockquote {
    padding: 8px 12px;
    margin: 12px 0;
    font-size: 14px;
  }
  
  .text-area ul,
  .text-area ol {
    padding-left: 20px;
  }
  
  .text-area li {
    font-size: 14px;
    margin-bottom: 6px;
  }
}

/* Orientação landscape em mobile */
@media only screen and (max-height: 500px) and (orientation: landscape) {
  .game-container {
    height: calc(100vh - 40px);
    padding: 6px;
  }
  
  #maincomplete {
    flex-direction: row;
    gap: 8px;
  }
  
  #area-superior {
    width: 60%;
    height: 100%;
    border-right: 1px solid var(--neutral-300);
    border-bottom: none;
  }
  
  #area-inferior {
    width: 40%;
    height: 100%;
  }
  
  .text-area { font-size: 14px; }
  lac {
    font-size: 13px;
    padding: 4px 8px;
  }
  
  .peca {
    font-size: 13px;
    padding: 6px 10px;
    margin: 2px;
  }
}

/* Otimizações touch - consolidadas */
@media (hover: none) and (pointer: coarse) {
  .peca:hover, lac:hover, .btn-limpar:hover, .btn-conferir:hover {
    transform: none;
  }
  
  .peca:active, lac:active {
    background-color: var(--primary);
    color: white;
    transform: scale(0.95);
  }
  
  .btn-limpar:active {
    background-color: var(--neutral-500);
    color: white;
  }
  
  .btn-conferir:active {
    background-color: var(--primary-dark);
    color: white;
  }
}

/* Scrolling e zoom para mobile - consolidado */
@media only screen and (max-width: 768px) {
  .text-area, #area-superior, #area-inferior {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
  
  .game-container {
    touch-action: pan-y pinch-zoom;
  }
  
  .peca, lac, .btn-limpar, .btn-conferir {
    font-size: 16px !important;
  }
  
  /* Suporte a notch (iPhone X+) */
  @supports (padding: max(0px)) {
    .game-container {
      padding-left: 0;
      padding-right: 0;
      padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
  }
}

/* Melhorias para acessibilidade */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .loading-spinner {
    animation: none;
    border: 3px solid var(--primary);
  }
}

@media (prefers-contrast: high) {
  :root {
    --primary: #0066CC;
    --tertiary: #FFCC00;
    --success-color: #006600;
    --error-color: #CC0000;
    --neutral-800: #000000;
    --neutral-700: #000000;
    --neutral-600: #333333;
  }
  
  .text-area, #enunciado_texto, #enunciado {
    color: var(--text-high-contrast) !important;
    background-color: var(--bg-high-contrast) !important;
    font-weight: 600 !important;
    border: 2px solid var(--text-high-contrast) !important;
  }
  
  lac,
  .peca {
    border: 3px solid var(--text-high-contrast) !important;
    font-weight: 700 !important;
  }
  
  lac {
    background-color: var(--bg-high-contrast) !important;
    color: var(--text-high-contrast) !important;
  }
  
  .peca {
    background-color: var(--tertiary) !important;
    color: var(--text-high-contrast) !important;
  }
  
  .btn-limpar, .btn-conferir {
    border: 3px solid var(--text-high-contrast) !important;
    font-weight: 700 !important;
    color: var(--text-high-contrast) !important;
  }
  
  .btn-limpar {
    background-color: var(--bg-high-contrast) !important;
  }
  
  .btn-conferir {
    background-color: var(--primary) !important;
    color: var(--bg-high-contrast) !important;
  }
  
  .laccerto {
    background-color: var(--success-color) !important;
    color: var(--bg-high-contrast) !important;
    border: 3px solid var(--success-color) !important;
  }
  
  .lacerrado {
    background-color: var(--error-color) !important;
    color: var(--bg-high-contrast) !important;
    border: 3px solid var(--error-color) !important;
  }
}

/* ===== FORMATAÇÃO DE TABELAS MODERNA ===== */
.text-area table,
table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  font-size: 14px;
  line-height: 1.5;
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

/* Garantir que tabelas dentro da text-area tenham os estilos corretos */
.text-area table {
  margin: 16px 0;
}

thead {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
}

thead th {
  padding: 16px 20px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  border: none;
  position: relative;
}

thead th:first-child {
  border-top-left-radius: 12px;
}

thead th:last-child {
  border-top-right-radius: 12px;
}

thead th::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.2);
}

tbody {
  background: white;
}

tbody tr {
  transition: all 0.2s ease;
  border-bottom: 1px solid #f1f5f9;
}

tbody tr:hover {
  background: linear-gradient(135deg, rgba(43, 217, 226, 0.05), rgba(31, 168, 176, 0.05));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(43, 217, 226, 0.1);
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:last-child td:first-child {
  border-bottom-left-radius: 12px;
}

tbody tr:last-child td:last-child {
  border-bottom-right-radius: 12px;
}

td {
  padding: 16px 20px;
  border: none;
  color: #374151;
  font-size: 14px;
  line-height: 1.6;
  vertical-align: top;
}

th {
  padding: 16px 20px;
  border: none;
  font-weight: 600;
  font-size: 14px;
  text-align: left;
}

/* th dentro de thead - cabeçalho da tabela */
thead th {
  color: white;
}

/* th dentro de tbody ou outras situações - células normais */
tbody th,
th:not(thead th) {
  color: #374151;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
}

/* Estilos para diferentes tipos de conteúdo nas células */
td p {
  margin: 0 0 8px 0;
  line-height: 1.6;
}

td p:last-child {
  margin-bottom: 0;
}

td strong,
td b {
  font-weight: 600;
  color: #1f2937;
}

td em,
td i {
  font-style: italic;
  color: #6b7280;
}

/* Lacunas dentro de tabelas */
td lac,
th lac {
  min-height: 32px;
  font-size: 14px;
  padding: 4px 10px;
  margin: 0 2px;
  display: inline-flex;
  vertical-align: middle;
}

.text-area table lac {
  margin-bottom: 0;
}

/* Estilos para números e dados */
td[data-type="number"] {
  text-align: right;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-weight: 500;
  color: var(--success-color);
}

td[data-type="currency"] {
  text-align: right;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-weight: 600;
  color: var(--success-color);
}

td[data-type="percentage"] {
  text-align: right;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-weight: 500;
  color: var(--error-color);
}

/* Estilos para células com status */
td[data-status="success"] {
  background: rgba(46, 125, 50, 0.1);
  color: var(--success-color);
  font-weight: 500;
}

td[data-status="warning"] {
  background: rgba(255, 193, 7, 0.1);
  color: #f57c00;
  font-weight: 500;
}

td[data-status="error"] {
  background: rgba(211, 47, 47, 0.1);
  color: var(--error-color);
  font-weight: 500;
}

td[data-status="info"] {
  background: rgba(43, 217, 226, 0.1);
  color: var(--primary);
  font-weight: 500;
}

/* Estilos para tabelas zebradas */
table[data-style="zebra"] tbody tr:nth-child(even) {
  background: #f8fafc;
}

table[data-style="zebra"] tbody tr:nth-child(even):hover {
  background: linear-gradient(135deg, rgba(43, 217, 226, 0.08), rgba(31, 168, 176, 0.08));
}

/* Estilos para tabelas compactas */
table[data-size="compact"] th,
table[data-size="compact"] td {
  padding: 8px 12px;
  font-size: 13px;
}

/* Estilos para tabelas grandes */
table[data-size="large"] th,
table[data-size="large"] td {
  padding: 20px 24px;
  font-size: 16px;
}

/* Bordas personalizadas para tabelas */
table[data-border="all"] {
  border: 2px solid #e5e7eb;
}

table[data-border="all"] th,
table[data-border="all"] td {
  border: 1px solid #e5e7eb;
}

table[data-border="vertical"] td {
  border-left: 1px solid #e5e7eb;
  border-right: 1px solid #e5e7eb;
}

table[data-border="vertical"] td:first-child {
  border-left: none;
}

table[data-border="vertical"] td:last-child {
  border-right: none;
}

/* Responsividade para tabelas */
@media only screen and (max-width: 768px) {
  table {
    font-size: 12px;
    margin: 15px 0;
  }
  
  th,
  td {
    padding: 8px 12px;
  }
  
  table[data-size="large"] th,
  table[data-size="large"] td {
    padding: 12px 16px;
    font-size: 14px;
  }
  
  /* Scroll horizontal para tabelas muito largas */
  table {
    overflow-x: auto;
    display: block;
    white-space: nowrap;
  }
  
  table thead,
  table tbody,
  table tr {
    display: table;
    width: 100%;
    table-layout: fixed;
  }
}

@media only screen and (max-width: 480px) {
  table {
    font-size: 11px;
    margin: 10px 0;
  }
  
  th,
  td {
    padding: 6px 8px;
  }
  
  thead th {
    font-size: 12px;
    padding: 10px 8px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --neutral-100: #2a2a2a;
    --neutral-200: #1f1f1f;
    --neutral-300: #404040;
    --neutral-700: #e0e0e0;
    --neutral-800: #f0f0f0;
  }
  
  .text-area, #enunciado_texto, #enunciado {
    color: #f0f0f0;
    text-shadow: 0 0 1px rgba(240, 240, 240, 0.5);
  }
  
  lac {
    color: #f0f0f0;
    font-weight: 500;
  }
  
  .peca {
    color: #2a2a2a;
    font-weight: 500;
  }
  
  /* ===== FORMATAÇÕES DE TEXTO NO MODO DARK ===== */
  .text-area strong,
  .text-area b,
  .text-area em,
  .text-area i,
  .text-area u,
  .text-area li {
    color: #f0f0f0;
  }
  
  .text-area s,
  .text-area strike,
  .text-area del {
    color: #b0b0b0;
  }
  
  .text-area blockquote {
    background-color: rgba(43, 217, 226, 0.15);
    color: #e0e0e0;
    border-left-color: var(--primary-light);
  }
  
  /* ===== MODO DARK PARA TABELAS ===== */
  table {
    background: #1f2937;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  }
  
  thead {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  }
  
  tbody {
    background: #1f2937;
  }
  
  tbody tr {
    border-bottom-color: #374151;
  }
  
  tbody tr:hover {
    background: linear-gradient(135deg, rgba(43, 217, 226, 0.1), rgba(31, 168, 176, 0.1));
  }
  
  td {
    color: #f3f4f6;
  }
  
  tbody th,
  th:not(thead th) {
    color: #f3f4f6;
    background: #111827;
    border-bottom-color: #374151;
  }
  
  td strong,
  td b {
    color: #f9fafb;
  }
  
  td em,
  td i {
    color: #d1d5db;
  }
  
  td[data-type="number"],
  td[data-type="currency"] {
    color: #10b981;
  }
  
  td[data-type="percentage"] {
    color: #f87171;
  }
  
  table[data-style="zebra"] tbody tr:nth-child(even) {
    background: #111827;
  }
  
  table[data-border="all"] {
    border-color: #374151;
  }
  
  table[data-border="all"] th,
  table[data-border="all"] td {
    border-color: #374151;
  }
  
  table[data-border="vertical"] td {
    border-color: #374151;
  }
}