/* =========================================================
   E.P.D. — Estação dos Pequenos Destinos
   Tema visual: cozy visual novel / ficha mágica pastel
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700;800&family=Nunito:ital,wght@0,400;0,600;0,700;1,600&display=swap');

:root {
  --cream: #f8ecd9;
  --cream-deep: #f0dcc0;
  --paper: #fffaf0;
  --paper-line: #e8d8bf;
  --brown-deep: #5b4130;
  --brown: #8a6a4f;
  --brown-soft: #c3a281;
  --ink: #4a3527;
  --ink-soft: #7a6350;

  --accent: #d98ea3;
  --accent-soft: #f6dce2;
  --accent-deep: #b9647d;

  --blue: #7f96c9;
  --blue-soft: #dbe3f3;
  --lilac: #a98fd2;
  --lilac-soft: #e7ddf5;
  --pink: #f2a6b3;
  --pink-soft: #fbe1e5;

  /* tons sólidos (sem gradiente) usados na animação de troca de tema — paleta 3, bem suave */
  --flood-azul-a: #e9f0fc;
  --flood-azul-b: #d7e3f8;
  --flood-lilas-a: #f3e9fb;
  --flood-lilas-b: #e6d5f5;
  --flood-rosa-a: #fdecf1;
  --flood-rosa-b: #f9d9e3;

  --shadow: rgba(90, 62, 40, 0.22);
  --shadow-soft: rgba(90, 62, 40, 0.12);

  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;

  --font-display: 'Baloo 2', 'Segoe UI Rounded', sans-serif;
  --font-body: 'Nunito', 'Segoe UI', sans-serif;
}

body.theme-azul {
  --accent: var(--blue);
  --accent-soft: var(--blue-soft);
  --accent-deep: #5c74ab;
  background: var(--flood-azul-b);
}
body.theme-lilas {
  --accent: var(--lilac);
  --accent-soft: var(--lilac-soft);
  --accent-deep: #8a6cbd;
  background: var(--flood-lilas-b);
}
body.theme-rosa {
  --accent: var(--pink);
  --accent-soft: var(--pink-soft);
  --accent-deep: #d97f8f;
  background: var(--flood-rosa-b);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, #fff5e4 0%, transparent 45%),
    radial-gradient(circle at 85% 90%, var(--accent-soft) 0%, transparent 50%),
    linear-gradient(160deg, var(--cream) 0%, var(--cream-deep) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  transition: background 0.8s ease;
}

#app-frame {
  position: relative;
  z-index: 5;
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  background: var(--paper);
  box-shadow: 0 30px 60px var(--shadow), 0 0 0 1px var(--paper-line) inset;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 560px) {
  body { padding: 32px 0; }
  #app-frame {
    min-height: 88vh;
    max-height: 900px;
    border-radius: var(--radius-lg);
    border: 6px solid var(--paper);
    outline: 2px solid var(--paper-line);
  }
}

#app-root {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.mood-intense #app-frame {
  box-shadow: 0 30px 70px rgba(40, 25, 15, 0.45);
}

/* ---------- decorative texture ---------- */
.paper-texture {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(var(--paper-line) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: 0.35;
}

.corner-star {
  position: absolute;
  font-family: var(--font-display);
  color: var(--accent);
  opacity: 0.55;
  font-size: 22px;
  user-select: none;
}

/* ---------- reset link ---------- */
#reset-link {
  position: fixed;
  bottom: 6px;
  right: 10px;
  font-size: 10px;
  color: var(--brown-soft);
  opacity: 0.4;
  z-index: 999;
  font-family: var(--font-body);
  background: none;
  border: none;
  cursor: pointer;
}
#reset-link:hover { opacity: 0.9; }

/* ============= BUTTONS ============= */
.btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
  border: none;
  border-radius: 999px;
  padding: 13px 28px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-deep) 100%);
  box-shadow: 0 6px 0 var(--accent-deep), 0 10px 18px var(--shadow-soft);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--accent-deep), 0 4px 10px var(--shadow-soft);
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}
.btn-ghost {
  background: transparent;
  color: var(--brown);
  box-shadow: none;
  border: 2px solid var(--brown-soft);
}
.btn-ghost:active { transform: translateY(2px); box-shadow: none; }

/* ============= BOOT SCREEN ============= */
.boot-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 32px;
  gap: 18px;
  position: relative;
}
.boot-emblem {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px dashed var(--brown-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--brown);
  letter-spacing: 0.05em;
  animation: spin-slow 18s linear infinite;
}
@keyframes spin-slow { to { transform: rotate(360deg); } }
.boot-screen h1 {
  font-family: var(--font-display);
  font-size: 30px;
  margin: 4px 0 0;
  color: var(--brown-deep);
  letter-spacing: 0.04em;
}
.boot-screen p.subtitle {
  margin: 0;
  color: var(--ink-soft);
  font-weight: 600;
}
.boot-hint {
  margin-top: 22px;
  font-size: 13px;
  color: var(--brown-soft);
  animation: pulse-fade 1.8s ease-in-out infinite;
}
@keyframes pulse-fade { 0%,100% { opacity: 0.45; } 50% { opacity: 1; } }

/* ============= LOGIN SCREEN ============= */
.login-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 28px;
  gap: 20px;
  text-align: center;
}
.login-card {
  width: 100%;
  background: var(--paper);
  border: 2px solid var(--paper-line);
  border-radius: var(--radius-md);
  padding: 26px 22px;
  box-shadow: 0 14px 30px var(--shadow-soft);
}
.login-card h2 {
  font-family: var(--font-display);
  font-size: 19px;
  color: var(--brown-deep);
  margin: 0 0 4px;
  letter-spacing: 0.03em;
}
.login-card .login-sub {
  font-size: 12px;
  color: var(--brown-soft);
  margin-bottom: 20px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.login-card label {
  display: block;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.login-card input {
  width: 100%;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.06em;
  text-align: center;
  padding: 12px 10px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--brown-soft);
  background: #fff;
  color: var(--brown-deep);
  outline: none;
  text-transform: uppercase;
}
.login-card input:focus { border-color: var(--accent); }
.login-card input::placeholder {
  color: var(--brown-soft);
  opacity: 0.45;
}
.login-card input.error {
  border-color: #c1554f;
  animation: shake 0.35s ease;
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.login-error-msg {
  min-height: 18px;
  font-size: 12px;
  color: #a8433d;
  font-weight: 700;
  margin-top: 8px;
}
.login-card .btn { margin-top: 18px; width: 100%; }

.login-confirm {
  width: 100%;
  text-align: left;
  background: var(--brown-deep);
  color: #f4e9d8;
  border-radius: var(--radius-md);
  padding: 22px 20px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.9;
  min-height: 110px;
  box-shadow: 0 14px 30px var(--shadow-soft);
}
.login-confirm .line { opacity: 0; animation: line-in 0.4s ease forwards; }
.login-confirm .line::before { content: '> '; color: var(--pink); }
@keyframes line-in { to { opacity: 1; } }

/* ============= LORE TITLE ============= */
.lore-title-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 30px;
  cursor: pointer;
}
.lore-title-screen .eyebrow {
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.35em;
  color: var(--accent-deep);
  margin-bottom: 10px;
}
.lore-title-screen h1 {
  font-family: var(--font-display);
  font-size: 32px;
  color: var(--brown-deep);
  margin: 0;
  line-height: 1.25;
}
.lore-title-screen .divider {
  width: 70px;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  margin: 18px 0;
  opacity: 0.7;
}
.lore-title-screen .tap-hint {
  margin-top: 26px;
  font-size: 12px;
  color: var(--brown-soft);
}

/* ============= STAGE (dialogue scenes) ============= */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  justify-content: flex-end;
  min-height: 100%;
}
.sprite-wrap {
  position: absolute;
  bottom: 150px;
  left: 50%;
  transform: translateX(-50%);
  width: 62%;
  max-width: 280px;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.sprite-wrap img {
  width: 100%;
  filter: drop-shadow(0 18px 20px var(--shadow-soft));
  animation: sprite-bob 3.2s ease-in-out infinite;
}
@keyframes sprite-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.mood-intense .sprite-wrap img { animation: sprite-still 3.2s ease-in-out infinite; filter: drop-shadow(0 18px 20px var(--shadow-soft)) brightness(0.92); }
@keyframes sprite-still {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.dialogue-area {
  position: relative;
  padding: 16px 16px 22px;
  cursor: pointer;
  user-select: none;
}
.nameplate {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: #fff;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-deep) 100%);
  padding: 6px 20px;
  border-radius: 999px 999px 0 0;
  margin-left: 18px;
  box-shadow: 0 -2px 0 rgba(0,0,0,0.02);
  position: relative;
  top: 2px;
  z-index: 2;
}
.dialogue-box {
  background: var(--paper);
  border: 2px solid var(--paper-line);
  border-radius: var(--radius-md);
  padding: 20px 22px 24px;
  min-height: 110px;
  box-shadow: 0 -6px 0 rgba(0,0,0,0.015), 0 14px 30px var(--shadow-soft);
  position: relative;
  z-index: 1;
}
.dialogue-box p {
  margin: 0;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  min-height: 52px;
  white-space: pre-line;
}
.dialogue-box .cursor-blink {
  display: inline-block;
  width: 2px;
}
.advance-hint {
  position: absolute;
  bottom: 10px;
  right: 18px;
  font-size: 13px;
  color: var(--accent-deep);
  opacity: 0;
  animation: bounce-hint 1.2s ease-in-out infinite;
}
.advance-hint.show { opacity: 0.85; }
@keyframes bounce-hint {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

/* ============= DOCUMENT / FICHA ============= */
.doc-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 30px 22px 22px;
  gap: 16px;
}
.doc-card {
  background: var(--paper);
  border: 2px dashed var(--brown-soft);
  border-radius: var(--radius-md);
  padding: 22px 20px;
  box-shadow: 0 14px 30px var(--shadow-soft);
  position: relative;
}
.doc-card .stamp {
  position: absolute;
  top: 14px;
  right: 14px;
  border: 2px solid var(--accent-deep);
  color: var(--accent-deep);
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.05em;
  padding: 4px 8px;
  border-radius: 6px;
  transform: rotate(8deg);
  opacity: 0.75;
}
.doc-heading {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--brown-deep);
  margin: 0 0 4px;
  letter-spacing: 0.02em;
}
.doc-sub {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--brown-soft);
  text-transform: uppercase;
  margin-bottom: 16px;
}
.doc-field {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dotted var(--paper-line);
  font-size: 14px;
}
.doc-field:last-child { border-bottom: none; }
.doc-field .label { color: var(--ink-soft); font-weight: 700; }
.doc-field .value { color: var(--ink); text-align: right; font-weight: 600; }
.doc-field .value.redacted {
  background: repeating-linear-gradient(45deg, var(--brown-deep), var(--brown-deep) 4px, #3f2c1f 4px, #3f2c1f 8px);
  color: transparent;
  border-radius: 4px;
  padding: 1px 8px;
}
.doc-field .value.restricted { color: var(--accent-deep); font-style: italic; }
.doc-field .value.confirmed { color: #4c8c5e; }
.doc-field .value.detected { color: var(--accent-deep); }
.doc-field .value.unknown { color: var(--brown-soft); font-style: italic; }

.integrity-wrap { margin-top: 14px; }
.integrity-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.progress-track {
  width: 100%;
  height: 12px;
  background: var(--cream-deep);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--paper-line);
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-deep) 100%);
  width: 0%;
  transition: width 1.4s cubic-bezier(.22,.9,.4,1);
}
.doc-screen .btn { align-self: center; margin-top: 4px; }

/* ============= CHOICES ============= */
.choice-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 18px 20px;
}
.choice-btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 14.5px;
  text-align: left;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--brown-soft);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
}
.choice-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.choice-btn.selected {
  border-color: var(--accent-deep);
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.choice-btn:disabled { cursor: default; opacity: 0.55; }
.choice-btn:disabled.selected { opacity: 1; }
.question-card {
  margin: 0 18px 14px;
  background: var(--paper);
  border: 2px solid var(--paper-line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  font-weight: 700;
  color: var(--brown-deep);
  font-size: 15px;
  box-shadow: 0 10px 22px var(--shadow-soft);
}
.choice-screen { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; padding-top: 26px; gap: 8px; }

/* ============= PROCESSING ============= */
.processing-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 30px;
  text-align: center;
}
.processing-screen .proc-sprite { width: 150px; animation: sprite-bob 3.2s ease-in-out infinite; filter: drop-shadow(0 14px 16px var(--shadow-soft)); }
.processing-lines {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: var(--brown);
  min-height: 40px;
  line-height: 1.7;
}
.processing-lines .line { opacity: 0; animation: line-in 0.4s ease forwards; }
.proc-bar-wrap { width: 100%; max-width: 260px; }
.proc-flavor {
  font-size: 12px;
  font-style: italic;
  color: var(--brown-soft);
  min-height: 16px;
}

/* ============= UNLOCK / GIFT SCREEN ============= */
.unlock-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 34px 24px 26px;
  gap: 16px;
  text-align: center;
}
.unlock-screen h2 {
  font-family: var(--font-display);
  font-size: 21px;
  color: var(--brown-deep);
  margin: 6px 0 0;
}
.ticket-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 6px 0 4px;
}
.ticket-chip {
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--accent-deep);
  border: 2px dashed var(--accent);
  background: var(--accent-soft);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  animation: chip-pop 0.5s ease backwards;
}
.ticket-chip:nth-child(1) { animation-delay: 0.1s; }
.ticket-chip:nth-child(2) { animation-delay: 0.28s; }
.ticket-chip:nth-child(3) { animation-delay: 0.46s; }
@keyframes chip-pop {
  from { opacity: 0; transform: scale(0.6) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.auth-badge {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: #4c8c5e;
  border: 2px solid #4c8c5e;
  padding: 7px 16px;
  border-radius: 999px;
  transform: rotate(-3deg);
  margin: 6px 0;
}
.clue-card {
  background: var(--paper);
  border: 2px solid var(--paper-line);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: 0 12px 24px var(--shadow-soft);
  width: 100%;
}
.clue-card .clue-label {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--accent-deep);
  margin-bottom: 8px;
}
.clue-card p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink);
}
.unlock-close {
  margin-top: 8px;
  font-size: 13px;
  color: var(--brown-soft);
  font-style: italic;
}

/* ============= TROCA DE TEMA (bolhas mágicas) ============= */
@keyframes blob-wobble {
  0%, 100% { border-radius: 42% 58% 65% 35% / 45% 45% 55% 55%; }
  33%      { border-radius: 58% 42% 38% 62% / 60% 35% 65% 40%; }
  66%      { border-radius: 48% 52% 55% 45% / 40% 60% 40% 60%; }
}

.sparkle {
  position: fixed;
  z-index: 3;
  pointer-events: none;
  font-size: 16px;
  line-height: 1;
  color: #fff9ec;
  text-shadow: 0 0 8px rgba(255,255,255,.95), 0 0 2px #fff;
  opacity: 0;
  transform: translate(-50%,-50%) scale(0) rotate(0deg);
  animation: sparkle-pop 900ms ease-out forwards;
}
@keyframes sparkle-pop {
  0%   { opacity: 0; transform: translate(-50%,-50%) scale(0) rotate(0deg); }
  30%  { opacity: 1; transform: translate(-50%,-50%) scale(1.2) rotate(70deg); }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(.5) rotate(150deg); }
}

.flood-blob {
  position: fixed;
  z-index: 1;
  pointer-events: none;
  width: 240vmax;
  height: 240vmax;
  left: var(--ox, 50%);
  top: var(--oy, 50%);
  background: var(--shade-b);
  border-radius: 42% 58% 65% 35% / 45% 45% 55% 55%;
  transform: translate(-50%, -50%) scale(0);
  transition: transform 1s cubic-bezier(.22,.85,.28,1);
  animation: blob-wobble 4.5s ease-in-out infinite;
}
.flood-blob.layer-a {
  background: var(--shade-a);
  width: 190vmax;
  height: 190vmax;
  transition: transform 1s cubic-bezier(.22,.85,.28,1) .09s;
  animation-delay: .4s;
}
.flood-blob.is-open { transform: translate(-50%, -50%) scale(1); }

.bubble {
  position: fixed;
  z-index: 1;
  pointer-events: none;
  left: var(--bx);
  bottom: -35vh;
  width: var(--bsize);
  height: var(--bsize);
  background: var(--bcolor);
  border-radius: 45% 55% 60% 40% / 50% 45% 55% 50%;
  opacity: 0;
  transform: translateY(0) scale(.6);
  animation: bubble-rise var(--bdur, 1.2s) cubic-bezier(.28,.8,.28,1) forwards, blob-wobble 3.6s ease-in-out infinite;
  animation-delay: var(--bdelay, 0s), var(--bdelay, 0s);
}
@keyframes bubble-rise {
  0%   { opacity: 0; transform: translateY(0) scale(.5); }
  18%  { opacity: 1; }
  100% { opacity: 1; transform: translateY(-130vh) scale(1.1); }
}

/* ============= UTIL ============= */
.fade-in { animation: fade-in 0.5s ease both; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: translateY(0);} }
