* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: #2a2440;
  background: linear-gradient(180deg, #fff5fb 0%, #eef6ff 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.page-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.hero,
.games-section,
.game-page {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(104, 81, 162, 0.15);
  border-radius: 28px;
  box-shadow: 0 20px 45px rgba(82, 59, 125, 0.12);
}

.hero {
  padding: 28px;
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ff5a8f;
}

.hero h1,
.game-header h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.1;
}

.hero-copy,
.game-header p,
.section-heading p {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.7;
  color: #5f5a72;
}

.games-section,
.game-page {
  margin-top: 24px;
  padding: 24px;
}

.section-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  margin-bottom: 20px;
}

.section-heading h2,
.panel h2 {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.game-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 24px;
  background: #ffffff;
  border: 1px solid rgba(104, 81, 162, 0.15);
  box-shadow: 0 14px 30px rgba(82, 59, 125, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.game-card:hover,
.game-card:focus-within {
  transform: translateY(-4px);
  box-shadow: 0 18px 40px rgba(82, 59, 125, 0.16);
}

.game-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: #f6f0ff;
}

.game-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
}

.game-card-body h3 {
  margin: 0;
  font-size: 1.35rem;
}

.game-card-body p {
  margin: 0;
  line-height: 1.6;
  color: #5f5a72;
}

.button-link,
.action-button,
.tile {
  border: none;
  border-radius: 18px;
}

.button-link,
.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
}

.button-link.primary,
.action-button.primary {
  color: #ffffff;
  background: linear-gradient(135deg, #7757ff 0%, #ff5a8f 100%);
}

.button-link.secondary,
.action-button.secondary {
  color: #493f69;
  background: #efe7ff;
}

.game-page {
  display: grid;
  gap: 24px;
}

.game-header {
  display: grid;
  gap: 12px;
}

.game-nav {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 24px;
}

.panel {
  padding: 20px;
  border-radius: 24px;
  background: #fff;
  border: 1px solid rgba(104, 81, 162, 0.15);
}

.control-group {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.control-group label {
  font-weight: 700;
}

.control-group input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(104, 81, 162, 0.3);
  border-radius: 16px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.status-box {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 18px;
  background: #f8f4ff;
  color: #4f4671;
  line-height: 1.6;
}

.board-panel {
  display: grid;
  gap: 18px;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 14px;
}

.tile {
  aspect-ratio: 1 / 1;
  font-size: clamp(1.5rem, 5vw, 2.4rem);
  font-weight: 700;
  color: #493f69;
  background: #fff;
  border: 3px solid #e0d2ff;
  box-shadow: 0 10px 18px rgba(82, 59, 125, 0.08);
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease;
}

.tile:hover:not(:disabled) {
  transform: translateY(-2px);
}

.tile.hidden {
  color: transparent;
  background: linear-gradient(135deg, #8a7bff 0%, #ffc5d8 100%);
}

.tile:disabled {
  cursor: default;
}

.tile.preview {
  color: #493f69;
  background: #fff;
}

.tile.correct {
  color: #1f5f35;
  background: linear-gradient(180deg, #e8fff0 0%, #b8f0c8 100%);
  border-color: #7ed99a;
  box-shadow: 0 10px 18px rgba(56, 142, 88, 0.16);
}

.tile.wrong {
  color: #7a1f2d;
  background: linear-gradient(180deg, #ffe8ec 0%, #ffb8c4 100%);
  border-color: #ff8aa0;
  box-shadow: 0 10px 18px rgba(180, 56, 82, 0.18);
}

.order-memory-board .tile.hidden {
  color: transparent;
}

.helper-list {
  margin: 0;
  padding-left: 18px;
  line-height: 1.7;
  color: #5f5a72;
}

.mini-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 18px;
  background: #f8f4ff;
  color: #4f4671;
  font-weight: 700;
}

.sequence-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(100px, 1fr));
  gap: 16px;
}

.sequence-pad {
  aspect-ratio: 1 / 1;
  min-height: 110px;
  padding: 16px;
  color: #493f69;
  border: 3px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 12px 24px rgba(82, 59, 125, 0.12);
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.16s ease, box-shadow 0.16s ease;
}

.sequence-pad:hover:not(:disabled) {
  transform: translateY(-2px);
}

.sequence-pad.active {
  transform: scale(1.02);
  filter: brightness(1.08);
  box-shadow: 0 16px 28px rgba(82, 59, 125, 0.22);
}

.sequence-pad:disabled {
  cursor: default;
}

.sequence-pad-label {
  font-size: clamp(1.25rem, 4vw, 1.8rem);
  font-weight: 700;
}

.pad-pink {
  background: linear-gradient(180deg, #ffd7e6 0%, #ffb8d2 100%);
}

.pad-purple {
  background: linear-gradient(180deg, #e9dcff 0%, #cdb7ff 100%);
}

.pad-yellow {
  background: linear-gradient(180deg, #fff5bf 0%, #ffe487 100%);
}

.pad-blue {
  background: linear-gradient(180deg, #d9f1ff 0%, #a9ddff 100%);
}

.pair-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(92px, 1fr));
  gap: 14px;
}

.pair-card {
  position: relative;
  aspect-ratio: 1 / 1;
  min-height: 96px;
  padding: 14px;
  color: #493f69;
  background: #fff;
  border: 3px solid #e0d2ff;
  box-shadow: 0 10px 18px rgba(82, 59, 125, 0.08);
  cursor: pointer;
}

.pair-card.hidden {
  color: transparent;
  background: linear-gradient(135deg, #8a7bff 0%, #ffc5d8 100%);
}

.pair-card.matched {
  border-color: #9bdba8;
  background: linear-gradient(180deg, #effff1 0%, #d7f9dc 100%);
}

.pair-card-front,
.pair-card-back {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  font-weight: 700;
}

.pair-card.hidden .pair-card-front {
  display: none;
}

.pair-card:not(.hidden) .pair-card-back,
.pair-card.matched .pair-card-back {
  display: none;
}

.difficulty-group {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.difficulty-button {
  display: grid;
  gap: 4px;
  justify-items: start;
  width: 100%;
  padding: 14px 16px;
  color: #2f2945;
  border: 3px solid transparent;
  border-radius: 18px;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 10px 18px rgba(82, 59, 125, 0.08);
}

.difficulty-button span {
  font-size: 0.95rem;
  font-weight: 700;
  opacity: 0.8;
}

.difficulty-button.active {
  border-color: #493f69;
  transform: translateY(-1px);
}

.difficulty-easy {
  background: linear-gradient(180deg, #dff7df 0%, #b9ecb9 100%);
}

.difficulty-medium {
  background: linear-gradient(180deg, #fff6c7 0%, #ffe78f 100%);
}

.difficulty-hard {
  background: linear-gradient(180deg, #ffd6d6 0%, #ffacac 100%);
}

.fruit-board {
  display: grid;
  grid-template-columns: repeat(var(--fruit-columns, 5), minmax(72px, 1fr));
  gap: 12px;
}

.fruit-card {
  position: relative;
  aspect-ratio: 1 / 1.08;
  min-height: 94px;
  padding: 8px;
  color: #493f69;
  background: #fff;
  border: 3px solid #e0d2ff;
  box-shadow: 0 10px 18px rgba(82, 59, 125, 0.08);
  cursor: pointer;
}

.fruit-card.hidden {
  background: linear-gradient(135deg, #8a7bff 0%, #ffc5d8 100%);
}

.fruit-card.matched {
  border-color: #9bdba8;
  background: linear-gradient(180deg, #effff1 0%, #d7f9dc 100%);
}

.fruit-card-front,
.fruit-card-back {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fruit-card-front {
  flex-direction: column;
  gap: 6px;
  padding: 8px;
}

.fruit-card.hidden .fruit-card-front {
  display: none;
}

.fruit-card:not(.hidden) .fruit-card-back,
.fruit-card.matched .fruit-card-back {
  display: none;
}

.fruit-card-back {
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 700;
  color: #ffffff;
}

.fruit-card-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}

.fruit-image {
  display: block;
  width: min(100%, 94px);
  height: 72px;
  object-fit: contain;
  object-position: center;
}

.spots-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(86px, 1fr));
  gap: 14px;
}

.spot-cell {
  aspect-ratio: 1 / 1;
  min-height: 96px;
  background: #fff;
  border: 3px solid #e0d2ff;
  box-shadow: 0 10px 18px rgba(82, 59, 125, 0.08);
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease;
}

.spot-cell:hover:not(:disabled) {
  transform: translateY(-2px);
}

.spot-cell.preview,
.spot-cell.reveal {
  background: linear-gradient(180deg, #ffe8f1 0%, #ffd0e2 100%);
}

.spot-cell.selected {
  background: linear-gradient(180deg, #e8f7ff 0%, #cbeaff 100%);
}

.spot-dot {
  display: block;
  width: 24px;
  height: 24px;
  margin: 0 auto;
  border-radius: 999px;
  background: rgba(119, 87, 255, 0.24);
}

.spot-cell.preview .spot-dot,
.spot-cell.reveal .spot-dot {
  background: #ff5a8f;
}

.spot-cell.selected .spot-dot {
  background: #4b84ff;
}

.teddy-room-body {
  background:
    radial-gradient(circle at top left, rgba(255, 198, 226, 0.55), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 214, 236, 0.45), transparent 24%),
    linear-gradient(180deg, #fff4fa 0%, #ffe8f3 100%);
}

.teddy-room-page {
  background: linear-gradient(180deg, rgba(255, 244, 250, 0.96) 0%, rgba(255, 232, 243, 0.96) 100%);
}

.teddy-board-panel {
  background: linear-gradient(180deg, #fff8fc 0%, #ffeef7 100%);
  border-color: #f3c4dd;
}

.teddy-status {
  background: #fff7fb;
  border-color: #f2c0da;
}

.teddy-board-wrap {
  position: relative;
}

.teddy-shuffle-hint {
  position: absolute;
  z-index: 4;
  display: grid;
  gap: 2px;
  justify-items: center;
  padding: 8px 14px;
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
  background: linear-gradient(180deg, #ff6aaa 0%, #ff3f8d 100%);
  border: 3px solid #ffffff;
  border-radius: 999px;
  box-shadow: 0 12px 24px rgba(214, 72, 132, 0.28);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.7);
  transition:
    opacity 0.2s ease,
    transform 0.24s cubic-bezier(0.34, 1.3, 0.64, 1);
}

.teddy-shuffle-hint.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.teddy-shuffle-arrows {
  font-size: 1.35rem;
  line-height: 1;
}

.teddy-board {
  display: grid;
  grid-template-columns: repeat(var(--teddy-columns, 3), minmax(96px, 1fr));
  gap: 16px;
  align-items: end;
}

.teddy-board.is-shuffling {
  perspective: 900px;
}

.teddy-box {
  position: relative;
  display: grid;
  gap: 10px;
  justify-items: center;
  min-height: 148px;
  padding: 14px 12px 12px;
  color: #6b3f63;
  background: linear-gradient(180deg, #fff8fc 0%, #ffe3f1 100%);
  border: 4px solid #f0a6cb;
  border-radius: 24px 24px 18px 18px;
  box-shadow: 0 14px 24px rgba(214, 98, 150, 0.16);
  cursor: pointer;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease;
  will-change: transform;
}

.teddy-box:hover:not(:disabled):not(.swap-moving) {
  transform: translateY(-3px);
}

.teddy-box:disabled {
  cursor: default;
}

.teddy-box-ribbon {
  position: absolute;
  top: 38px;
  left: 10px;
  width: 14px;
  height: 58px;
  border-radius: 999px;
  background: var(--teddy-ribbon, #ff8fc0);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.08);
}

.teddy-tone-0 {
  --teddy-ribbon: #ff7eb8;
  --teddy-lid: linear-gradient(180deg, #ffb8d8 0%, #ff7eb8 100%);
  border-color: #f08cbb;
}

.teddy-tone-1 {
  --teddy-ribbon: #b58cff;
  --teddy-lid: linear-gradient(180deg, #d4c0ff 0%, #b58cff 100%);
  border-color: #c7b0ff;
}

.teddy-tone-2 {
  --teddy-ribbon: #67c7ff;
  --teddy-lid: linear-gradient(180deg, #b8e5ff 0%, #67c7ff 100%);
  border-color: #8fd4ff;
}

.teddy-tone-3 {
  --teddy-ribbon: #ffc96a;
  --teddy-lid: linear-gradient(180deg, #ffe2a8 0%, #ffc96a 100%);
  border-color: #ffd98f;
}

.teddy-tone-4 {
  --teddy-ribbon: #8ce6b0;
  --teddy-lid: linear-gradient(180deg, #c9f5da 0%, #8ce6b0 100%);
  border-color: #a8edc4;
}

.teddy-box-lid {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 34px;
  border-radius: 20px 20px 8px 8px;
  background: var(--teddy-lid, linear-gradient(180deg, #ffbad8 0%, #ff8fc0 100%));
}

.teddy-box-content {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 92px;
  margin-top: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.teddy-icon {
  font-size: clamp(2.4rem, 8vw, 3.4rem);
  line-height: 1;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.teddy-box.show-teddy .teddy-icon,
.teddy-box.reveal-teddy .teddy-icon,
.teddy-box.correct .teddy-icon {
  opacity: 1;
  transform: scale(1);
}

.teddy-box.closed .teddy-box-content {
  background: linear-gradient(180deg, #fff 0%, #ffe8f3 100%);
}

.teddy-box.closed .teddy-icon {
  opacity: 0;
  transform: scale(0.7);
}

.teddy-box.swap-active {
  z-index: 3;
  border-color: #ff4f96;
  box-shadow:
    0 0 0 5px rgba(255, 90, 157, 0.22),
    0 20px 34px rgba(214, 98, 150, 0.28);
}

.teddy-box.swap-moving {
  cursor: default;
}

.teddy-board.is-shuffling .teddy-box:not(.swap-moving) {
  opacity: 0.82;
  filter: saturate(0.88);
}

.teddy-box.correct,
.teddy-box.reveal-teddy {
  border-color: #ff5a9d;
  background: linear-gradient(180deg, #fff4fa 0%, #ffd4e8 100%);
}

.teddy-box-label {
  font-size: 0.92rem;
  font-weight: 700;
}

.flashcards-page .flashcards-app {
  display: grid;
  gap: 18px;
}

.flashcards-status {
  background: #f8f4ff;
  border-color: #e0d2ff;
}

.flashcards-screen .panel {
  margin: 0;
}

.flashcard-screen-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.flashcard-screen-header h2 {
  margin: 0;
}

.flashcard-back-button {
  width: auto;
}

.flashcard-quiz-button {
  display: grid;
  gap: 8px;
  justify-items: start;
  width: 100%;
  margin-bottom: 18px;
  padding: 18px 20px;
  color: #3f2f66;
  text-align: left;
  background: linear-gradient(135deg, #fff4d8 0%, #ffe8f4 55%, #efe6ff 100%);
  border: 3px solid #c9a6ff;
  border-radius: 22px;
  box-shadow: 0 12px 22px rgba(106, 72, 168, 0.14);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.flashcard-quiz-button:hover {
  transform: translateY(-2px);
  border-color: #8a7bff;
}

.flashcard-quiz-button span:last-child {
  font-size: 0.92rem;
  font-weight: 700;
  color: #6b5f8f;
}

.flashcard-topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.flashcard-topic-button,
.flashcard-deck-button {
  display: grid;
  gap: 8px;
  justify-items: start;
  width: 100%;
  padding: 16px 18px;
  color: #493f69;
  text-align: left;
  background: #fff;
  border: 3px solid #e0d2ff;
  border-radius: 20px;
  box-shadow: 0 10px 18px rgba(82, 59, 125, 0.08);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.flashcard-topic-button:hover,
.flashcard-deck-button:hover {
  transform: translateY(-2px);
  border-color: #8a7bff;
}

.flashcard-topic-emoji {
  font-size: 2rem;
  line-height: 1;
}

.flashcard-topic-button span:last-child,
.flashcard-deck-count {
  font-size: 0.92rem;
  font-weight: 700;
  color: #6b5f8f;
}

.flashcard-deck-list {
  display: grid;
  gap: 12px;
}

.flashcard-player-panel {
  background: linear-gradient(180deg, #fff8fc 0%, #f8f4ff 100%);
}

.flashcard-stage {
  display: grid;
  gap: 14px;
  justify-items: center;
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.72);
  border: 3px solid #e8ddff;
}

.flashcard-stage.flashcard-playing {
  border-color: #8a7bff;
  box-shadow: 0 0 0 4px rgba(138, 123, 255, 0.16);
}

.flashcard-image-button {
  display: block;
  width: min(100%, 360px);
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 22px;
  cursor: pointer;
  transition: transform 0.16s ease;
}

.flashcard-image-button:hover {
  transform: scale(1.02);
}

.flashcard-image {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 22px;
  background: #fff;
}

.flashcard-word {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 800;
  color: #493f69;
  text-transform: capitalize;
}

.flashcard-word-hidden {
  letter-spacing: 0.12em;
  color: #8a7bff;
}

.flashcard-speak-button {
  width: auto;
}

.flashcard-nav-row {
  margin-top: 18px;
}

@media (max-width: 820px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .page-shell {
    width: min(100% - 20px, 1120px);
    padding-top: 20px;
  }

  .hero,
  .games-section,
  .game-page,
  .panel {
    border-radius: 22px;
  }

  .button-row,
  .game-nav {
    flex-direction: column;
  }

  .button-link,
  .action-button {
    width: 100%;
  }

  .pair-board {
    grid-template-columns: repeat(2, minmax(92px, 1fr));
  }

  .fruit-board {
    grid-template-columns: repeat(4, minmax(68px, 1fr));
  }
}
