:root {
  font-family: "Comic Sans MS", "Comic Sans", cursive, sans-serif;
  color: #333;
  background: #b5d4fb;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: linear-gradient(135deg, #9ad7ff, #c4d5fa);
}

button,
summary,
[draggable="true"] {
  font: inherit;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
.game-card:focus-visible,
.bubble:focus-visible,
.animal:focus-visible,
.chest-container:focus-visible,
.treasure:focus-visible,
.target:focus-visible {
  outline: 4px solid #1d4ed8;
  outline-offset: 3px;
}

.app-shell {
  min-height: 100vh;
}

.site-header {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 86px;
  padding: 1rem 2rem;
  border-bottom: 3px solid rgba(107, 166, 255, 0.85);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.site-header h1 {
  display: block;
  min-width: 0;
  margin: 0;
  color: #65a9ff;
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  line-height: 1.15;
}

.site-header h1 span {
  display: inline-block;
  animation: bounce 1s infinite;
}

.back-button {
  flex: none;
  border: 0;
  border-radius: 16px;
  padding: 14px 28px;
  color: #4a5568;
  background: #d7e7ff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 8px 8px 16px rgba(163, 177, 198, 0.6), -8px -8px 16px rgba(255, 255, 255, 0.8);
  transition: 0.25s ease;
}

.back-button:hover {
  transform: scale(0.98);
  box-shadow: 4px 4px 8px rgba(163, 177, 198, 0.6), -4px -4px 8px rgba(255, 255, 255, 0.8);
}

#menu-view {
  padding: 1.8rem 1rem 0;
}

.intro {
  max-width: 900px;
  margin: 0 auto 1.5rem;
  padding: 1.1rem 1.5rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  text-align: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.intro h2 {
  margin: 0 0 0.35rem;
  color: #315d9d;
  font-size: 1.45rem;
}

.intro p {
  margin: 0;
  color: #516070;
  line-height: 1.55;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.game-card {
  position: relative;
  overflow: hidden;
  min-height: 315px;
  border-radius: 20px;
  padding: 1.5rem;
  background: #fff;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  transition: 0.3s ease;
}

.game-card::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 8px;
  content: "";
}

.game-card.blue::before { background: #4ecdc4; }
.game-card.green::before { background: #45b7d1; }
.game-card.purple::before { background: #96ceb4; }
.game-card.orange::before { background: #ffeaa7; }
.game-card.pink::before { background: #ff9ff3; }
.game-card.yellow::before { background: #feca57; }

.game-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
}

.game-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100px;
  height: 100px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #f4f7fb, #fff);
  font-size: 3rem;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  animation: pulse 2s infinite;
}

.game-card h3 {
  margin: 0 0 0.5rem;
  color: #333;
  font-size: 1.4rem;
}

.game-card p {
  min-height: 2.8rem;
  margin: 0 0 1.2rem;
  color: #666;
  line-height: 1.4;
}

.play-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 30px;
  padding: 0.8rem 1.5rem;
  color: #fff;
  background: linear-gradient(45deg, #ff6b6b, #ff8e8e);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(255, 107, 107, 0.3);
  transition: 0.3s ease;
}

.play-button:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 15px rgba(255, 107, 107, 0.4);
}

.play-button span {
  animation: shake 0.5s infinite alternate;
}

.seo-content {
  max-width: 1040px;
  margin: 3rem auto 0;
  padding: 0 1rem 1rem;
}

.seo-content > section,
.policy-page {
  margin-bottom: 1.5rem;
  border-radius: 18px;
  padding: clamp(1.2rem, 3vw, 2rem);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 24px rgba(48, 84, 130, 0.12);
}

.seo-content h2,
.policy-page h2 {
  margin: 0 0 0.75rem;
  color: #315d9d;
  font-size: 1.5rem;
}

.seo-content p,
.seo-content li,
.policy-page p {
  color: #465769;
  line-height: 1.7;
}

.seo-content ol {
  margin: 0;
  padding-left: 1.5rem;
}

.skill-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.skill-list article {
  border: 2px solid #dbeafe;
  border-radius: 12px;
  padding: 1rem;
  background: #f8fbff;
}

.skill-list h3 {
  margin: 0 0 0.35rem;
  color: #365f95;
  font-size: 1.1rem;
}

.skill-list p {
  margin: 0;
}

.faq details {
  border-top: 1px solid #dbe4ef;
  padding: 0.9rem 0;
}

.faq summary {
  color: #315d9d;
  font-weight: 700;
  cursor: pointer;
}

.faq details p {
  margin-bottom: 0;
}

.game-panel {
  width: min(900px, calc(100% - 2rem));
  margin: 4rem auto;
  border-radius: 20px;
  padding: 2.5rem;
  background: #fff;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
}

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

.exercise-header h2 {
  margin: 0;
  font-size: 1.55rem;
}

.stats {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.5rem;
  font-weight: 700;
  white-space: nowrap;
}

.score-badge {
  color: #10b981;
  font-size: 1.55rem;
}

.level {
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.95rem;
}

.progress {
  width: 100%;
  height: 24px;
  overflow: hidden;
  border-radius: 6px;
  background: #e5e7eb;
}

.progress-value {
  width: 0;
  height: 100%;
  border-radius: 6px;
  background: #22c55e;
  transition: width 0.35s ease;
}

.game-area,
.game-container {
  position: relative;
  width: 100%;
  height: 500px;
  overflow: hidden;
  margin: 1.5rem 0;
  border: 3px solid var(--accent);
  border-radius: 12px;
  background: var(--area-bg);
}

.hint {
  border-radius: 8px;
  padding: 1rem;
  background: var(--hint-bg);
  color: var(--hint-text);
  text-align: center;
  font-size: 1.05rem;
}

.success-message {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  border-radius: 10px;
  background: var(--success-bg);
  text-align: center;
}

.success-animation {
  animation: success-bounce 0.6s ease;
}

.success-animation .emoji-large {
  display: block;
  margin-bottom: 1rem;
  font-size: 5rem;
  animation: spin 1s ease;
}

.success-animation h3 {
  margin: 0.5rem 0;
  color: var(--accent-dark);
  font-size: 2rem;
}

.success-animation p {
  margin: 0;
  color: var(--hint-text);
  font-size: 1.45rem;
}

.bubbles-game { --accent: #3b82f6; --accent-dark: #f59e0b; --area-bg: linear-gradient(to bottom, #e0f2fe, #bae6fd); --hint-bg: #dbeafe; --hint-text: #1e40af; --success-bg: linear-gradient(135deg, #fef3c7, #fde68a); }
.feed-game { --accent: #10b981; --accent-dark: #059669; --area-bg: linear-gradient(to bottom, #d1fae5, #a7f3d0); --hint-bg: #d1fae5; --hint-text: #065f46; --success-bg: linear-gradient(135deg, #d1fae5, #a7f3d0); }
.chest-game { --accent: #8b5cf6; --accent-dark: #7c3aed; --area-bg: linear-gradient(to bottom, #e9d5ff, #ddd6fe); --hint-bg: #e9d5ff; --hint-text: #5b21b6; --success-bg: linear-gradient(135deg, #e9d5ff, #ddd6fe); }
.sort-game { --accent: #f59e0b; --accent-dark: #d97706; --area-bg: #fff; --hint-bg: #fef3c7; --hint-text: #92400e; --success-bg: linear-gradient(135deg, #fef3c7, #fde68a); }
.treasure-game { --accent: #ec4899; --accent-dark: #db2777; --area-bg: linear-gradient(to bottom, #0ea5e9, #0284c7, #0369a1, #075985 90%, #0c4a6e); --hint-bg: #fce7f3; --hint-text: #831843; --success-bg: linear-gradient(135deg, #fce7f3, #fbcfe8); }
.target-game { --accent: #eab308; --accent-dark: #ca8a04; --area-bg: linear-gradient(135deg, #fef3c7, #fde68a); --hint-bg: #fef3c7; --hint-text: #78350f; --success-bg: linear-gradient(135deg, #fef3c7, #fde68a); }

.bubbles-game h2 { color: #3b82f6; }
.feed-game h2 { color: #10b981; }
.chest-game h2 { color: #8b5cf6; }
.sort-game h2 { color: #f59e0b; }
.treasure-game h2 { color: #ec4899; }
.target-game h2 { color: #eab308; }

.bubble {
  position: absolute;
  border: 0;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  box-shadow: inset -10px -10px 20px rgba(255, 255, 255, 0.5), inset 10px 10px 20px rgba(0, 0, 0, 0.1), 0 8px 16px rgba(0, 0, 0, 0.2);
  animation: float 3s ease-in-out infinite;
  transition: filter 0.3s ease;
}

.bubble:hover { filter: brightness(1.18); }
.bubble:active { animation: pop 0.3s ease forwards; }

.bubble::after {
  position: absolute;
  top: 15%;
  left: 20%;
  width: 40%;
  height: 40%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.8), transparent);
  content: "";
}

.animal {
  position: absolute;
  width: 120px;
  border: 0;
  border-radius: 12px;
  padding: 1rem;
  background: #fff;
  text-align: center;
  cursor: context-menu;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transition: 0.3s ease;
}

.animal:hover { transform: scale(1.1); box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2); }
.animal.fed { border: 2px solid #10b981; background: #d1fae5; }
.animal-emoji { display: block; margin-bottom: 0.5rem; font-size: 3rem; }
.animal-name { display: block; color: #333; font-weight: 700; }
.fed-badge { display: block; margin-top: 0.5rem; color: #059669; font-size: 0.85rem; font-weight: 700; }

.context-menu {
  position: absolute;
  z-index: 1000;
  min-width: 225px;
  overflow: hidden;
  border: 2px solid #10b981;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  animation: menu-appear 0.2s ease;
}

.menu-title {
  padding: 0.75rem 1rem;
  border-bottom: 2px solid #d1fae5;
  color: #059669;
  font-weight: 700;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  border: 0;
  padding: 0.7rem 1rem;
  background: #fff;
  color: #222;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover,
.menu-item.correct { background: #d1fae5; }
.food-emoji { font-size: 1.4rem; }

.chest-container {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100px;
  height: 100px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.chest-box { font-size: 4rem; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3)); animation: bounce 2s ease-in-out infinite; }
.click-hint { position: absolute; top: 82px; border-radius: 4px; padding: 0.25rem 0.5rem; background: #fef3c7; color: #92400e; font-size: 0.8rem; font-weight: 700; white-space: nowrap; }
.opened-treasure { font-size: 3rem; animation: treasure-appear 0.5s ease; }
.sparkles { position: absolute; top: 74px; font-size: 1.4rem; animation: pulse 1s infinite; }

.sort-game .game-container {
  height: auto;
  overflow: visible;
  border: 0;
  background: transparent;
}

.items-pool {
  margin-bottom: 2rem;
  border: 3px solid #f59e0b;
  border-radius: 12px;
  padding: 1.5rem;
  background: #fff;
}

.items-pool h3 { margin: 0 0 1rem; color: #d97706; text-align: center; }
.items-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 1rem; }

.draggable-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border: 3px solid #f59e0b;
  border-radius: 12px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  font-size: 3rem;
  cursor: move;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transition: 0.3s ease;
}

.draggable-item:hover { transform: scale(1.1) rotate(5deg); }
.draggable-item.dragging { opacity: 0.5; transform: scale(0.9); }

.categories-container { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem; }
.category-box { min-height: 285px; border: 4px dashed; border-radius: 12px; padding: 1.5rem; transition: 0.3s ease; }
.category-box.blue { border-color: #3b82f6; background: linear-gradient(135deg, #dbeafe, #bfdbfe); }
.category-box.green { border-color: #10b981; background: linear-gradient(135deg, #d1fae5, #a7f3d0); }
.category-box.purple { border-color: #8b5cf6; background: linear-gradient(135deg, #e9d5ff, #ddd6fe); }
.category-box.drag-over { transform: scale(1.04); box-shadow: 0 8px 16px rgba(245, 158, 11, 0.3); }
.category-header { display: flex; gap: 0.75rem; align-items: center; padding-bottom: 0.75rem; border-bottom: 2px solid rgba(0, 0, 0, 0.1); }
.category-emoji { font-size: 2rem; }
.category-name { font-size: 1.15rem; font-weight: 700; }
.category-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 0.75rem; min-height: 140px; padding: 1rem 0; }
.placed-item { display: flex; align-items: center; justify-content: center; width: 56px; height: 56px; border: 2px solid rgba(0, 0, 0, 0.1); border-radius: 8px; background: #fff; font-size: 2rem; animation: place-item 0.3s ease; }
.category-count { color: #666; text-align: center; font-size: 0.9rem; font-weight: 700; }

.treasure-game .game-area { cursor: grab; }
.treasure-game .game-area:active { cursor: grabbing; }
.scroll-content { position: relative; height: 3000px; transition: transform 0.3s ease; }
.depth-marker { position: absolute; left: 20px; border-radius: 4px; padding: 0.25rem 0.5rem; color: rgba(255, 255, 255, 0.75); background: rgba(0, 0, 0, 0.3); font-size: 0.9rem; font-weight: 700; }
.treasure { position: absolute; left: 50%; width: 80px; height: 80px; transform: translateX(-50%); border: 0; background: transparent; cursor: pointer; transition: 0.3s ease; }
.treasure:hover { transform: translateX(-50%) scale(1.2); }
.treasure.found { opacity: 0.5; pointer-events: none; }
.treasure-glow { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle, rgba(255, 215, 0, 0.6), transparent); animation: glow 2s ease-in-out infinite; }
.treasure-emoji { position: relative; font-size: 4rem; filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.8)); animation: float 3s ease-in-out infinite; }
.found-badge { position: absolute; top: -10px; right: -10px; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: #fff; background: #10b981; font-weight: 700; }
.sea-floor { position: absolute; top: 2800px; left: 0; display: flex; align-items: center; justify-content: center; width: 100%; height: 150px; background: linear-gradient(to bottom, transparent, #1e293b); color: #94a3b8; font-size: 1.5rem; font-weight: 700; }
.scroll-indicator { position: absolute; top: 50%; right: 20px; display: flex; flex-direction: column; align-items: center; gap: 0.35rem; transform: translateY(-50%); border-radius: 8px; padding: 0.8rem 1rem; color: #db2777; background: rgba(255, 255, 255, 0.85); font-weight: 700; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); animation: pulse 2s infinite; }
.scroll-arrows { font-size: 2rem; line-height: 0.8; }

.target-game .game-area { cursor: none; }
.crosshair { position: absolute; z-index: 100; width: 30px; height: 30px; pointer-events: none; }
.crosshair::before,
.crosshair::after { position: absolute; background: rgba(220, 38, 38, 0.8); content: ""; }
.crosshair::before { top: 50%; left: 0; width: 30px; height: 2px; transform: translateY(-50%); }
.crosshair::after { top: 0; left: 50%; width: 2px; height: 30px; transform: translateX(-50%); }
.level-info { position: absolute; top: 20px; left: 50%; z-index: 2; transform: translateX(-50%); border-radius: 8px; padding: 0.75rem 1.5rem; color: #92400e; background: rgba(255, 255, 255, 0.9); font-weight: 700; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); white-space: nowrap; }
.target { position: absolute; border: 0; border-radius: 50%; padding: 0; background: transparent; cursor: none; animation: target-pulse 2s ease-in-out infinite; }
.target > span { position: absolute; border: 3px solid; border-radius: 50%; pointer-events: none; }
.target-ring-1 { inset: 0; border-color: #dc2626 !important; background: #fca5a5; }
.target-ring-2 { inset: 17%; border-color: #ef4444 !important; background: #fff; }
.target-ring-3 { inset: 33.5%; border-color: #dc2626 !important; background: #fca5a5; }
.target-center { inset: 42.5% !important; border: 0 !important; background: #dc2626; box-shadow: 0 0 10px rgba(220, 38, 38, 0.5); }
.target.hit { pointer-events: none; animation: target-hit 0.5s ease forwards; }
.hit-mark { position: absolute !important; inset: 50% auto auto 50% !important; z-index: 3; transform: translate(-50%, -50%); border: 0 !important; color: #10b981; font-size: 3rem; font-weight: 700; text-shadow: 0 0 10px rgba(16, 185, 129, 0.8); }

.policy-shell { background: linear-gradient(135deg, #dcebff, #f7fbff); }
.policy-page { max-width: 900px; margin: 2.5rem auto; }
.policy-page h1 { color: #315d9d; }
.policy-date { font-weight: 700; }
.text-link { color: #1d4ed8; font-weight: 700; }

footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1.5rem 1rem 2rem;
  color: #3f5877;
}

footer a { color: #315d9d; font-weight: 700; }
.game-active footer { display: none; }

@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@keyframes shake { from { transform: translateX(-2px); } to { transform: translateX(2px); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-20px); } }
@keyframes pop { 0% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.3); opacity: 0.7; } 100% { transform: scale(0); opacity: 0; } }
@keyframes success-bounce { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes menu-appear { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
@keyframes treasure-appear { from { opacity: 0; transform: scale(0) translateY(20px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes place-item { from { opacity: 0; transform: scale(0) rotate(-180deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes glow { 0%, 100% { opacity: 0.6; transform: scale(1); } 50% { opacity: 0.3; transform: scale(1.3); } }
@keyframes target-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes target-hit { 0% { opacity: 1; transform: scale(1); } 50% { opacity: 0.7; transform: scale(1.3); } 100% { opacity: 0; transform: scale(0); } }

@media (max-width: 900px) {
  .games-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .categories-container { grid-template-columns: 1fr; }
  .category-box { min-height: 180px; }
  .game-panel { padding: 1.5rem; }
}

@media (max-width: 620px) {
  .site-header { align-items: flex-start; padding: 1rem; }
  .site-header h1 { font-size: 1.2rem; }
  .back-button { padding: 10px 12px; font-size: 0.82rem; }
  #menu-view { padding-inline: 0.35rem; }
  .intro { text-align: left; }
  .games-grid,
  .skill-list { grid-template-columns: 1fr; }
  .game-card { min-height: 290px; }
  .game-panel { width: calc(100% - 1rem); margin: 1rem auto; padding: 1rem; }
  .exercise-header { align-items: flex-start; }
  .exercise-header h2 { font-size: 1.05rem; }
  .stats { gap: 0.35rem; font-size: 1rem; }
  .score-badge { font-size: 1.05rem; }
  .game-area { height: 430px; }
  .animal { width: 88px; padding: 0.6rem; }
  .animal-emoji { font-size: 2rem; }
  .animal-name { font-size: 0.8rem; }
  .context-menu { min-width: 190px; font-size: 0.85rem; }
  .scroll-indicator { right: 8px; padding: 0.55rem; font-size: 0.72rem; }
  .level-info { font-size: 0.78rem; }
  .hint { font-size: 0.88rem; }
}

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