*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg-sky: #74b9ff;
  --bg-grass: #55efc4;
  --card-shadow: 0 8px 0 #2d3436, 0 12px 24px rgba(45, 52, 54, 0.25);
  --card-radius: 18px;
  --card-aspect: 5 / 7;
  --font: "Fredoka", "Comic Sans MS", cursive, sans-serif;
  --text-dark: #2d3436;
  --accent-pink: #fd79a8;
  --accent-yellow: #ffeaa7;
  --accent-green: #00b894;
  --accent-red: #e17055;
  --correct-glow: #55efc4;
  --wrong-glow: #fab1a0;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text-dark);
  overflow-x: hidden;
}

body {
  background-color: var(--bg-sky);
  background-image: url("../assets/bg.png");
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: opacity 0.5s ease;
}

.app--waiting {
  opacity: 0;
  pointer-events: none;
}

.app.is-fading-out .header,
.app.is-fading-out .main {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.title {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  color: #fff;
  text-shadow:
    3px 3px 0 var(--accent-pink),
    -1px -1px 0 #2d3436;
  letter-spacing: 0.02em;
}

.score-badge {
  background: var(--accent-yellow);
  border: 4px solid #2d3436;
  border-radius: 999px;
  padding: 0.4rem 1rem;
  box-shadow: 0 4px 0 #2d3436;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 4.5rem;
}

.score-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.75;
}

.score-value {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.1;
}

.main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-grid {
  display: grid;
  gap: clamp(0.75rem, 2.5vw, 1.25rem);
  width: 100%;
  justify-content: center;
}

.playing-card {
  position: relative;
  width: 100%;
  aspect-ratio: var(--card-aspect);
  max-width: 260px;
  margin: 0 auto;
  padding: 0;
  background: transparent;
  cursor: pointer;
  outline: none;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.playing-card:hover:not(.is-locked) {
  transform: translateY(-4px) scale(1.02);
}

.playing-card:active:not(.is-locked) {
  transform: translateY(2px) scale(0.98);
  box-shadow: 0 4px 0 #2d3436, 0 6px 12px rgba(45, 52, 54, 0.2);
}

.playing-card:focus-visible .card-inner {
  outline: 3px solid var(--accent-yellow);
  outline-offset: 3px;
}

.playing-card.is-locked {
  cursor: default;
}

.playing-card.is-answered {
  cursor: default;
}

.playing-card.is-correct .card-inner {
  border-color: var(--accent-green);
}

.playing-card.is-wrong .card-inner {
  border-color: var(--accent-red);
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--card-radius);
  overflow: hidden;
  background: #fff;
  border: 4px solid #2d3436;
}

.card-back,
.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  text-align: center;
  transition: opacity 0.45s ease;
}

.card-back {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 1;
}

.card-back.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.card-result-badge {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease 0.15s;
}

.card-result-badge.is-visible {
  opacity: 1;
}

.card-result-badge::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(45, 52, 54, 0.2);
}

.card-result-icon {
  position: relative;
  z-index: 1;
  width: clamp(52px, 35%, 72px);
  height: clamp(52px, 35%, 72px);
  border-radius: 50%;
  border: 4px solid #2d3436;
  font-size: clamp(1.75rem, 8vw, 2.5rem);
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 0 #2d3436;
  color: #fff;
}

.card-result-badge--correct .card-result-icon {
  background: var(--accent-green);
}

.card-result-badge--wrong .card-result-icon {
  background: var(--accent-red);
}

.card-face {
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(160deg, #fff 0%, #dfe6e9 100%);
}

.card-face.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.card-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-pink);
  margin-bottom: 0.35rem;
}

.card-text {
  margin: 0;
  font-size: clamp(0.85rem, 2.2vw, 1rem);
  font-weight: 600;
  line-height: 1.35;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
  justify-content: center;
}

.btn-feedback {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid #2d3436;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 0 #2d3436;
  transition: transform 0.12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.btn-feedback:hover {
  transform: scale(1.08);
}

.btn-feedback:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #2d3436;
}

.btn-feedback--correct {
  background: var(--accent-green);
}

.btn-feedback--wrong {
  background: var(--accent-red);
}

.intro-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(45, 52, 54, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.intro-screen.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.intro-card {
  background: #fff;
  border: 5px solid #2d3436;
  border-radius: 28px;
  padding: 1.75rem 1.75rem 1.5rem;
  text-align: center;
  max-width: 440px;
  width: 100%;
  max-height: min(90vh, 640px);
  overflow-y: auto;
  box-shadow: 0 12px 0 #2d3436, 0 20px 40px rgba(45, 52, 54, 0.3);
  transform: scale(0.92);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.intro-screen.is-visible .intro-card {
  transform: scale(1);
}

.intro-emoji {
  font-size: 3.25rem;
  margin: 0 0 0.35rem;
}

.intro-heading {
  margin: 0 0 0.35rem;
  font-size: 1.85rem;
  color: var(--accent-pink);
}

.intro-lead {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.intro-steps {
  margin: 0 0 1.25rem;
  padding-left: 1.25rem;
  text-align: left;
  font-size: 1rem;
  line-height: 1.45;
}

.intro-steps li {
  margin-bottom: 0.5rem;
  padding-left: 0.25rem;
}

.intro-steps li::marker {
  color: var(--accent-pink);
  font-weight: 700;
}

.intro-deck-wrap {
  margin-bottom: 1rem;
  text-align: left;
}

.intro-deck-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.intro-deck-select {
  width: 100%;
  font-family: var(--font);
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
  border: 3px solid #2d3436;
  border-radius: 12px;
  background: #fff;
}

.btn-start {
  font-family: var(--font);
  font-size: 1.2rem;
  font-weight: 700;
  padding: 0.85rem 2.25rem;
  border: 4px solid #2d3436;
  border-radius: 999px;
  background: var(--accent-green);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 0 #2d3436;
  transition: transform 0.12s ease;
}

.btn-start:hover {
  transform: scale(1.05);
}

.btn-start:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #2d3436;
}

.intro-builder-link {
  margin: 1rem 0 0;
  font-size: 0.85rem;
}

.intro-builder-link a {
  color: var(--text-dark);
  opacity: 0.75;
}

.results-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(45, 52, 54, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s ease;
}

.results-screen.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.results-card {
  background: #fff;
  border: 5px solid #2d3436;
  border-radius: 28px;
  padding: 2rem 2rem 1.75rem;
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 12px 0 #2d3436, 0 20px 40px rgba(45, 52, 54, 0.3);
  transform: scale(0.9);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.results-screen.is-visible .results-card {
  transform: scale(1);
}

.results-emoji {
  font-size: 3.5rem;
  margin: 0 0 0.5rem;
}

.results-heading {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
  color: var(--accent-pink);
}

.results-score {
  margin: 0 0 0.75rem;
  font-size: 1.35rem;
  font-weight: 700;
}

.results-message {
  margin: 0 0 1.5rem;
  font-size: 1rem;
  opacity: 0.85;
}

.btn-play-again {
  font-family: var(--font);
  font-size: 1.15rem;
  font-weight: 700;
  padding: 0.85rem 2rem;
  border: 4px solid #2d3436;
  border-radius: 999px;
  background: var(--accent-yellow);
  color: var(--text-dark);
  cursor: pointer;
  box-shadow: 0 6px 0 #2d3436;
  transition: transform 0.12s ease;
}

.btn-play-again:hover {
  transform: scale(1.05);
}

.btn-play-again:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #2d3436;
}

.btn-mute {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 30;
  width: 52px;
  height: 52px;
  border: 4px solid #2d3436;
  border-radius: 50%;
  background: var(--accent-yellow);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 5px 0 #2d3436;
  transition: transform 0.12s ease, background 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.btn-mute:hover {
  transform: scale(1.08);
}

.btn-mute:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #2d3436;
}

.btn-mute.is-muted {
  background: #dfe6e9;
}

@media (max-width: 520px) {
  .playing-card {
    max-width: 200px;
  }

  .btn-feedback {
    width: 42px;
    height: 42px;
    font-size: 1.25rem;
  }

  .btn-mute {
    right: 1rem;
    bottom: 1rem;
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
  }
}
