:root {
  /* ── "Cuaderno de opositor" palette — warm paper, ink accents ── */
  --c-green:   #3F9B2E;
  --c-orange:  #E08A1E;
  --c-blue:    #2C86C9;
  --c-red:     #C4433A;
  --c-gold:    #D9A441;

  --c-bg:      #F3E9D0;
  --c-surface: #FFFCF3;
  --c-surface2:#EDE0C0;
  --c-text:    #3A3226;
  --c-muted:   #8A7C63;
  --c-border:  #E1D3AC;

  --c-margin:    rgba(196,67,58,0.4);
  --c-rule-line: rgba(90,110,150,0.14);

  --font-hand: 'Kalam', 'Comic Sans MS', cursive;
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;

  --shadow-paper:  0 2px 8px rgba(90,65,20,0.10), 0 1px 2px rgba(90,65,20,0.08);
  --shadow-paper-lg: 0 6px 20px rgba(90,65,20,0.14), 0 2px 6px rgba(90,65,20,0.08);

  --r-sm:   8px;
  --r-md:   14px;
  --r-lg:   18px;
  --r-full: 999px;

  --sp-xs:  4px;
  --sp-sm:  8px;
  --sp-md:  16px;
  --sp-lg:  24px;
  --sp-xl:  32px;

  --fs-xs:   0.70rem;
  --fs-sm:   0.85rem;
  --fs-base: 1rem;
  --fs-lg:   1.125rem;
  --fs-xl:   1.25rem;
  --fs-2xl:  1.5rem;
  --fs-3xl:  2rem;

  --t-fast: 150ms ease;
  --t-base: 250ms ease;

  --nav-height: 64px;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--c-bg);
  background-image:
    linear-gradient(90deg, transparent 31px, var(--c-margin) 31px, var(--c-margin) 32px, transparent 32px),
    repeating-linear-gradient(var(--c-bg), var(--c-bg) 31px, var(--c-rule-line) 31px, var(--c-rule-line) 32px);
  background-repeat: no-repeat, repeat;
  color: var(--c-text);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
  overflow-x: hidden;
}

#app {
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
}

/* ── Screen system ── */
.screen {
  display: none;
  flex-direction: column;
  min-height: calc(100dvh - var(--nav-height) - env(safe-area-inset-bottom, 0px));
  padding: var(--sp-md);
  padding-top: var(--sp-lg);
  max-width: 480px;
  margin: 0 auto;
  gap: var(--sp-md);
}

.screen.active {
  display: flex;
  animation: screenIn 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* Question screen has no gap — layout managed per-section */
#screen-question.active {
  gap: 0;
}

.hidden { display: none !important; }

/* ── Typography helpers ── */
.text-muted   { color: var(--c-muted); }
.text-sm      { font-size: var(--fs-sm); }
.text-xs      { font-size: var(--fs-xs); }
.text-xl      { font-size: var(--fs-xl); }
.text-2xl     { font-size: var(--fs-2xl); }
.font-bold    { font-weight: 700; }
.font-black   { font-weight: 900; }
.text-center  { text-align: center; }
.text-green   { color: var(--c-green); }
.text-red     { color: var(--c-red); }
.text-orange  { color: var(--c-orange); }
.text-blue    { color: var(--c-blue); }
.text-gold    { color: var(--c-gold); }

/* ── Spacing helpers ── */
.mt-xs  { margin-top: var(--sp-xs); }
.mt-sm  { margin-top: var(--sp-sm); }
.mt-md  { margin-top: var(--sp-md); }
.mt-lg  { margin-top: var(--sp-lg); }
.mb-sm  { margin-bottom: var(--sp-sm); }
.mb-md  { margin-bottom: var(--sp-md); }
.gap-xs { gap: var(--sp-xs); }
.gap-sm { gap: var(--sp-sm); }
.gap-md { gap: var(--sp-md); }

/* ── Layout helpers ── */
.row         { display: flex; align-items: center; gap: var(--sp-sm); }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.col         { display: flex; flex-direction: column; }
.flex-1      { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

/* ── Section title ── */
.section-title {
  font-family: var(--font-hand);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: var(--sp-sm);
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
}

/* ── Divider ── */
.divider {
  height: 2px;
  background-image: repeating-linear-gradient(90deg, var(--c-border) 0 6px, transparent 6px 12px);
  margin: var(--sp-md) 0;
}

/* ── Scrollable area ── */
.scroll-y {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Screen header ── */
.screen-header {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-sm);
}

.screen-header h1 {
  font-family: var(--font-hand);
  font-size: 1.7rem;
  font-weight: 700;
  flex: 1;
  color: var(--c-text);
}

.back-btn {
  background: none;
  border: none;
  color: var(--c-text);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--sp-xs);
  line-height: 1;
  border-radius: var(--r-sm);
  transition: background var(--t-fast);
  flex-shrink: 0;
}

.back-btn:hover { background: var(--c-surface2); }

/* ── App name / logo ── */
.app-name {
  font-family: var(--font-hand);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--c-text);
  transform: rotate(-1.5deg);
  display: inline-block;
}

.app-name span {
  color: var(--c-green);
}

/* ── Screen transition ── */
@keyframes screenIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

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