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

:root {
  color-scheme: only light;
  --ink: #24324a;
  --ink-soft: #526178;
  --accent: #ffb703;
  --accent-2: #fb8500;
  --mint: #66c7b4;
  --sky: #8fd3ff;
  --grass: #b7e4a4;
  --paper: #fffaf0;
  --peach: #ffe5d1;
  --cream: #fffdf7;
  --card: #ffffff;
  --line: #f1d7a8;
  --shadow: 0 18px 35px rgba(36, 50, 74, 0.16);
  --shadow-soft: 0 10px 24px rgba(36, 50, 74, 0.1);
  --danger: #e76f51;
  --success: #2a9d8f;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(255, 195, 113, 0.7) 0%, transparent 36%),
    linear-gradient(180deg, #fef6d8 0%, #e6f7ff 54%, #eef9dc 100%);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: -20% -10%;
  background:
    radial-gradient(circle at 12% 24%, rgba(255, 184, 108, 0.3), transparent 42%),
    radial-gradient(circle at 88% 18%, rgba(126, 214, 223, 0.24), transparent 42%),
    radial-gradient(circle at 52% 82%, rgba(184, 235, 148, 0.28), transparent 46%);
  z-index: 0;
  pointer-events: none;
  animation: float 12s ease-in-out infinite;
}

.game {
  position: relative;
  z-index: 1;
  width: min(1080px, 100%);
  background: var(--paper);
  border-radius: 30px;
  padding: 26px 26px 22px;
  box-shadow: var(--shadow);
  border: 4px solid #ffe4b3;
}

.game__header {
  text-align: center;
}

.lang-toggle {
  margin-top: 12px;
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(251, 133, 0, 0.18);
}

.badge,
.profile-chip,
.mode-icon,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 800;
}

.badge {
  background: var(--accent);
  color: #4d3400;
  padding: 7px 16px;
  letter-spacing: 0.4px;
  font-size: 0.9rem;
}

h1,
h2 {
  margin: 0;
}

h1 {
  margin-top: 14px;
  font-size: clamp(2rem, 4vw, 3rem);
}

h2 {
  font-size: clamp(1.15rem, 2vw, 1.45rem);
}

.subtitle {
  margin: 8px auto 0;
  max-width: 44rem;
  font-size: 1.05rem;
  color: var(--ink-soft);
}

.panel-kicker,
.mission__label,
.carousel__label,
.difficulty__label,
.scoreboard__label,
.dashboard-card__label,
.field__label {
  text-transform: uppercase;
  letter-spacing: 0.9px;
  font-size: 0.8rem;
  font-weight: 800;
  color: #8b6a3e;
}

.profile-panel,
.dashboard,
.mission,
.carousel,
.difficulty,
.toggles,
.stage-selector,
.scoreboard__item,
.celebration__card {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
}

.profile-panel,
.stage-selector,
.mission {
  margin-top: 18px;
}

.play-hero {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.88);
  border: 2px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.play-hero__title {
  font-size: 1.35rem;
  font-weight: 900;
}

.options-layout {
  margin-top: 22px;
  display: grid;
  gap: 18px;
  padding-top: 6px;
  border-top: 2px dashed #e8d9bb;
}

.options-panel {
  margin-top: 0;
}

.scoreboard {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.cards {
  gap: 14px;
}

.card {
  min-height: 210px;
}

.feedback {
  justify-content: center;
  text-align: center;
}

.profile-panel,
.stage-selector,
.carousel,
.difficulty,
.toggles,
.scoreboard__item,
.dashboard-card {
  border: 2px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.profile-panel {
  border-radius: 24px;
  padding: 18px;
  display: grid;
  gap: 16px;
}

.profile-panel__header,
.profile-panel__footer,
.stage-selector__header {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.profile-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.field {
  display: grid;
  gap: 8px;
}

.field--small {
  max-width: 150px;
}

.field--wide {
  grid-column: span 2;
}

.field__input {
  width: 100%;
  min-height: 48px;
  border-radius: 16px;
  border: 2px solid #f4ddba;
  padding: 10px 14px;
  font: inherit;
  color: var(--ink);
  background: var(--cream);
}

.field__input:focus-visible {
  outline: 3px solid rgba(102, 199, 180, 0.28);
  border-color: var(--mint);
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.avatar-option {
  min-height: 64px;
  border-radius: 18px;
  border: 2px solid #f4ddba;
  background: linear-gradient(180deg, #fffdf5 0%, #fff2dc 100%);
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.avatar-option:hover,
.avatar-option:focus-visible,
.avatar-option.is-selected {
  transform: translateY(-2px);
  border-color: var(--accent-2);
  box-shadow: 0 12px 22px rgba(251, 133, 0, 0.16);
}

.profile-chip {
  min-height: 38px;
  padding: 8px 14px;
  background: #eef8ff;
  color: #27536f;
  font-size: 0.92rem;
}

.dashboard {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.dashboard-card {
  border-radius: 22px;
  padding: 16px;
  display: grid;
  gap: 10px;
}

.dashboard-card--hero,
.dashboard-card--wide,
.dashboard-card--actions {
  grid-column: span 2;
}

.dashboard-card__value {
  font-size: clamp(1.2rem, 2vw, 1.7rem);
  font-weight: 900;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-card__avatar {
  width: 70px;
  height: 70px;
  border-radius: 22px;
  background: linear-gradient(180deg, #fff0c8 0%, #ffe1a3 100%);
  display: grid;
  place-items: center;
  font-size: 2rem;
  border: 2px solid #f8d898;
}

.profile-card__name {
  font-size: 1.4rem;
  font-weight: 900;
}

.profile-card__meta {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.skills-list,
.stage-progress {
  display: grid;
  gap: 10px;
}

.progress-row {
  display: grid;
  gap: 6px;
}

.progress-row__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
}

.progress-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: #eef3f7;
  border: 1px solid #dfe8ee;
}

.progress-bar__fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint), var(--sky));
  transition: width 0.25s ease;
}

.stage-progress__item {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 18px;
  background: #fffdf7;
  border: 1px solid #f0e2c0;
}

.stage-progress__status {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.mission {
  border-radius: 24px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 1.35rem;
  font-weight: 800;
  text-align: center;
  border: 2px solid #ffd3b4;
  background: linear-gradient(180deg, #fff1e6 0%, #ffe9d7 100%);
}

.mission__label {
  color: #9b5333;
}

.mission__text {
  line-height: 1.4;
}

.setup {
  margin-top: 16px;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: start;
}

.carousel,
.difficulty,
.toggles,
.stage-selector {
  border-radius: 22px;
  padding: 14px;
}

.carousel,
.difficulty {
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
}

.toggles {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.carousel__controls {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.carousel__card {
  background: linear-gradient(180deg, #fffdf7 0%, #fff3de 100%);
  border-radius: 18px;
  padding: 12px;
  border: 2px solid #ffdcb1;
  display: grid;
  gap: 6px;
  justify-items: center;
}

.mode-icon {
  min-height: 36px;
  min-width: 72px;
  padding: 6px 12px;
  background: #ffe7b8;
}

.mode-name {
  font-weight: 800;
}

.difficulty__buttons,
.stage-selector__buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stage-selector__label {
  font-weight: 900;
  font-size: 1.1rem;
}

.stage-button {
  border: 0;
  border-radius: 999px;
  min-height: 46px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 800;
  background: #fff5dc;
  color: var(--ink);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.stage-button:hover,
.stage-button:focus-visible,
.stage-button.is-active {
  transform: translateY(-2px);
  background: #ffe1ad;
  border-color: var(--accent-2);
}

.stage-button.is-locked {
  background: #f5f1ea;
  color: #97856e;
  border-color: #e4d4bc;
}

.scoreboard {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.scoreboard__item {
  border-radius: 18px;
  padding: 12px;
  display: grid;
  gap: 6px;
  justify-items: center;
  text-align: center;
}

.scoreboard__value {
  font-size: 1.1rem;
  font-weight: 900;
}

.cards {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
}

.card {
  background: linear-gradient(180deg, #ffffff 0%, #fff8ea 100%);
  border-radius: 24px;
  padding: 16px;
  border: 3px solid transparent;
  box-shadow: 0 14px 22px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  display: grid;
  gap: 12px;
  align-items: center;
  justify-items: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  min-height: 196px;
}

.animal-card {
  background:
    radial-gradient(circle at top, rgba(255, 244, 206, 0.9) 0%, transparent 42%),
    linear-gradient(180deg, #ffffff 0%, #fff9ef 100%);
}

.memory-preview {
  border-style: dashed;
  border-color: var(--accent);
}

.card:disabled {
  cursor: default;
  opacity: 0.82;
}

.card:focus-visible {
  outline: 4px solid rgba(102, 199, 180, 0.45);
  outline-offset: 3px;
}

.card:hover:not(:disabled) {
  transform: translateY(-4px) rotate(-1deg);
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.12);
}

.card__shape {
  width: 110px;
  height: 110px;
  display: grid;
  place-items: center;
}

.card__shape svg {
  width: 100%;
  height: 100%;
}

.card__text {
  font-size: 3rem;
  font-weight: 900;
  line-height: 1;
}

.card__label {
  font-size: 1.02rem;
  font-weight: 800;
  text-align: center;
}

.card__hint {
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.feedback {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.stars {
  display: flex;
  gap: 6px;
}

.stars span {
  font-size: 1.6rem;
  color: #f4a261;
  opacity: 0.25;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.stars span.is-on {
  opacity: 1;
  transform: scale(1.1);
}

.message {
  font-size: 1.08rem;
  font-weight: 800;
}

.controls {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 999px;
  min-height: 46px;
  padding: 10px 20px;
  font-size: 1rem;
  font-weight: 800;
  background: #fff1cc;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn--small {
  min-height: 38px;
  padding: 7px 14px;
  font-size: 0.92rem;
  background: #ffe2a4;
}

.btn--small.is-active,
.btn--primary {
  background: var(--accent-2);
  color: #fffaf2;
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.14);
}

.btn:focus-visible {
  outline: 3px solid rgba(102, 199, 180, 0.3);
}

.game__footer {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pill {
  padding: 7px 12px;
  background: #e9ffef;
  font-size: 0.85rem;
}

.celebration {
  position: fixed;
  inset: 0;
  background: rgba(36, 50, 74, 0.55);
  display: grid;
  place-items: center;
  z-index: 5;
  padding: 20px;
}

.celebration.is-hidden {
  display: none;
}

.celebration__card {
  border-radius: 28px;
  padding: 30px 26px;
  border: 4px solid #ffd6a5;
  width: min(520px, 100%);
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: pop 0.5s ease;
}

.celebration__title {
  font-size: 2rem;
  font-weight: 900;
  margin-bottom: 6px;
}

.celebration__text {
  font-size: 1.1rem;
  margin: 0 0 10px;
}

.celebration__score {
  font-size: 1.2rem;
  font-weight: 900;
  margin-bottom: 18px;
}

.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.confetti span {
  position: absolute;
  width: 10px;
  height: 14px;
  border-radius: 3px;
  opacity: 0.85;
  animation: confetti 2s ease-in-out infinite;
}

.confetti span:nth-child(1) { left: 10%; background: #ffadad; animation-delay: 0s; }
.confetti span:nth-child(2) { left: 20%; background: #ffd6a5; animation-delay: 0.2s; }
.confetti span:nth-child(3) { left: 35%; background: #fdffb6; animation-delay: 0.4s; }
.confetti span:nth-child(4) { left: 50%; background: #caffbf; animation-delay: 0.1s; }
.confetti span:nth-child(5) { left: 65%; background: #9bf6ff; animation-delay: 0.3s; }
.confetti span:nth-child(6) { left: 80%; background: #a0c4ff; animation-delay: 0.5s; }
.confetti span:nth-child(7) { left: 15%; background: #bdb2ff; animation-delay: 0.6s; }
.confetti span:nth-child(8) { left: 30%; background: #ffc6ff; animation-delay: 0.7s; }
.confetti span:nth-child(9) { left: 55%; background: #f08080; animation-delay: 0.45s; }
.confetti span:nth-child(10) { left: 75%; background: #ffb703; animation-delay: 0.25s; }

.card.is-correct {
  border-color: var(--success);
  animation: pop 0.5s ease;
}

.card.is-wrong {
  border-color: var(--danger);
  animation: wiggle 0.4s ease;
}

@keyframes pop {
  0% { transform: scale(1); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes wiggle {
  0%,
  100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

@keyframes confetti {
  0% { transform: translateY(-120%) rotate(0deg); }
  100% { transform: translateY(120%) rotate(360deg); }
}

@keyframes float {
  0%,
  100% { transform: translateY(0); }
  50% { transform: translateY(14px); }
}

@media (max-width: 920px) {
  .profile-form,
  .dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .avatar-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  body {
    padding: 12px;
  }

  .game {
    padding: 18px 16px 18px;
    border-radius: 24px;
  }

  .mission {
    flex-direction: column;
    gap: 8px;
    padding: 14px 16px;
    font-size: 1.15rem;
  }

  .play-hero {
    padding: 14px;
    border-radius: 18px;
  }

  .play-hero__title {
    font-size: 1.1rem;
  }

  .profile-form,
  .dashboard {
    grid-template-columns: 1fr;
  }

  .field--wide,
  .dashboard-card--hero,
  .dashboard-card--wide,
  .dashboard-card--actions {
    grid-column: auto;
  }

  .avatar-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .feedback,
  .profile-panel__header,
  .profile-panel__footer,
  .stage-selector__header,
  .profile-card {
    justify-content: center;
    text-align: center;
  }

  .scoreboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .card {
    min-height: 168px;
    padding: 12px;
    border-radius: 20px;
  }

  .card__shape {
    width: 92px;
    height: 92px;
  }

  .controls {
    position: sticky;
    bottom: 8px;
    z-index: 3;
    padding: 8px;
    border-radius: 20px;
    background: rgba(255, 250, 240, 0.92);
    backdrop-filter: blur(10px);
  }

  .game__footer {
    margin-bottom: 72px;
  }
}

[dir="rtl"] body {
  font-family: "Segoe UI", Tahoma, sans-serif;
}

[dir="rtl"] .mission {
  flex-direction: row-reverse;
}

[dir="rtl"] .profile-card,
[dir="rtl"] .progress-row__head,
[dir="rtl"] .profile-panel__header,
[dir="rtl"] .profile-panel__footer,
[dir="rtl"] .stage-selector__header {
  flex-direction: row-reverse;
}
