:root {
  --accent: #2e9b4e;
  --accent-dark: #248a42;
  --accent-soft: rgba(46, 155, 78, 0.12);
  --surface: #ffffff;
  --bg: #eef1f5;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --border: #d1d5db;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.07);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}

.screen {
  min-height: 100vh;
}

.screen.hidden {
  display: none;
}

.loader {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
}

.loader-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 16px 12px 24px;
  padding: 22px 18px;
}

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

.form-header-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 8px;
}

.intro-card h1 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 6px;
}

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

.meta-form {
  margin-bottom: 8px;
}

.form-field {
  margin-bottom: 16px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 7px;
  font-size: 0.88rem;
  color: #374151;
}

.label-optional {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.input-interactive,
.form-field select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  background: #fafbfc;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.input-interactive:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-date,
.input-time {
  min-height: 48px;
  cursor: pointer;
}

.datetime-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 10px;
}

.field-hint {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.field-hint-success {
  color: var(--accent-dark);
  font-weight: 500;
}

.field-hint.hidden {
  display: none;
}

.input-action-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.input-action-row .input-interactive {
  flex: 1;
  min-width: 0;
}

.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s, background 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

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

.btn-pulse {
  margin-top: 8px;
  box-shadow: 0 4px 14px rgba(46, 155, 78, 0.35);
}

.btn-save-card {
  width: auto;
  flex-shrink: 0;
  padding: 0 16px;
  font-size: 0.88rem;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1.5px solid var(--accent);
  white-space: nowrap;
}

.btn-save-card.saved-flash {
  background: var(--accent);
  color: #fff;
}

.btn-finish {
  background: var(--accent);
  color: #fff;
  margin: 0;
}

.btn-clear {
  background: #fff;
  color: #c62828;
  border: 1px solid #ef9a9a;
  width: auto;
  padding: 8px 14px;
  font-size: 0.85rem;
  margin-top: 10px;
}

.app-header {
  text-align: center;
  padding: 16px;
  font-weight: 700;
  font-size: 1.05rem;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.timer-bar {
  text-align: center;
  padding: 10px;
  background: #fff8e1;
  font-size: 0.9rem;
  font-weight: 600;
  color: #b45309;
}

.timer-bar.hidden {
  display: none;
}

#questions-container {
  padding: 8px 12px 100px;
}

.question-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  padding: 16px;
  margin-bottom: 14px;
  animation: fadeIn 0.25s ease;
}

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

.question-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.question-card h2 {
  font-size: 1rem;
  margin-bottom: 0;
}

.score-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.score-input {
  width: 64px;
  padding: 6px 8px;
  text-align: center;
}

.mcq-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.mcq-btn {
  flex: 1;
  min-width: 44px;
  max-width: 56px;
  height: 44px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #f9fafb;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  color: #333;
  transition: all 0.15s;
}

.mcq-btn:active {
  transform: scale(0.95);
}

.mcq-btn.selected {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(46, 155, 78, 0.35);
}

.math-wrap {
  border: 2px solid #333;
  border-radius: 10px;
  padding: 4px 8px;
  min-height: 48px;
  background: #fff;
  transition: opacity 0.2s, background 0.2s, border-color 0.2s;
}

.math-wrap-locked {
  opacity: 0.5;
  pointer-events: none;
  background: #f3f4f6;
  border-color: #d1d5db;
}

.math-wrap math-field {
  width: 100%;
  font-size: 1.1rem;
}

.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
}

.error-text {
  color: #c62828;
  text-align: center;
}
