* {
  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;
}

.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;
}

.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;
}
