/* ═══════════════════════════════════════════════════════════════════════════
   style.css — Design System · Jogo da Memória LPT
   Laboratório de Leitura e Produção Textual
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

/* ─── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  /* ── Paleta LPT — Baseada em BG (#008990) e Cor 2 (#00bba7) ──────────── */
  /*  #008990 → H 183° S 100% L 28% (Fundo Principal)                      */
  /*  #00bba7 → H 173° S 100% L 36% (Cor Secundária/Destaque)              */

  --teal-dark: #00665c;
  /* L 20% — ênfase alta, ícones e textos         */
  --teal: #00bba7;
  /* L 36% — cor secundária / destaque            */
  --teal-mid: #009e8e;
  /* L 31% — hover / gradiente intermediário      */
  --teal-light: #4dd0bf;
  /* L 55% — destaques suaves                    */
  --teal-pale: #b2ece6;
  /* L 80% — bordas, badges                      */

  /* Destaque dourado — mantido para iconografia e rankings */
  --gold: #f0a500;
  /* âmbar — legível sobre branco                 */
  --gold-light: #fef3c7;
  /* dourado muito claro                          */
  --gold-dark: #b37800;
  /* dourado escuro para texto                    */

  /* Backgrounds */
  --bg-deep: #008990;
  /* fundo principal escuro                       */
  --bg-dark: #e0f5f3;
  /* seção alternada / fundo claro secundário     */
  --bg-card: #ffffff;
  /* cards / modais                               */
  --bg-surface: #f0fbf9;
  /* superfícies elevadas                         */

  /* Texto — escuro sobre fundo claro */
  --text-primary: #0b2d2a;
  /* quase preto com leve matiz teal              */
  --text-muted: #245c55;
  /* texto secundário                             */
  --text-dim: #568c85;
  /* texto terciário / placeholder                */

  /* Sistema */
  --border: rgba(0, 187, 167, 0.22);
  --shadow-sm: 0 2px 8px rgba(0, 50, 45, 0.15);
  --shadow-md: 0 8px 24px rgba(0, 50, 45, 0.20);
  --shadow-lg: 0 20px 60px rgba(0, 50, 45, 0.28);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --transition: all .25s cubic-bezier(.4, 0, .2, 1);
  --font: 'Outfit', sans-serif;
}

/* ─── Reset & Base ───────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

img {
  display: block;
  max-width: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

button {
  font-family: var(--font);
  cursor: pointer;
  border: none;
  outline: none;
}

/* ─── Background Mesh ────────────────────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 10% 20%, rgba(0, 187, 167, .10) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 90% 80%, rgba(77, 208, 191, .07) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 50% 50%, rgba(240, 165, 0, .04) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.screen {
  display: none;
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .85rem 2rem;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .02em;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0);
  transition: background .2s;
}

.btn:hover::after {
  background: rgba(255, 255, 255, .15);
}

.btn:active {
  transform: scale(.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--teal-mid), var(--teal));
  color: #fff;
  box-shadow: 0 4px 18px rgba(0, 187, 167, .35);
}

.btn-primary:hover {
  box-shadow: 0 6px 24px rgba(0, 187, 167, .5);
  transform: translateY(-1px);
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #fff;
  box-shadow: 0 4px 18px rgba(240, 165, 0, .35);
}

.btn-gold:hover {
  box-shadow: 0 6px 24px rgba(240, 165, 0, .5);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--teal-dark);
  border: 1.5px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--teal);
  background: rgba(0, 187, 167, .06);
  color: var(--teal-dark);
}

.btn-danger {
  background: rgba(220, 50, 50, .08);
  color: #c0392b;
  border: 1.5px solid rgba(220, 50, 50, .25);
}

.btn-danger:hover {
  background: rgba(220, 50, 50, .15);
}

/* ─── Logo / Brand ───────────────────────────────────────────────────────── */
.brand {
  text-align: center;
  padding: 2.5rem 1rem 1rem;
}

.brand-acronym {
  font-size: clamp(2.5rem, 8vw, 3.5rem);
  font-weight: 800;
  background: linear-gradient(135deg, var(--bg-deep), var(--teal));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
  letter-spacing: -.02em;
}

.brand-name {
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: .5rem;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.brand-divider {
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, var(--bg-deep), var(--teal));
  border-radius: 99px;
  margin: 1rem auto;
}

/* ─── Inputs ─────────────────────────────────────────────────────────────── */
.input-group {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.input-group label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.input-group input {
  font-family: var(--font);
  font-size: 1.05rem;
  padding: .9rem 1.2rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 187, 167, .04);
  border: 1.5px solid var(--border);
  color: var(--text-primary);
  transition: var(--transition);
  width: 100%;
}

.input-group input:focus {
  outline: none;
  border-color: var(--teal);
  background: rgba(0, 187, 167, .07);
  box-shadow: 0 0 0 3px rgba(0, 187, 167, .18);
}

.input-group input::placeholder {
  color: var(--text-dim);
}

/* ─── Card ─────────────────────────────────────────────────────────────── */
.card {
  aspect-ratio: 3/4;
  cursor: pointer;
  perspective: 900px;
  border-radius: var(--radius-sm);
  transition: transform .15s ease;
}

.card:hover:not(.matched) {
  transform: scale(1.04);
}

.card.matched {
  cursor: default;
}

.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.4, 0, .2, 1);
  border-radius: var(--radius-sm);
}

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

.card-front,
.card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 2px solid rgba(0, 0, 0, .06);
}

.card-front img,
.card-back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-back {
  transform: rotateY(180deg);
  background: #fff;
}


.card.matched .card-front,
.card.matched .card-back {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(240, 165, 0, .45);
}

/* ─── HUD ────────────────────────────────────────────────────────────────── */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  padding: 1rem 1.5rem;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .1rem;
  min-width: 60px;
}

.hud-item .label {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-dim);
}

.hud-item .value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.hud-item.highlight .value {
  color: var(--gold-dark);
}

/* ─── Verso Badge ────────────────────────────────────────────────────────── */
.verso-badge {
  font-size: .78rem;
  font-weight: 700;
  padding: .3rem .8rem;
  border-radius: 99px;
  letter-spacing: .04em;
}

.verso-badge.azul {
  background: rgba(59, 130, 246, .12);
  color: #1d4ed8;
  border: 1px solid rgba(59, 130, 246, .25);
}

.verso-badge.vermelho {
  background: rgba(239, 68, 68, .10);
  color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, .22);
}

/* ─── Time Warning (últimos 10s) ─────────────────────────────────────────── */
@keyframes pulse-red {

  0%,
  100% {
    color: #dc2626;
    text-shadow: 0 0 8px rgba(220, 38, 38, .4);
  }

  50% {
    color: #991b1b;
    text-shadow: 0 0 18px rgba(220, 38, 38, .6);
  }
}

.time-warning {
  animation: pulse-red .7s ease-in-out infinite;
}

/* ─── Modal title danger variant ─────────────────────────────────────────── */
.modal-title--danger {
  color: #dc2626;
}

/* ─── Game Grid ──────────────────────────────────────────────────────────── */
#game-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
  padding: 1.25rem;
  flex: 1;
  align-content: center;
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
}

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13, 46, 43, .45);
  backdrop-filter: blur(6px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: modalIn .35s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(.88) translateY(20px);
  }

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

.modal-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
}

.modal-title {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--teal-dark);
  margin-bottom: .5rem;
}

.modal-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.modal-stats {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.modal-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.modal-stat .stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--teal);
  line-height: 1;
}

.modal-stat .stat-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-dim);
  margin-top: .3rem;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

/* ─── Confetti Canvas ────────────────────────────────────────────────────── */
#confetti-canvas {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99;
  pointer-events: none;
}

/* ─── Screen: Home ───────────────────────────────────────────────────────── */
#screen-home {
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.home-card {
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
}



.home-actions {
  display: flex;
  flex-direction: column;
  gap: .8rem;
  margin-top: 1.5rem;
}

/* ─── Screen: Game ───────────────────────────────────────────────────────── */
#screen-game {
  background: transparent;
}

.game-screen-inner {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Screen: Ranking ────────────────────────────────────────────────────── */
#screen-ranking {
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.ranking-card {
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 680px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  z-index: 1;
}

.ranking-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ranking-header h2 {
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(90deg, var(--bg-deep), var(--teal));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.ranking-list {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: .65rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.ranking-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 1rem;
  padding: 3rem 1rem;
}

.ranking-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.ranking-item:hover {
  border-color: var(--teal);
  transform: translateX(4px);
  box-shadow: var(--shadow-md);
}

.ranking-item.top-1 {
  border-color: var(--gold);
  background: linear-gradient(135deg, rgba(240, 165, 0, .10), var(--bg-surface));
}

.ranking-item.top-2 {
  border-color: #a0a0a0;
}

.ranking-item.top-3 {
  border-color: #cd7f32;
}

.rank-position {
  font-size: 1.4rem;
  font-weight: 800;
  min-width: 36px;
  text-align: center;
}

.top-1 .rank-position {
  color: var(--gold);
}

.top-2 .rank-position {
  color: #909090;
}

.top-3 .rank-position {
  color: #cd7f32;
}

.rank-info {
  flex: 1;
}

.rank-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.rank-meta {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .15rem;
}

.rank-scores {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .2rem;
}

.rank-attempts {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--teal);
}

.rank-time {
  font-size: .8rem;
  color: var(--text-muted);
}

.ranking-actions {
  display: flex;
  gap: .75rem;
  margin-top: 1.5rem;
  width: 100%;
  max-width: 680px;
}

.ranking-actions .btn {
  flex: 1;
}


/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
  background: var(--teal-pale);
  border-radius: 99px;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .brand-acronym {
    font-size: 3.8rem;
  }

  #game-grid {
    gap: .5rem;
    padding: .75rem;
  }

  .hud {
    padding: .75rem 1rem;
  }

  .hud-item .value {
    font-size: .95rem;
  }

  .modal-box {
    padding: 2rem 1.5rem;
  }

  .modal-stats {
    gap: 1rem;
  }
}

@media (max-width: 360px) {
  #game-grid {
    gap: .4rem;
    padding: .5rem;
  }
}