:root {
  --papel: #efe7d4;
  --hoja: #f7f1e0;
  --tinta: #2a2420;
  --gris: #6e6358;
  --verde: #3f6b55;
  --azul: #2a3256;
  --raya: #cdc1a2;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--papel);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .16  0 0 0 0 .14  0 0 0 0 .12  0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
  color: var(--tinta);
  font-family: Spectral, Georgia, 'Times New Roman', serif;
  font-size: 17px;
  line-height: 1.55;
}

#app {
  max-width: 460px;
  margin: 0 auto;
  padding-block: 10px 56px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

#app.entra > * { animation: entra .5s ease both; }
@keyframes entra { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Cabecera ---------- */
.cab {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0 8px;
  border-bottom: 1px solid var(--tinta);
  margin-bottom: 10px;
}
.cab .dia { font-weight: 600; letter-spacing: .02em; flex: 1; }
.puntos { display: inline-flex; gap: 5px; }
.punto { width: 9px; height: 9px; border-radius: 50%; background: var(--tinta); }
.punto.gastado { background: transparent; border: 1px solid var(--tinta); opacity: .5; }
.herr { display: inline-flex; gap: 6px; }
.herr button {
  font: inherit; font-size: 14px; color: var(--tinta);
  background: transparent; border: 1px solid var(--tinta);
  border-radius: 3px 9px 4px 8px; padding: 3px 9px; cursor: pointer;
}
.herr button.mudo { opacity: .45; text-decoration: line-through; }

/* ---------- Ilustraciones ---------- */
.arte { margin: 4px -4px 6px; }
.arte svg { display: block; width: 100%; height: auto; overflow: visible; }
.tinta { filter: url(#mano); }
.t { fill: none; stroke: var(--tinta); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.t.fino { stroke-width: .8; }
.t.gruesa { stroke-width: 2.6; }
.f { fill: var(--tinta); }
.w { fill: var(--tinta); opacity: .075; }
.w2 { fill: var(--tinta); opacity: .13; }
.a { fill: var(--verde); opacity: .85; }
.papel { fill: var(--hoja); }
.rot { font: 600 7px Spectral, Georgia, serif; letter-spacing: 1.6px; fill: var(--tinta); }
.humo { animation: humo 4.5s ease-in-out infinite; }
@keyframes humo { 0% { opacity: 0; transform: translateY(3px); } 40% { opacity: .9; } 100% { opacity: 0; transform: translateY(-6px); } }
.lluvia { animation: lluvia .9s linear infinite; }
@keyframes lluvia { 0% { opacity: 0; transform: translate(2px, -6px); } 30% { opacity: .8; } 100% { opacity: 0; transform: translate(-2px, 6px); } }
.seco .lluvia { display: none; }

/* ---------- Texto ---------- */
.texto p { margin: 0 0 .7em; animation: entra .6s ease both; }
.texto p.dialogo { padding-left: .2em; }
.chico { font-size: 14px; color: var(--gris); margin: 2px 0 14px; }
h1 { font-weight: 600; font-size: 38px; line-height: 1.05; margin: 8px 0 8px; letter-spacing: -.01em; }
h2 { font-weight: 600; font-size: 26px; margin: 2px 0 6px; }
.bajada { font-style: italic; margin: 0 0 20px; }
.firma { font-size: 13px; color: var(--gris); margin-top: 26px; text-align: center; }

/* ---------- Botones ---------- */
.opciones { margin-top: 12px; }
.boton {
  display: block; width: 100%; text-align: left;
  font: inherit; color: var(--tinta);
  padding: 11px 14px; margin: 8px 0;
  background: transparent; border: 1px solid var(--tinta);
  border-radius: 3px 10px 4px 11px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.boton:hover, .boton:focus-visible { background: rgba(42, 36, 32, .07); outline: none; }
.boton.principal { background: var(--tinta); color: var(--papel); text-align: center; margin-top: 16px; }
.boton.principal:hover { background: #453c35; }
.boton.conlibreta { border-color: var(--verde); color: var(--verde); }
.boton.conlibreta::before { content: '✎  '; }
.boton.suave { border-color: transparent; color: var(--gris); text-align: center; font-size: 15px; text-decoration: underline; text-underline-offset: 3px; }
.boton.lugar { display: flex; flex-direction: column; gap: 0; }
.boton.lugar small { color: var(--gris); font-size: 13.5px; font-style: italic; }

/* ---------- La libreta ---------- */
.hoja {
  background: var(--hoja);
  border: 1px solid #d9ceb0;
  border-radius: 2px;
  box-shadow: 0 1px 0 #e3d9bf, 2px 3px 0 rgba(42, 36, 32, .08);
  padding: 8px 12px 14px 22px;
  margin: 14px 0;
  position: relative;
}
.hoja::before {
  content: ''; position: absolute; left: 13px; top: 0; bottom: 0;
  border-left: 1px solid rgba(160, 80, 70, .28);
}
.hoja-tit { font-size: 12.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--gris); padding: 2px 0 4px; }
.renglon {
  display: flex; align-items: flex-end; gap: 6px;
  min-height: 33px; width: 100%;
  border: 0; border-bottom: 1px solid var(--raya);
  background: transparent; padding: 0; margin: 0; text-align: left;
}
.mano {
  font-family: Caveat, 'Segoe Script', 'Bradley Hand', cursive;
  font-size: clamp(17px, 5.05vw, 23px);
  line-height: 1.15; color: var(--tinta);
  white-space: nowrap;
}
.renglon .mano { flex: 1; min-width: 0; overflow: hidden; padding-bottom: 1px; }
.ajeno .mano { color: var(--azul); letter-spacing: .012em; }
button.renglon.elegible { cursor: pointer; }
button.renglon.elegible:hover, button.renglon.elegible:focus-visible { background: rgba(63, 107, 85, .13); outline: none; }
.renglon .num { font-size: 10px; color: var(--raya); position: absolute; left: 3px; margin-bottom: 4px; }
input.mano { width: 100%; border: 0; background: transparent; outline: none; padding: 0 0 1px; border-radius: 0; }
input.mano:focus { background: rgba(63, 107, 85, .08); }
.pasar {
  flex: none; min-width: 30px;
  font: inherit; font-size: 15px; color: var(--verde);
  background: transparent; border: 1px solid var(--verde); border-radius: 3px 8px 3px 7px;
  padding: 1px 7px; margin-bottom: 3px; cursor: pointer; white-space: nowrap;
}
.pasar:disabled { opacity: .4; cursor: default; border-style: dashed; }
.vieja .mano { font-size: clamp(15.5px, 4.6vw, 21px); }
.pista { margin: 8px 0 0; }
.cuenta { font-size: 13.5px; color: var(--gris); margin: -6px 0 4px; text-align: right; }
.aviso { color: var(--verde); font-style: italic; min-height: 1.4em; margin: 4px 0; }

/* ---------- Recuerdos del día ---------- */
.recuerdos { border-left: 2px solid var(--tinta); padding: 2px 0 2px 12px; margin: 14px 0; }
.recuerdos summary { cursor: pointer; font-weight: 600; }
.recuerdos ul { margin: 8px 0 0; padding-left: 18px; }
.recuerdos li { margin-bottom: 6px; font-size: 15.5px; line-height: 1.45; }

/* ---------- Carta ---------- */
.texto.carta {
  background: var(--hoja); border: 1px solid #d9ceb0;
  box-shadow: 2px 3px 0 rgba(42, 36, 32, .08);
  padding: 14px 16px 6px; margin: 12px 0; transform: rotate(-.4deg);
}
.texto.carta p { font-family: Caveat, 'Segoe Script', cursive; font-size: 22px; line-height: 1.28; }

/* ---------- Modal ---------- */
.velo {
  position: fixed; inset: 0; background: rgba(42, 36, 32, .5);
  display: flex; align-items: flex-end; justify-content: center; z-index: 10;
  animation: aparece .2s ease both;
}
@keyframes aparece { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--papel); width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto;
  padding: 14px max(16px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); border-top: 2px solid var(--tinta);
  border-radius: 10px 10px 0 0;
}
.modal h3 { margin: 0 0 2px; font-size: 19px; font-weight: 600; }
.dehoy { margin: 4px 0 10px; }
.dehoy .boton { padding: 8px 12px; margin: 6px 0; font-size: 15.5px; }
@media (min-width: 560px) { .velo { align-items: center; } .modal { border: 1px solid var(--tinta); border-radius: 4px 12px 5px 13px; } }

/* ---------- Noche y final ---------- */
.oscuro { padding: 56px 0 20px; text-align: center; font-style: italic; }
.fin { border-top: 1px solid var(--tinta); margin-top: 22px; padding-top: 14px; text-align: center; }
.fin-eti { font-size: 12.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--verde); }
.fin p { margin: 6px 0; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
