:root {
  --ink: #1e293b;
  --muted: #64748b;
  --paper: #fffdf6;
  --sun: #ffd166;
  --coral: #ff6b6b;
  --sky: #58c7f3;
  --mint: #56d68a;
  --violet: #8b5cf6;
  --rose: #f472b6;
  --orange: #fb923c;
  --line: rgba(30, 41, 59, 0.12);
  --shadow: 0 18px 38px rgba(31, 41, 55, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family:
    "Trebuchet MS",
    "Segoe UI",
    system-ui,
    sans-serif;
  background:
    radial-gradient(circle at 16% 10%, rgba(255, 209, 102, 0.45), transparent 25%),
    radial-gradient(circle at 86% 8%, rgba(88, 199, 243, 0.38), transparent 28%),
    linear-gradient(135deg, #fff7cf 0%, #dff9fb 45%, #ecfccb 100%);
}

button {
  border: 0;
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: clamp(14px, 3vw, 28px);
}

.stage {
  width: min(1120px, 100%);
  min-height: calc(100vh - clamp(28px, 6vw, 56px));
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo-burst {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 18px;
  color: #fff;
  font-size: 32px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--coral), var(--orange), var(--mint));
  box-shadow: var(--shadow);
  animation: floaty 3.6s ease-in-out infinite;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: clamp(25px, 4vw, 44px);
  line-height: 1;
  letter-spacing: 0;
}

.brand p {
  color: var(--muted);
  font-size: clamp(15px, 2vw, 20px);
}

.brand-detail {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: clamp(14px, 1.8vw, 18px);
  font-weight: 700;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.home-link {
  min-width: 50px;
  min-height: 50px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  font-size: 24px;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.88);
  border: 4px solid rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 18px rgba(30, 41, 59, 0.12);
  transition: transform 160ms ease;
}

.home-link:hover {
  transform: translateY(-2px) scale(1.04);
}

.pill {
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  color: #fff;
  font-weight: 900;
  background: #0ea5e9;
  box-shadow: 0 10px 20px rgba(14, 165, 233, 0.24);
  white-space: nowrap;
}

.back-button,
.round-button {
  min-width: 50px;
  min-height: 50px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  cursor: pointer;
  background: #1e293b;
  box-shadow: 0 10px 18px rgba(30, 41, 59, 0.2);
  transition:
    transform 160ms ease,
    filter 160ms ease;
}

.back-button:hover,
.round-button:hover,
.lesson-card:hover,
.menu-card:hover,
.answer-button:hover {
  transform: translateY(-3px) scale(1.02);
}

.back-button:active,
.round-button:active,
.lesson-card:active,
.menu-card:active,
.answer-button:active {
  transform: translateY(1px) scale(0.98);
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(16px, 3vw, 28px);
  flex: 1;
  align-items: stretch;
}

.lesson-card {
  min-height: 440px;
  padding: 0;
  border-radius: 32px;
  border: 5px solid rgba(255, 255, 255, 0.88);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  color: #fff;
  background: var(--lesson-color);
  box-shadow: var(--shadow);
  text-align: left;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease;
}

.lesson-cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.12) brightness(0.88);
  transform: scale(1.02);
}

.lesson-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.05), rgba(15, 23, 42, 0.72));
}

.lesson-card.image-missing::before {
  content: "Lecke";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(52px, 9vw, 96px);
  font-weight: 900;
  background: var(--lesson-color);
}

.lesson-info {
  position: absolute;
  z-index: 1;
  left: clamp(18px, 3vw, 30px);
  right: clamp(18px, 3vw, 30px);
  bottom: clamp(18px, 3vw, 30px);
}

.lesson-page {
  display: inline-grid;
  place-items: center;
  min-height: 42px;
  padding: 0 15px;
  border-radius: 999px;
  color: #fff;
  background: rgba(15, 23, 42, 0.62);
  font-weight: 900;
  text-decoration: none;
}

.source-link {
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(30, 41, 59, 0.18);
  transition:
    transform 160ms ease,
    background 160ms ease;
}

.source-link:hover {
  transform: translateY(-2px);
  background: #0ea5e9;
}

.lesson-info h2 {
  margin: 12px 0 8px;
  font-size: clamp(30px, 4.4vw, 58px);
  line-height: 1;
  letter-spacing: 0;
}

.lesson-info p {
  margin: 0;
  font-size: clamp(18px, 2.2vw, 25px);
  font-weight: 900;
}

.lesson-selected {
  min-height: 176px;
  padding: clamp(12px, 2vw, 18px);
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: clamp(16px, 3vw, 28px);
  align-items: center;
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.78);
  border: 4px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.lesson-selected img {
  width: 100%;
  height: 148px;
  object-fit: cover;
  border-radius: 24px;
}

.lesson-selected h2,
.lesson-selected p {
  margin: 0;
}

.lesson-selected h2 {
  margin-top: 10px;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
  letter-spacing: 0;
}

.lesson-selected p {
  margin-top: 8px;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 22px);
  font-weight: 900;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(14px, 2vw, 22px);
  flex: 1;
  align-items: stretch;
}

.menu-card {
  min-height: 360px;
  padding: clamp(18px, 3vw, 30px);
  border: 4px solid rgba(255, 255, 255, 0.76);
  border-radius: 30px;
  color: #fff;
  cursor: pointer;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease;
}

.menu-card::after {
  content: "";
  position: absolute;
  inset: auto -18% -24% 36%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
}

.menu-card.word {
  background: linear-gradient(145deg, #ff6b6b, #fb923c);
}

.menu-card.picture {
  background: linear-gradient(145deg, #0ea5e9, #56d68a);
}

.menu-card.match {
  background: linear-gradient(145deg, #8b5cf6, #f472b6);
}

.menu-icon {
  width: min(170px, 44vw);
  height: min(170px, 44vw);
  display: grid;
  place-items: center;
  align-self: center;
  border-radius: 34px;
  font-size: 84px;
  background: rgba(255, 255, 255, 0.23);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.36);
  animation: bounceSoft 2.8s ease-in-out infinite;
}

.menu-card h2 {
  margin: 0;
  font-size: clamp(25px, 3vw, 36px);
  line-height: 1.08;
  letter-spacing: 0;
  position: relative;
  z-index: 1;
}

.menu-card p {
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 18px;
  font-weight: 800;
  position: relative;
  z-index: 1;
}

.game-panel {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.task-board {
  min-height: 280px;
  padding: clamp(18px, 3vw, 30px);
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  justify-items: center;
  text-align: center;
  border: 4px solid rgba(255, 255, 255, 0.9);
}

.task-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: clamp(18px, 2vw, 23px);
  font-weight: 900;
}

.target-word {
  margin: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(52px, 10vw, 116px);
  line-height: 0.96;
  letter-spacing: 0;
}

.target-chip {
  display: inline-grid;
  place-items: center;
  min-height: 120px;
  min-width: min(600px, 100%);
  padding: 18px 34px;
  border-radius: 40px;
  color: #fff;
  background: linear-gradient(135deg, var(--coral), var(--orange));
  box-shadow: inset 0 -12px 0 rgba(0, 0, 0, 0.08);
}

.answers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.answer-button {
  min-height: 94px;
  padding: 16px;
  border-radius: 26px;
  color: #fff;
  cursor: pointer;
  font-size: clamp(25px, 4vw, 42px);
  font-weight: 900;
  letter-spacing: 0;
  box-shadow:
    0 14px 24px rgba(30, 41, 59, 0.18),
    inset 0 -10px 0 rgba(0, 0, 0, 0.09);
  transition:
    transform 160ms ease,
    filter 160ms ease;
  overflow-wrap: anywhere;
}

.answer-button:nth-child(4n + 1) {
  background: #0ea5e9;
}

.answer-button:nth-child(4n + 2) {
  background: #f97316;
}

.answer-button:nth-child(4n + 3) {
  background: #22c55e;
}

.answer-button:nth-child(4n + 4) {
  background: #a855f7;
}

.answer-button.correct {
  background: #16a34a;
  animation: pop 460ms ease both;
}

.answer-button.wrong {
  background: #ef4444;
  animation: shake 360ms ease both;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.progress-track {
  height: 18px;
  flex: 1 1 220px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 0 0 2px rgba(30, 41, 59, 0.08);
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint), var(--sun), var(--coral));
  transition: width 320ms ease;
}

.feedback {
  min-height: 48px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 900;
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.feedback.show {
  opacity: 1;
  transform: translateY(0);
}

.feedback.good {
  background: #22c55e;
}

.feedback.try {
  background: #f59e0b;
}

.picture-wrap {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.picture-card {
  width: min(360px, 82vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 42px;
  background: #f8fafc;
  background:
    radial-gradient(circle at 28% 20%, rgba(255, 255, 255, 0.9), transparent 26%),
    color-mix(in srgb, var(--picture-color) 18%, white);
  border: 6px solid rgba(255, 255, 255, 0.96);
  box-shadow:
    0 18px 28px rgba(30, 41, 59, 0.18),
    inset 0 -14px 0 rgba(30, 41, 59, 0.08);
}

.picture-card.photo-card {
  overflow: hidden;
  background: #f8fafc;
}

.picture-image {
  width: 72%;
  height: 72%;
  object-fit: contain;
  filter: drop-shadow(0 12px 8px rgba(30, 41, 59, 0.18));
}

.photo-card .picture-image {
  width: 88%;
  height: 88%;
  object-fit: contain;
  filter: drop-shadow(0 12px 8px rgba(30, 41, 59, 0.12));
}

.image-fallback {
  display: none;
  padding: 18px;
  color: var(--picture-color);
  font-size: clamp(42px, 8vw, 72px);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.picture-card.image-missing .image-fallback {
  display: block;
}

.picture-name {
  min-width: min(320px, 100%);
  padding: 10px 24px;
  border-radius: 999px;
  color: #fff;
  background: var(--picture-color);
  box-shadow: 0 10px 18px rgba(30, 41, 59, 0.15);
  font-size: clamp(27px, 5vw, 44px);
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  overflow-wrap: anywhere;
}

.match-board {
  position: relative;
  min-height: 370px;
  padding: clamp(12px, 2vw, 20px);
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.78);
  border: 4px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  overflow: hidden;
  touch-action: none;
}

.match-columns {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(74px, 11vw, 140px);
  min-height: 100%;
}

.match-column {
  display: grid;
  grid-template-rows: repeat(var(--word-count, 15), minmax(38px, 1fr));
  gap: 6px;
}

.match-item {
  min-height: 38px;
  padding: 7px 11px;
  border-radius: 16px;
  color: #fff;
  font-size: clamp(15px, 1.8vw, 20px);
  font-weight: 900;
  letter-spacing: 0;
  box-shadow:
    0 8px 14px rgba(30, 41, 59, 0.14),
    inset 0 -5px 0 rgba(0, 0, 0, 0.08);
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  user-select: none;
  transition:
    transform 150ms ease,
    filter 150ms ease,
    opacity 150ms ease;
}

.match-item.left {
  background: #0ea5e9;
}

.match-item.right {
  background: #f97316;
}

.match-item.selected {
  transform: scale(1.05);
  filter: brightness(1.12);
}

.match-item.done {
  cursor: default;
  background: #22c55e;
}

.match-item.dim {
  opacity: 0.55;
}

.match-item.wrong {
  background: #ef4444;
  animation: shake 360ms ease both;
}

.match-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.match-lines line,
.match-lines path {
  stroke-linecap: round;
  stroke-width: 8;
  fill: none;
}

.drag-line {
  stroke: rgba(139, 92, 246, 0.75);
  stroke-dasharray: 14 12;
}

.done-line {
  stroke: #22c55e;
}

.celebration {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 22px;
  color: #fff;
  background: rgba(15, 23, 42, 0.8);
  overflow: hidden;
}

.celebration-message {
  width: min(760px, 100%);
  padding: clamp(24px, 6vw, 58px);
  border-radius: 42px;
  text-align: center;
  background: linear-gradient(135deg, #ff6b6b, #ffd166, #22c55e, #0ea5e9);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.35);
  animation: pop 560ms ease both;
}

.celebration-message h2 {
  margin: 0 0 8px;
  font-size: clamp(58px, 14vw, 132px);
  line-height: 0.9;
  letter-spacing: 0;
}

.celebration-message p {
  margin: 0;
  font-size: clamp(24px, 5vw, 48px);
  font-weight: 900;
}

.confetti {
  position: absolute;
  top: -12vh;
  width: 14px;
  height: 22px;
  border-radius: 5px;
  animation: confettiFall linear forwards;
}

.hidden {
  display: none;
}

@keyframes floaty {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes bounceSoft {
  0%,
  100% {
    transform: rotate(-2deg) scale(1);
  }
  50% {
    transform: rotate(3deg) scale(1.04);
  }
}

@keyframes pop {
  0% {
    transform: scale(0.9);
  }
  70% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

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

@keyframes confettiFall {
  0% {
    transform: translateY(-15vh) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(120vh) rotate(760deg);
    opacity: 0.95;
  }
}

@media (max-width: 820px) {
  .top-bar {
    align-items: flex-start;
  }

  .menu-grid {
    grid-template-columns: 1fr;
  }

  .lesson-grid {
    grid-template-columns: 1fr;
  }

  .lesson-card {
    min-height: 320px;
  }

  .lesson-selected {
    grid-template-columns: 1fr;
  }

  .lesson-selected img {
    height: 190px;
  }

  .menu-card {
    min-height: 245px;
  }

  .menu-icon {
    width: 132px;
    height: 132px;
    font-size: 66px;
  }

  .answers {
    grid-template-columns: 1fr;
  }

  .answer-button {
    min-height: 78px;
  }

  .match-board {
    min-height: 430px;
  }

  .match-columns {
    gap: 30px;
  }

  .match-column {
    grid-template-rows: repeat(var(--word-count, 15), minmax(38px, 1fr));
  }

  .match-item {
    padding: 6px;
    border-radius: 13px;
    font-size: 15px;
  }

  .match-lines line,
  .match-lines path {
    stroke-width: 6;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
