* {
  box-sizing: border-box;
}

:root {
  --bg-0: #0f172a;
  --bg-1: #1e293b;
  --fg: #f8fafc;
  --muted: #94a3b8;
  --card: #ffffff;
  --card-fg: #0f172a;
  --familjeliv: #ec4899;
  --familjeliv-2: #f472b6;
  --flashback: #0ea5e9;
  --flashback-2: #38bdf8;
  --correct: #22c55e;
  --wrong: #ef4444;
  --shadow:
    0 30px 60px -20px rgba(0, 0, 0, 0.55), 0 18px 36px -18px rgba(0, 0, 0, 0.4);
  --radius: 22px;
}

html,
body {
  margin: 0;
  height: 100%;
  color: var(--fg);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
  background:
    radial-gradient(
      900px 600px at 80% -10%,
      rgba(236, 72, 153, 0.25),
      transparent 60%
    ),
    radial-gradient(
      900px 600px at -10% 110%,
      rgba(14, 165, 233, 0.25),
      transparent 60%
    ),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  padding-top: max(1rem, env(safe-area-inset-top));
}

.topbar h1 {
  margin: 0;
  flex: 1;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.title-btn {
  appearance: none;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  text-align: left;
}

.title-btn:hover {
  opacity: 0.85;
}

.topbar .vs {
  display: inline-block;
  margin: 0 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  background: linear-gradient(90deg, var(--familjeliv), var(--flashback-2));
  color: #fff;
  vertical-align: 2px;
}

.topbar nav {
  display: flex;
  gap: 0.35rem;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg);
  cursor: pointer;
  transition:
    background 0.15s ease,
    transform 0.1s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}
.icon-btn:active {
  transform: translateY(1px);
}
.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 0 1rem 1.5rem;
}

.screen {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.screen[hidden] {
  display: none;
}

.hero {
  background: linear-gradient(
    160deg,
    rgba(255, 255, 255, 0.07),
    rgba(255, 255, 255, 0.02)
  );
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
  backdrop-filter: blur(8px);
}

.hero-badge {
  display: inline-block;
  margin-bottom: 1rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0.15em;
  font-size: 0.75rem;
  background: linear-gradient(90deg, var(--familjeliv), var(--flashback-2));
  color: #fff;
}

.hero h2 {
  margin: 0 0 0.5rem;
  font-size: 1.85rem;
  line-height: 1.2;
}

.hero p {
  color: var(--muted);
  margin: 0 0 1.5rem;
  line-height: 1.55;
}

.hero p:last-child {
  margin-bottom: 0;
}
.hero strong {
  color: var(--fg);
  font-weight: 600;
}
.hero a {
  color: var(--flashback-2);
}
.hero img {
  max-width: 200px;
  height: auto;
  opacity: 0.9;
}
.hint-text {
  font-size: 0.85rem;
  margin-top: 1rem !important;
}
.credits {
  font-size: 0.9rem;
  line-height: 1.7;
}

.primary-btn {
  appearance: none;
  border: none;
  padding: 0.95rem 1.8rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  background: linear-gradient(90deg, var(--familjeliv), var(--flashback-2));
  cursor: pointer;
  box-shadow: 0 14px 30px -12px rgba(56, 189, 248, 0.55);
  transition:
    transform 0.1s ease,
    filter 0.15s ease;
}

.primary-btn:hover {
  filter: brightness(1.08);
}
.primary-btn:active {
  transform: translateY(1px) scale(0.98);
}

.score {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--muted);
}

.score strong {
  color: var(--fg);
  font-weight: 700;
  margin: 0 0.25rem;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin: 0 0.4rem;
  vertical-align: middle;
}

.dot-correct {
  background: var(--correct);
  box-shadow: 0 0 12px var(--correct);
}
.dot-wrong {
  background: var(--wrong);
  box-shadow: 0 0 12px var(--wrong);
}

.score-correct.flash strong,
.score-wrong.flash strong {
  animation: pop 0.4s ease;
}

@keyframes pop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.5);
  }
  100% {
    transform: scale(1);
  }
}

.progress {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 100%;
  background: var(--correct);
  transition:
    width 0.35s ease,
    background 0.35s ease;
}

.card-stack {
  position: relative;
  min-height: 300px;
  display: flex;
  align-items: stretch;
}

.card {
  position: relative;
  width: 100%;
  background: var(--card);
  color: var(--card-fg);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
  cursor: grab;
  transition:
    transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 0.25s ease;
  will-change: transform;
}

.card.dragging {
  transition: none;
  cursor: grabbing;
}

#sentence {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.55;
  font-weight: 500;
  color: #0f172a;
}

.card-label {
  position: absolute;
  top: 1rem;
  padding: 0.35rem 0.75rem;
  border-radius: 10px;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 3px solid currentColor;
  opacity: 0;
  pointer-events: none;
}

.card-label-familjeliv {
  left: 1rem;
  color: var(--familjeliv);
  transform: rotate(-14deg);
}

.card-label-flashback {
  right: 1rem;
  color: var(--flashback);
  transform: rotate(14deg);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.action-btn {
  appearance: none;
  border: none;
  padding: 1.05rem 1rem;
  border-radius: 18px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  transition:
    transform 0.1s ease,
    filter 0.15s ease,
    box-shadow 0.15s ease;
  box-shadow: 0 12px 22px -14px rgba(0, 0, 0, 0.6);
}

.action-btn:active {
  transform: translateY(1px) scale(0.98);
}
.action-btn:hover {
  filter: brightness(1.1);
}
.action-familjeliv {
  background: linear-gradient(135deg, var(--familjeliv), var(--familjeliv-2));
}
.action-flashback {
  background: linear-gradient(135deg, var(--flashback), var(--flashback-2));
}

.action-arrow {
  font-size: 1.2rem;
  line-height: 1;
  opacity: 0.85;
}

.feedback-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 100;
}

.feedback-flash.show {
  animation: flash 0.45s ease;
}
.feedback-flash.correct {
  background: radial-gradient(
    circle at center,
    rgba(34, 197, 94, 0.35),
    transparent 60%
  );
}
.feedback-flash.wrong {
  background: radial-gradient(
    circle at center,
    rgba(239, 68, 68, 0.35),
    transparent 60%
  );
}

@keyframes flash {
  0% {
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@media (min-width: 600px) {
  .topbar h1 {
    font-size: 1.15rem;
  }
  .hero h2 {
    font-size: 2.2rem;
  }
  #sentence {
    font-size: 1.4rem;
  }
  .card {
    padding: 2.5rem 2rem;
  }
  .card-stack {
    min-height: 340px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .progress-bar,
  .icon-btn,
  .primary-btn,
  .action-btn {
    transition: none !important;
  }

  .feedback-flash.show,
  .score-correct.flash strong,
  .score-wrong.flash strong {
    animation: none !important;
  }
}
