/* Vectron-Juniors - FLL România - Cartoon Kid Style! */
:root {
  --color-earth: #a16207;
  --color-bronze: #ea580c;
  --color-river: #0ea5e9;
  --color-mammoth: #fcd34d;
  --color-gold: #fbbf24;
  --color-cream: #fffbeb;
  --color-bark: #78716c;
  --color-stone: #d6d3d1;
  --color-sun: #fde047;
  --color-grass: #22c55e;
  --color-sky: #38bdf8;
  --shadow: 0 4px 0 rgba(0,0,0,0.15), 0 8px 20px rgba(0,0,0,0.1);
  --shadow-big: 0 6px 0 rgba(0,0,0,0.2), 0 12px 30px rgba(0,0,0,0.12);
  --radius: 28px;
  --radius-sm: 18px;
  --radius-pill: 999px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

button, a, .game-card {
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Nunito', sans-serif;
  background: #fef3c7;
  min-height: 100vh;
  color: #292524;
  overflow-x: hidden;
}

body.page-game {
  background: linear-gradient(165deg, #a5f3fc 0%, #fbcfe8 50%, #fef3c7 100%);
}

/* ========== POPUP & OVERLAY - Fixed centering, no jump ========== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 31, 20, 0.5);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.overlay.hidden {
  display: none !important;
}

/* Centering wrapper - uses flex, popup never jumps */
.popup-center {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100%;
}

.education-popup {
  background: linear-gradient(180deg, #fff 0%, #fffbeb 100%);
  padding: 32px;
  border-radius: var(--radius);
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-big);
  border: 5px solid #292524;
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.education-popup h3 {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.5rem;
  color: #2d1f14;
  margin-bottom: 16px;
  text-align: center;
}

.education-popup p {
  color: #5d4a35;
  line-height: 1.7;
  margin-bottom: 24px;
  font-size: 1.05rem;
}

.popup-btn {
  width: 100%;
  padding: 18px 24px;
  background: linear-gradient(135deg, #f97316, #fbbf24);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 1.2rem;
  cursor: pointer;
  font-family: 'Fredoka', sans-serif;
  transition: all 0.2s;
  box-shadow: 0 5px 0 #c2410c;
  border: 4px solid #292524;
  touch-action: manipulation;
}

.popup-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 7px 0 #c2410c;
}

.popup-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #c2410c;
}

.username-popup input {
  width: 100%;
  padding: 16px 20px;
  font-size: 1.2rem;
  font-family: 'Fredoka', sans-serif;
  border: 5px solid #292524;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  box-shadow: 0 4px 0 #44403c;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.username-display {
  font-weight: 700;
  color: #5d4a35;
}

.change-name-btn {
  background: none;
  border: none;
  color: var(--color-bronze);
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
}

.change-name-btn:hover {
  color: var(--color-gold);
}

.leaderboard-link {
  padding: 12px 24px;
  background: #f97316;
  color: white;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-family: 'Fredoka', sans-serif;
  border: 3px solid #292524;
  transition: all 0.2s;
}

.leaderboard-link:hover {
  opacity: 0.9;
}

.game-card-secret {
  border-color: #292524 !important;
  background: linear-gradient(180deg, #fef3c7 0%, #fde68a 100%) !important;
  box-shadow: 0 6px 0 #ca8a04 !important;
}

/* Lego bonus game - full width row at top, locked until all 6 games completed */
.game-card-lego {
  grid-column: 1 / -1;
}

/* Locked Lego bonus game - visible but greyed until all 7 games completed */
.game-card-locked {
  opacity: 0.85;
  background: linear-gradient(180deg, #e7e5e4 0%, #d6d3d1 100%) !important;
  border-color: #78716c !important;
  box-shadow: 0 5px 0 #57534e !important;
  cursor: not-allowed;
  position: relative;
}

.game-card-locked:hover {
  transform: none;
}

.game-card-locked .game-icon {
  filter: grayscale(0.4);
}

.game-card-lego .lego-lock-msg {
  font-size: 0.9rem;
  color: #57534e;
  font-weight: 600;
  margin-top: 4px;
}

.game-card-lego .lego-progress {
  font-size: 1rem;
  font-weight: 700;
  color: #78716c;
  margin-top: 8px;
}

.game-card-lego:not(.game-card-locked) .lego-lock-msg {
  color: #44403c;
}

.lego-canvas-wrapper .boat-canvas {
  width: 400px;
  height: 400px;
  max-width: 100%;
}

/* ========== LEADERBOARD ========== */
.leaderboard-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
}

.leaderboard-card {
  background: linear-gradient(180deg, #fff 0%, #fffbeb 100%);
  border-radius: var(--radius);
  padding: 24px;
  border: 5px solid #292524;
  box-shadow: 0 5px 0 #44403c;
}

.leaderboard-card h3 {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.2rem;
  margin-bottom: 16px;
  color: #2d1f14;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.leaderboard-table th {
  background: #f8f0e3;
  font-weight: 700;
}

.leaderboard-loading {
  text-align: center;
  padding: 40px;
  color: #6b5b4a;
}

.leaderboard-error {
  text-align: center;
  padding: 20px;
  color: #c62828;
  max-width: 500px;
  margin: 20px auto;
}

.leaderboard-error.hidden,
.hidden {
  display: none;
}

.leaderboard-error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  gap: 16px;
}

.retry-btn {
  padding: 12px 24px;
  background: #f97316;
  color: white;
  border: 3px solid #292524;
  border-radius: 14px;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.retry-btn:hover {
  opacity: 0.9;
}

.win-score-line { margin-top: 12px; font-weight: 700; }

/* ========== WIN POPUP - Kid-friendly celebration ========== */
.win-overlay {
  background: rgba(255, 215, 0, 0.3);
}

.win-popup {
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
  padding: 40px 36px;
  border-radius: 32px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-big);
  border: 6px solid #292524;
  animation: bounceIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes bounceIn {
  from {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.08);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.win-emoji {
  font-size: 4rem;
  display: block;
  margin-bottom: 16px;
  animation: wobble 0.6s ease infinite;
}

@keyframes wobble {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}

.win-popup h2 {
  font-family: 'Fredoka', sans-serif;
  font-size: 2rem;
  color: #2d1f14;
  margin-bottom: 12px;
}

.win-popup p {
  font-size: 1.15rem;
  color: #5d4a35;
  margin-bottom: 8px;
}

.win-sub {
  font-size: 1rem !important;
  color: #8a7a6a !important;
  margin-bottom: 24px !important;
}

.win-btn {
  display: inline-block;
  padding: 16px 32px;
  background: linear-gradient(135deg, #22c55e, #4ade80);
  color: white !important;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 1.1rem;
  font-family: 'Fredoka', sans-serif;
  cursor: pointer;
  border: 4px solid #292524;
  transition: all 0.2s;
  box-shadow: 0 5px 0 #15803d;
}

.win-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 7px 0 #15803d;
}

.gameover-popup {
  border-color: #292524;
}

.gameover-popup .win-btn {
  background: linear-gradient(135deg, #fb923c, #fbbf24);
  box-shadow: 0 5px 0 #ea580c;
}

/* ========== HOME PAGE ========== */
.app {
  min-height: 100vh;
  padding: 24px;
}

.page-home .app {
  max-width: 960px;
  margin: 0 auto;
}

.hero {
  text-align: center;
  margin-bottom: 48px;
}

.badge {
  display: inline-block;
  background: #f97316;
  color: white;
  padding: 12px 28px;
  border-radius: var(--radius-pill);
  font-size: 0.95rem;
  font-weight: 700;
  font-family: 'Fredoka', sans-serif;
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: 3px solid #292524;
}

.hero h1 {
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  color: #292524;
  margin-bottom: 12px;
  text-shadow: 3px 3px 0 rgba(255,255,255,0.9);
}

.subtitle {
  font-size: 1.4rem;
  color: #5d4a35;
  margin-bottom: 16px;
  font-weight: 700;
}

.intro {
  font-size: 1.1rem;
  color: #6b5b4a;
  max-width: 620px;
  margin: 0 auto;
  line-height: 1.7;
}

.unlock-hint {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  color: #57534e;
  margin: 0 auto 24px auto;
  padding: 10px 20px;
  background: #fef3c7;
  border-radius: var(--radius-sm);
  border: 3px solid #292524;
  max-width: 520px;
}

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

.game-card {
  background: linear-gradient(180deg, #fff 0%, #fffbeb 100%);
  border: 5px solid #292524;
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: inherit;
  box-shadow: 0 6px 0 #292524;
  display: block;
}

.game-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 10px 0 #292524;
  border-color: #292524;
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
}

.game-card:active {
  transform: translateY(-4px) scale(1.01);
}

.game-icon {
  font-size: 4.5rem;
  display: block;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 0 rgba(0,0,0,0.15));
  animation: iconBounce 2s ease-in-out infinite;
}

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

.game-card h3 {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.35rem;
  color: #2d1f14;
  margin-bottom: 8px;
}

.game-card p {
  font-size: 1rem;
  color: #6b5b4a;
}

.game-status {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.game-status-todo {
  color: #78716c;
}

.game-status-done {
  color: #15803d;
}

.home-footer {
  margin-top: 56px;
  text-align: center;
  color: #8a7a6a;
  font-size: 1rem;
}

.home-footer .privacy-link {
  display: block;
  margin-top: 12px;
  color: #ea580c;
  font-size: 0.875rem;
  text-decoration: underline;
}

.home-footer .privacy-link:hover {
  opacity: 0.9;
}

/* ========== GAME PAGES ========== */
.game-page {
  max-width: 700px;
  margin: 0 auto;
}

.back-btn {
  display: inline-block;
  background: #fff;
  border: 4px solid #292524;
  padding: 14px 28px;
  border-radius: var(--radius-sm);
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  color: #292524;
  text-decoration: none;
  margin-bottom: 20px;
  transition: all 0.2s;
}

.back-btn:hover {
  opacity: 0.9;
}

.game-container {
  width: 100%;
  min-height: 450px;
  background: linear-gradient(180deg, #fff 0%, #fffbeb 100%);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: 0 5px 0 #292524;
  border: 5px solid #292524;
}

/* Game elements */
.game-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.9rem;
  text-align: center;
  margin-bottom: 16px;
  color: #292524;
  text-shadow: 2px 2px 0 rgba(255,255,255,0.8);
}

.game-info {
  text-align: center;
  color: #5d4a35;
  margin-bottom: 16px;
  font-size: 1.05rem;
}

.game-timer {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  font-family: 'Fredoka', sans-serif;
  color: #292524;
  margin-bottom: 16px;
  padding: 12px 24px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-radius: var(--radius-sm);
  display: inline-block;
  border: 4px solid #292524;
  box-shadow: 0 4px 0 #ca8a04;
}

.game-stats {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: #2d1f14;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.game-stats .game-timer { margin: 0; padding: 8px 16px; }
.game-stats .score-display,
.game-stats .secera-score { padding: 8px 20px; background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); border-radius: var(--radius-sm); border: 3px solid #292524; box-shadow: 0 3px 0 #ca8a04; }

/* ========== MEMORY GAME ========== */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  max-width: 460px;
  margin: 0 auto;
}

.memory-card {
  aspect-ratio: 1;
  background: linear-gradient(145deg, #78716c, #a8a29e);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 5px solid #292524;
  box-shadow: 0 5px 0 #44403c;
  touch-action: manipulation;
}

.memory-card:hover:not(.flipped):not(.matched) {
  transform: scale(1.08);
  box-shadow: 0 6px 0 #44403c;
}

.memory-card.flipped,
.memory-card.matched {
  background: linear-gradient(145deg, #fde68a, #fcd34d);
  transform: scale(1.03);
  border-color: #292524;
  box-shadow: 0 4px 0 #ca8a04;
}

.memory-card.matched {
  cursor: default;
  animation: matchPulse 0.4s ease;
}

@keyframes matchPulse {
  0% { transform: scale(1.1); }
  100% { transform: scale(1.02); }
}

/* ========== BOAT GAME ========== */
.boat-game {
  text-align: center;
}

.boat-canvas-wrapper {
  background: linear-gradient(180deg, #7dd3fc 0%, #0ea5e9 100%);
  border-radius: var(--radius);
  padding: 20px;
  margin: 20px 0;
  border: 5px solid #292524;
  box-shadow: 0 5px 0 #0369a1, inset 0 0 40px rgba(255,255,255,0.3);
}

.boat-canvas {
  display: block;
  margin: 0 auto;
  background: #38bdf8;
  border-radius: 20px;
  max-width: 100%;
  width: 400px;
  border: 5px solid #292524;
  box-shadow: 0 5px 0 #0369a1;
}

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

.boat-btn {
  padding: 18px 36px;
  font-size: 1.3rem;
  background: linear-gradient(135deg, #f97316, #fbbf24);
  color: white;
  border: 4px solid #292524;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 700;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: 'Fredoka', sans-serif;
  box-shadow: 0 5px 0 #c2410c;
  touch-action: manipulation;
}

.boat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 7px 0 #c2410c;
}

.boat-btn:active {
  transform: scale(0.98);
}

.score-display {
  font-size: 1.4rem;
  font-weight: 700;
  font-family: 'Fredoka', sans-serif;
  color: #292524;
  padding: 12px 20px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-radius: var(--radius-sm);
  display: inline-block;
  border: 3px solid #292524;
  box-shadow: 0 3px 0 #ca8a04;
}

/* ========== PUZZLE GAME ========== */
.puzzle-container {
  max-width: 440px;
  margin: 0 auto;
}

.puzzle-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: #57534e;
  padding: 16px;
  border-radius: var(--radius);
  margin: 24px 0;
  border: 5px solid #292524;
  box-shadow: 0 5px 0 #44403c;
}

.puzzle-piece {
  aspect-ratio: 1;
  background: linear-gradient(145deg, #e7e5e4, #d6d3d1);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  cursor: grab;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 4px solid #292524;
  box-shadow: 0 4px 0 #78716c;
  touch-action: manipulation;
}

.puzzle-piece:hover {
  background: linear-gradient(145deg, #fef3c7, #fde68a);
  transform: scale(1.06);
}

.puzzle-piece.puzzle-piece-selected {
  background: linear-gradient(145deg, #fde68a, #fcd34d) !important;
  box-shadow: 0 0 0 4px #f97316;
}

.puzzle-piece.correct {
  background: linear-gradient(145deg, #86efac, #4ade80);
  border-color: #15803d;
  box-shadow: 0 4px 0 #15803d;
}

/* ========== QUIZ GAME ========== */
.quiz-container {
  max-width: 520px;
  margin: 0 auto;
}

.quiz-question {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 24px;
  color: #2d1f14;
  line-height: 1.5;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.quiz-option {
  padding: 20px 24px;
  background: linear-gradient(145deg, #fffbeb 0%, #fef3c7 100%);
  border: 5px solid #292524;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font-size: 1.05rem;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: inherit;
  touch-action: manipulation;
  box-shadow: 0 4px 0 #44403c;
}

.quiz-option:hover {
  background: linear-gradient(145deg, #fef3c7 0%, #fde68a 100%);
  transform: translateX(8px);
  box-shadow: 0 5px 0 #44403c;
}

.quiz-option.correct {
  background: linear-gradient(145deg, #bbf7d0, #86efac);
  border-color: #15803d;
  box-shadow: 0 4px 0 #15803d;
}

.quiz-option.wrong {
  background: linear-gradient(145deg, #fecaca, #fca5a5);
  border-color: #b91c1c;
  box-shadow: 0 4px 0 #991b1b;
}

.quiz-btn {
  margin-top: 28px;
  padding: 18px 40px;
  background: linear-gradient(135deg, #f97316, #fbbf24);
  color: white;
  border: 4px solid #292524;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Fredoka', sans-serif;
  box-shadow: 0 5px 0 #c2410c;
}

.quiz-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 7px 0 #c2410c;
}

/* ========== DECODER GAME ========== */
.decoder-container {
  max-width: 480px;
  margin: 0 auto;
}

.decoder-stone {
  background: linear-gradient(145deg, #78716c 0%, #57534e 100%);
  padding: 24px 20px;
  border-radius: var(--radius);
  margin: 20px 0;
  border: 5px solid #292524;
  box-shadow: 0 5px 0 #44403c, inset 0 2px 8px rgba(0,0,0,0.2);
}

.decoder-stone-label {
  font-size: 0.9rem;
  color: rgba(255,248,231,0.8);
  margin: 0 0 8px 0;
  font-weight: 600;
}

.decoder-encoded {
  font-size: 1.8rem;
  letter-spacing: 8px;
  color: #fff8e7;
  margin: 12px 0 20px 0;
  font-family: 'Courier New', monospace;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.decoder-display {
  background: rgba(0,0,0,0.25);
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 1.8rem;
  letter-spacing: 6px;
  font-family: 'Courier New', monospace;
  color: #ffd93d;
  border: 2px solid rgba(255,248,231,0.2);
  min-height: 52px;
  transition: transform 0.2s;
}

.decoder-display.decoder-reveal {
  animation: decoderReveal 0.4s ease;
}

@keyframes decoderReveal {
  0% { transform: scale(1.02); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.decoder-hint {
  font-size: 1rem;
  color: #5d4a35;
  margin: 16px 0 12px 0;
  font-weight: 700;
  text-align: center;
}

.decoder-key {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 16px 0 20px 0;
}

.decoder-btn {
  width: 56px;
  height: 56px;
  font-size: 1.5rem;
  background: linear-gradient(135deg, #f97316, #fbbf24);
  color: white;
  border: 4px solid #292524;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: inherit;
  box-shadow: 0 5px 0 #c2410c;
  touch-action: manipulation;
}

.decoder-btn:hover:not(:disabled) {
  transform: scale(1.1);
  box-shadow: 0 5px 15px rgba(0,0,0,0.25);
}

.decoder-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.decoder-btn.decoder-wrong {
  animation: decoderShake 0.4s ease;
  background: linear-gradient(135deg, #c62828, #e53935);
}

@keyframes decoderShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.decoder-btn.decoder-correct {
  animation: decoderPulse 0.3s ease;
  background: linear-gradient(135deg, #2E7D32, #43A047);
}

@keyframes decoderPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.decoder-btn.decoder-used {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

.decoder-btn:disabled {
  cursor: default;
}

.decoder-fact {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  padding: 16px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: #44403c;
  line-height: 1.6;
  border: 4px solid #292524;
  margin-top: 16px;
  box-shadow: 0 4px 0 #ca8a04;
}

.decoder-fact.hidden {
  display: none;
}

/* ========== PATTERN GAME ========== */
.pattern-game {
  text-align: center;
}

.pattern-sequence {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 24px 0;
  flex-wrap: wrap;
}

.pattern-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 5px solid #292524;
  font-size: 2rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  background: linear-gradient(145deg, #fff, #f5f5f4);
  touch-action: manipulation;
  box-shadow: 0 5px 0 #44403c;
}

.pattern-btn:hover {
  transform: scale(1.12);
}

.pattern-btn.gold { background: linear-gradient(145deg, #fde047, #fbbf24); box-shadow: 0 5px 0 #ca8a04; }
.pattern-btn.bronze { background: linear-gradient(145deg, #f97316, #ea580c); box-shadow: 0 5px 0 #c2410c; }
.pattern-btn.copper { background: linear-gradient(145deg, #fb923c, #f97316); box-shadow: 0 5px 0 #ea580c; }
.pattern-btn.silver { background: linear-gradient(145deg, #e7e5e4, #a8a29e); box-shadow: 0 5px 0 #78716c; }

.pattern-btn.lit {
  transform: scale(1.25);
  box-shadow: 0 0 35px rgba(253,224,71,0.9);
}

.pattern-sequence .pattern-btn {
  pointer-events: none;
}

.pattern-input {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 24px 0;
  flex-wrap: wrap;
}

.pattern-input .pattern-btn {
  pointer-events: auto;
  cursor: pointer;
}

.start-pattern-btn {
  padding: 18px 44px;
  font-size: 1.3rem;
  background: linear-gradient(135deg, #f97316, #fbbf24);
  color: white;
  border: 4px solid #292524;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 700;
  margin: 20px 0;
  font-family: 'Fredoka', sans-serif;
  box-shadow: 0 5px 0 #c2410c;
}

.start-pattern-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 7px 0 #c2410c;
}

/* Odd One game (bratari) - bracelet beads */
.oddone-game {
  margin: 16px 0;
}
.oddone-grid {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 24px 0;
  flex-wrap: wrap;
}
.oddone-btn {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.oddone-btn.bead-gold { background: linear-gradient(145deg, #fde047, #fbbf24) !important; box-shadow: 0 5px 0 #ca8a04; }
.oddone-btn.bead-bronze { background: linear-gradient(145deg, #f97316, #ea580c) !important; box-shadow: 0 5px 0 #c2410c; }
.oddone-btn.bead-copper { background: linear-gradient(145deg, #fb923c, #f97316) !important; box-shadow: 0 5px 0 #ea580c; }
.oddone-btn.bead-silver { background: linear-gradient(145deg, #e7e5e4, #a8a29e) !important; box-shadow: 0 5px 0 #78716c; }
.oddone-btn.bead-turquoise { background: linear-gradient(145deg, #2dd4bf, #14b8a6) !important; box-shadow: 0 5px 0 #0d9488; }
.oddone-btn.bead-amber { background: linear-gradient(145deg, #fcd34d, #f59e0b) !important; box-shadow: 0 5px 0 #d97706; }
.oddone-btn.wrong {
  background: linear-gradient(145deg, #fecaca, #f87171) !important;
  animation: oddoneShake 0.4s ease;
}
@keyframes oddoneShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* ========== RESPONSIVE - Mobile First ========== */
@media (max-width: 768px) {
  .app {
    padding: 16px;
  }
  
  .hero h1 {
    font-size: 1.8rem;
  }
  
  .subtitle {
    font-size: 1.2rem;
  }
  
  .intro {
    font-size: 1rem;
  }
  
  .unlock-hint {
    font-size: 0.95rem;
    padding: 8px 16px;
    margin-bottom: 16px;
  }
  
  .game-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .game-card {
    padding: 20px 16px;
  }
  
  .game-icon {
    font-size: 3rem;
  }
  
  .game-card h3 {
    font-size: 1.2rem;
  }
  
  .header-actions {
    gap: 12px;
    flex-direction: column;
  }
  
  .game-container {
    padding: 20px 16px;
    min-height: 380px;
  }
  
  .game-title {
    font-size: 1.4rem;
  }
  
  .education-popup,
  .win-popup {
    padding: 24px 20px;
    margin: 16px;
  }
  
  .popup-btn,
  .win-btn {
    padding: 16px 24px;
    font-size: 1rem;
    min-height: 48px;
  }
  
  .boat-canvas-wrapper {
    padding: 12px;
    margin: 12px 0;
    overflow-x: auto;
  }
  
  .boat-canvas {
    max-width: 100%;
    height: auto;
  }
  
  .boat-controls {
    gap: 12px;
    margin-top: 16px;
  }
  
  .boat-btn {
    padding: 16px 24px;
    font-size: 1.1rem;
    min-height: 52px;
  }
  
  .leaderboard-container {
    gap: 16px;
  }
  
  .leaderboard-card {
    padding: 16px;
  }
}

@media (max-width: 500px) {
  .app {
    padding: 12px;
  }
  
  .back-btn {
    padding: 12px 20px;
    font-size: 0.95rem;
  }
  
  .memory-grid {
    gap: 8px;
    max-width: 100%;
  }
  
  .memory-card {
    font-size: 1.6rem;
  }
  
  .puzzle-grid {
    gap: 4px;
    padding: 8px;
  }
  
  .puzzle-piece {
    font-size: 1.5rem;
  }
  
  .quiz-option {
    padding: 16px 18px;
    font-size: 1rem;
  }
  
  .pattern-btn {
    width: 64px;
    height: 64px;
    font-size: 1.6rem;
  }
  
  .pattern-sequence,
  .pattern-input {
    gap: 12px;
  }
  
  .decoder-stone {
    padding: 16px 12px;
  }
  
  .decoder-encoded {
    font-size: 1.4rem;
    letter-spacing: 4px;
  }
  
  .decoder-display {
    font-size: 1.4rem;
    letter-spacing: 4px;
  }
  
  .decoder-btn {
    width: 52px;
    height: 52px;
    font-size: 1.3rem;
  }
  
  .decoder-key {
    gap: 10px;
  }
  
  .game-timer,
  .score-display {
    font-size: 1.1rem;
    padding: 10px 14px;
  }
  
  .game-stats {
    flex-direction: column;
  }
}

/* Touch-friendly: larger tap targets, no hover reliance */
@media (hover: none) and (pointer: coarse) {
  .game-card {
    min-height: 120px;
  }
  
  .game-card:hover {
    transform: none;
  }
  
  .game-card:active {
    transform: scale(0.98);
    opacity: 0.95;
  }
  
  .boat-btn,
  .decoder-btn,
  .popup-btn,
  .win-btn {
    min-height: 48px;
  }
  
  .quiz-option {
    min-height: 56px;
  }
}

/* Prevent zoom on input focus (iOS) */
@media (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}
