* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #eef2f7;
  color: #111827;
  -webkit-text-size-adjust: 100%;
}

.app {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: #ffffff;
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}

.header {
  text-align: center;
  margin-bottom: 18px;
}

.header h1 {
  font-size: 1.65rem;
  margin: 0 0 8px;
}

.header p {
  margin: 0;
  color: #6b7280;
  font-size: 0.95rem;
}

.score-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.score-box div {
  background: #f9fafb;
  border-radius: 16px;
  padding: 14px;
  text-align: center;
  border: 1px solid #e5e7eb;
}

.score-label {
  display: block;
  color: #6b7280;
  font-size: 0.8rem;
  margin-bottom: 4px;
}

.score-box span:last-child {
  font-size: 1.4rem;
  font-weight: 800;
}

.prompt-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 18px;
  padding: 20px;
  text-align: center;
  margin: 20px 0;
}

.prompt-box p {
  margin: 0 0 8px;
  color: #1d4ed8;
  font-weight: 700;
}

.prompt-box h2 {
  margin: 0;
  font-size: 1.7rem;
  word-break: break-word;
}

label {
  display: block;
  font-weight: 700;
  margin-top: 16px;
  margin-bottom: 6px;
}

input,
select {
  width: 100%;
  min-height: 52px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid #d1d5db;
  font-size: 16px;
  background-color: #ffffff;
  color: #111827;
  cursor: pointer;
  position: relative;
  z-index: 2;
  touch-action: manipulation;
}

select {
  appearance: auto;
  -webkit-appearance: menulist;
}

input:focus,
select:focus {
  outline: 3px solid #bfdbfe;
  border-color: #2563eb;
}

button {
  width: 100%;
  min-height: 50px;
  margin-top: 18px;
  padding: 14px;
  border: none;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  background: #2563eb;
  color: white;
  touch-action: manipulation;
}

.secondary-button {
  background: #e5e7eb;
  color: #111827;
}

.small-button {
  min-height: 42px;
  margin-top: 0;
  margin-bottom: 18px;
  font-size: 0.9rem;
}

.feedback {
  margin-top: 18px;
  padding: 14px;
  border-radius: 14px;
  font-size: 0.95rem;
  line-height: 1.4;
  display: none;
}

.feedback.correct {
  display: block;
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
}

.feedback.incorrect {
  display: block;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}

.explanation-box {
  margin-top: 8px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.45);
  text-align: left;
  font-weight: 600;
}

.match-status {
  margin: 16px 0;
  padding: 12px;
  border-radius: 14px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  text-align: center;
  font-weight: 800;
}

.matched-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.matched-item {
  padding: 12px;
  border-radius: 14px;
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
  font-weight: 800;
  text-align: center;
}

.match-board,
.pronunciation-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin-top: 18px;
}

.match-board h2,
.pronunciation-board h2 {
  font-size: 0.9rem;
  margin: 0 0 10px;
  text-align: center;
}

.match-column,
.pronunciation-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.match-card,
.pronunciation-card {
  min-height: 42px;
  padding: 10px;
  border-radius: 14px;
  background: #ffffff;
  border: 2px solid #d1d5db;
  color: #111827;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  word-break: break-word;
  touch-action: manipulation;
}

.match-card.selected,
.pronunciation-card.active {
  border-color: #2563eb;
  background: #eff6ff;
}

.match-card.hidden {
  display: none;
}

@media (min-width: 768px) {
  .app {
    padding-top: 48px;
  }

  .card {
    padding: 32px;
  }

  .header h1 {
    font-size: 2rem;
  }

  .prompt-box h2 {
    font-size: 2rem;
  }

  .match-board,
  .pronunciation-board {
    gap: 20px;
  }

  .match-board h2,
  .pronunciation-board h2 {
    font-size: 1rem;
  }

  .match-card,
  .pronunciation-card {
    min-height: 48px;
    padding: 12px;
    font-size: 0.95rem;
  }
}

body.dark {
  background: #020617;
  color: #e5e7eb;
}

body.dark .card {
  background: #0f172a;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

body.dark .header p,
body.dark .score-label {
  color: #94a3b8;
}

body.dark .score-box div,
body.dark .match-status {
  background: #111827;
  border-color: #334155;
}

body.dark .prompt-box {
  background: #1e293b;
  border-color: #334155;
}

body.dark .prompt-box p {
  color: #93c5fd;
}

body.dark input,
body.dark select {
  background-color: #111827;
  color: #e5e7eb;
  border-color: #475569;
}

body.dark .secondary-button {
  background: #334155;
  color: #e5e7eb;
}

body.dark .match-card,
body.dark .pronunciation-card {
  background: #111827;
  color: #e5e7eb;
  border-color: #475569;
}

body.dark .match-card.selected,
body.dark .pronunciation-card.active {
  border-color: #60a5fa;
  background: #1e3a8a;
}

body.dark .matched-item {
  background: #064e3b;
  border-color: #10b981;
  color: #d1fae5;
}

body.dark .feedback.correct {
  background: #064e3b;
  border-color: #10b981;
  color: #d1fae5;
}

body.dark .feedback.incorrect {
  background: #7f1d1d;
  border-color: #ef4444;
  color: #fee2e2;
}

body.dark .explanation-box {
  background: rgba(15, 23, 42, 0.45);
}

.floating-theme-button {
  position: fixed;
  right: 18px;
  bottom: 18px;

  width: 58px;
  height: 58px;

  min-width: 58px;
  min-height: 58px;

  margin: 0;
  padding: 0;

  border-radius: 999px;
  border: none;

  display: flex;
  align-items: center;
  justify-content: center;

  background: #2563eb;
  color: #ffffff;

  font-size: 1.6rem;
  line-height: 1;

  cursor: pointer;

  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.28);

  z-index: 9999;

  touch-action: manipulation;

  -webkit-tap-highlight-color: transparent;
}

.floating-theme-button:hover {
  transform: translateY(-1px);
}

.floating-theme-button:active {
  transform: scale(0.96);
}

body.dark .floating-theme-button {
  background: #facc15;
  color: #111827;
}

.mastery-indicator {
  margin: 14px auto 0;
  padding: 10px 14px;
  border-radius: 999px;
  text-align: center;
  font-weight: 900;
  font-size: 0.95rem;
  width: fit-content;
  max-width: 100%;
  border: 1px solid transparent;
}

.mastery-new {
  background: #eef2ff;
  color: #3730a3;
  border-color: #c7d2fe;
}

.mastery-weak {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

.mastery-review {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

.mastery-improving {
  background: #e0f2fe;
  color: #075985;
  border-color: #7dd3fc;
}

.mastery-strong {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

.mastery-mastered {
  background: #f3e8ff;
  color: #6b21a8;
  border-color: #d8b4fe;
}

body.dark .mastery-new {
  background: #312e81;
  color: #e0e7ff;
  border-color: #6366f1;
}

body.dark .mastery-weak {
  background: #7f1d1d;
  color: #fee2e2;
  border-color: #ef4444;
}

body.dark .mastery-review {
  background: #78350f;
  color: #fef3c7;
  border-color: #f59e0b;
}

body.dark .mastery-improving {
  background: #0c4a6e;
  color: #e0f2fe;
  border-color: #38bdf8;
}

body.dark .mastery-strong {
  background: #064e3b;
  color: #d1fae5;
  border-color: #10b981;
}

body.dark .mastery-mastered {
  background: #581c87;
  color: #f3e8ff;
  border-color: #a855f7;
}

.dashboard-section {
  margin-top: 22px;
}

.dashboard-section h2 {
  font-size: 1.1rem;
  margin: 0 0 12px;
  text-align: center;
}

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

.dashboard-stat-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 14px;
  text-align: center;
}

.dashboard-stat-value {
  font-size: 1.45rem;
  font-weight: 900;
  color: #2563eb;
}

.dashboard-stat-label {
  margin-top: 4px;
  font-size: 0.8rem;
  font-weight: 800;
  color: #6b7280;
}

.dashboard-stat-detail {
  margin-top: 4px;
  font-size: 0.75rem;
  color: #6b7280;
}

.dashboard-game-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dashboard-game-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  padding: 14px;
}

.dashboard-game-card h2 {
  margin-bottom: 12px;
}

.dashboard-mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dashboard-mini-grid .dashboard-stat-card {
  padding: 12px;
}

.dashboard-mini-grid .dashboard-stat-value {
  font-size: 1.2rem;
}

.dashboard-med-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dashboard-med-row {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 12px;
}

.dashboard-med-title {
  font-weight: 900;
  color: #111827;
}

.dashboard-med-detail {
  margin-top: 4px;
  font-size: 0.85rem;
  color: #6b7280;
  font-weight: 700;
}

.dashboard-empty {
  padding: 14px;
  border-radius: 14px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  text-align: center;
  color: #6b7280;
  font-weight: 800;
}

body.dark .dashboard-stat-card,
body.dark .dashboard-game-card,
body.dark .dashboard-empty {
  background: #111827;
  border-color: #334155;
}

body.dark .dashboard-stat-value {
  color: #93c5fd;
}

body.dark .dashboard-stat-label,
body.dark .dashboard-stat-detail,
body.dark .dashboard-med-detail,
body.dark .dashboard-empty {
  color: #94a3b8;
}

body.dark .dashboard-med-row {
  background: #111827;
  border-color: #334155;
}

body.dark .dashboard-med-title {
  color: #e5e7eb;
}

#splashScreen {
  position: fixed;
  inset: 0;
  z-index: 99999;

  min-height: 100vh;
  width: 100vw;

  display: flex;
  align-items: center;
  justify-content: center;

  background: linear-gradient(135deg, #2563eb, #1d4ed8, #1e40af);

  opacity: 1;
  visibility: visible;
  pointer-events: auto;

  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#splashScreen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-content {
  text-align: center;
  padding: 24px;
}

.splash-logo {
  width: 120px;
  height: 120px;
  max-width: 120px;
  max-height: 120px;
  object-fit: contain;
  border-radius: 28px;
  background: white;
  padding: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.splash-title {
  margin-top: 22px;
  margin-bottom: 8px;
  color: white;
  font-size: 2rem;
  font-weight: 900;
}

.splash-subtitle {
  color: rgba(255, 255, 255, 0.9);
  font-size: 1rem;
  font-weight: 600;
}

.splash-loader {
  width: 44px;
  height: 44px;
  margin: 28px auto 0;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: white;
  animation: splashSpin 1s linear infinite;
}

@keyframes splashSpin {
  to {
    transform: rotate(360deg);
  }
}
