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

:root {
  --bg: #f0ece4;
  --surface: #e8e2d8;
  --surface-hover: #ddd6ca;
  --primary: #6b4c3b;
  --primary-hover: #573d2f;
  --accent: #8c7a6b;
  --text: #3b2a1a;
  --text-muted: #8c7a6b;
  --success: #5a7a4a;
  --error: #a04030;
  --border: #d4cbbf;
  --radius: 8px;
}

html, body {
  font-family: 'Lora', Georgia, 'Times New Roman', serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

#root {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
}

h1 {
  font-size: 2rem;
  margin-bottom: 16px;
  text-align: center;
  color: var(--text);
  letter-spacing: 0.5px;
}

h2 {
  font-size: 1.5rem;
  margin-bottom: 12px;
}

button {
  font-family: inherit;
  font-size: 1rem;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: #f5f0eb;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

button:active {
  background: var(--primary-hover);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button.secondary {
  background: var(--accent);
}

button.secondary:active {
  background: var(--surface-hover);
}

button.danger {
  background: var(--error);
  font-size: 0.85rem;
  padding: 6px 12px;
}

button.icon-btn {
  background: none;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

button.icon-btn:active {
  background: var(--surface-hover);
  color: var(--text);
}

button.icon-btn.danger {
  color: var(--error);
  background: none;
}

button.icon-btn.danger:active {
  background: var(--surface-hover);
}

button.icon-btn-labeled {
  background: none;
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: 8px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  line-height: 1;
}

button.icon-btn-labeled:active {
  background: var(--surface-hover);
  color: var(--text);
}

button.icon-btn-labeled.danger {
  color: var(--error);
}

button.icon-btn-labeled.danger:active {
  background: var(--surface-hover);
}

input[type="text"] {
  font-family: inherit;
  font-size: 1rem;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

input[type="text"]::placeholder {
  color: var(--text-muted);
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}

a {
  text-decoration: none;
  color: inherit;
}

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

.stack > * {
  animation: fadeIn 0.15s ease-out;
}

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

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.back-link {
  display: inline-block;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.back-link:active {
  color: var(--text);
}

.fretboard-container {
  display: flex;
  justify-content: center;
  padding: 8px 0;
}

.feedback-correct {
  color: var(--success);
  font-size: 1.5rem;
  font-weight: bold;
  text-align: center;
  padding: 16px;
}

.feedback-wrong {
  color: var(--error);
  font-size: 1.2rem;
  text-align: center;
  padding: 16px;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 8px 16px;
  border-radius: 20px;
  background: var(--accent);
  color: #f5f0eb;
  border: 2px solid transparent;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.15s, border-color 0.15s;
}

.chip:active {
  background: var(--surface-hover);
}

.chip.selected {
  border-color: var(--primary);
  background: var(--primary);
}

.chip:disabled {
  opacity: 0.4;
  cursor: default;
}

.quiz-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.quiz-deck-name {
  flex: 1;
  font-size: 0.95rem;
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mode-cycle-btn {
  padding: 6px 14px;
  font-size: 0.9rem;
  border-radius: 20px;
  background: var(--accent);
  border: 2px solid var(--primary);
  flex-shrink: 0;
}

.mode-cycle-btn:active {
  background: var(--primary);
}

.try-again-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(59, 42, 26, 0.9);
  color: #f5f0eb;
  font-size: 1.5rem;
  font-weight: bold;
  padding: 16px 32px;
  border-radius: 12px;
  z-index: 100;
  pointer-events: none;
  animation: overlayFade 0.5s ease-out forwards;
}

@keyframes overlayFade {
  0% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

.chord-thumbnail {
  display: inline-block;
}

.search-input {
  margin-bottom: 12px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
}

.checkbox-row.checked {
  border-color: var(--primary);
}

.checkbox-indicator {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.8rem;
}

.checkbox-row.checked .checkbox-indicator {
  background: var(--primary);
  border-color: var(--primary);
}
