*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #f0f4ff;
  color: #111827;
  display: flex;
  padding-top: 35px;
  align-items: stretch;
  justify-content: center;
}

@media screen and (min-width: 480px) {
  body {
    padding-top: 0;
  }
}

.app {
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  /* padding: 16px; */
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media screen and (min-width: 480px) {
  .app {
    padding: 16px;
  }
}

.app-header {
  font-size: 1.2rem;
  font-weight: 600;
  background: #1973bd;
  color: #ffffff;
  text-align: center;
  padding: 16px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.15);
}

.screen {
  display: none;
  width: 100%;
  flex: 1;
}

.screen.active {
  display: flex;
  width: 100%;
}

.card {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.15);
  padding: 24px 20px 20px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.quiz-card {
  min-height: 75vh;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
}

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.header-title {
  flex: 1;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  color: #111827;
}

.header-btn {
  border: none;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 500;
  color: #4f46e5;
  padding: 4px 4px;
  cursor: pointer;
}

.header-btn-left {
  text-align: left;
}

.header-btn-right {
  text-align: right;
}

.title {
  margin: 0 0 8px;
  font-size: 1.6rem;
  font-weight: 700;
  color: #111827;
  text-align: center;
}

.subtitle {
  margin: 0;
  font-size: 0.95rem;
  color: #6b7280;
  text-align: center;
}

.session-section {
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px solid #e5e7eb;
}

.session-section-title {
  margin: 0 0 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #4b5563;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.08s ease,
    box-shadow 0.15s ease;
}

.session-item:hover {
  background: #eef2ff;
  box-shadow: 0 8px 18px rgba(148, 163, 184, 0.35);
  transform: translateY(-1px);
}

.session-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.session-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.session-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #111827;
}

.session-status {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e0e7ff;
  color: #3730a3;
}

.session-meta {
  font-size: 0.8rem;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-delete-btn {
  border: none;
  background: transparent;
  color: #9ca3af;
  font-size: 1.1rem;
  padding: 4px 4px 4px 8px;
  cursor: pointer;
  flex-shrink: 0;
}

.session-delete-btn:hover {
  color: #ef4444;
}

.mode-selector {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 14px;
}

.mode-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 12px;
  border-radius: 14px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  color: #111827;
  text-align: center;
  transition: background-color 0.15s ease, transform 0.08s ease,
    box-shadow 0.15s ease, border-color 0.15s ease;
}

.mode-option:hover {
  background: #e0e7ff;
  border-color: #4f46e5;
  box-shadow: 0 10px 20px rgba(129, 140, 248, 0.45);
  transform: translateY(-1px);
}

.mode-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-option span {
  pointer-events: none;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.18s ease, transform 0.12s ease,
    box-shadow 0.18s ease, opacity 0.18s ease;
}

.btn-primary {
  background: #4f46e5;
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(79, 70, 229, 0.35);
}

.btn-primary:hover:not(:disabled) {
  background: #4338ca;
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(79, 70, 229, 0.4);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 6px 12px rgba(79, 70, 229, 0.35);
}

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

.btn-secondary:hover:not(:disabled) {
  background: #d1d5db;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
  box-shadow: none;
}

.btn-next {
  margin-top: auto;
}

.progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.score-summary {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.8rem;
  color: #4b5563;
  flex-wrap: wrap;
}

.score-pill {
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2ff;
  white-space: nowrap;
}

.score-correct {
  background: #d1fae5;
  color: #065f46;
}

.score-wrong {
  background: #fee2e2;
  color: #b91c1c;
}

.score-remaining {
  background: #e5e7eb;
  color: #374151;
}

#progress-bar {
  width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

#progress-fill {
  width: 0%;
  height: 100%;
  background: #4f46e5;
  border-radius: inherit;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.9rem;
  color: #4b5563;
}

.question-wrapper {
  margin-top: 12px;
}

.question-text {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: #111827;
}

.options-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.option-btn {
  width: 100%;
  text-align: left;
  background: #f9fafb;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  padding: 12px 14px;
  font-size: 0.98rem;
  font-weight: 500;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background-color 0.18s ease, transform 0.12s ease,
    box-shadow 0.18s ease, border-color 0.18s ease;
}

.option-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #e0e7ff;
  color: #3730a3;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.option-text {
  flex: 1;
}

.option-btn:hover:not(.disabled) {
  background: #eef2ff;
  border-color: #c7d2fe;
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(148, 163, 184, 0.45);
}

.option-btn.disabled {
  cursor: default;
  opacity: 0.9;
  box-shadow: none;
  transform: none;
}

.option-btn.correct {
  background: #d1fae5;
  border-color: #34d399;
}

.option-btn.wrong {
  background: #fee2e2;
  border-color: #f87171;
}

.result-card {
  align-items: center;
  text-align: center;
  gap: 16px;
}

.result-emoji {
  font-size: 3rem;
}

.result-score {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
  color: #111827;
}

.result-message {
  margin: 0 0 4px;
  font-size: 1rem;
  color: #4b5563;
}

@media (max-width: 400px) {
  .card {
    padding: 18px 16px 16px;
  }

  .title {
    font-size: 1.4rem;
  }

  .question-text {
    font-size: 1rem;
  }

  .btn {
    padding: 10px 16px;
    font-size: 0.95rem;
  }
}

