/* Piilotus */
.is-hidden {
  display: none !important;
}

/* ============================================================
   SANASTOPELI.CSS — DigiOpo
   Kaikki sanastopeli-* säännöt ja animaatiot
   ============================================================ */

.sanastopeli-page {
  min-height: 100vh;
  background:
    radial-gradient(
      circle at top left,
      rgba(99, 102, 241, 0.22),
      transparent 28%
    ),
    radial-gradient(
      circle at top right,
      rgba(236, 72, 153, 0.18),
      transparent 28%
    ),
    linear-gradient(135deg, #0f172a, #1e1b4b 45%, #3b0764);
  color: #ffffff;
}

.sanastopeli-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
}

.sanastopeli-hero {
  margin-bottom: 1.5rem;
}

.sanastopeli-back-row {
  margin-bottom: 1rem;
}

.sanastopeli-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: #ffffff;
  font-weight: 700;
  padding: 0.85rem 1.1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition:
    background 0.2s ease,
    transform 0.2s ease;
}

.sanastopeli-back-link:hover,
.sanastopeli-back-link:focus-visible {
  background: rgba(255, 255, 255, 0.16);
  transform: translateY(-2px);
  outline: 2px solid rgba(255, 255, 255, 0.4);
  outline-offset: 2px;
}

.sanastopeli-heading {
  text-align: center;
  padding: 1rem 0 0.5rem;
}

.sanastopeli-kicker {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fbbf24;
}

.sanastopeli-heading h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.08;
  font-weight: 800;
  text-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
}

.sanastopeli-heading p {
  margin: 0 auto;
  max-width: 760px;
  color: #ddd6fe;
  font-size: 1rem;
  line-height: 1.6;
}

/* Tilastot */

.sanastopeli-stats {
  display: grid;
  gap: 1rem;
  margin-bottom: 2rem;
  padding: 1rem;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.25);
}

.sanastopeli-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
}

.sanastopeli-stat-card {
  padding: 1rem 0.9rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.sanastopeli-stat-label {
  display: block;
  font-size: 0.82rem;
  color: #ddd6fe;
  margin-bottom: 0.45rem;
}

.sanastopeli-stat-card strong {
  display: block;
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
}

.sanastopeli-stat-card.is-score strong {
  color: #facc15;
}
.sanastopeli-stat-card.is-total strong {
  color: #fde68a;
}
.sanastopeli-stat-card.is-matches strong {
  color: #4ade80;
}
.sanastopeli-stat-card.is-hints strong {
  color: #f472b6;
}

/* Edistymispalkki */

.sanastopeli-progress-wrap {
  width: 100%;
}

.sanastopeli-progress-track {
  height: 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.8);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.sanastopeli-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4ade80, #10b981);
  transition: width 0.35s ease;
}

/* Toimintanapit */

.sanastopeli-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.sanastopeli-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  border-radius: 18px;
  padding: 0.95rem 1.2rem;
  font-size: 0.98rem;
  font-weight: 800;
  color: #ffffff;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    opacity 0.2s ease;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.sanastopeli-btn:hover,
.sanastopeli-btn:focus-visible {
  transform: translateY(-2px);
  outline: 2px solid rgba(255, 255, 255, 0.4);
  outline-offset: 2px;
}

.sanastopeli-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.sanastopeli-btn-hint {
  background: linear-gradient(135deg, #f59e0b, #f97316);
}
.sanastopeli-btn-shuffle {
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
}
.sanastopeli-btn-next {
  width: 100%;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

/* Pelilauta */

.sanastopeli-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
}

.sanastopeli-column h2 {
  margin: 0 0 0.9rem;
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.88);
}

.sanastopeli-cards {
  display: grid;
  gap: 0.9rem;
}

/* Kortit */

.sanastopeli-card {
  width: 100%;
  border: 3px solid transparent;
  border-radius: 22px;
  padding: 1rem;
  text-align: left;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.24);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease,
    opacity 0.2s ease;
}

.sanastopeli-card:hover:not(.matched):not(.card-selected),
.sanastopeli-card:focus-visible:not(.matched):not(.card-selected) {
  transform: translateY(-3px) scale(1.01);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
  outline: 2px solid rgba(255, 255, 255, 0.35);
  outline-offset: 2px;
}

.sanastopeli-card.term-card {
  background: linear-gradient(135deg, #4f46e5, #2563eb);
}
.sanastopeli-card.def-card {
  background: linear-gradient(135deg, #db2777, #ea580c);
}

.sanastopeli-card strong {
  display: block;
  font-size: 1.08rem;
  font-weight: 800;
}

.sanastopeli-card p {
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.55;
}

.sanastopeli-card.card-selected {
  border-color: #fbbf24 !important;
  box-shadow:
    0 0 0 4px rgba(251, 191, 36, 0.18),
    0 16px 34px rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
}

.sanastopeli-card.matched {
  opacity: 0.5;
  transform: scale(0.97);
  pointer-events: none;
  border-color: #22c55e !important;
}

.sanastopeli-card.card-wrong {
  animation: sanastopeli-shake 0.35s ease-in-out;
}

.sanastopeli-card.card-correct {
  animation: sanastopeli-celebrate 0.5s ease-in-out;
}

.sanastopeli-card.hint-highlight {
  border-color: #fbbf24 !important;
  box-shadow:
    0 0 0 4px rgba(251, 191, 36, 0.2),
    0 0 28px rgba(251, 191, 36, 0.35);
  animation: sanastopeli-pulseGlow 1.2s ease-in-out infinite;
}

/* Palaute (toast) */

.sanastopeli-feedback {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 1200;
  opacity: 0;
  pointer-events: none;
  padding: 0.9rem 1.25rem;
  border-radius: 18px;
  font-weight: 800;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.3);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
}

.sanastopeli-feedback.show {
  opacity: 1;
}
.sanastopeli-feedback.success {
  background: #22c55e;
  color: #ffffff;
}
.sanastopeli-feedback.error {
  background: #ef4444;
  color: #ffffff;
}
.sanastopeli-feedback.warning {
  background: #f59e0b;
  color: #ffffff;
}
.sanastopeli-feedback.info {
  background: #3b82f6;
  color: #ffffff;
}

/* Modaali */

.sanastopeli-modal {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sanastopeli-modal.show {
  opacity: 1;
  pointer-events: auto;
}

.sanastopeli-modal-card {
  width: min(100%, 460px);
  padding: 4px;
  border-radius: 28px;
  background: linear-gradient(135deg, #facc15, #fb7185);
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.34);
}

.sanastopeli-modal-inner {
  background: #ffffff;
  color: #1f2937;
  border-radius: 24px;
  padding: 2rem 1.5rem;
  text-align: center;
}

.sanastopeli-modal-inner h2 {
  margin: 0 0 0.5rem;
  font-size: 2rem;
}

.sanastopeli-modal-inner p {
  margin: 0 0 1.25rem;
  color: #4b5563;
}

.sanastopeli-modal-stats {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-bottom: 1.25rem;
}

.sanastopeli-modal-stat {
  min-width: 120px;
  padding: 0.9rem 1rem;
  border-radius: 18px;
  background: #f8fafc;
}

.sanastopeli-modal-stat strong {
  display: block;
  font-size: 1.8rem;
  margin-bottom: 0.25rem;
}

.sanastopeli-modal-stat span {
  color: #6b7280;
  font-size: 0.85rem;
}

/* Konfetti */

.sanastopeli-confetti {
  position: fixed;
  top: -20px;
  width: 12px;
  height: 12px;
  opacity: 1;
  z-index: 1400;
  animation: sanastopeli-confettiFall 3s ease-out forwards;
}

/* Animaatiot */

@keyframes sanastopeli-pulseGlow {
  0%,
  100% {
    box-shadow:
      0 0 0 4px rgba(251, 191, 36, 0.18),
      0 0 18px rgba(251, 191, 36, 0.28);
  }
  50% {
    box-shadow:
      0 0 0 6px rgba(251, 191, 36, 0.24),
      0 0 34px rgba(251, 191, 36, 0.5);
  }
}

@keyframes sanastopeli-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

@keyframes sanastopeli-celebrate {
  0% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.05) rotate(-2deg);
  }
  50% {
    transform: scale(1.08) rotate(2deg);
  }
  75% {
    transform: scale(1.04) rotate(-2deg);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes sanastopeli-confettiFall {
  0% {
    transform: translateY(-10vh) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0;
  }
}

/* Mobiili */

@media (max-width: 900px) {
  .sanastopeli-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .sanastopeli-board {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .sanastopeli-main {
    padding: 1.25rem 0.8rem 2.5rem;
  }
  .sanastopeli-heading h1 {
    font-size: 2.1rem;
  }
  .sanastopeli-actions {
    flex-direction: column;
  }
  .sanastopeli-btn {
    width: 100%;
  }
  .sanastopeli-feedback {
    width: calc(100% - 24px);
    text-align: center;
  }
}