/* VocabCastle - Redesigned Layout */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&family=Quicksand:wght@500;600;700&display=swap');

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary: #ec4899;
  --success: #10b981;
  --success-light: #d1fae5;
  --success-bg: #ecfdf5;
  --error: #ef4444;
  --error-light: #fee2e2;
  --error-bg: #fef2f2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --gold: #fbbf24;
  
  --bg-main: #f0f9ff;
  --bg-card: #ffffff;
  --bg-input: #f1f5f9;
  
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  
  --border: #e2e8f0;
  --shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.1);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
}

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

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

.container { 
  max-width: 800px; 
  margin: 0 auto; 
  padding: 12px; 
}

/* Header */
header { 
  margin-bottom: 12px;
}

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

.logo-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  cursor: pointer;
}

.logo-img {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo {
  font-family: 'Quicksand', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.tagline { 
  color: var(--text-secondary); 
  font-size: 0.75rem;
  margin: 0;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-header {
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-secondary);
}

.btn-header:hover {
  background: var(--bg-input);
  border-color: var(--primary);
}

/* Castle Box */
.castle-box {
  padding: 14px 18px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-radius: var(--radius);
  border: 2px solid var(--gold);
  margin-bottom: 12px;
}

.castle-info { width: 100%; }

.castle-level-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.castle-level { 
  font-weight: 800; 
  font-size: 1.1rem; 
  color: #92400e; 
}

.castle-separator {
  color: #b45309;
}

.castle-points-inline { 
  font-size: 0.9rem; 
  color: #b45309;
  font-weight: 600;
}

.level-progress-bar {
  height: 8px;
  background: rgba(146, 64, 14, 0.2);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.level-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #f59e0b);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.castle-bottom-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.points-to-next { 
  font-size: 0.75rem; 
  color: #b45309; 
}

.castle-view-link {
  font-size: 0.8rem;
  color: #92400e;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

.castle-view-link:hover {
  text-decoration: underline;
}

/* Control Bar */
.control-bar {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.control-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.control-item {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.control-item label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
}

.control-item select {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 180px;
}

.btn-end {
  padding: 10px 24px;
  background: var(--error);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  margin-left: auto;
}

.control-row-playing {
  justify-content: flex-end;
  padding: 0;
}

.control-bar.playing-mode {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 8px 0;
}

/* Game Area */
#game-area { 
  min-height: 350px; 
  display: flex; 
  justify-content: center; 
  align-items: flex-start;
  padding-top: 10px;
}

/* Mode Selection - Grid Cards */
.mode-selection { 
  text-align: center; 
  width: 100%; 
}

.mode-selection h2 { 
  font-family: 'Quicksand', sans-serif; 
  font-size: 1.3rem; 
  margin-bottom: 20px; 
}

.mode-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.mode-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.mode-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.mode-card:hover { 
  transform: translateY(-3px); 
  border-color: var(--primary); 
}

.mode-card:hover::before { transform: scaleX(1); }

.mode-icon { 
  font-size: 2rem; 
  margin-bottom: 6px;
}

.mode-icon img { 
  width: 36px; 
  height: 27px; 
  object-fit: cover; 
  border-radius: 4px; 
  box-shadow: 0 2px 4px rgba(0,0,0,0.2); 
}

.mode-title { 
  font-family: 'Quicksand', sans-serif; 
  font-size: 0.95rem; 
  font-weight: 700; 
  margin-bottom: 2px; 
}

.mode-desc { 
  color: var(--text-secondary); 
  font-size: 0.7rem; 
  margin-bottom: 6px; 
}

.mode-points {
  display: inline-block;
  background: linear-gradient(135deg, var(--gold), #f59e0b);
  color: #78350f;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
}

/* Question Card */
.question-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  max-width: 500px;
  width: 100%;
  position: relative;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: slideUp 0.4s ease;
}

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

.category-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.card-top-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.level-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.level-badge.level-Pre_A1 {
  background: #dcfce7;
  color: #166534;
}

.level-badge.level-A1 {
  background: #fef3c7;
  color: #92400e;
}

.level-badge.level-A2 {
  background: #fee2e2;
  color: #991b1b;
}

/* Sound Unlock Banner */
.sound-unlock-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  color: var(--text-primary);
  padding: 14px 18px;
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  border: 2px solid var(--warning);
  z-index: 1000;
  animation: slideUpBanner 0.4s ease;
  max-width: 90%;
  width: 360px;
}

.sound-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sound-banner-content .sound-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.sound-banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sound-banner-text strong {
  font-size: 0.95rem;
  color: var(--text-primary);
}

.sound-banner-text span {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.sound-banner-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}

@keyframes slideUpBanner {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.sound-unlock-banner.fade-out {
  animation: fadeOutBanner 0.3s ease forwards;
}

@keyframes fadeOutBanner {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to { opacity: 0; transform: translateX(-50%) translateY(20px); }
}

/* Backup buttons */
.backup-buttons {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.btn-export, .btn-import {
  flex: 1;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.btn-export {
  background: var(--success);
  color: white;
  border: none;
}

.btn-export:hover {
  background: #059669;
}

.btn-import {
  background: var(--primary);
  color: white;
  border: none;
  display: inline-block;
}

.btn-import:hover {
  background: var(--primary-dark);
}

.progress-indicator { 
  display: flex; 
  justify-content: center; 
  gap: 5px; 
  margin-top: 8px; 
  margin-bottom: 12px; 
}

.progress-dot { 
  width: 10px; 
  height: 10px; 
  border-radius: 50%; 
  background: var(--border); 
  transition: all 0.3s ease; 
}

.progress-dot.correct { background: var(--success); }
.progress-dot.wrong { background: var(--error); }
.progress-dot.current { background: var(--primary); transform: scale(1.3); }

.question-word { 
  font-family: 'Quicksand', sans-serif; 
  font-size: 1.8rem; 
  font-weight: 700; 
  text-align: center; 
  margin: 14px 0 10px; 
}

.question-prompt { 
  text-align: center; 
  color: var(--text-secondary); 
  margin-bottom: 16px; 
  font-size: 0.9rem; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  gap: 8px; 
  flex-wrap: wrap; 
}

.speaker-btn {
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: 50%;
  width: 40px; 
  height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.speaker-btn:hover { 
  background: var(--primary-light); 
  border-color: var(--primary); 
}

.speaker-btn.large {
  width: 70px;
  height: 70px;
  font-size: 2rem;
  margin: 10px auto 20px;
}

.answer-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1.1rem;
  text-align: center;
  transition: all 0.3s ease;
}

.answer-input:focus { 
  outline: none; 
  border-color: var(--primary); 
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15); 
  background: white; 
}

.btn-check {
  display: block;
  width: 100%;
  padding: 12px;
  margin-top: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

/* Choice buttons */
.choices { 
  display: flex; 
  flex-direction: column; 
  gap: 8px; 
}

.choice-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.choice-btn:hover:not(:disabled) { 
  border-color: var(--primary); 
  background: white; 
  transform: translateX(4px); 
}

.choice-btn:disabled { cursor: not-allowed; }
.choice-btn.correct { border-color: var(--success); background: var(--success-bg); color: #065f46; }
.choice-btn.wrong { border-color: var(--error); background: var(--error-bg); color: #991b1b; }

.choice-key { 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  width: 26px; 
  height: 26px; 
  background: var(--border); 
  border-radius: 6px; 
  font-weight: 700; 
  font-size: 0.8rem; 
  flex-shrink: 0; 
}

.choice-btn.correct .choice-key { background: var(--success); color: white; }
.choice-btn.wrong .choice-key { background: var(--error); color: white; }

/* Feedback */
.feedback { 
  margin-top: 14px; 
  text-align: center; 
  min-height: 30px; 
  opacity: 0; 
  transition: opacity 0.3s ease; 
}

.feedback.visible { opacity: 1; }
.feedback-correct { color: var(--success); font-size: 1.1rem; font-weight: 800; }
.feedback-wrong { color: var(--error); font-size: 0.95rem; font-weight: 600; }
.feedback-wrong strong { color: var(--text-primary); }

.spelling-reveal {
  background: var(--bg-input);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}

.level-up {
  background: linear-gradient(135deg, var(--gold), #f59e0b);
  color: #78350f;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-weight: 700;
  margin-top: 8px;
  animation: pulse 0.5s ease;
}

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

.session-progress { 
  display: flex; 
  justify-content: center; 
  gap: 16px; 
  margin-top: 16px; 
  padding-top: 12px; 
  border-top: 1px solid var(--border); 
}

.correct-count { color: var(--success); font-weight: 700; }
.wrong-count { color: var(--error); font-weight: 700; }
.points-count { color: var(--gold); font-weight: 700; }

/* Matching Game */
.matching-game {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  width: 100%;
  max-width: 550px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

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

.matching-header h3 { 
  font-family: 'Quicksand', sans-serif; 
  font-size: 1.1rem; 
}

.matching-progress { 
  background: var(--success-bg); 
  color: #065f46; 
  padding: 5px 10px; 
  border-radius: 10px; 
  font-weight: 700; 
  font-size: 0.8rem; 
}

.matching-columns { 
  display: grid; 
  grid-template-columns: 1fr 1fr; 
  gap: 12px; 
}

.matching-column { 
  display: flex; 
  flex-direction: column; 
  gap: 6px; 
}

.match-btn {
  padding: 10px 12px;
  background: white;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.match-btn:hover:not(:disabled) { border-color: var(--primary); background: var(--bg-card); }
.match-btn:hover:not(:disabled):not(.selected) { border-color: var(--primary); background: var(--bg-card); }
.match-btn.selected { border-color: var(--primary); background: var(--primary); color: white; font-weight: 700; }
.match-btn.selected:hover { background: var(--primary-dark); color: white; }
.match-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.match-btn.matched-success { 
  border-color: var(--success); 
  background: var(--success-bg); 
  color: #065f46;
  animation: matchSuccess 0.5s ease;
}

.match-btn.matched-error { 
  border-color: var(--error); 
  background: var(--error-bg); 
  color: #991b1b;
  animation: matchError 0.3s ease;
}

.match-btn.matched-hidden {
  visibility: hidden;
  pointer-events: none;
}

@keyframes matchSuccess {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); background: var(--success); color: white; }
  100% { transform: scale(0.8); opacity: 0; }
}

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

.last-matched-pair {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  background: linear-gradient(135deg, var(--success-bg), #d1fae5);
  border: 2px solid var(--success);
  border-radius: var(--radius);
  margin-top: 10px;
  flex-wrap: wrap;
}

.last-matched-label { font-size: 0.75rem; color: var(--text-secondary); }
.last-matched-pl { font-weight: 700; color: var(--text-primary); }
.last-matched-arrow { color: var(--success); }
.last-matched-en { font-weight: 700; color: var(--primary); }

.speaker-btn-small {
  background: white;
  border: 1px solid var(--success);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 0.85rem;
  cursor: pointer;
}

/* Session Summary */
.session-summary {
  text-align: center;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  max-width: 420px;
  width: 100%;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: slideUp 0.4s ease;
}

.session-summary h2 { 
  font-family: 'Quicksand', sans-serif; 
  font-size: 1.5rem; 
  margin-bottom: 4px; 
}

.summary-emoji { font-size: 3rem; margin-bottom: 10px; }
.summary-message { color: var(--text-secondary); margin-bottom: 20px; font-size: 0.95rem; }

.summary-stats { 
  display: grid; 
  grid-template-columns: repeat(2, 1fr); 
  gap: 10px; 
  margin-bottom: 20px; 
}

.summary-stat { 
  padding: 14px 10px; 
  background: var(--bg-input); 
  border-radius: var(--radius); 
  border: 1px solid var(--border); 
}

.summary-stat.highlight { 
  background: linear-gradient(135deg, #fef3c7, #fde68a); 
  border-color: var(--gold); 
}

.summary-stat .stat-value { font-size: 1.6rem; font-weight: 800; color: var(--primary); }
.summary-stat.highlight .stat-value { color: #92400e; }
.summary-stat .stat-label { font-size: 0.75rem; color: var(--text-secondary); font-weight: 600; }

.btn-primary { 
  padding: 12px 28px; 
  background: linear-gradient(135deg, var(--primary), var(--primary-dark)); 
  color: white; 
  border: none; 
  border-radius: var(--radius); 
  font-family: inherit; 
  font-size: 1rem; 
  font-weight: 700; 
  cursor: pointer; 
  width: 100%; 
}

/* Presentation Mode */
.presentation-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 35px 25px;
  max-width: 450px;
  width: 100%;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: slideUp 0.4s ease;
}

.presentation-word-en {
  font-family: 'Quicksand', sans-serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
}

.presentation-word-pl {
  font-size: 1.4rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.presentation-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
}

.presentation-timer {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.presentation-timer-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 3px;
  transition: width 0.1s linear;
}

.presentation-counter {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.presentation-speaker {
  font-size: 1.8rem;
  animation: pulse 1s ease infinite;
}

/* Listening Mode */
.listening-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  max-width: 500px;
  width: 100%;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: slideUp 0.4s ease;
}

.listening-prompt {
  color: var(--text-secondary);
  margin-bottom: 12px;
  font-size: 0.9rem;
}

/* Flash Effects */
body.flash-success { animation: flashSuccess 0.6s ease; }
body.flash-error { animation: flashError 0.6s ease; }

@keyframes flashSuccess {
  0% { background-color: var(--bg-main); }
  30% { background-color: rgba(16, 185, 129, 0.15); }
  100% { background-color: var(--bg-main); }
}

@keyframes flashError {
  0% { background-color: var(--bg-main); }
  30% { background-color: rgba(239, 68, 68, 0.15); }
  100% { background-color: var(--bg-main); }
}

/* Modals */
.castle-modal, .stats-modal, .settings-modal { 
  position: fixed; 
  top: 0; left: 0; right: 0; bottom: 0; 
  background: rgba(0, 0, 0, 0.6); 
  backdrop-filter: blur(4px); 
  display: flex; 
  justify-content: center; 
  align-items: center; 
  z-index: 1000; 
  padding: 12px; 
}

.castle-modal-content, .stats-modal-content, .settings-modal-content { 
  background: var(--bg-card); 
  border-radius: var(--radius-lg); 
  max-width: 550px; 
  width: 100%; 
  max-height: 90vh; 
  overflow-y: auto; 
  padding: 24px; 
  position: relative; 
}

/* Wider stats modal for desktop */
@media (min-width: 768px) {
  .stats-modal-content {
    max-width: 900px;
  }
}

.castle-modal-content { border: 2px solid var(--gold); }
.stats-modal-content, .settings-modal-content { border: 1px solid var(--border); }

.castle-modal-content h2, .stats-modal-content h2, .settings-modal-content h2 { 
  font-family: 'Quicksand', sans-serif; 
  font-size: 1.3rem; 
  margin-bottom: 16px; 
  text-align: center; 
}

.close-modal { 
  position: absolute; 
  top: 12px; right: 12px; 
  width: 32px; height: 32px; 
  background: var(--bg-input); 
  border: 1px solid var(--border); 
  border-radius: 50%; 
  color: var(--text-secondary); 
  font-size: 1.2rem; 
  cursor: pointer; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
}

/* Castle Modal */
.castle-image-wrapper { position: relative; margin-bottom: 16px; }
.castle-image-container { 
  position: relative; 
  width: 100%; 
  height: 350px; 
  overflow: hidden; 
  border-radius: var(--radius); 
  background: white; 
  touch-action: none; 
  cursor: default; 
  border: 1px solid var(--border); 
}
.castle-image { 
  width: 100%; 
  height: 100%; 
  object-fit: contain; 
  transition: transform 0.1s ease; 
  transform-origin: center center; 
  user-select: none; 
  pointer-events: none; 
}

.zoom-controls { 
  position: absolute; 
  bottom: 10px; right: 10px; 
  display: flex; 
  gap: 6px; 
  z-index: 10; 
}

.zoom-btn { 
  width: 34px; height: 34px; 
  border-radius: 50%; 
  border: none; 
  background: white; 
  box-shadow: 0 2px 8px rgba(0,0,0,0.2); 
  cursor: pointer; 
  font-size: 0.9rem; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
}

.castle-progress-info { text-align: center; margin-bottom: 16px; }
.progress-bar-container { height: 10px; background: var(--border); border-radius: 5px; overflow: hidden; margin-bottom: 6px; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--gold), #f59e0b); border-radius: 5px; }
.progress-text { color: var(--text-secondary); font-size: 0.85rem; }
.total-points-text { color: var(--gold); font-weight: 700; margin-top: 4px; }

.castle-levels-preview h3 { font-size: 0.95rem; margin-bottom: 10px; color: var(--text-secondary); }
.levels-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.level-tile { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 4px; font-size: 0.65rem; font-weight: 700; transition: all 0.2s ease; }
.level-tile.locked { background: var(--border); color: var(--text-muted); }
.level-tile.unlocked { background: var(--success-bg); color: #065f46; cursor: pointer; }
.level-tile.unlocked:hover { background: var(--success-light); transform: scale(1.1); }
.level-tile.current { background: linear-gradient(135deg, var(--gold), #f59e0b); color: #78350f; box-shadow: 0 0 8px var(--gold); }

/* Stats Modal */
.stats-tabs { 
  display: flex; 
  gap: 4px; 
  margin-bottom: 16px; 
  border-bottom: 1px solid var(--border); 
  padding-bottom: 8px; 
  overflow-x: auto; 
}

.stats-tab { 
  padding: 7px 12px; 
  background: transparent; 
  border: none; 
  border-radius: var(--radius-sm); 
  color: var(--text-secondary); 
  font-family: inherit; 
  font-size: 0.8rem; 
  font-weight: 600; 
  cursor: pointer; 
  white-space: nowrap; 
}

.stats-tab.active { background: var(--primary); color: white; }
.tab-content { display: none; }
.tab-content.active { display: block; }

.overview-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.overview-card { background: var(--bg-input); border-radius: var(--radius); padding: 14px; text-align: center; border: 1px solid var(--border); }
.overview-card.highlight { background: linear-gradient(135deg, #fef3c7, #fde68a); border-color: var(--gold); }
.overview-value { font-size: 1.4rem; font-weight: 800; color: var(--primary); }
.overview-card.highlight .overview-value { color: #92400e; }
.overview-label { color: var(--text-secondary); font-size: 0.75rem; margin-top: 2px; }

.categories-list { display: flex; flex-direction: column; gap: 8px; }
.category-stat-card { background: var(--bg-input); border-radius: var(--radius); padding: 12px; border: 1px solid var(--border); }
.category-name { font-weight: 700; margin-bottom: 6px; font-size: 0.9rem; }
.category-metrics { display: flex; gap: 16px; margin-bottom: 6px; }
.metric-value { font-size: 1rem; font-weight: 700; color: var(--primary); }
.metric-label { font-size: 0.65rem; color: var(--text-muted); }
.coverage-bar { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.coverage-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--secondary)); border-radius: 3px; }

/* Words Tab - Table View */
.words-tab-container { display: flex; flex-direction: column; gap: 12px; }

.words-filters { display: flex; flex-direction: column; gap: 8px; }
.filter-row { display: flex; gap: 8px; }
.words-search {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
}
.words-search:focus {
  outline: none;
  border-color: var(--primary);
}
.words-filter-select {
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: inherit;
  background: white;
  cursor: pointer;
  min-width: 140px;
}

.words-table-container {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.words-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.words-table th {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  padding: 10px 8px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.words-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.words-table tbody tr:hover {
  background: var(--bg-input);
}

.words-table .col-en { min-width: 100px; }
.words-table .col-pl { min-width: 120px; color: var(--text-secondary); }
.words-table .col-cat { min-width: 80px; font-size: 0.75rem; color: var(--text-muted); }
.words-table .col-correct { text-align: center; color: var(--success); font-weight: 600; }
.words-table .col-wrong { text-align: center; color: var(--error); font-weight: 600; }
.words-table .col-total { text-align: center; }
.words-table .col-accuracy { text-align: center; }
.words-table .col-status { text-align: center; }

.accuracy-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.8rem;
}
.accuracy-badge.good { background: var(--success-light); color: #065f46; }
.accuracy-badge.medium { background: var(--warning-light); color: #92400e; }
.accuracy-badge.bad { background: var(--error-light); color: #991b1b; }

.status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
}
.status-badge.mastered { background: #dcfce7; color: #166534; }
.status-badge.problematic { background: #fee2e2; color: #991b1b; }

.row-problematic { background: #fef2f2; }
.row-mastered { background: #f0fdf4; }

.no-results {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
}

.words-legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  padding-top: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.legend-item { display: flex; align-items: center; gap: 6px; }

/* Word List Modal (session summary) */
.word-list-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  padding: 20px;
}

.word-list-modal-content {
  background: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.word-list-summary {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
}

.correct-badge, .wrong-badge {
  padding: 6px 14px;
  border-radius: 16px;
  font-weight: 600;
  font-size: 0.9rem;
}
.correct-badge { background: #dcfce7; color: #166534; }
.wrong-badge { background: #fee2e2; color: #991b1b; }

.word-list-section {
  margin-bottom: 20px;
}

.word-list-section h3 {
  font-size: 1rem;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
}

.wrong-section h3 { color: #991b1b; border-color: #fca5a5; }
.correct-section h3 { color: #166534; border-color: #86efac; }

.word-list-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.word-list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border-left: 4px solid;
}

.word-list-row.wrong { border-color: var(--error); }
.word-list-row.correct { border-color: var(--success); }

.word-list-en {
  font-weight: 700;
  min-width: 100px;
}

.word-list-pl {
  flex: 1;
  color: var(--text-secondary);
}

.word-speak-btn {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.word-speak-btn:hover { opacity: 1; }

/* Summary actions */
.summary-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}

.btn-secondary {
  padding: 12px 24px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--bg-card);
  border-color: var(--primary);
}

.sessions-list { display: flex; flex-direction: column; gap: 6px; max-height: 350px; overflow-y: auto; }
.session-row { 
  display: flex; 
  align-items: center; 
  gap: 10px; 
  padding: 10px 12px; 
  background: var(--bg-input); 
  border-radius: var(--radius-sm); 
  border: 1px solid var(--border); 
  flex-wrap: wrap; 
}
.session-date { min-width: 70px; }
.date-day { font-weight: 700; font-size: 0.8rem; }
.date-time { font-size: 0.65rem; color: var(--text-muted); }
.session-mode { 
  background: var(--primary-light); 
  color: white;
  padding: 3px 8px; 
  border-radius: 6px; 
  font-size: 0.7rem; 
  font-weight: 600;
}
.session-category { 
  font-size: 0.7rem; 
  color: var(--text-secondary); 
  background: var(--border);
  padding: 3px 8px;
  border-radius: 6px;
}
.session-results { margin-left: auto; display: flex; gap: 8px; font-size: 0.8rem; align-items: center; }
.session-results .correct { color: var(--success); font-weight: 700; }
.session-results .wrong { color: var(--error); font-weight: 700; }
.session-results .accuracy { color: var(--text-secondary); font-size: 0.75rem; }
.session-results .points { color: var(--gold); font-weight: 700; }

.chart-container { background: var(--bg-input); border-radius: var(--radius); padding: 14px; border: 1px solid var(--border); }
.chart-wrapper { display: flex; position: relative; height: 120px; }
.chart-scale { width: 28px; position: relative; flex-shrink: 0; }
.scale-mark { position: absolute; left: 0; right: 0; display: flex; align-items: center; }
.scale-label { font-size: 0.6rem; color: var(--text-muted); width: 22px; text-align: right; }
.scale-line { flex: 1; height: 1px; background: var(--border); margin-left: 4px; opacity: 0.5; }
.chart-bars { display: flex; align-items: flex-end; justify-content: space-around; flex: 1; gap: 4px; padding-left: 6px; height: 100%; }
.chart-bar-wrapper { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; cursor: help; }
.chart-bar { width: 100%; max-width: 28px; display: flex; flex-direction: column; justify-content: flex-end; border-radius: 3px 3px 0 0; overflow: hidden; margin-top: auto; }
.bar-correct { background: var(--success); }
.bar-wrong { background: var(--error); }
.chart-label { font-size: 0.55rem; color: var(--text-muted); margin-top: 3px; }
.chart-legend { display: flex; justify-content: center; gap: 14px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 0.7rem; color: var(--text-secondary); }
.legend-color { width: 10px; height: 10px; border-radius: 2px; }
.legend-color.correct { background: var(--success); }
.legend-color.wrong { background: var(--error); }

.reset-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); text-align: center; }
.btn-reset { padding: 8px 16px; background: transparent; color: var(--error); border: 2px solid var(--error); border-radius: var(--radius-sm); font-family: inherit; font-size: 0.8rem; font-weight: 700; cursor: pointer; }
.btn-reset:hover { background: var(--error); color: white; }
.no-data { text-align: center; color: var(--text-muted); padding: 20px; font-style: italic; }
h3 { font-size: 0.95rem; margin: 16px 0 10px; color: var(--text-secondary); }

/* Settings Modal */
.settings-section { margin-bottom: 20px; }
.settings-section h3 { margin-top: 0; }
.custom-words-textarea { width: 100%; min-height: 130px; padding: 10px; border: 2px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; font-size: 0.85rem; resize: vertical; }
.custom-words-textarea:focus { outline: none; border-color: var(--primary); }
.custom-words-help { font-size: 0.75rem; color: var(--text-secondary); margin-top: 6px; }
.custom-words-example { background: var(--bg-input); padding: 6px 10px; border-radius: var(--radius-sm); font-family: monospace; font-size: 0.75rem; margin-top: 6px; }
.btn-save { padding: 10px 20px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; border: none; border-radius: var(--radius); font-family: inherit; font-size: 0.95rem; font-weight: 700; cursor: pointer; width: 100%; }
.custom-words-count { font-size: 0.8rem; color: var(--text-secondary); margin-top: 6px; }

/* Fullscreen Castle */
.fullscreen-castle-modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.95); display: flex; justify-content: center; align-items: center; z-index: 2000; }
.fullscreen-castle-content { width: 100%; height: 100%; display: flex; flex-direction: column; position: relative; }
.close-fullscreen { position: absolute; top: 16px; right: 16px; width: 40px; height: 40px; background: white; border: none; border-radius: 50%; font-size: 1.3rem; cursor: pointer; z-index: 10; display: flex; align-items: center; justify-content: center; }
.fullscreen-image-container { flex: 1; overflow: hidden; cursor: grab; display: flex; justify-content: center; align-items: center; }
.fullscreen-castle-image { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform 0.1s ease; user-select: none; pointer-events: none; }
.fullscreen-controls { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; background: white; padding: 8px 16px; border-radius: 24px; box-shadow: 0 4px 20px rgba(0,0,0,0.3); }
.zoom-level { font-weight: 700; min-width: 45px; text-align: center; font-size: 0.9rem; }

/* Level Up Notification */
.level-up-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 3000;
  animation: fadeIn 0.3s ease;
}

.level-up-overlay.fade-out {
  animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.level-up-content {
  text-align: center;
  padding: 40px 50px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-radius: var(--radius-lg);
  border: 4px solid var(--gold);
  box-shadow: 0 0 60px rgba(251, 191, 36, 0.5), 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: levelUpBounce 0.6s ease;
}

@keyframes levelUpBounce {
  0% { transform: scale(0.3) rotate(-10deg); opacity: 0; }
  50% { transform: scale(1.1) rotate(3deg); }
  70% { transform: scale(0.95) rotate(-2deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.level-up-castle {
  font-size: 4rem;
  animation: castleFloat 2s ease-in-out infinite;
}

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

.level-up-stars {
  font-size: 1.5rem;
  margin: 10px 0;
  animation: starsSparkle 1s ease-in-out infinite;
}

@keyframes starsSparkle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.2); }
}

.level-up-title {
  font-family: 'Quicksand', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: #92400e;
  margin: 10px 0 5px;
}

.level-up-number {
  font-size: 4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.level-up-message {
  color: #b45309;
  font-size: 1rem;
  margin: 15px 0 20px;
}

.level-up-btn {
  padding: 12px 40px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.level-up-btn:hover {
  transform: scale(1.05);
}

/* Mobile Responsive */
@media (max-width: 600px) {
  .container { padding: 8px; }
  
  .header-content { 
    flex-direction: row; 
    gap: 8px; 
    flex-wrap: nowrap;
  }
  .header-actions {
    gap: 4px;
  }
  .btn-header {
    padding: 6px 10px;
    font-size: 0.9rem;
  }
  .tagline { font-size: 0.65rem; }
  .logo-img { width: 40px; height: 40px; }
  .logo { font-size: 1.2rem; }
  .logo-text { max-width: 140px; }
  
  .castle-box { padding: 12px 14px; }
  
  .control-bar { padding: 10px 12px; }
  .control-row { flex-direction: row; align-items: center; }
  .control-item { flex-direction: row; align-items: center; gap: 6px; flex: 1; }
  .control-item label { font-size: 0.8rem; }
  .control-item select { min-width: unset; flex: 1; font-size: 0.85rem; padding: 8px 10px; }
  
  .mode-cards { grid-template-columns: repeat(2, 1fr); }
  
  .question-card, .listening-card, .presentation-card, .matching-game { padding: 18px 14px; }
  .question-word { font-size: 1.5rem; }
  .presentation-word-en { font-size: 1.8rem; }
  
  .matching-columns { gap: 8px; }
  .match-btn { padding: 8px 10px; font-size: 0.85rem; }
  
  .castle-image-container { height: 280px; }
  .levels-grid { grid-template-columns: repeat(6, 1fr); }
  
  .summary-stat .stat-value { font-size: 1.4rem; }
}

@media (max-width: 380px) {
  .mode-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .levels-grid { grid-template-columns: repeat(5, 1fr); }
  .logo-text { display: none; }
  .logo-link::after {
    content: 'VocabCastle';
    font-family: 'Quicksand', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }
}

@media (hover: none) {
  .mode-card:hover, .choice-btn:hover:not(:disabled), .match-btn:hover:not(:disabled) { transform: none; }
  .mode-card:active { transform: scale(0.98); }
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg-input); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Mode stats cells */
.col-typing, .col-choice, .col-listen, .col-match {
  text-align: center;
  min-width: 40px;
}

.mode-zero {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.mode-good {
  color: #166534;
  font-weight: 600;
}

.mode-medium {
  color: #92400e;
  font-weight: 600;
}

.mode-bad {
  color: #991b1b;
  font-weight: 600;
}

/* Settings select */
.settings-select {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  font-size: 1rem;
  font-family: inherit;
  background: white;
  cursor: pointer;
}

.settings-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Danger zone */
.danger-zone {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px solid #fca5a5;
  background: #fef2f2;
  border-radius: var(--radius-sm);
  padding: 16px;
}

.danger-zone h3 {
  color: #991b1b;
}

.btn-reset-danger {
  width: 100%;
  padding: 12px;
  background: white;
  color: #991b1b;
  border: 2px solid #fca5a5;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-reset-danger:hover {
  background: #fee2e2;
  border-color: #f87171;
}
