:root {
  --font-family: 'Fredoka', cursive, sans-serif;
  --bg-gradient: linear-gradient(135deg, #f0f4fd 0%, #e3edf7 100%);
  --primary: #4361ee;
  --primary-hover: #3a0ca3;
  --success: #2ec4b6;
  --warning: #ff9f1c;
  --danger: #e71d36;
  --card-bg: #ffffff;
  --text-main: #2b2d42;
  --text-muted: #6c757d;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --shadow: 0 10px 25px -5px rgba(50, 50, 93, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 18px 30px -5px rgba(50, 50, 93, 0.15), 0 10px 15px -5px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: var(--font-family);
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: stretch;
}

.app-container {
  width: 100%;
  max-width: 960px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
  margin: 0 auto;
}

/* HEADER */
.game-header {
  background: var(--card-bg);
  padding: 16px 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.logo {
  font-size: 1.8rem;
  font-weight: 700;
  background: linear-gradient(45deg, #e71d36, #ff9f1c, #2ec4b6, #4361ee, #7209b7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: #f1f3f9;
  border: none;
  font-size: 1.3rem;
  padding: 8px 14px;
  border-radius: 50px;
  cursor: pointer;
  transition: transform 0.15s, background-color 0.2s;
}

.icon-btn:hover {
  background: #e2e6f0;
  transform: scale(1.08);
}

.mode-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tab-btn {
  flex: 1;
  min-width: 130px;
  padding: 10px 16px;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: #f4f6fc;
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  background: #e8ecf8;
  color: var(--primary);
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(67, 97, 238, 0.35);
}

/* MAIN */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.game-section {
  display: none;
  flex: 1;
  animation: fadeIn 0.3s ease-in-out;
}

.game-section.active-section {
  display: flex;
  flex-direction: column;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* EXPLORE / FLASHCARDS */
.section-intro {
  text-align: center;
  margin-bottom: 20px;
}

.section-intro h2 {
  font-size: 1.6rem;
  color: #2b2d42;
  margin-bottom: 6px;
}

.section-intro p {
  color: var(--text-muted);
  font-size: 1rem;
}

.flashcards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.color-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
  border: 3px solid transparent;
}

.color-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: var(--shadow-hover);
  border-color: rgba(67, 97, 238, 0.3);
}

.card-sample {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.15), 0 6px 12px rgba(0, 0, 0, 0.08);
  border: 4px solid #ffffff;
}

.card-info {
  text-align: center;
}

.card-en {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
}

.card-pl {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
}

.card-speak-btn {
  margin-top: 10px;
  background: #f1f4fc;
  border: none;
  font-size: 1.1rem;
  border-radius: 20px;
  padding: 6px 14px;
  color: var(--primary);
  font-family: var(--font-family);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.card-speak-btn:hover {
  background: var(--primary);
  color: #fff;
}

/* MODAL */
.card-detail-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.card-detail-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  background: #fff;
  border-radius: 24px;
  padding: 32px 24px;
  width: 90%;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  transform: scale(0.9);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 10;
}

.card-detail-modal.active .modal-card {
  transform: scale(1);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 18px;
  background: #f1f3f9;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.modal-close:hover {
  background: #e2e6f0;
  color: var(--text-main);
}

.color-splash-preview {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  margin: 0 auto 16px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 20px rgba(0,0,0,0.12);
  border: 5px solid #fff;
}

.color-emoji {
  font-size: 3.2rem;
}

.color-en-title {
  font-size: 2rem;
  font-weight: 700;
}

.color-pl-title {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.pronunciation-hint {
  font-size: 1rem;
  color: #8892b0;
  margin: 8px 0 16px 0;
  font-style: italic;
}

.examples-box {
  background: #f8fafc;
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.example-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}

.speaker-action-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 1.05rem;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  box-shadow: 0 6px 15px rgba(67, 97, 238, 0.35);
  transition: all 0.2s;
}

.speaker-action-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

/* QUIZ */
.quiz-hud {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 14px 24px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-around;
  margin-bottom: 20px;
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
}

.hud-label {
  color: var(--text-muted);
}

.hud-value {
  font-weight: 700;
}

.score-text {
  color: var(--primary);
}

.streak-text {
  color: var(--warning);
}

.quiz-card-box {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.quiz-prompt-bubble {
  text-align: center;
}

.prompt-sub {
  font-size: 1.1rem;
  color: var(--text-muted);
}

.prompt-word-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 6px 0;
}

.quiz-word {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: 1px;
}

.icon-speak-btn {
  background: #eef2ff;
  border: 2px solid #dbeafe;
  color: var(--primary);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.icon-speak-btn:hover {
  transform: scale(1.1);
  background: #dbeafe;
}

.icon-speak-btn.mini {
  width: 38px;
  height: 38px;
  font-size: 1.1rem;
}

.quiz-hint-text {
  font-size: 0.9rem;
  color: #94a3b8;
}

.quiz-options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 500px;
}

.quiz-opt-btn {
  min-height: 110px;
  border-radius: var(--radius-md);
  border: 4px solid #ffffff;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-family);
  font-size: 1.15rem;
  font-weight: 700;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}

.quiz-opt-btn:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.quiz-opt-btn:active {
  transform: scale(0.97);
}

.quiz-opt-btn.correct-burst {
  animation: pulseSuccess 0.5s ease;
  border-color: #2ec4b6 !important;
}

.quiz-opt-btn.wrong-shake {
  animation: shakeWrong 0.5s ease;
  opacity: 0.5;
}

@keyframes pulseSuccess {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

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

.quiz-feedback-box {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* END SCREEN */
.quiz-end-screen {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.quiz-end-screen.active {
  opacity: 1;
  pointer-events: auto;
}

.end-card {
  background: #fff;
  border-radius: 24px;
  padding: 36px 28px;
  width: 90%;
  max-width: 440px;
  text-align: center;
  box-shadow: var(--shadow-hover);
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.trophy-icon {
  font-size: 4rem;
  margin-bottom: 12px;
}

.final-score-msg {
  font-size: 1.3rem;
  color: var(--primary);
  font-weight: 700;
  margin: 12px 0 24px 0;
}

.end-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.primary-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 22px;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(67, 97, 238, 0.35);
  transition: all 0.2s;
}

.primary-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

.primary-btn.pulse {
  animation: btnPulse 1.8s infinite;
}

@keyframes btnPulse {
  0% { box-shadow: 0 0 0 0 rgba(67, 97, 238, 0.5); }
  70% { box-shadow: 0 0 0 16px rgba(67, 97, 238, 0); }
  100% { box-shadow: 0 0 0 0 rgba(67, 97, 238, 0); }
}

.secondary-btn {
  background: #f1f3f9;
  color: var(--text-main);
  border: none;
  padding: 12px 20px;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all 0.2s;
}

.secondary-btn:hover {
  background: #e2e6f0;
}

/* BUBBLE GAME */
.bubble-game-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.bubble-hud {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.target-task {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 600;
}

.target-badge-container {
  display: flex;
  align-items: center;
  gap: 6px;
}

.target-name {
  background: #2b2d42;
  color: #fff;
  padding: 6px 16px;
  border-radius: 50px;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.bubble-stats {
  display: flex;
  gap: 16px;
}

.bubble-stat-box {
  background: #f8fafc;
  padding: 6px 14px;
  border-radius: 12px;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.canvas-container {
  position: relative;
  background: linear-gradient(180deg, #bde0fe 0%, #a2d2ff 60%, #cdb4db 100%);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 480px;
}

#bubbleCanvas {
  display: block;
  max-width: 100%;
  height: auto;
  cursor: crosshair;
}

.bubble-start-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s;
}

.bubble-start-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-modal {
  background: #fff;
  border-radius: 24px;
  padding: 32px 24px;
  max-width: 440px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.game-big-icon {
  font-size: 3.5rem;
}

.overlay-modal h2 {
  font-size: 1.8rem;
  margin: 10px 0;
  color: var(--text-main);
}

.overlay-modal p {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.5;
  margin-bottom: 24px;
}

/* FOOTER */
.game-footer {
  margin-top: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* RESPONSIVE */
@media (max-width: 640px) {
  .logo {
    font-size: 1.4rem;
  }
  
  .tab-btn {
    font-size: 0.88rem;
    padding: 8px 10px;
  }
  
  .flashcards-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .quiz-options-grid {
    grid-template-columns: 1fr;
  }

  .bubble-hud {
    flex-direction: column;
    align-items: flex-start;
  }
}
