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

:root {
  --bg: #0a0a1a;
  --surface: #1a1a2e;
  --surface-light: #25253d;
  --accent: #FFE81F;
  --text: #e0e0e0;
  --text-dim: #888;
  --correct: #4caf50;
  --incorrect: #f44336;
  --radius: 12px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.app {
  overflow-y: auto;
}

.aurebesh {
  font-family: 'Aurebesh', sans-serif;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
}

/* Header */
.header {
  text-align: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--surface-light);
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 1px;
}

/* Screens */
.screen {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  overscroll-behavior: contain;
}

#screen-learn {
  touch-action: pan-y pinch-zoom;
}

.screen.hidden {
  display: none;
}

.btn-reveal.hidden {
  display: none;
}

/* Nav */
.nav {
  display: flex;
  border-top: 1px solid var(--surface-light);
  padding: 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--surface);
}

.nav-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  padding: 8px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.nav-btn.active {
  color: var(--accent);
}

.nav-icon {
  font-size: 20px;
}

/* Learn screen */
.learn-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  margin-top: 24px;
}

.learn-card.hidden {
  display: none;
}

.learn-glyph {
  font-size: 120px;
  line-height: 1.2;
  color: var(--accent);
}

.learn-letter {
  font-size: 36px;
  font-weight: 700;
  margin-top: 16px;
}

.learn-name {
  font-size: 16px;
  color: var(--text-dim);
  margin-top: 8px;
}

.learn-meta {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-dim);
}

.learn-hint-area {
  margin-top: 12px;
}

.learn-hint-row {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
}

.learn-hint {
  font-size: 14px;
  color: var(--text-dim);
  font-style: italic;
  flex: 1;
  min-height: 40px;
}

.learn-pin-btn {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0 4px;
  flex-shrink: 0;
}

.learn-pin-btn.pinned {
  color: var(--accent);
}

.learn-hint-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.learn-hint-tab {
  background: var(--surface-light);
  border: 1px solid transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 16px;
  cursor: pointer;
}

.learn-hint-tab.active {
  background: var(--accent);
  color: var(--bg);
}

.learn-hint-tab.custom {
  border: 1px dashed var(--text-dim);
}

.learn-hint-tab.custom.active {
  border-color: var(--accent);
}

.learn-custom-input-row {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.learn-custom-input-row.hidden {
  display: none;
}

.learn-custom-input {
  flex: 1;
  background: var(--surface-light);
  border: 1px solid var(--surface-light);
  color: var(--text);
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 8px;
  outline: none;
}

.learn-custom-input:focus {
  border-color: var(--accent);
}

.learn-custom-save {
  background: var(--accent);
  color: var(--bg);
  border: none;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}


/* Learn transforms section */
.learn-transforms {
  text-align: center;
  padding-top: 48px;
}

.learn-transforms.hidden {
  display: none;
}

.transform-stage {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 24px;
}

.transform-font-glyph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 170px;
  color: var(--accent);
  line-height: 1;
  transition: none;
  z-index: 1;
}

.transform-stage svg {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

.btn-animate {
  background: var(--surface-light);
  border: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 24px;
  border-radius: var(--radius);
  cursor: pointer;
}

.btn-animate:active {
  background: var(--accent);
  color: var(--bg);
}

/* Learn compare strip */
.learn-compare {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
  text-align: center;
}

.learn-compare.hidden {
  display: none;
}

.compare-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.compare-glyphs {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 10px;
}

.compare-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.compare-glyph {
  font-size: 36px;
  color: var(--accent);
}

.compare-letter {
  font-size: 16px;
  font-weight: 700;
}

.compare-tip {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.4;
}

.learn-nav {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
}

.learn-nav button {
  background: var(--surface-light);
  border: none;
  color: var(--text);
  font-size: 16px;
  padding: 12px 32px;
  border-radius: var(--radius);
  cursor: pointer;
  min-width: 100px;
}

.learn-nav button:disabled {
  opacity: 0.3;
  cursor: default;
}

.learn-nav button:active:not(:disabled) {
  background: var(--accent);
  color: var(--bg);
}

.learn-nav.hidden {
  display: none;
}

/* Learn card slide animations */
@keyframes slideOutLeft {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(-60px); opacity: 0; }
}
@keyframes slideOutRight {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(60px); opacity: 0; }
}
@keyframes slideInRight {
  from { transform: translateX(60px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes slideInLeft {
  from { transform: translateX(-60px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.slide-out-left {
  animation: slideOutLeft 0.15s ease-in forwards;
}
.slide-out-right {
  animation: slideOutRight 0.15s ease-in forwards;
}
.slide-in-right {
  animation: slideInRight 0.2s ease-out forwards;
}
.slide-in-left {
  animation: slideInLeft 0.2s ease-out forwards;
}

/* Drill level selector */
.drill-level-select {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 24px;
  padding: 0 16px;
}

.drill-level-select.hidden {
  display: none;
}

.btn-level {
  flex: 1;
  background: var(--surface);
  border: none;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  padding: 12px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
}

.btn-level:active {
  background: var(--accent);
  color: var(--bg);
}

.drill-picker {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.drill-picker.hidden {
  display: none;
}


.drill-picker-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
  min-width: fit-content;
}

.drill-picker-row {
  display: flex;
  flex: 1;
  gap: 8px;
}

.btn-pick {
  flex: 1;
  background: var(--surface-light);
  border: 2px solid transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  padding: 6px 4px;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
}

.btn-pick.selected {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.word-level-group {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.word-level-label {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.word-level-tiers {
  display: flex;
  gap: 8px;
}

.btn-level.selected {
  background: var(--accent);
  color: var(--bg);
}

.drill-start-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: var(--radius);
}

.drill-start-row.hidden {
  display: none;
}

.drill-start-info {
  font-size: 16px;
  color: var(--text-dim);
}

.btn-start-drill {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 12px 28px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

/* Drill screen */
.drill-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  margin-top: 24px;
}

.drill-glyph {
  font-size: 140px;
  line-height: 1.2;
  color: var(--accent);
}

.drill-glyph.word-glyph {
  font-size: 72px;
  letter-spacing: 4px;
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-all;
}

.drill-glyph.flash-dashes {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 48px;
  color: var(--text-dim);
  letter-spacing: 8px;
}

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  min-width: 200px;
}

.btn-reveal {
  background: var(--accent);
  color: var(--bg);
}

.btn-reveal:active {
  opacity: 0.8;
}

.drill-feedback {
  text-align: center;
  margin-top: 16px;
  font-size: 22px;
  font-weight: 700;
  min-height: 60px;
}

.drill-feedback.hidden {
  visibility: hidden;
}

.feedback-correct {
  color: var(--correct);
}

.feedback-incorrect {
  color: var(--incorrect);
}

.drill-feedback-hint {
  font-size: 14px;
  font-style: italic;
  color: var(--text-dim);
  margin-top: 4px;
  font-weight: 400;
}

.drill-choice-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
  padding: 0 16px;
}

.drill-choice-btns.hidden {
  display: none;
}

.btn-choice {
  background: var(--surface-light);
  border: 2px solid transparent;
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  padding: 16px;
  border-radius: var(--radius);
  cursor: pointer;
}

.btn-choice:active {
  background: var(--surface);
}

.btn-choice.correct {
  background: var(--correct);
  color: #fff;
  border-color: var(--correct);
}

.btn-choice.incorrect {
  background: var(--incorrect);
  color: #fff;
  border-color: var(--incorrect);
}

.drill-type-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

.drill-type-area.hidden {
  display: none;
}

.drill-type-input {
  background: var(--surface-light);
  border: 2px solid var(--surface-light);
  color: var(--text);
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  padding: 14px 20px;
  border-radius: var(--radius);
  width: 200px;
  outline: none;
}

.drill-type-input:focus {
  border-color: var(--accent);
}

.drill-type-input.correct {
  border-color: var(--correct);
  color: var(--correct);
}

.drill-type-input.incorrect {
  border-color: var(--incorrect);
  color: var(--incorrect);
}

.drill-count {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-dim);
}

.drill-card.hidden {
  display: none;
}

.drill-complete {
  text-align: center;
  margin-top: 48px;
}

.drill-complete.hidden {
  display: none;
}

.drill-complete-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 16px;
}

.drill-complete-stats {
  font-size: 16px;
  color: var(--text-dim);
  margin-bottom: 24px;
}

.drill-complete-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.btn-level-back {
  background: var(--surface-light);
  color: var(--text);
  border: none;
  border-radius: var(--radius);
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  min-width: 200px;
}

.btn-level-back:active {
  background: var(--accent);
  color: var(--bg);
}

/* Reference screen */
.ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  padding-bottom: 16px;
}

.ref-card {
  background: var(--surface);
  border-radius: 8px;
  padding: 12px 8px;
  text-align: center;
}

.ref-glyph {
  font-size: 36px;
  color: var(--accent);
  line-height: 1.3;
}

.ref-letter {
  font-size: 16px;
  font-weight: 700;
  margin-top: 4px;
}

.ref-name {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Confusable pairs */
.confusable-section {
  margin-top: 32px;
  padding-bottom: 16px;
}

.confusable-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 16px;
}

.confusable-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.confusable-row {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
}

.confusable-glyphs {
  display: flex;
  justify-content: center;
  gap: 32px;
}

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

.confusable-glyph {
  font-size: 56px;
  color: var(--accent);
  line-height: 1.3;
}

.confusable-label {
  font-size: 16px;
  font-weight: 700;
  margin-top: 4px;
}

.confusable-tip {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 12px;
  line-height: 1.4;
}
