/* ============================================
   HELLA Memory Game — Design System
   ============================================ */

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

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Montserrat', sans-serif;
  background-color: #1A1A1A;
  color: #FFFFFF;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Design Tokens ─────────────────────────── */
:root {
  --hella-yellow: #FFCC00;
  --hella-yellow-glow: rgba(255, 204, 0, 0.4);
  --hella-dark: #1A1A1A;
  --hella-darker: #111111;
  --hella-green: #00A550;
  --hella-green-glow: rgba(0, 165, 80, 0.4);
  --hella-white: #FFFFFF;
  --hella-gray: #AAAAAA;
  --hella-red: #FF4444;

  --glass-bg: rgba(0, 0, 0, 0.55);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-blur: 20px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow-yellow: 0 0 30px var(--hella-yellow-glow), 0 0 60px rgba(255, 204, 0, 0.15);
  --shadow-glow-green: 0 0 20px var(--hella-green-glow);

  --transition-fast: 0.2s ease;
  --transition-normal: 0.35s ease;
  --transition-slow: 0.6s ease;
  --transition-flip: 0.5s ease;
}

/* ── Background ───────────────────────────── */
.screen {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

.bg-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.bg-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg,
      rgba(0, 0, 0, 0.6) 0%,
      rgba(0, 0, 0, 0.3) 40%,
      rgba(0, 0, 0, 0.5) 100%);
  z-index: 1;
}

.content {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Glassmorphism Utilities ──────────────── */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
}

/* ── Logo ─────────────────────────────────── */
.logo {
  width: clamp(280px, 35vw, 400px);
  height: auto;
  filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.5));
}

.logo-large {
  width: clamp(300px, 40vw, 420px);
  height: auto;
  filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.5));
}

/* ── Typography ───────────────────────────── */
.title {
  font-size: clamp(44px, 6vw, 80px);
  font-weight: 700;
  text-align: center;
  line-height: 1.1;
  color: var(--hella-white);
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
  max-width: 820px;
  letter-spacing: -1px;
}

.title .highlight {
  color: var(--hella-yellow);
  font-weight: 800;
  text-shadow: 0 0 40px var(--hella-yellow-glow);
}

.subtitle {
  font-size: clamp(18px, 2.2vw, 26px);
  font-weight: 400;
  text-align: center;
  color: var(--hella-gray);
  max-width: 480px;
  line-height: 1.6;
}

/* ── Buttons ──────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: clamp(14px, 2vh, 24px) clamp(40px, 6vw, 80px);
  font-family: 'Montserrat', sans-serif;
  font-size: clamp(16px, 2.5vh, 28px);
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--hella-dark);
  background: var(--hella-yellow);
  border: none;
  border-radius: var(--radius-xl);
  cursor: pointer;
  box-shadow: var(--shadow-glow-yellow);
  transition: all var(--transition-normal);
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 60%);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 0 40px var(--hella-yellow-glow), 0 0 80px rgba(255, 204, 0, 0.2);
}

.btn-primary:hover::before {
  opacity: 1;
}

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

/* Pulse animation for CTA */
.btn-pulse {
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {

  0%,
  100% {
    box-shadow: var(--shadow-glow-yellow);
  }

  50% {
    box-shadow: 0 0 50px var(--hella-yellow-glow), 0 0 100px rgba(255, 204, 0, 0.25);
  }
}

/* ── Game Logo ─────────────────────────────── */
.game-logo {
  width: clamp(260px, 32vw, 400px);
  height: auto;
  margin: calc(clamp(8px, 1vh, 16px) + 50px) auto clamp(6px, 0.8vh, 12px);
  filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.6));
  display: block;
}

/* ── Card Grid ────────────────────────────── */
.card-grid {
  width: 94%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(6px, 1vw, 14px);
  align-content: start;
  flex: 1;
  margin-top: clamp(16px, 3vh, 40px);
}

/* ── HUD: Timer (floating bottom-left) ────── */
.hud-timer {
  position: fixed;
  top: clamp(16px, 2.5vh, 36px);
  left: clamp(20px, 3vw, 50px);
  width: clamp(100px, 13vw, 150px);
  /* ← LINHA 243: tamanho do círculo do timer */
  height: clamp(100px, 13vw, 150px);
  /* ← LINHA 244: igual ao width acima */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

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

.hud-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 6;
}

.hud-ring-fill {
  fill: none;
  stroke: var(--hella-yellow);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 213.6;
  /* 2π × 34 */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
  filter: drop-shadow(0 0 6px var(--hella-yellow-glow));
}

.hud-ring-fill.warning {
  stroke: var(--hella-red);
  filter: drop-shadow(0 0 8px rgba(255, 68, 68, 0.7));
}

.hud-timer-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.hud-timer-value {
  font-size: clamp(26px, 3.5vw, 46px);
  /* ← LINHA 292: número do cronômetro */
  font-weight: 900;
  color: var(--hella-yellow);
  line-height: 1;
  letter-spacing: -1px;
}

.hud-timer-inner.warning .hud-timer-value {
  color: var(--hella-red);
  animation: timer-pulse 0.8s ease-in-out infinite;
}

.hud-timer-label {
  font-size: clamp(7px, 0.9vw, 12px);
  /* ← LINHA 305: label "segundos" */
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.45);
  line-height: 1;
}

@keyframes timer-pulse {

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

  50% {
    opacity: 0.7;
    transform: scale(1.05);
  }
}

/* ── HUD: Score (floating bottom-right) ───── */
.hud-score {
  position: fixed;
  top: clamp(16px, 2.5vh, 36px);
  right: clamp(20px, 3vw, 50px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 1vw, 10px);
  z-index: 50;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl);
  padding: clamp(14px, 2vw, 24px) clamp(18px, 2.5vw, 32px);
  /* ← LINHA 342: padding interno do score */
}

.hud-score-inner {
  display: flex;
  align-items: baseline;
  gap: 4px;
  line-height: 1;
}

.hud-score-value {
  font-size: clamp(36px, 5vw, 60px);
  /* ← LINHA 353: número de acertos */
  font-weight: 900;
  color: var(--hella-green);
  text-shadow: 0 0 16px var(--hella-green-glow);
  line-height: 1;
}

.hud-score-label {
  font-size: clamp(10px, 1.1vw, 15px);
  /* ← LINHA 361: label "/ 8 pares" */
  font-weight: 600;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hud-score-dots {
  display: flex;
  gap: clamp(4px, 0.5vw, 7px);
  flex-wrap: wrap;
  justify-content: center;
  max-width: clamp(80px, 12vw, 150px);
}

.score-dot {
  width: clamp(10px, 1.2vw, 17px);
  /* ← LINHA 377: tamanho dos pontos do score */
  height: clamp(10px, 1.2vw, 17px);
  /* ← LINHA 378: igual ao width */
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.score-dot.filled {
  background: var(--hella-green);
  border-color: var(--hella-green);
  box-shadow: 0 0 8px var(--hella-green-glow);
  transform: scale(1.15);
}

/* ── Card ─────────────────────────────────── */
.card {
  perspective: 1000px;
  cursor: pointer;
  aspect-ratio: 1 / 1;
  transition: transform var(--transition-fast);
}

.card:hover {
  transform: translateY(-3px);
}

.card:active {
  transform: scale(0.96);
}

.card.matched {
  cursor: default;
}

.card.matched:hover {
  transform: none;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform var(--transition-flip);
  transform-style: preserve-3d;
}

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

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Card back (frente.png) ─────────────── */
.card-back {
  background: #0d1520;
  border: 2px solid rgba(255, 204, 0, 0.15);
  box-shadow: var(--shadow-card);
}

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

/* ── Card front (product image, no white) ── */
.card-front {
  transform: rotateY(180deg);
  background: #111;
  border: 2px solid rgba(255, 204, 0, 0.25);
  box-shadow: var(--shadow-card);
  flex-direction: column;
  padding: 0;
  position: relative;
}

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

/* Name overlay: gradient + white text at bottom */
.card-front .card-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: clamp(6px, 1vh, 12px) clamp(6px, 1vw, 10px) clamp(4px, 0.6vh, 8px);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.5) 60%, transparent 100%);
  font-size: clamp(8px, 1.1vh, 13px);
  font-weight: 700;
  color: #FFFFFF;
  text-align: center;
  line-height: 1.2;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

/* ── Matched state ──────────────────────── */
.card.matched .card-front {
  border-color: var(--hella-green);
  box-shadow: var(--shadow-glow-green), var(--shadow-card);
}

.card.matched .card-inner {
  animation: match-pop 0.4s ease;
}

@keyframes match-pop {
  0% {
    transform: rotateY(180deg) scale(1);
  }

  50% {
    transform: rotateY(180deg) scale(1.09);
  }

  100% {
    transform: rotateY(180deg) scale(1);
  }
}

/* ── Wrong shake ───────────────────────── */
.card.wrong .card-inner {
  animation: shake 0.4s ease;
}

@keyframes shake {

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

  25% {
    transform: rotateY(180deg) translateX(-8px);
  }

  75% {
    transform: rotateY(180deg) translateX(8px);
  }
}

/* ── Match Overlay ─────────────────────────── */
.match-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.match-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.match-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(14px, 2.5vh, 28px);
  padding: clamp(16px, 3vh, 36px);
  border-radius: var(--radius-xl);
  max-width: 92%;
  animation: overlay-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes overlay-in {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.match-image {
  /* 70% do menor lado da viewport → preserva proporção landscape/portrait */
  width: 70vmin;
  height: 70vmin;
  max-width: 70vw;
  max-height: 70vh;
  object-fit: contain;
  filter: drop-shadow(0 8px 40px rgba(0, 0, 0, 0.55));
  border-radius: var(--radius-lg);
}

.match-product-name {
  font-size: clamp(22px, 4vh, 44px);
  font-weight: 800;
  color: var(--hella-yellow);
  text-align: center;
  text-shadow: 0 0 20px rgba(255, 204, 0, 0.4);
}

.match-description {
  font-size: clamp(14px, 2.2vh, 24px);
  font-weight: 400;
  color: var(--hella-gray);
  text-align: center;
  max-width: 60ch;
}

/* ── Screen: Index ──────────────────────── */
.screen-index .content {
  justify-content: center;
  gap: 0;
  padding-bottom: 12vh;
}

.screen-index .logo-large {
  margin-bottom: clamp(28px, 4vh, 56px);
}

.screen-index .title {
  margin-bottom: clamp(14px, 2vh, 28px);
}

.screen-index .subtitle {
  margin-bottom: clamp(32px, 5vh, 64px);
}

.screen-index #btn-start {
  margin-top: clamp(20px, 3vh, 48px);
}

/* ── Screen: End ──────────────────────────── */
/* ── Screen: End ──────────────────────────── */
.screen-end .content {
  justify-content: center;
  align-items: center;
  gap: clamp(20px, 3vh, 40px);
  padding-bottom: 4vh;
}

/* Logo no topo */
.screen-end .logo-large {
  width: 400px;
  margin: 0 auto;
}

/* Card central de resultado */
.end-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(12px, 1.8vh, 22px);
  padding: clamp(28px, 4vw, 52px) clamp(32px, 5vw, 70px);
  border-radius: var(--radius-xl);
  max-width: clamp(340px, 55vw, 720px);
  width: 92%;
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* Brilho atrás do card */
.end-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 204, 0, 0.18) 0%, transparent 60%);
  pointer-events: none;
}

/* Ícone/emoji grande */
.end-icon {
  font-size: clamp(48px, 7vw, 80px);
  line-height: 1;
  filter: drop-shadow(0 0 24px rgba(255, 204, 0, 0.5));
  animation: icon-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.4s both;
}

@keyframes icon-pop {
  from {
    transform: scale(0) rotate(-20deg);
    opacity: 0;
  }

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

/* Título do resultado */
.end-title {
  font-size: clamp(28px, 4.5vw, 56px);
  font-weight: 900;
  color: var(--hella-white);
  letter-spacing: -1px;
  line-height: 1;
  margin: 0;
}

/* Mensagem */
.end-message {
  font-size: clamp(14px, 2vw, 20px);
  font-weight: 400;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.55;
  max-width: 46ch;
  margin: 0;
}

/* Divisor "seu resultado" */
.end-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.end-divider-line {
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
}

.end-divider-label {
  font-size: clamp(9px, 1vw, 12px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.3);
  white-space: nowrap;
}

/* Stats: pares | tempo */
.end-stats {
  display: flex;
  align-items: center;
  gap: clamp(24px, 4vw, 60px);
  width: 100%;
  justify-content: center;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-value {
  font-size: clamp(42px, 6.5vw, 72px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -2px;
}

.stat-pairs {
  color: var(--hella-yellow);
  text-shadow: 0 0 24px rgba(255, 204, 0, 0.45);
}

.stat-time {
  color: var(--hella-green);
  text-shadow: 0 0 24px var(--hella-green-glow);
}

.stat-label {
  font-size: clamp(9px, 1.1vw, 13px);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 1px;
  line-height: 1.3;
}

/* Separador vertical entre stats */
.stat-sep {
  width: 1px;
  height: clamp(48px, 7vh, 72px);
  background: rgba(255, 255, 255, 0.12);
  border-radius: 1px;
}

/* CTA box */
.end-cta {
  font-size: clamp(12px, 1.5vw, 16px);
  font-weight: 500;
  color: var(--hella-white);
  background: rgba(255, 204, 0, 0.12);
  border: 1px solid rgba(255, 204, 0, 0.3);
  border-radius: var(--radius-lg);
  padding: clamp(12px, 1.5vh, 18px) clamp(18px, 2.5vw, 28px);
  line-height: 1.5;
  max-width: 44ch;
}

/* Confetti burst */
.confetti-burst {
  position: fixed;
  top: 40%;
  left: 50%;
  pointer-events: none;
  z-index: 200;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--color);
  animation: confetti-fly 1.6s var(--delay) cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes confetti-fly {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(1);
    opacity: 1;
  }

  80% {
    opacity: 0.8;
  }

  100% {
    transform: translate(var(--x), -60vh) rotate(var(--r)) scale(0.4);
    opacity: 0;
  }
}

/* ── Animations: Page enter ──────────────── */
.fade-in {
  animation: fadeIn 0.6s ease forwards;
}

.slide-up {
  opacity: 0;
  transform: translateY(30px);
  animation: slideUp 0.6s ease forwards;
}

.slide-up-delay-1 {
  animation-delay: 0.15s;
}

.slide-up-delay-2 {
  animation-delay: 0.3s;
}

.slide-up-delay-3 {
  animation-delay: 0.45s;
}

.slide-up-delay-4 {
  animation-delay: 0.6s;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Particles (subtle bg effect) ─────────── */
.particles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 3px;
  height: 3px;
  background: var(--hella-yellow);
  border-radius: 50%;
  opacity: 0;
  animation: float-particle linear infinite;
}

@keyframes float-particle {
  0% {
    opacity: 0;
    transform: translateY(100vh) scale(0);
  }

  10% {
    opacity: 0.6;
  }

  90% {
    opacity: 0.2;
  }

  100% {
    opacity: 0;
    transform: translateY(-10vh) scale(1);
  }
}

/* Generate some particles via nth-child */
.particle:nth-child(1) {
  left: 10%;
  animation-duration: 12s;
  animation-delay: 0s;
  width: 2px;
  height: 2px;
}

.particle:nth-child(2) {
  left: 20%;
  animation-duration: 15s;
  animation-delay: 2s;
  width: 4px;
  height: 4px;
}

.particle:nth-child(3) {
  left: 35%;
  animation-duration: 10s;
  animation-delay: 4s;
}

.particle:nth-child(4) {
  left: 50%;
  animation-duration: 18s;
  animation-delay: 1s;
  width: 2px;
  height: 2px;
}

.particle:nth-child(5) {
  left: 65%;
  animation-duration: 14s;
  animation-delay: 3s;
  width: 4px;
  height: 4px;
}

.particle:nth-child(6) {
  left: 75%;
  animation-duration: 11s;
  animation-delay: 5s;
}

.particle:nth-child(7) {
  left: 85%;
  animation-duration: 16s;
  animation-delay: 2.5s;
  width: 2px;
  height: 2px;
}

.particle:nth-child(8) {
  left: 45%;
  animation-duration: 13s;
  animation-delay: 6s;
  width: 5px;
  height: 5px;
}

.particle:nth-child(9) {
  left: 5%;
  animation-duration: 17s;
  animation-delay: 3.5s;
}

.particle:nth-child(10) {
  left: 92%;
  animation-duration: 12s;
  animation-delay: 1.5s;
  width: 3px;
  height: 3px;
}