﻿* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #0f0c29;
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  color: #fff;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
body::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
      circle at 20% 50%,
      rgba(120, 119, 198, 0.3),
      transparent 50%
    ),
    radial-gradient(circle at 80% 80%, rgba(67, 233, 123, 0.2), transparent 50%);
  pointer-events: none;
  animation: bgPulse 8s ease-in-out infinite;
}
@keyframes bgPulse {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 0.8;
  }
}
#app {
  width: 100%;
  max-width: 1200px;
  padding: 20px;
  position: relative;
  z-index: 1;
}
.screen {
  display: none;
  animation: fadeIn 0.5s ease;
}
.screen.active {
  display: block;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.hero {
  text-align: center;
  margin-bottom: 40px;
  position: relative;
}
.title {
  font-size: 4rem;
  margin-bottom: 15px;
  background: linear-gradient(45deg, #43e97b, #38f9d7, #667eea);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: titleGlow 3s ease-in-out infinite;
  font-weight: 900;
  letter-spacing: -2px;
}
@keyframes titleGlow {
  0%,
  100% {
    filter: drop-shadow(0 0 20px rgba(67, 233, 123, 0.6));
  }
  50% {
    filter: drop-shadow(0 0 40px rgba(56, 249, 215, 0.8));
  }
}
.subtitle {
  font-size: 1.5rem;
  opacity: 0.95;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.9),
    rgba(255, 255, 255, 0.7)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 600;
}
.difficulty-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 25px;
  margin: 40px 0;
}
.diff-btn {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0.03)
  );
  backdrop-filter: blur(20px);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 40px 25px;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  color: #fff;
  font-family: inherit;
  position: relative;
  overflow: hidden;
}
.diff-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(67, 233, 123, 0.2),
    rgba(56, 249, 215, 0.2)
  );
  opacity: 0;
  transition: opacity 0.4s ease;
}
.diff-btn:hover::before {
  opacity: 1;
}
.diff-btn:hover {
  transform: translateY(-12px) scale(1.05);
  border-color: rgba(67, 233, 123, 0.6);
  box-shadow: 0 20px 60px rgba(67, 233, 123, 0.4),
    0 0 40px rgba(56, 249, 215, 0.3);
}
.diff-btn.easy:hover {
  box-shadow: 0 20px 60px rgba(46, 204, 113, 0.4);
}
.diff-btn.medium:hover {
  box-shadow: 0 20px 60px rgba(52, 152, 219, 0.4);
}
.diff-btn.hard:hover {
  box-shadow: 0 20px 60px rgba(155, 89, 182, 0.4);
}
.diff-icon {
  font-size: 3.5rem;
  margin-bottom: 15px;
  filter: drop-shadow(0 4px 12px rgba(67, 233, 123, 0.5));
  animation: iconFloat 3s ease-in-out infinite;
  position: relative;
  z-index: 1;
}
@keyframes iconFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}
.diff-name {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 10px;
  position: relative;
  z-index: 1;
}
.diff-desc {
  font-size: 1.1rem;
  opacity: 0.85;
  position: relative;
  z-index: 1;
}
.instructions {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.05)
  );
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 35px;
  margin-top: 40px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
h3 {
  margin-bottom: 20px;
  font-size: 1.6rem;
  font-weight: 700;
  background: linear-gradient(90deg, #43e97b, #38f9d7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
ul {
  list-style: none;
  padding: 0;
}
li {
  padding: 12px 0;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  opacity: 0.95;
  transition: all 0.3s ease;
}
li:hover {
  transform: translateX(8px);
  opacity: 1;
}
.hud {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 40px;
}
.timer-box,
.score-box {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.12),
    rgba(255, 255, 255, 0.05)
  );
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 25px 50px;
  text-align: center;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}
.timer-box::before,
.score-box::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #43e97b, #38f9d7);
  opacity: 0.8;
}
.timer-label,
.score-label {
  font-size: 1rem;
  opacity: 0.8;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 600;
}
.timer,
.score {
  font-size: 3.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, #43e97b, #38f9d7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 4px 8px rgba(67, 233, 123, 0.3));
}
.timer.warning {
  background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    filter: drop-shadow(0 4px 8px rgba(255, 107, 107, 0.3));
  }
  50% {
    transform: scale(1.15);
    filter: drop-shadow(0 8px 16px rgba(255, 107, 107, 0.6));
  }
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  max-width: 700px;
  margin: 0 auto;
  perspective: 1000px;
}
.card {
  aspect-ratio: 1;
  background: transparent;
  border-radius: 16px;
  cursor: pointer;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
}
.card:hover:not(.flipped):not(.matched) {
  transform: translateY(-10px) rotateX(5deg);
  filter: drop-shadow(0 20px 40px rgba(67, 233, 123, 0.4));
}
.card.flipped,
.card.matched {
  transform: rotateY(180deg);
  pointer-events: none;
}
.card.matched {
  opacity: 0;
  transition: opacity 0.5s ease 0.3s;
}
.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  padding: 15px;
}
.card-front {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 10px 40px rgba(102, 126, 234, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  position: relative;
  overflow: hidden;
}
.card-front::before {
  content: "?";
  font-size: 4rem;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.15);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-shadow: 0 4px 20px rgba(255, 255, 255, 0.3);
}
.card-front::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 30% 30%,
    rgba(255, 255, 255, 0.2),
    transparent 70%
  );
  pointer-events: none;
}
.card-back {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  transform: rotateY(180deg);
  color: #2d3436;
  font-size: 1.3rem;
  font-weight: 800;
  word-wrap: break-word;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  line-height: 1.3;
  text-transform: lowercase;
}
.card.correct {
  animation: correctFlash 0.8s ease;
}
.card.incorrect {
  animation: shake 0.6s ease;
}
@keyframes correctFlash {
  0% {
    transform: rotateY(180deg) scale(1);
    filter: drop-shadow(0 0 0 transparent);
  }
  25% {
    transform: rotateY(180deg) scale(1.2);
    filter: drop-shadow(0 0 30px rgba(46, 204, 113, 1));
  }
  50% {
    transform: rotateY(180deg) scale(1.15) rotateZ(5deg);
    filter: drop-shadow(0 0 50px rgba(46, 204, 113, 1));
  }
  75% {
    transform: rotateY(180deg) scale(1.2) rotateZ(-5deg);
    filter: drop-shadow(0 0 30px rgba(46, 204, 113, 0.8));
  }
  100% {
    transform: rotateY(180deg) scale(1);
    filter: drop-shadow(0 0 0 transparent);
  }
}
@keyframes shake {
  0%,
  100% {
    transform: rotateY(180deg) translateX(0) rotateZ(0);
  }
  15% {
    transform: rotateY(180deg) translateX(-15px) rotateZ(-5deg);
  }
  30% {
    transform: rotateY(180deg) translateX(15px) rotateZ(5deg);
  }
  45% {
    transform: rotateY(180deg) translateX(-15px) rotateZ(-5deg);
  }
  60% {
    transform: rotateY(180deg) translateX(15px) rotateZ(5deg);
  }
  75% {
    transform: rotateY(180deg) translateX(-10px) rotateZ(-3deg);
  }
  90% {
    transform: rotateY(180deg) translateX(10px) rotateZ(3deg);
  }
}
.card.correct .card-back {
  background: linear-gradient(135deg, #2ecc71, #27ae60);
  color: #fff;
  box-shadow: 0 0 60px rgba(46, 204, 113, 1),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.card.incorrect .card-back {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: #fff;
  box-shadow: 0 0 40px rgba(231, 76, 60, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.time-bonus {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 6rem;
  font-weight: 900;
  background: linear-gradient(135deg, #2ecc71, #27ae60);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  pointer-events: none;
  z-index: 1000;
  filter: drop-shadow(0 0 40px rgba(46, 204, 113, 1));
}
.time-bonus.show {
  animation: bonusAppear 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes bonusAppear {
  0% {
    transform: translate(-50%, -50%) scale(0) rotate(-180deg);
    opacity: 0;
    filter: drop-shadow(0 0 0 transparent);
  }
  40% {
    transform: translate(-50%, -50%) scale(1.8) rotate(10deg);
    opacity: 1;
    filter: drop-shadow(0 0 60px rgba(46, 204, 113, 1));
  }
  60% {
    transform: translate(-50%, -50%) scale(1.6) rotate(-5deg);
    opacity: 1;
    filter: drop-shadow(0 0 50px rgba(46, 204, 113, 0.8));
  }
  100% {
    transform: translate(-50%, -80%) scale(0.3) rotate(0);
    opacity: 0;
    filter: drop-shadow(0 0 0 transparent);
  }
}
.results-card {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.12),
    rgba(255, 255, 255, 0.05)
  );
  backdrop-filter: blur(25px);
  border-radius: 24px;
  padding: 60px 50px;
  text-align: center;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: hidden;
}
.results-card::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle,
    rgba(67, 233, 123, 0.15),
    transparent 70%
  );
  animation: resultGlow 4s ease-in-out infinite;
}
@keyframes resultGlow {
  0%,
  100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(20px, 20px);
  }
}
.results-title {
  font-size: 3rem;
  margin-bottom: 35px;
  background: linear-gradient(135deg, #43e97b, #38f9d7, #667eea);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 900;
  position: relative;
  z-index: 1;
  animation: titlePulse 2s ease-in-out infinite;
}
@keyframes titlePulse {
  0%,
  100% {
    filter: drop-shadow(0 0 20px rgba(67, 233, 123, 0.5));
  }
  50% {
    filter: drop-shadow(0 0 40px rgba(56, 249, 215, 0.8));
  }
}
.final-score-display {
  margin: 40px 0;
  position: relative;
  z-index: 1;
}
.final-score-display span:first-child {
  font-size: 6rem;
  font-weight: 900;
  background: linear-gradient(135deg, #ffd700, #ffed4e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 8px 20px rgba(255, 215, 0, 0.5));
  display: inline-block;
  animation: scoreCount 1s ease-out;
}
.score-label-text {
  font-size: 2.2rem;
  opacity: 0.85;
  margin-left: 15px;
  font-weight: 600;
}
@keyframes scoreCount {
  from {
    transform: scale(0);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
.new-high-badge {
  background: linear-gradient(135deg, #ffd700, #ffed4e);
  color: #1a1a2e;
  padding: 18px 40px;
  border-radius: 50px;
  font-weight: 900;
  font-size: 1.4rem;
  margin: 25px 0;
  display: inline-block;
  box-shadow: 0 10px 40px rgba(255, 215, 0, 0.6);
  position: relative;
  z-index: 1;
  animation: bounce 1.5s ease-in-out infinite, shine 3s linear infinite;
}
@keyframes bounce {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-15px) scale(1.05);
  }
}
@keyframes shine {
  0% {
    filter: brightness(1) saturate(1);
  }
  50% {
    filter: brightness(1.2) saturate(1.3);
  }
  100% {
    filter: brightness(1) saturate(1);
  }
}
.results-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 25px;
  margin: 50px 0;
  position: relative;
  z-index: 1;
}
.stat-item {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.05)
  );
  padding: 30px;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}
.stat-item:hover {
  transform: translateY(-8px);
  box-shadow: 0 15px 40px rgba(67, 233, 123, 0.3);
  border-color: rgba(67, 233, 123, 0.5);
}
.stat-value {
  font-size: 2.8rem;
  font-weight: 900;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #43e97b, #38f9d7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 8px rgba(67, 233, 123, 0.3));
}
.stat-label {
  font-size: 1.1rem;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}
.btn-primary,
.btn-secondary {
  width: 100%;
  padding: 20px;
  font-size: 1.3rem;
  font-weight: 800;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  color: #fff;
  margin-top: 15px;
  text-transform: uppercase;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
}
.btn-primary::before,
.btn-secondary::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
  opacity: 0;
  transition: opacity 0.4s ease;
}
.btn-primary:hover::before,
.btn-secondary:hover::before {
  opacity: 1;
}
.btn-primary {
  background: linear-gradient(135deg, #43e97b, #38f9d7);
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 10px 30px rgba(67, 233, 123, 0.4);
}
.btn-primary:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 15px 50px rgba(67, 233, 123, 0.6);
}
.btn-secondary {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.15),
    rgba(255, 255, 255, 0.08)
  );
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}
.btn-secondary:hover {
  transform: translateY(-5px);
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.25),
    rgba(255, 255, 255, 0.15)
  );
  box-shadow: 0 12px 30px rgba(255, 255, 255, 0.2);
}
.results-actions {
  display: flex;
  gap: 20px;
  position: relative;
  z-index: 1;
}
@media (max-width: 768px) {
  .title {
    font-size: 3rem;
  }
  .subtitle {
    font-size: 1.2rem;
  }
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 100%;
  }
  .card-back {
    font-size: 1.1rem;
  }
  .difficulty-selector {
    grid-template-columns: 1fr;
  }
  .diff-btn {
    padding: 30px 20px;
  }
  .hud {
    gap: 20px;
    flex-wrap: wrap;
  }
  .timer-box,
  .score-box {
    padding: 20px 35px;
  }
  .timer,
  .score {
    font-size: 2.8rem;
  }
  .results-stats {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  .results-actions {
    flex-direction: column;
    gap: 15px;
  }
  .time-bonus {
    font-size: 4.5rem;
  }
}
