/* ==========================================================================
   FlagFind - Visual Retrô de Alto Contraste (Modo Escuro Clássico)
   Suporte a tamanhos grandes (até 15x15) e ícones perfeitamente escaláveis
   ========================================================================== */

:root {
  --bg-main: #0c0e12;
  --bg-frame: #141720;
  --bg-button: #2d3340;
  --bg-button-active: #1c2029;

  /* Bordas em relevo 3D de alto contraste */
  --border-light: #525a6f;
  --border-dark: #08090c;
  --border-cell: rgba(0, 0, 0, 0.6);

  --text-primary: #ffffff;
  --text-secondary: #c5cbd8;
  --text-badge: #fcd34d;
  --font-retro: Tahoma, Verdana, "Segoe UI", Arial, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --grid-size: 10;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-retro);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* Layout vertical ajustado para tela cheia mobile */
.mobile-layout {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 8px) 12px calc(var(--safe-bottom) + 8px);
  background-color: var(--bg-main);
}

/* ==========================================================================
   TOPO: Instruções (Somente texto centralizado, alto contraste)
   ========================================================================== */
.instructions-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  padding: 4px 6px;
  flex-shrink: 0;
}

.rule-line {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--text-primary);
  margin: 1px 0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* ==========================================================================
   MEIO: Tabuleiro do Jogo
   ========================================================================== */
.game-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  padding: 4px 0;
}

/* Moldura rebaixada clássica com bordas 3D bem visíveis */
.board-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  background-color: #08090c;
  border-top: 2px solid var(--border-dark);
  border-left: 2px solid var(--border-dark);
  border-right: 2px solid var(--border-light);
  border-bottom: 2px solid var(--border-light);
  border-radius: 2px;
}

.board {
  display: grid;
  grid-template-columns: repeat(var(--grid-size, 10), 1fr);
  grid-template-rows: repeat(var(--grid-size, 10), 1fr);
  width: min(94vw, 440px, calc(100dvh - 170px));
  height: min(94vw, 440px, calc(100dvh - 170px));
  aspect-ratio: 1 / 1;
  background: #000000;
}

/* Células individuais: grid simples sem linhas grossas nas cores */
.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-right: 1px solid var(--border-cell);
  border-bottom: 1px solid var(--border-cell);
  overflow: hidden;
}

/* Ícones grandes e nítidos */
.cell-icon {
  width: 82%;
  height: 82%;
  max-width: 32px;
  max-height: 32px;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.9));
}

.cell-icon.icon-x {
  width: 68%;
  height: 68%;
  max-width: 24px;
  max-height: 24px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.9));
}

/* Bandeiras verde e vermelha com contraste reforçado */
.cell-icon.icon-flag-green {
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.9)) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}

.cell-icon.icon-flag-red {
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.9)) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}

/* ==========================================================================
   EMBAIXO: Barra de Controle Retrô de Alto Contraste
   ========================================================================== */
.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 2px;
  flex-shrink: 0;
  border-top: 1px solid #20242e;
}

/* Indicador de dimensões e contador de bandeiras */
.status-counter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: #090a0d;
  border-top: 1px solid var(--border-dark);
  border-left: 1px solid var(--border-dark);
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  border-radius: 2px;
}

.dim-badge {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-badge);
  letter-spacing: 0.5px;
}

.counter-group {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
}

.counter-icon {
  width: 14px;
  height: 14px;
}

.actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Botões 3D Retrô */
.retro-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background-color: var(--bg-button);
  border-top: 1px solid var(--border-light);
  border-left: 1px solid var(--border-light);
  border-right: 2px solid var(--border-dark);
  border-bottom: 2px solid var(--border-dark);
  border-radius: 3px;
  cursor: pointer;
}

.retro-btn:active {
  background-color: var(--bg-button-active);
  border-top: 2px solid var(--border-dark);
  border-left: 2px solid var(--border-dark);
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  padding-top: 1px;
  padding-left: 1px;
}

.btn-icon {
  width: 18px;
  height: 18px;
  pointer-events: none;
}

/* ==========================================================================
   MODAL DE VITÓRIA (Caixa de Diálogo Retrô)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.75);
  opacity: 0;
  pointer-events: none;
  z-index: 100;
  padding: 16px;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.retro-dialog {
  width: 100%;
  max-width: 300px;
  background-color: #242935;
  border-top: 2px solid var(--border-light);
  border-left: 2px solid var(--border-light);
  border-right: 2px solid var(--border-dark);
  border-bottom: 2px solid var(--border-dark);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.9);
  border-radius: 2px;
}

.dialog-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  background: linear-gradient(90deg, #1e3a68, #2a5294);
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 700;
}

.dialog-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 18px 16px;
}

.dialog-icon {
  width: 26px;
  height: 26px;
  margin-bottom: 10px;
}

.dialog-msg {
  font-size: 13.5px;
  line-height: 1.45;
  color: #ffffff;
  margin-bottom: 18px;
}

.dialog-btn {
  font-family: var(--font-retro);
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  background-color: var(--bg-button);
  border-top: 1px solid var(--border-light);
  border-left: 1px solid var(--border-light);
  border-right: 2px solid var(--border-dark);
  border-bottom: 2px solid var(--border-dark);
  border-radius: 2px;
  padding: 7px 22px;
  cursor: pointer;
}

.dialog-btn:active {
  background-color: var(--bg-button-active);
  border-top: 2px solid var(--border-dark);
  border-left: 2px solid var(--border-dark);
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  padding-top: 8px;
  padding-left: 23px;
}
