

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-primary);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-bg);
  overflow-x: hidden;
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
.choice-btn:focus-visible,
.match-item:focus-visible,
.nav-button:focus-visible,
.btn:focus-visible,
.answer-input:focus-visible {
  outline: 3px solid rgba(var(--territory-b1-rgb), 0.4);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(var(--blue-rgb), 0.12);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3) 0;
  z-index: var(--z-sticky);
  box-shadow: var(--shadow-sm);
}

.header h1 {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--color-accent);
}

.header nav {
  display: flex;
  gap: var(--space-3);
}

.nav-button {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-base);
  transition: var(--transition-fast);
}

.nav-button:hover,
.nav-button:focus {
  background: var(--color-gold-tint);
  color: var(--color-gold-dark);
}

.nav-button.active {
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-dark) 100%);
  color: white;
}

/* Main content */
.main {
  flex: 1;
  padding: var(--space-6) 0;
}

/* View transitions */
.view {
  display: none;
  animation: fadeSlideIn 0.3s ease-out;
}

.view.active {
  display: block;
}

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

/* Cards */
.card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--color-accent);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  box-shadow: var(--card-shadow-elevated);
  transition: var(--transition-normal);
}

.card:hover {
  box-shadow: var(--shadow-base);
  border-top-color: var(--color-gold);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-base);
  padding: var(--space-3) var(--space-5);
  font-size: var(--font-size-base);
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-fast);
  min-height: var(--touch-min);
  width: auto;
  gap: var(--space-2);
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-dark) 100%);
  color: white;
  box-shadow: 0 6px 18px rgba(var(--accent-rgb), 0.2);
}

.btn-primary:hover,
.btn-primary:focus {
  background: linear-gradient(135deg, var(--color-accent-medium) 0%, var(--color-accent) 100%);
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(var(--accent-rgb), 0.28);
}

.btn-secondary {
  background: var(--color-bg-alt);
  color: var(--color-text);
  border: 1px solid var(--color-gold);
}

.btn-secondary:hover,
.btn-secondary:focus {
  background: var(--color-gold-tint);
  border-color: var(--color-gold);
}

.btn-block {
  display: block;
  width: 100%;
}

.card .btn + .btn,
.action-group .btn + .btn {
  margin-top: var(--space-2);
}

/* Home screen */
.hero {
  text-align: center;
  padding: var(--space-8) 0;
}

.hero h1 {
  font-size: var(--font-size-3xl);
  margin-bottom: var(--space-4);
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: var(--font-size-lg);
  color: var(--color-text-secondary);
}

.stats-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin: var(--space-6) 0;
}

.stat-card {
  text-align: center;
  padding: var(--space-5);
}

.stat-value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-accent);
}

.stat-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
}

.stat-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  text-align: center;
  transition: var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-accent), var(--color-gold));
}

.progress-overview {
  margin-bottom: var(--space-5);
}

.progress-overview-header {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-3);
}

.progress-overview-header span {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

.progress-track {
  width: 100%;
  height: 10px;
  background: var(--color-bg-alt);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: var(--space-3);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-accent) 0%, var(--color-gold) 100%);
  border-radius: inherit;
  transition: width 0.2s ease;
}

.progress-status {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

.action-card {
  display: grid;
  gap: var(--space-4);
}

.action-group {
  display: grid;
  gap: var(--space-2);
}

.action-group-label {
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-gold-dark);
}

.lesson-context {
  margin-bottom: var(--space-4);
}

.lesson-context h2 {
  margin-bottom: var(--space-1);
}

.lesson-context p {
  margin: 0;
  color: var(--color-text-secondary);
}

.listen-status {
  margin: var(--space-2) 0 0;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

.feedback-title {
  margin: 0 0 var(--space-2);
  font-weight: 700;
  color: var(--color-gold-dark);
}

.feedback-copy {
  margin: 0 0 var(--space-3);
}

/* Lesson player */
.lesson-player {
  padding: var(--space-4) 0;
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-5);
  gap: var(--space-3);
}

.question-counter {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--color-bg-alt);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: var(--space-4) 0;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-accent) 0%, var(--color-gold) 100%);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
  width: 0%;
}

.progress-label {
  text-align: center;
  margin-top: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  font-weight: 500;
}

.en-content {
  font-size: var(--font-size-xl);
  font-weight: 500;
  margin-bottom: var(--space-5);
  color: var(--color-text);
}

/* Choices */
.choices {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.choice-btn {
  text-align: left;
  padding: var(--space-4);
  background: var(--color-bg-alt);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-base);
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: var(--font-size-base);
  min-height: 44px;
  width: 100%;
}

.choice-btn:hover {
  background: var(--color-gold-tint);
  border-color: var(--color-gold);
}

.choice-btn.selected {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

.choice-btn.correct {
  background: var(--color-success);
  color: white;
  border-color: var(--color-success);
}

.choice-btn.wrong {
  background: var(--color-error);
  color: white;
  border-color: var(--color-error);
}

/* Feedback */
.feedback {
  padding: var(--space-4);
  border-radius: var(--radius-base);
  margin-top: var(--space-4);
  border-left: 4px solid var(--color-gold);
  animation: slideUp 0.3s ease-out;
  border: 1px solid;
  background: var(--color-gold-tint);
}

.feedback.correct {
  background: rgba(var(--accent-medium-rgb), 0.06);
  border-color: var(--color-correct);
  border-left: 4px solid var(--color-correct);
}

.feedback.wrong {
  background: rgba(var(--danger-rgb), 0.05);
  border-color: var(--color-wrong);
  border-left: 4px solid var(--color-wrong);
}

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

@keyframes flashCorrect {
  0%, 100% { background-color: transparent; }
  50% { background-color: var(--color-accent-light); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.shake {
  animation: shake 0.4s ease-in-out;
}

.match-item.selected {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

.listen-btn {
  background: var(--color-accent);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  padding: var(--space-3) var(--space-5);
  font-size: var(--font-size-base);
  cursor: pointer;
  margin: var(--space-4) 0;
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.25);
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: var(--z-banner);
  /* The container outlives its transient toasts; it must never block clicks
     on the UI beneath it (lesson-end buttons were unclickable because of
     this). Individual toasts re-enable hit-testing for themselves. */
  pointer-events: none;
}

.toast-container .toast { pointer-events: auto; }

.toast {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease-out;
  max-width: 90%;
  text-align: center;
}

.toast.achievement {
  background: linear-gradient(135deg, var(--color-accent-light) 0%, var(--color-gold-light) 100%);
  border-color: var(--color-gold);
  color: var(--color-accent-dark);
  font-weight: 600;
}

.status-banner {
  display: block;
  width: 100%;
  border-radius: var(--radius-base);
  padding: var(--space-3) var(--space-4);
  margin: 0 0 var(--space-4);
  border: 1px solid var(--color-border);
  background: var(--color-bg-alt);
  color: var(--color-text);
  font-weight: 500;
  line-height: 1.5;
}

.status-banner.success {
  background: rgba(var(--accent-medium-rgb), 0.08);
  border-color: rgba(var(--accent-medium-rgb), 0.4);
  color: var(--color-accent-dark);
}

.status-banner.error {
  background: rgba(var(--danger-rgb), 0.08);
  border-color: rgba(var(--danger-rgb), 0.3);
  color: var(--danger-deep);
}

.status-banner.info {
  background: var(--color-gold-tint);
  border-color: var(--color-gold);
  color: var(--warning-deep);
}

/* Empty states */
.empty-state {
  text-align: center;
  padding: var(--space-10) var(--space-4);
  color: var(--color-text-secondary);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(var(--metal-silver-rgb),, 0.04), rgba(var(--ink-rgb), 0.02));
  box-shadow: inset 0 1px 0 rgba(var(--surface-rgb), 0.2);
}

.empty-state h2,
.empty-state h3 {
  margin-bottom: var(--space-3);
  color: var(--color-text);
}

.empty-state p {
  margin-bottom: var(--space-3);
  line-height: 1.6;
}

.empty-state .btn {
  max-width: 280px;
  margin: 0 auto;
}

.empty-state.error-state {
  border-style: solid;
  border-color: rgba(var(--danger-rgb), 0.28);
  background: rgba(var(--red-wash-rgb), 0.35);
  color: var(--danger-darkest);
}

.empty-state .icon {
  font-size: var(--font-size-3xl);
  margin-bottom: var(--space-4);
  width: 4rem;
  height: 4rem;
  display: grid;
  place-items: center;
  margin-inline: auto;
  border-radius: 50%;
  background: var(--color-gold-tint);
  border: 2px solid var(--color-gold);
}

.review-tag {
  display: inline-flex;
  width: fit-content;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-gold-tint);
  color: var(--color-gold-dark);
  font-size: var(--font-size-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--color-gold);
}

.review-prompt,
.review-answer,
.review-choices {
  margin: 0;
  line-height: 1.6;
}

.review-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.achievement-card.unlocked {
  background: linear-gradient(135deg, var(--color-accent-lighter), var(--color-gold-tint));
  border-color: var(--color-gold);
  border-top: 3px solid var(--color-gold);
}

.achievement-card.locked {
  opacity: 0.5;
}

.achievement-icon {
  font-size: var(--font-size-2xl);
  margin-bottom: var(--space-2);
}

.choice-list,
.fill-form,
.dialog-choices,
.review-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.answer-input,
.match-select {
  width: 100%;
  min-height: var(--touch-min);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  font: inherit;
  background: white;
}

.fill-empty-msg {
  color: var(--color-error);
  font-size: var(--font-size-sm);
  margin-top: var(--space-2);
  background: #fef2f2;
  border: 1px solid var(--color-error);
  border-radius: var(--radius-base);
  padding: var(--space-2) var(--space-3);
  display: inline-block;
}

.answer-input.input-shake {
  border-color: var(--color-error);
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.25);
}

.match-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: var(--space-4) 0;
}

.match-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(130px, 180px);
  gap: var(--space-3);
  align-items: center;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: var(--space-3) 0;
}

.achievement-list {
  display: grid;
  gap: var(--space-3);
}

.achievement-unlocked {
  border-left: 4px solid var(--color-gold);
  border-top: 3px solid var(--color-gold);
}

.achievement-locked {
  opacity: 0.7;
}

.activity-chart {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-2);
  height: 140px;
  margin-top: var(--space-4);
}

.activity-bar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: end;
  flex: 1;
  height: 100%;
  gap: var(--space-2);
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
}

.activity-bar {
  width: 100%;
  min-height: 10px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: linear-gradient(180deg, var(--color-accent-light) 0%, var(--color-gold-light) 100%);
}

/* Assessment View Specific Styles */
.assess-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-4) var(--space-4);
}

.assess-view header,
.assess-view main,
.assess-view .card,
.assess-view .status-banner,
.assess-view #assess-root > * {
  width: 100%;
  max-width: var(--max-width-container);
  margin-left: auto;
  margin-right: auto;
}

.assess-view .view {
  display: block;
  width: 100%;
}

.choice-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  list-style: none;
  padding: 0;
  margin: var(--space-4) 0;
}

.choice-item {
  margin: 0;
}

.feedback-area {
  margin-top: var(--space-4);
}

.feedback-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  flex-wrap: wrap;
}

.feedback .btn {
  flex: 1;
  min-width: 120px;
}

.nav-group {
  display: flex;
  gap: var(--space-2);
}

.nav-button.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
  min-height: 44px;
}

.listen-btn {
  width: auto;
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-base);
  min-height: 44px;
}

.listen-btn:hover,
.listen-btn:focus {
  background: var(--color-accent-medium);
  color: white;
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(var(--accent-rgb), 0.35);
}

.question {
  padding: var(--space-4) 0;
}

.question-text {
  font-size: var(--font-size-lg);
  line-height: 1.5;
  color: var(--color-text);
  margin-bottom: var(--space-5);
}

.question-number {
  font-size: var(--font-size-sm);
  color: var(--color-gold-dark);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.choice-btn:focus-visible,
.nav-button:focus-visible,
.listen-btn:focus-visible {
  outline: 3px solid rgba(var(--territory-b1-rgb), 0.4);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(var(--blue-rgb), 0.12);
}

/* Toast container for assessment view */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: var(--z-banner);
  max-width: 360px;
  pointer-events: none;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 480px) {
  .stats-summary {
    grid-template-columns: 1fr;
  }
  
  .choices {
    gap: var(--space-2);
  }
  
  .btn {
    font-size: var(--font-size-base);
    padding: var(--space-3) var(--space-4);
  }
  
  .assessment-container {
    padding: var(--space-3);
  }
  
  .progress-bar-container {
    margin: var(--space-3) 0 var(--space-2);
  }
  
  .question-header {
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
  }
  
  .nav-group {
    align-self: flex-start;
  }
  
  .choice-btn {
    padding: var(--space-2);
  }
  
  .feedback-actions {
    flex-direction: column;
  }
  
  .progress-bar-container {
    height: 6px;
  }
}

/* Large screen adjustments */
@media (min-width: 1024px) {
  .assessment-container {
    max-width: var(--max-width-container);
    margin: 0 auto;
  }
  
  .choice-btn {
    max-width: 600px;
  }
}

@media (min-width: 768px) {
  .header-content,
  .container {
    padding: 0 var(--space-6);
  }
  
  .match-container {
    grid-template-columns: 1fr 1fr;
  }
  
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   Interactivity & Motion Enhancements
   Press feedback, richer hovers, answer pop/shake, entrances
   ============================================================ */

/* Press feedback: every interactive control compresses on click */
.btn:active,
.nav-button:active,
.choice-btn:active,
.review-rate:active,
.match-submit:active,
.listen-btn:active {
  transform: translateY(0) scale(0.97);
}

/* Secondary/neutral buttons share the primary lift language */
.btn-secondary:hover:not(:disabled),
.btn-secondary:focus-visible:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-base);
}

/* Choice buttons: lift with accent ring + soft green wash */
.choice-btn:hover:not(:disabled),
.choice-btn:focus-visible:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--color-accent-medium);
  background: var(--color-accent-lighter);
  box-shadow: var(--shadow-base);
}

/* Locked primary actions: visually disabled with lock affordance */
.btn-locked {
  opacity: 0.55;
  cursor: not-allowed;
  position: relative;
}
.btn-locked:hover {
  transform: none;
  box-shadow: none;
}
.btn-locked:active {
  transform: none;
  scale: 1;
}

@keyframes shakeLock {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px); }
  30% { transform: translateX(6px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
  90% { transform: translateX(2px); }
}

.btn-shake-locked {
  animation: shakeLock 0.45s ease-in-out;
}

/* Answer verdict animations */
@keyframes popCorrect {
  0% { transform: scale(1); }
  40% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes shakeWrong {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.choice-btn.correct {
  animation: popCorrect 0.35s ease-out;
}

.choice-btn.wrong {
  animation: shakeWrong 0.4s ease-in-out;
}

/* New question entrance: content fades/slides in on each render */
.question-area > .card,
.question-area > .lesson-card {
  animation: fadeSlideIn 0.28s ease-out both;
}

/* Feedback panel entrance with slight overshoot for liveliness */
.feedback {
  animation: slideUpOvershoot 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes slideUpOvershoot {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Text inputs & match selects respond to focus/hover */
.answer-input:hover,
.match-select:hover {
  border-color: var(--color-gold-medium);
}

.answer-input:focus,
.match-select:focus {
  border-color: var(--color-accent-medium);
  box-shadow: 0 0 0 3px rgba(var(--accent-medium-rgb), 0.15);
}

/* Review rating buttons lift toward the cursor */
.review-rate:hover:not(:disabled),
.review-rate:focus-visible:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-base);
}

/* ============================================================
   Brand wordmark - Xeque-Inglês
   ============================================================ */

.brand-wordmark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}

.brand-glyph {
  color: var(--color-gold);
  font-size: 0.85em;
  transform: translateY(-2px);
  text-shadow: 0 2px 6px rgba(var(--legacy-gold-rgb),, 0.35);
}

.hero h1 {
  position: relative;
  padding-bottom: var(--space-3);
}

.hero h1::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 140px;
  height: 3px;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--color-accent) 0%, var(--color-gold) 100%);
}

/* ============================================================
   Meu progresso - isometric castle (decorative, non-interactive)
   ============================================================ */

.progress-header {
  text-align: center;
  padding: var(--space-6) 0 var(--space-4);
}

.progress-header p {
  color: var(--color-text-secondary);
}

.castle-card {
  overflow: hidden;
}

.castle-scene {
  position: relative;
  height: 250px;
  margin: var(--space-2) auto 0;
  max-width: 340px;
  pointer-events: none;
  user-select: none;
}

.castle-ground {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  width: 300px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(var(--accent-rgb), 0.18) 0%, rgba(var(--accent-rgb), 0) 70%);
}

/* Faux-3D block anatomy: front face = element itself,
   skewed top + side spans complete the isometric corner */
.castle-block {
  position: absolute;
  --d: 24px;
  border-radius: 2px;
  opacity: 0.14;
  filter: grayscale(0.9);
}

.castle-block .face-top {
  position: absolute;
  left: calc(var(--d) / 2);
  bottom: 100%;
  width: 100%;
  height: var(--d);
  background: var(--cb-top, var(--emerald-tint));
  transform: skewX(-45deg);
  transform-origin: bottom left;
}

.castle-block .face-side {
  position: absolute;
  left: 100%;
  bottom: 0;
  width: var(--d);
  height: 100%;
  background: var(--cb-side, var(--emerald-strong));
  transform: skewY(-45deg);
  transform-origin: top left;
}

.castle-block.built {
  opacity: 1;
  filter: none;
  animation: riseBuild 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

.castle-block[data-stage='1'].built { animation-delay: 0.05s; }
.castle-block[data-stage='2'].built { animation-delay: 0.12s; }
.castle-block[data-stage='3'].built { animation-delay: 0.19s; }
.castle-block[data-stage='4'].built { animation-delay: 0.26s; }
.castle-block[data-stage='5'].built { animation-delay: 0.33s; }
.castle-block[data-stage='6'].built { animation-delay: 0.4s; }
.castle-block[data-stage='7'].built { animation-delay: 0.47s; }

/* Stage 1 - foundation slab */
.cb-foundation {
  left: 28px;
  bottom: 8px;
  width: 244px;
  height: 16px;
  --d: 20px;
  background: linear-gradient(180deg, var(--color-border-strong) 0%, var(--metal-silver) 100%);
  --cb-top: var(--color-border-soft);
  --cb-side: var(--color-text-muted);
}

/* Stage 2 - main walls */
.cb-walls {
  left: 82px;
  bottom: 24px;
  width: 136px;
  height: 76px;
  --d: 38px;
  background: linear-gradient(180deg, var(--color-accent-medium) 0%, var(--color-accent-dark) 100%);
  --cb-top: var(--emerald-light);
  --cb-side: var(--emerald-deep);
}

/* Crenellations on walls */
.cb-walls::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 100%;
  width: 100%;
  height: 9px;
  background: repeating-linear-gradient(
    90deg,
    var(--color-accent-medium) 0 16px,
    transparent 16px 32px
  );
}

/* Stage 3 - west tower */
.cb-tower-left {
  left: 42px;
  bottom: 24px;
  width: 44px;
  height: 108px;
  --d: 24px;
  background: linear-gradient(180deg, var(--color-accent) 0%, var(--color-accent-dark) 100%);
  --cb-top: var(--emerald-soft);
  --cb-side: var(--color-accent-dark);
  z-index: 2;
}

.cb-tower-left::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 100%;
  width: 100%;
  height: 8px;
  background: repeating-linear-gradient(
    90deg,
    var(--color-accent) 0 10px,
    transparent 10px 20px
  );
}

/* Stage 4 - golden gate arch on the walls */
.cb-gate {
  left: 134px;
  bottom: 24px;
  width: 32px;
  height: 36px;
  background: linear-gradient(180deg, var(--color-gold-medium) 0%, var(--color-gold-dark) 100%);
  border-radius: 16px 16px 0 0;
  box-shadow: inset 0 -4px 0 rgba(var(--shadow-rgb), 0.25);
  z-index: 3;
}

.cb-gate .face-top,
.cb-gate .face-side {
  display: none;
}

/* Stage 5 - keep atop the walls */
.cb-keep {
  left: 106px;
  bottom: 109px;
  width: 88px;
  height: 34px;
  --d: 28px;
  background: linear-gradient(180deg, var(--emerald-soft) 0%, var(--color-accent) 100%);
  --cb-top: var(--emerald-tint);
  --cb-side: var(--emerald-strong);
  border-top: 3px solid var(--color-gold);
  z-index: 2;
}

/* Stage 6 - east tower */
.cb-tower-right {
  left: 214px;
  bottom: 24px;
  width: 44px;
  height: 92px;
  --d: 24px;
  background: linear-gradient(180deg, var(--color-accent) 0%, var(--color-accent-dark) 100%);
  --cb-top: var(--emerald-soft);
  --cb-side: var(--color-accent-dark);
  z-index: 2;
}

.cb-tower-right::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 100%;
  width: 100%;
  height: 8px;
  background: repeating-linear-gradient(
    90deg,
    var(--color-accent) 0 10px,
    transparent 10px 20px
  );
}

/* Stage 6 - gold pennant on the west tower */
.cb-banner {
  left: 56px;
  bottom: 138px;
  width: 22px;
  height: 13px;
  background: linear-gradient(135deg, var(--color-gold-medium) 0%, var(--color-gold-dark) 100%);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  border-left: 3px solid var(--color-accent-dark);
  z-index: 4;
}

.cb-banner .face-top,
.cb-banner .face-side {
  display: none;
}

/* Stage 7 - royal flag on the keep */
.cb-flag {
  left: 142px;
  bottom: 146px;
  width: 3px;
  height: 26px;
  background: var(--color-accent-dark);
  z-index: 4;
}

.cb-flag::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0;
  width: 24px;
  height: 14px;
  background: linear-gradient(135deg, var(--color-gold-medium) 0%, var(--color-gold) 100%);
  clip-path: polygon(0 0, 100% 35%, 0 70%);
  transform-origin: left center;
  animation: waveFlag 1.6s ease-in-out infinite;
}

@keyframes waveFlag {
  0%, 100% { transform: skewY(0deg) scaleX(1); }
  50% { transform: skewY(-6deg) scaleX(0.94); }
}

.cb-flag .face-top,
.cb-flag .face-side {
  display: none;
}

/* Next-milestone hint / completion badge */
.castle-next-hint,
.castle-complete-badge {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.castle-next-hint {
  background: var(--color-gold-tint);
  color: var(--color-gold-dark);
  border: 1px solid var(--color-gold);
}

.castle-complete-badge {
  background: var(--color-accent-lighter);
  color: var(--color-accent-dark);
  border: 1px solid var(--color-accent);
}

/* Milestone checklist */
.milestone-list {
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.milestone-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  background: var(--color-bg-alt);
  transition: var(--transition-fast);
}

.milestone-item.earned {
  background: var(--color-accent-lighter);
  border-color: rgba(var(--accent-medium-rgb), 0.4);
}

.milestone-icon {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: var(--font-size-sm);
  font-weight: 700;
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  color: var(--color-text-secondary);
}

.milestone-item.earned .milestone-icon {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: white;
}

.milestone-body {
  flex: 1;
  min-width: 0;
}

.milestone-body strong {
  display: block;
  font-size: var(--font-size-sm);
}

.milestone-body p {
  margin: 2px 0 0;
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

.milestone-status {
  flex: none;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-secondary);
  text-align: right;
}

.milestone-item.earned .milestone-status {
  color: var(--color-accent-dark);
}

/* ============================================================
   Chess duel overlay - decorative, question modes only
   ============================================================ */

.duel-root {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: var(--z-sticky);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transform: translateX(10px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.duel-root.visible {
  opacity: 1;
  transform: translateX(0);
}

.duel-label {
  font-size: var(--font-size-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-gold-dark);
  background: var(--color-gold-tint);
  border: 1px solid var(--color-gold);
  border-radius: var(--radius-full);
  padding: 1px 8px;
}

.duel-board {
  position: relative;
  width: 102px;
  height: 102px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-accent-dark);
  box-shadow: var(--shadow-base), 0 0 0 3px var(--color-gold);
  background: var(--color-bg);
  overflow: hidden;
}

.duel-cell {
  position: absolute;
  left: calc(var(--c) * 34px);
  top: calc(var(--r) * 34px);
  width: 34px;
  height: 34px;
  background: var(--success-wash);
}

.duel-cell.dark {
  background: var(--success-border);
}

.duel-piece {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 30px;
  height: 30px;
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  filter: drop-shadow(0 2px 2px rgba(var(--ink-rgb), 0.25));
}

.duel-piece svg {
  width: 100%;
  height: 100%;
  display: block;
}

.duel-piece.spawn {
  animation: duelSpawn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes duelSpawn {
  from { opacity: 0; scale: 0.4; }
  to { opacity: 1; scale: 1; }
}

.duel-piece.captured {
  animation: duelCapture 0.45s ease-in both;
}

@keyframes duelCapture {
  0% { opacity: 1; rotate: 0deg; }
  60% { opacity: 1; rotate: 70deg; translate: 4px 6px; }
  100% { opacity: 0; rotate: 84deg; translate: 6px 10px; }
}

.duel-piece.downed {
  animation: duelDown 0.5s ease-in both;
}

@keyframes duelDown {
  0% { opacity: 1; rotate: 0deg; }
  100% { opacity: 0.15; rotate: -84deg; translate: -4px 8px; }
}

@media (max-width: 480px) {
  .duel-root {
    top: 8px;
    right: 8px;
    scale: 0.85;
    transform-origin: top right;
  }
}

/* ============================================================
   Persistent app navigation chrome (all routes)
   ============================================================ */
.app-nav {
  position: fixed;
  top: 12px;
  left: 12px;
  right: auto;
  bottom: auto;
  z-index: var(--z-flash);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-4);
  background: var(--color-bg);
  border-bottom: 1px solid rgba(var(--shadow-rgb),0.08);
}
.app-nav-link.active {
  color: var(--color-accent);
  font-weight: 600;
}
.app-nav.compact {
  justify-content: flex-end;
  min-height: 40px;
  box-shadow: 0 1px 4px rgba(var(--shadow-rgb),0.12);
}
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--shadow-rgb),0.45);
  padding: var(--space-4);
}
.confirm-modal {
  background: var(--color-bg);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(var(--shadow-rgb),0.25);
  max-width: 420px;
  width: 100%;
  padding: var(--space-5) var(--space-4);
}
.confirm-modal h3 {
  margin: 0 0 var(--space-2);
}
.confirm-modal p {
  margin: 0 0 var(--space-4);
  color: var(--color-text-secondary);
}
.confirm-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  flex-wrap: wrap;
}

.app-nav.is-home { display: none; }
 }

.tense-hint-chip {
  display: inline-block;
  margin: var(--space-2) 0;
  padding: 4px 12px;
  border: 1px solid var(--color-accent);
  border-radius: 999px;
  font-size: var(--font-size-sm);
  color: var(--color-accent);
  background: rgba(var(--accent-rgb), 0.08);
}

/* ============================================================
   Phase 1 decorative FX: checkmate streak (aria-hidden; inert
   under prefers-reduced-motion). Chessboard bg layer removed
   2026-08-25 (PM ruling: decorative-only, low value).
   ============================================================ */

.fx-streak-counter {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: auto;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-sticky);
  display: none;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--color-surface, var(--color-surface));
  border: 1px solid var(--color-border, var(--color-border-soft));
  box-shadow: 0 2px 8px rgba(var(--ink-rgb), 0.12);
  font-size: var(--font-size-sm, 0.875rem);
  font-weight: 700;
  color: var(--color-text, var(--color-ink));
  pointer-events: none;
  user-select: none;
}

.fx-streak-counter.visible { display: inline-flex; }

.checkmate-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-flash);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background-image: repeating-conic-gradient(var(--flash-dark) 0% 25%, var(--color-surface-bright) 0% 50%);
  background-size: 72px 72px;
  opacity: 0;
  animation: checkmate-flash 1.5s ease-out forwards;
}

.checkmate-overlay span {
  padding: 14px 26px;
  border-radius: 16px;
  background: rgba(var(--surface-bright-rgb), 0.92);
  border: 2px solid var(--flash-dark);
  font-size: var(--font-size-2xl, 1.75rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--flash-dark);
  box-shadow: 0 10px 30px rgba(var(--ink-deep-rgb),, 0.35);
}

@keyframes checkmate-flash {
  0% { opacity: 0; transform: scale(0.55); }
  35% { opacity: 0.9; }
  55% { opacity: 0.5; }
  100% { opacity: 0; transform: scale(1.6); }
}

@media (prefers-reduced-motion: reduce) {
  .checkmate-overlay,
  .promotion-piece {
    animation: none !important;
  }
}

/* ============================================================
   Phase 2: session phases, timers, hints, blunder feedback
   ============================================================ */






.blunder-note {
  margin-top: var(--space-2, 8px);
  padding: 10px 12px;
  border-left: 4px solid var(--color-error, var(--color-error));
  background: rgba(var(--error-rgb), 0.06);
  border-radius: 8px;
  color: var(--color-text, var(--color-ink));
}



/* ============================================================
   Phase 3: daily puzzle tile, puzzle modal, promotion ceremony
   ============================================================ */

.rank-glyph svg { width: 44px; height: 44px; }
.rank-card .stat-label { text-transform: capitalize; }

.daily-puzzle-tile {
  margin-top: var(--space-4, 16px);
  background: linear-gradient(160deg, var(--parchment-a) 0%, var(--parchment-b) 100%);
  border: 1px solid var(--parchment-border);
}

.daily-puzzle-tile h3 { color: var(--parchment-ink); }
.daily-puzzle-subtitle { color: var(--parchment-sub); }

.puzzle-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4, 16px);
  background: rgba(var(--ink-rgb), 0.55);
}

.puzzle-modal {
  width: min(480px, 100%);
  max-height: 85vh;
  overflow: auto;
}

/* Daily-puzzle result box: always green outline (PM ruling) — a wrong daily
   answer means "come back tomorrow", not "failure", so red read as broken. */
.puzzle-modal .feedback.puzzle-feedback,
.puzzle-modal .feedback.wrong {
  border-color: var(--color-success-strong);
}

.promotion-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-ceremony);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4, 16px);
  background: rgba(var(--ink-rgb), 0.65);
}

.promotion-modal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3, 12px);
  padding: var(--space-5, 24px) var(--space-6, 32px);
  border-radius: 20px;
  background: linear-gradient(170deg, var(--gold-wash-a) 0%, var(--gold-wash-b) 100%);
  border: 2px solid var(--metal-gold);
  box-shadow: 0 18px 50px rgba(var(--ink-rgb), 0.4);
  text-align: center;
}

.promotion-piece {
  animation: promote-rise 900ms cubic-bezier(0.22, 1.4, 0.36, 1) both,
    promote-glow 2.2s ease-in-out 400ms infinite;
}

.promotion-piece svg {
  width: 96px;
  height: 96px;
  filter: drop-shadow(0 0 10px rgba(var(--metal-gold-rgb), 0.55));
}

@keyframes promote-rise {
  from { transform: translateY(26px) scale(0.55); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes promote-glow {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

@media (prefers-reduced-motion: reduce) {
  .promotion-piece { animation: none !important; }
}

/* ============================================================
   Phase 4: skill tree (decorative mastery map)
   ============================================================ */

.skill-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-4, 16px);
  margin-bottom: var(--space-4, 16px);
}

@media (max-width: 720px) {
}

.skill-branch h3 {
  font-size: var(--font-size-sm, 0.875rem);
  letter-spacing: 0.08em;
  color: var(--color-text-secondary, var(--color-text-secondary-strong));
  border-bottom: 2px solid rgba(var(--ink-rgb), 0.08);
  padding-bottom: 6px;
  margin-bottom: 10px;
}

.tree-node {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: background-color 300ms ease, border-color 300ms ease, box-shadow 300ms ease;
}

.tree-node-piece {
  display: inline-flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tree-node-piece svg { width: 26px; height: 26px; }

.tree-node-body { display: flex; flex-direction: column; min-width: 0; }
.tree-node-body strong { font-size: var(--font-size-sm, 0.875rem); }
.tree-node-body small { color: var(--color-text-secondary, var(--color-text-muted)); }

.state-locked { background: rgba(var(--slate-rgb), 0.07); opacity: 0.65; }
.state-bronze { background: rgba(var(--bronze-rgb), 0.10); border-color: rgba(var(--bronze-rgb), 0.35); }
.state-silver { background: rgba(var(--slate-rgb), 0.14); border-color: rgba(var(--slate-deep-rgb), 0.45); }
.state-gold {
  background: rgba(var(--metal-gold-rgb), 0.13);
  border-color: rgba(var(--metal-gold-rgb), 0.55);
  box-shadow: 0 0 0 1px rgba(var(--metal-gold-rgb), 0.35), 0 4px 14px rgba(var(--metal-gold-rgb), 0.18);
}

.skill-collection .collection-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3, 12px);
}

.collection-piece {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.collection-piece svg {
  width: 44px;
  height: 44px;
  filter: drop-shadow(0 0 6px rgba(var(--metal-gold-rgb), 0.5));
}

/* Compact floating home control (replaces the old sticky bar) */
.app-nav {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: 12px;
  z-index: var(--z-float);
  background: transparent;
  border: none;
  box-shadow: none;
}

.app-nav.is-home { display: none; }

.home-float-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  color: var(--color-text, var(--color-ink));
  background: var(--color-surface, var(--color-surface));
  border: 1px solid var(--color-border, var(--color-border-soft));
  box-shadow: 0 2px 10px rgba(var(--ink-rgb), 0.16);
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.home-float-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(var(--ink-rgb), 0.22); }

.daily-puzzle-prompt {
  font-weight: 700;
  margin-bottom: 4px;
}

.storage-banner {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--tabbar-height, 60px) + 14px);
  z-index: var(--z-banner);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(520px, calc(100vw - 24px));
  padding: 10px 12px 10px 16px;
  border-radius: 12px;
  background: var(--gold-wash-b);
  border: 1px solid var(--metal-gold);
  color: var(--banner-ink);
  font-size: var(--font-size-sm, 0.875rem);
  box-shadow: 0 8px 24px rgba(var(--ink-rgb), 0.18);
}

.storage-banner button {
  margin-left: auto;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}

/* Install nudge (Phase A): dismissible home banner, iOS Safari non-standalone. */
.install-nudge {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--space-4);
  padding: 10px 12px 10px 16px;
  border-radius: 12px;
  background: var(--gold-wash-b);
  border: 1px solid var(--metal-gold);
  color: var(--banner-ink);
  font-size: var(--font-size-sm, 0.875rem);
}

.install-nudge span {
  flex: 1;
}

.install-nudge button {
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1;
}

/* ============================================================
   Step 3: chess-journey roadmap (serpentine trail + landmarks)
   ============================================================ */

.chess-roadmap {
  display: flex;
  flex-direction: column;
  gap: var(--space-2, 8px);
  margin-bottom: var(--space-4, 16px);
}

.territory-header {
  margin-top: var(--space-4, 16px);
  padding: 6px 12px;
  border-radius: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: rgba(var(--ink-rgb), 0.06);
  color: var(--color-text-secondary, var(--color-text-secondary-strong));
}

.territory-header.locked { opacity: 0.55; }
.territory-A1 { border-left: 5px solid var(--metal-silver); }
.territory-A2 { border-left: 5px solid var(--metal-bronze); }
.territory-B1 { border-left: 5px solid var(--territory-b1); }
.territory-B2 { border-left: 5px solid var(--territory-b2); }

.roadmap-row {
  display: flex;
  justify-content: space-between;
}

.roadmap-row.reverse { flex-direction: row-reverse; }

.roadmap-row .map-node { width: calc(50% - 6px); }

.roadmap-spacer { width: calc(50% - 6px); }

.map-node {
  position: relative;
  text-align: left;
  cursor: pointer;
  padding: 10px;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.map-node:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(var(--ink-rgb), 0.14);
}

.map-node:disabled { cursor: not-allowed; }

.map-node.no-content { opacity: 0.5; }

.map-node-tile {
  position: relative;
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.map-node-tile svg { width: 30px; height: 30px; }

.lock-tag, .done-tag {
  position: absolute;
  right: -6px;
  bottom: -4px;
  font-size: 13px;
  line-height: 1;
}

.done-tag {
  color: var(--color-success-strong);
  font-weight: 900;
  background: rgba(var(--surface-rgb), 0.9);
  border-radius: 999px;
  padding: 1px 4px;
  border: 1px solid var(--color-success-strong);
}

.availability-badge { display: block; margin-top: 2px; }

.depth-chooser {
  display: inline-flex;
  gap: 6px;
  margin-left: auto;
  align-self: center;
}

.landmark-row {
  display: flex;
  justify-content: center;
  padding: var(--space-3, 12px) 0;
}

.landmark-structure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.landmark-structure svg {
  width: 64px;
  height: 64px;
  filter: drop-shadow(0 4px 10px rgba(var(--ink-rgb), 0.25));
}

.landmark-structure span {
  font-size: var(--font-size-xs, 0.75rem);
  font-weight: 700;
  color: var(--color-text-secondary, var(--color-text-secondary-strong));
}

.landmark-row.locked { opacity: 0.5; }

@media (max-width: 560px) {
  .roadmap-row, .roadmap-row.reverse { flex-direction: column; }
  .roadmap-row .map-node, .roadmap-spacer { width: 100%; }
}

/* ============================================================
   Batch 2: mobile navigation shell (bottom tab bar + frame)
   ============================================================ */

:root {
  --frame-max: 480px;
  --tabbar-height: 60px;
}

/* App column: centered phone-width shell on desktop */
body {
  background: var(--color-surface-muted);
}

#app {
  max-width: var(--frame-max);
  margin-inline: auto;
  /* keep content clear of the bottom tab bar + home-indicator area */
  padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px) + var(--space-2));
  min-height: 100vh;
  box-shadow: 0 0 0 1px rgba(var(--shadow-rgb), 0.06), 0 12px 40px rgba(var(--shadow-rgb), 0.10);
}

@media (min-width: 720px) {
  #app {
    border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
    overflow: hidden;
  }
}

/* Bottom tab bar (replaces the floating button era) */
.app-nav {
  position: fixed;
  top: auto;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-float);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  align-items: stretch;
  gap: 0;
  width: 100%;
  max-width: var(--frame-max);
  margin-inline: auto;
  height: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px));
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
  background: var(--color-surface);
  border-top: 1px solid var(--color-border-soft);
  box-shadow: 0 -4px 16px rgba(var(--shadow-rgb), 0.08);
}

.nav-tab {
  min-height: var(--tap);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  border-radius: var(--radius-base);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.nav-tab.active {
  color: var(--color-accent);
  background: var(--color-accent-lighter);
}

.nav-tab:not(.active):hover { color: var(--color-text-secondary-strong); }

/* Fixed chrome centers within the frame */
.fx-streak-counter,
.storage-banner {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  max-width: calc(var(--frame-max) - 24px);
}

/* ============================================================
   Batch 3: overlay re-skin (tokens + sheet pattern)
   ============================================================ */

.confirm-overlay { z-index: var(--z-modal); }

.confirm-modal {
  width: min(420px, calc(100vw - 32px));
  border-radius: var(--radius-sheet);
  padding: var(--space-6);
  box-shadow: 0 20px 50px rgba(var(--shadow-rgb), 0.28);
}

.puzzle-modal {
  width: min(480px, calc(100vw - 24px));
  border-radius: var(--radius-card);
  padding: var(--space-5);
}

@media (max-width: 560px) {
  /* Sheet-style slide-up on phone widths */
  .puzzle-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .puzzle-modal {
    width: 100%;
    max-width: none;
    max-height: 88vh;
    border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
    padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
    animation: puzzle-sheet-in var(--transition-normal) var(--ease-out) both;
  }
}

@keyframes puzzle-sheet-in {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.promotion-modal {
  padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
}

.storage-banner {
  z-index: var(--z-banner);
}

/* ============================================================
   Batch 4: mobile component polish
   Tactile Duolingo-style controls, tap targets, focus rings.
   Styling only — class contract unchanged.
   ============================================================ */

/* Focus rings: loud, consistent, everywhere */
:focus-visible {
  outline: 3px solid var(--color-accent-medium);
  outline-offset: 2px;
}

/* Pressed-state micro-interaction (motion-safe users only) */
@media (prefers-reduced-motion: no-preference) {
  button:not(.nav-tab):not(.depth-chooser button),
  .choice-btn {
    transition: transform 80ms ease, box-shadow 80ms ease,
      background-color var(--transition-fast), border-color var(--transition-fast);
  }

  button:not(.nav-tab):not(.depth-chooser button):active,
  .choice-btn:active {
    transform: scale(0.97);
  }

  .btn-primary:active,
  .btn-secondary:active {
    transform: translateY(3px) scale(0.99);
  }
}

/* ---------- Buttons: chunky tactile edges ---------- */
.btn {
  font-weight: 800;
  letter-spacing: 0.02em;
  border-radius: var(--radius-base);
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-surface);
  box-shadow: 0 4px 0 var(--color-accent-dark);
}

.btn-primary:active {
  box-shadow: 0 1px 0 var(--color-accent-dark);
}

.btn-secondary {
  background: var(--color-surface);
  border: 2px solid var(--color-border-soft);
  color: var(--color-text-secondary-strong);
  box-shadow: 0 4px 0 var(--color-border-strong);
}

.btn-secondary:active {
  box-shadow: 0 1px 0 var(--color-border-strong);
}

.btn-sm { box-shadow: 0 3px 0 var(--color-border-strong); }
.btn-sm:active { box-shadow: 0 1px 0 var(--color-border-strong); }

button:not(.nav-tab):not(.depth-chooser button),
.select, input.answer-input, .match-select {
  min-height: var(--tap);
}

button:not(.nav-tab) {
  cursor: pointer;
}

/* ---------- Cards & stat tiles ---------- */
.card {
  border-radius: var(--radius-card);
  border: 1px solid var(--color-border-soft);
  box-shadow: 0 2px 10px rgba(var(--shadow-rgb), 0.06);
}

.stat-value {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-weight: 700;
  color: var(--color-text-muted);
}

.stat-card { border-radius: var(--radius-card); }

/* ---------- Exercise surfaces ---------- */
.lesson-card > h3,
.review-session-card > h3 {
  font-size: var(--font-size-lg);
  line-height: var(--line-height-tight);
}

.choice-list { gap: var(--space-2); display: flex; flex-direction: column; }

.choice-list .btn-block,
.choice-btn {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  font-weight: 600;
  border-radius: var(--radius-base);
}

.en-content {
  font-size: var(--font-size-lg);
  font-weight: 700;
  line-height: var(--line-height-normal);
}

input.answer-input,
.match-select {
  border: 2px solid var(--color-border-soft);
  border-radius: var(--radius-base);
  background: var(--color-surface);
  font-size: var(--font-size-base);
  padding: 0 var(--space-3);
}

input.answer-input:focus,
.match-select:focus {
  border-color: var(--color-accent-medium);
  outline: none;
  box-shadow: 0 0 0 3px var(--color-accent-lighter);
}

/* Feedback blocks read as banners */
.feedback.correct { border-left: 5px solid var(--color-success-strong); }
.feedback.wrong { border-left: 5px solid var(--color-error); }

/* ---------- Empty / completion states ---------- */
.empty-state .icon { font-size: 3rem; line-height: 1; margin-bottom: var(--space-2); }
.empty-state h2 { font-weight: 800; }

/* ---------- Headers & page rhythm ---------- */
.view header h2,
.card > h2 {
  font-weight: 800;
  letter-spacing: -0.01em;
}

.page-subtitle { color: var(--color-text-muted); }

.brand-wordmark {
  font-weight: 900;
  letter-spacing: -0.02em;
}

/* ============================================================
   Batch C1: WCAG AA contrast remediations
   ============================================================ */

/* Active tab: accent-dark on accent-lighter clears 7:1 */
.nav-tab.active { color: var(--color-accent-dark); }

/* Primary buttons: deep-emerald surface keeps white text above 7:1 */
.btn-primary {
  background: var(--color-accent-dark);
  box-shadow: 0 4px 0 var(--emerald-deep);
}
.btn-primary:active { box-shadow: 0 1px 0 var(--emerald-deep); }

/* Secondary text families: single high-contrast tone */
.view header p,
.page-subtitle,
.node-caption,
.review-prompt,
.milestone-status {
  color: var(--color-text-secondary-strong);
}

/* specificity bump: beat legacy ".tree-node-body small" */
.map-node .node-caption { color: var(--color-text-secondary-strong); }

/* C5: listen transcript affordance */
.listen-transcript { margin: var(--space-2) 0; }
.listen-transcript-btn[aria-expanded="true"] { opacity: 0.8; }


/* ============================================================
   C4: tablet/desktop two-pane home layout (first slice)
   ============================================================ */
@media (min-width: 900px) {
  .home main {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: var(--space-6);
    align-items: start;
  }

  .home .stats-summary { grid-column: 1 / -1; }

  .home .progress-overview,
  .home .daily-puzzle-tile { grid-column: 1; margin-bottom: 0; }

  .home .action-card { grid-column: 2; grid-row: 2 / span 3; }
}

/* C3/A1-rework: PT hint reveal */
.pt-hint-btn { margin-top: var(--space-2); }
.pt-hint-text {
  margin: var(--space-2) 0;
  padding: 10px 12px;
  border-left: 4px solid var(--color-accent-medium, #10b981);
  background: rgba(16, 185, 129, 0.06);
  border-radius: 8px;
  color: var(--color-text, #0f172a);
  font-style: italic;
}

/* ============================================================
   EXPLAINER CARDS (Feature 1 — skill-tree practice mode)
   ============================================================ */
.explainer-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgba(15, 23, 42, 0.55);
}

.explainer-modal {
  width: min(560px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-6);
  border-radius: var(--radius-sheet);
}

/* Two-page swipe layout: page 1 = rule, page 2 = pitfall. Scroll-snap gives
   touch users native card-by-card swiping; desktop scrolls horizontally. */
.explainer-pages {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  gap: var(--space-4);
  border-radius: var(--radius-sheet);
}

/* Pager controls (both tiers): click to flip pages; swipe still works. */
.explainer-pager {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-3);
}

.explainer-page {
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.explainer-page::after {
  content: 'Deslize para o lado →';
  display: block;
  margin-top: auto;
  padding-top: var(--space-3);
  font-size: var(--font-size-sm, 0.85rem);
  opacity: 0.65;
  text-align: center;
}

.explainer-page:last-child::after {
  content: '✓ Pronto para praticar';
}
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-lg);
}

.explainer-piece {
  width: 72px;
  height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: linear-gradient(160deg, #10b981, #064e3b);
  color: #ffffff;
}

.explainer-piece svg {
  width: 70%;
  height: 70%;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}

.explainer-title {
  margin: 0;
  text-align: center;
  font-size: var(--font-size-xl);
}

.explainer-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.explainer-label {
  margin: 0;
  font-size: var(--font-size-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.explainer-rule-pt {
  margin: 0;
  font-weight: 600;
}

.explainer-rule-en {
  margin: 0;
  color: var(--color-text-secondary-strong);
}

.explainer-pattern {
  display: inline-block;
  align-self: flex-start;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-base);
  background: var(--color-accent-lighter);
  border: 1px dashed var(--accent-medium, #10b981);
  font-family: var(--font-primary);
  font-weight: 600;
  color: var(--emerald-deep, #064e3b);
}

.explainer-example {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-base);
  background: var(--color-bg-alt);
  border-left: 3px solid var(--accent-medium, #10b981);
}

.explainer-example .en { margin: 0; font-weight: 600; }
.explainer-example .pt { margin: 0; color: var(--color-text-secondary-strong); font-size: var(--font-size-sm); }

.explainer-mistake {
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-base);
  background: var(--color-surface-bright);
  padding: var(--space-3);
}

.explainer-mistake .wrong { margin: 0; color: var(--color-error); font-weight: 700; }
.explainer-mistake .right { margin: 0; color: var(--color-success-strong); font-weight: 700; }
/* Inline error highlight inside explainer mistake lines ("[red:word]" markup):
   red underline makes the offending word obvious at a glance. */
.explainer-mistake .mistake-word {
  color: var(--color-error);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
.explainer-mistake .why { margin: 0; color: var(--color-text-secondary-strong); font-size: var(--font-size-sm); }

.explainer-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
}

.explainer-info-btn {
  align-self: flex-start;
  margin-top: var(--space-1);
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
}

.explainer-info-btn:hover,
.explainer-info-btn:focus-visible {
  background: var(--color-surface-muted);
}

/* ============================================================
   ADAPTIVE HINT (Feature 2 — R2 progressive hint ladder)
   ============================================================ */
.adaptive-hint {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-base);
  background: var(--color-accent-lighter);
  border-left: 3px solid var(--accent-medium, #10b981);
  color: var(--emerald-deep, #064e3b);
  font-size: var(--font-size-sm);
}

/* ============================================================
   PHASE 1 — UX quick wins (XP bar · skeleton · bests strip)
   ============================================================ */
.xp-progress {
  position: relative;
  margin: calc(-1 * var(--space-2)) auto var(--space-4);
  width: min(420px, 86%);
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--color-surface-muted);
  overflow: hidden;
}

.xp-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--accent-medium, #10b981), var(--emerald-deep, #064e3b));
  transition: width var(--transition-normal);
}

.xp-progress-label {
  margin: var(--space-1) 0 0;
  text-align: center;
  font-size: var(--font-size-xs);
  /* Phase 5 contrast fix: muted slate drops to 4.34:1 on the tinted
     backgrounds the desktop tier can place this label over; secondary-strong
     clears WCAG AA (>=4.5:1) on every surface it can appear on. */
  color: var(--color-text-secondary-strong);
}

.skeleton-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  border-radius: var(--radius-card);
  background: var(--color-surface);
}

.sk-line {
  display: block;
  height: 14px;
  border-radius: var(--radius-base);
  background: linear-gradient(90deg, var(--color-border) 25%, var(--color-surface-muted) 50%, var(--color-border) 75%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.2s infinite;
}
.sk-line.w60 { width: 60%; }
.sk-line.w80 { width: 80%; }

@keyframes sk-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .sk-line { animation: none; }
}

.pb-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.pb-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-3);
  border-radius: var(--radius-card);
  background: var(--color-accent-lighter);
  border: 1px solid var(--color-border);
}

.pb-chip strong { font-size: var(--font-size-xl); color: var(--emerald-deep, #064e3b); }
.pb-chip small { color: var(--color-text-secondary-strong); }

.listen-slow-btn { white-space: nowrap; }

/* ============================================================
   PHASE 2 — celebration · goal ring · calendar
   ============================================================ */
.celebration {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.celebration-ring {
  width: 132px;
  height: 132px;
  transform: rotate(-90deg);
}
.celebration-ring .ring-bg {
  fill: none;
  stroke: var(--color-border);
  stroke-width: 10;
}
.celebration-ring .ring-fg {
  fill: none;
  stroke: var(--accent-medium, #10b981);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset var(--transition-slow) var(--ease-out);
}
.celebration-ring .ring-pct {
  font-size: 26px;
  font-weight: 700;
  fill: var(--color-text);
  transform: rotate(90deg);
  transform-origin: 60px 60px;
}

.celebration-stats {
  display: flex;
  gap: var(--space-4);
  align-items: center;
}
.celebration-xp {
  font-weight: 700;
  color: var(--color-success-strong);
}
.celebration-flame {
  font-weight: 600;
}

.goal-ring { display: inline-flex; margin-left: auto; }
.goal-ring svg { width: 44px; height: 44px; transform: rotate(-90deg); }
.goal-ring-bg { fill: none; stroke: var(--color-border-soft, #e2e8f0); stroke-width: 5; }
.goal-ring-fg {
  fill: none;
  stroke: var(--accent-medium, #10b981);
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset var(--transition-normal);
}
.goal-ring-text { font-size: 11px; font-weight: 700; fill: var(--emerald-deep, #064e3b); }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--space-2);
  justify-items: center;
}
.cal-labels span {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-weight: 600;
}
.cal-cell {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}
.cal-cell.lvl0 { opacity: 0.55; }
.cal-cell.lvl1 { background: var(--color-accent-lighter); }
.cal-cell.lvl2 { background: var(--accent-light, #a7f3d0); }
.cal-cell.lvl3 { background: var(--accent-medium, #10b981); color: #ffffff; }

/* ============================================================
   PHASE 4 — session-length picker overlay
   ============================================================ */
.session-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: 1000;
}
.session-picker-card {
  background: var(--color-surface, #ffffff);
  border-radius: var(--radius-lg, 16px);
  padding: var(--space-5);
  max-width: 360px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.35);
}
.session-picker-card h3 {
  margin: 0 0 var(--space-4);
  font-size: var(--font-size-md);
  text-align: center;
}
.session-picker-bubbles {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.session-picker-bubble {
  min-width: 64px;
  font-weight: 700;
}
.session-picker-bubble.selected {
  border-color: var(--accent-medium, #10b981);
  color: var(--accent-medium, #10b981);
  box-shadow: inset 0 0 0 2px var(--accent-medium, #10b981);
}

@media (prefers-reduced-motion: reduce) {
  .session-picker-overlay,
  .session-picker-card,
  .session-picker-bubble {
    transition: none !important;
    animation: none !important;
  }
}

/* ============================================================
   PHASE 5 — Desktop FULL tier (@media min-width:1024px ONLY)
   Widened containers · two-col layouts (home/stats/skill-tree)
   · side-by-side explainer pages · hover/focus states ·
   type-scale bump. Everything below lives INSIDE this media
   query so the <1024px mobile experience stays byte-stable.
   ============================================================ */
@media (min-width: 1024px) {
  /* Type-scale bump */
  body {
    font-size: 17px;
  }

  /* Widened containers */
  .view {
    max-width: 1080px;
    margin-left: auto;
    margin-right: auto;
  }

  /* Home: two-column dashboard grid applied to <main> — ALL dashboard
     content lives inside it (header/XP bar stay stacked above, full width).
     Corrective fix: the earlier root-level .view.home grid split el's direct
     children instead of main's, bundling everything into one column. */
  .view.home main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
    align-items: start;
  }
  .view.home main > .progress-overview,
  .view.home main > .action-card,
  .view.home main > .daily-puzzle-tile {
    grid-column: 1 / -1;
  }

  /* Skill tree: sequential territory/landmark roadmap must stay single-column
     (two-col scrambled the journey); widened container + hover only. */

  /* Explainer cards: paged card pair (tier-independent pager in explainer.js);
     no responsive split — nothing to break between tiers. */

  /* Hover/focus affordances that only make sense with a pointer */
  .card {
    transition: box-shadow var(--transition-normal) var(--ease-out),
      transform var(--transition-normal) var(--ease-out);
  }
  .card:hover {
    box-shadow: var(--shadow-lg, 0 10px 30px rgba(15, 23, 42, 0.12));
  }
  .stat-card:hover,
  .cal-cell:hover,
  .map-node-tile:hover {
    transform: translateY(-2px);
  }
  .nav-tab:hover,
  .nav-button:hover {
    background: var(--color-accent-lighter);
  }
}

/* Safe-area insets (Phase A): viewport-fit=cover extends the viewport under
   device notches/home indicators. env() resolves to 0px on unaffected devices
   and desktop, so this block is a no-op everywhere except notched mobile.
   Full-screen overlays are verified on physical devices via BETA-TESTING.md.
   Using calc() to ADD to existing padding, not override it. */
@media (min-width: 1024px) {
  /* Desktop tier: widen the phone frame so the PHASE 5 layout is visible.
     Root cause fix (2026-08-26): --frame-max:480px clamped #app at every
     viewport, rendering the app as a narrow phone column on desktop. The
     variable (not just #app) is overridden so dependent calc() widths
     (.app-nav, inner frames) stay coherent. Mobile <1024px byte-stable. */
  :root {
    --frame-max: 1080px;
  }
}

@supports (padding: env(safe-area-inset-top)) {
  .header {
    /* Original: padding: var(--space-3) 0; --space-3 = 0.75rem */
    padding-top: calc(var(--space-3) + env(safe-area-inset-top, 0px));
    padding-bottom: var(--space-3);
  }

  .app-nav {
    /* Original: padding: var(--space-2) var(--space-4); --space-2 = 0.5rem */
    padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom, 0px));
    padding-top: var(--space-2);
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .view.active {
    /* Add safe-area horizontal padding to content area */
    padding-left: calc(var(--space-4) + env(safe-area-inset-left, 0px));
    padding-right: calc(var(--space-4) + env(safe-area-inset-right, 0px));
  }
}

/* ===== Legal consent gate (top-level, first-run) =====
   Surgical, scoped styles for the consent overlay rendered by
   js/legal-consent.js before any view mounts. Reuses the existing tokens
   and the .card class so the gate matches the rest of the design system.
   No animation, no theming overrides: minimal surface area to maintain. */
.legal-consent-gate {
  position: fixed;
  inset: 0;
  z-index: var(--z-ceremony, 200);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4, 16px);
  background: rgba(var(--ink-rgb, 15, 23, 42), 0.65);
}

.legal-consent-card {
  width: min(520px, 100%);
  max-height: 92vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.legal-consent-body {
  margin: 0;
  color: var(--color-text);
  line-height: var(--line-height-normal, 1.5);
}

.legal-consent-links {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.legal-consent-accept-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
}

.legal-consent-accept-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  cursor: pointer;
}

.legal-consent-accept-row span {
  flex: 1;
  color: var(--color-text);
  font-size: var(--font-size-sm, 0.875rem);
}

.legal-consent-farewell {
  margin: 0;
  text-align: center;
  color: var(--color-accent-dark, #065f46);
  font-weight: 600;
  font-size: var(--font-size-base, 1rem);
}

/* Settings: legal documents card (XE_TDU / XE_PLP). */
.legal-section-text {
  margin: 0 0 var(--space-3);
  color: var(--color-text-muted, #64748b);
  font-size: var(--font-size-sm, 0.875rem);
  line-height: var(--line-height-normal, 1.5);
}

.legal-section-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Settings: "Quem fez isso?" card — two equal-width buttons side by side. */
.credits-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.credits-actions .btn {
  box-sizing: border-box;
  min-height: 76px;
}

.credits-actions .btn + .btn {
  /* Grid gap supplies spacing; stacked-button margins shrink the second link. */
  margin-top: 0;
}
