:root {
  color-scheme: light;
  /* Base tone (from tokens.css) */
  --bg: #FAF4EC;
  --card: #FFFFFF;
  --border: #EDE2D4;
  --ink: #3D3229;
  --text-2: #6B5F51;
  --muted: #8C7F70;
  --error: #C0392B;
  --accent: #D9704C;
  --accent-hover: #C25B39;
  --accent-tint: #F8E4DA;
  --accent-line: #E8C9BB;
  --success: #2E9E54;
  --success-tint: #E3F3E8;
  --warn: #F5A623;
  --warn-text: #96650A;
  --warn-tint: #FCF0DA;
  --shadow-card: 0 2px 10px rgba(60,40,20,0.06);
  --focus-ring: 0 0 0 3px rgba(217,112,76,0.15);
  --radius-card: 20px;
  --radius-pill: 999px;
  --radius-icon: 14px;
  --font: "Nunito", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  padding: 40px 20px;
}

header,
main {
  max-width: 680px;
  margin: 0 auto;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.app-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-icon);
  flex-shrink: 0;
}

.app-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
}

.app-subtitle {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.section-title {
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 800;
}

.map-card {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 22px;
  box-shadow: var(--shadow-card);
}

.add-section {
  margin-bottom: 24px;
}

.list-section {
  margin-bottom: 24px;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 8px;
}

.map-input,
textarea {
  width: 100%;
  font-family: var(--font);
  font-size: 16px;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
}

textarea {
  resize: vertical;
}

.map-input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.error-msg {
  color: var(--error);
  font-size: 13px;
  margin: 8px 0 0;
}

.btn-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.primary-btn,
.secondary-btn {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 800;
  border-radius: var(--radius-pill);
  padding: 14px 18px;
  cursor: pointer;
  width: 100%;
}

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

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

.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.secondary-btn {
  background: var(--card);
  color: var(--accent-hover);
  border: 1.5px solid var(--accent-line);
}

.secondary-btn:hover:not(:disabled) {
  background: var(--accent-tint);
}

.secondary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.primary-btn:focus-visible,
.secondary-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.form-group {
  margin-top: 14px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 8px;
}

.fallback-block {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1.5px dashed var(--border);
}

.fallback-message {
  margin: 0;
  font-size: 14px;
  color: var(--text-2);
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.toolbar .map-input {
  flex: 1;
}

.toolbar .secondary-btn {
  width: auto;
  white-space: nowrap;
}

.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 480px) {
  .card-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

.card-cell {
  position: relative;
}

.flip-tile {
  perspective: 900px;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  width: 100%;
  min-height: 140px;
  cursor: pointer;
  font-family: var(--font);
  text-align: left;
  display: block;
}

.flip-inner {
  position: relative;
  display: block;
  width: 100%;
  min-height: 140px;
  transform-style: preserve-3d;
  transition: transform 0.45s;
}

.flip-tile.is-flipped .flip-inner {
  transform: rotateY(180deg);
}

.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 18px;
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.face-front {
  position: relative;
}

.face-back {
  transform: rotateY(180deg);
}

.tile-phrase {
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
  word-break: break-word;
}

.tile-hint {
  font-size: 12px;
  color: var(--muted);
}

.tile-pos {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-hover);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tile-def {
  font-size: 14px;
  color: var(--ink);
  line-height: 1.5;
}

.tile-ex {
  font-size: 13px;
  color: var(--text-2);
  font-style: italic;
  line-height: 1.4;
}

.flip-tile:focus-visible {
  outline: none;
}

.flip-tile:focus-visible .face {
  box-shadow: var(--focus-ring);
}

@media (prefers-reduced-motion: reduce) {
  .flip-inner {
    transition: none;
  }
}

.tile-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  color: var(--error);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card);
}

.tile-delete:hover {
  background: #fff;
}

.tile-delete:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.empty-state {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 30px 16px;
}

.empty-state p {
  margin: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 480px) {
  .btn-row {
    flex-direction: row;
  }

  .primary-btn,
  .secondary-btn {
    width: auto;
  }

  .add-section .btn-row .primary-btn {
    flex: 1;
  }
}

.quiz-section {
  margin-bottom: 24px;
}

.quiz-help {
  font-size: 14px;
  color: var(--text-2);
  margin: 0;
}

.quiz-progress {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  margin: 0;
}

.quiz-card {
  margin: 14px 0;
  padding: 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-card);
  text-align: center;
}

.quiz-phrase {
  font-size: 20px;
  font-weight: 800;
  margin: 0;
  word-break: break-word;
}

.quiz-answer {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1.5px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quiz-answer[hidden] {
  display: none;
}

.quiz-pos {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-hover);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0;
}

.quiz-def {
  font-size: 15px;
  color: var(--ink);
  margin: 0;
  line-height: 1.5;
}

.quiz-ex {
  font-size: 13px;
  color: var(--text-2);
  font-style: italic;
  margin: 0;
  line-height: 1.4;
}

.rate-row {
  margin-top: 4px;
}

.rate-btns {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.rate-btn {
  flex: 1;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 800;
  padding: 12px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  border: 1.5px solid;
  background: var(--card);
}

.rate-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.rate-no {
  color: var(--error);
  border-color: var(--error);
}

.rate-no:hover {
  background: rgba(192, 57, 43, 0.08);
}

.rate-sort-of {
  color: var(--warn-text);
  border-color: var(--warn);
}

.rate-sort-of:hover {
  background: var(--warn-tint);
}

.rate-complete {
  color: var(--success);
  border-color: var(--success);
}

.rate-complete:hover {
  background: var(--success-tint);
}

.quiz-result-text {
  font-size: 15px;
  color: var(--ink);
  text-align: center;
  margin: 6px 0 0;
}
