/* styles.css — Shell mínimo, responsive, y carteles */

:root{
  --bg: #0b0f16;
  --panel: #101827;
  --panel2: #0f172a;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --line: rgba(148,163,184,.18);

  --accent: #60a5fa;
  --accent2: #a78bfa;

  --radius: 14px;
  --shadow: 0 16px 40px rgba(0,0,0,.35);
  --shadow2: 0 10px 20px rgba(0,0,0,.28);

  --wrap: 980px;
  --header-h: 60px;   /* ajusta si hace falta */
  --lives-h: 40px;    /* ajusta si hace falta */
  --footer-h:40px;    /* ajusta si hace falta */
}

*{ box-sizing:border-box; }
html, body{
  height: 100%;
  overflow: hidden; /* <- clave */
}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  line-height:1.35;
  display:flex;
  flex-direction:column;

  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 20% 0%, rgba(96,165,250,.16), transparent 60%),
    radial-gradient(900px 500px at 90% 20%, rgba(167,139,250,.14), transparent 55%);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center top;
  background-attachment: fixed; /* <- CLAVE: fondo fijo */
}

.wrap{
  max-width: var(--wrap);
  margin: 0 auto;
  width: 100%;
}
.app-main > .wrap{
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Header */
.app-header{
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 40;
  background: rgba(11,15,22,.7);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-wrap{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  padding: 12px 5px;
}
.brand{
  display:flex;
  align-items:center;
  gap: 10px;
  min-width: 0;
}
.logo{
  width: 36px; height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(96,165,250,.95), rgba(167,139,250,.95));
  box-shadow: var(--shadow2);
}
.brand-text{ min-width: 0; }
.brand-title{
  font-weight: 800;
  letter-spacing: .2px;
  font-size: 15px;
}
.brand-subtitle{
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 48vw;
}

/* Main */
.app-main{
  padding-top: calc(var(--header-h) + var(--lives-h));
  height: 100vh;                 /* body no scrollea */
  padding-bottom: var(--footer-h);
  box-sizing: border-box;
}

/* Lives */
.lives-wrap{ width: 100%; }
.lives-bar{
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  z-index: 39;
  margin: 0;
  padding: 8px 12px;
  background: rgba(11,15,22,.70);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.lives-hearts{
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  color: #ffffff;
  user-select: none;
}
.heart{
  font-size: 22px;
  line-height: 1;
  user-select: none;
}
.heart.off{
  opacity: .18;
  filter: grayscale(1);
}

/* Footer */
.app-footer{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  border-top: 1px solid var(--line);
  background: rgba(11,15,22,.85);
  backdrop-filter: blur(8px);
}

.footer-wrap{
  display:flex;
  justify-content:space-between;
  gap: 10px;

  /* CAMBIO 1: padding lateral real para que no se corte el texto */
  padding: 12px 12px;

  font-size: 13px;

  /* CAMBIO 2: fuera márgenes que acercan el contenido al borde */
  margin-left: 0;
  margin-right: 0;
}

.muted{ color: var(--muted); }

/* Buttons */
.btn{
  appearance:none;
  border: 1px solid rgba(148,163,184,.24);
  background: rgba(15,23,42,.65);
  color: var(--text);
  border-radius: 12px;
  padding: 9px 12px;
  font-weight: 650;
  cursor:pointer;
  box-shadow: 0 8px 18px rgba(0,0,0,.18);
  transition: transform .06s ease, filter .15s ease, border-color .15s ease;
}
.btn:hover{ filter: brightness(1.08); border-color: rgba(148,163,184,.36); }
.btn:active{ transform: translateY(1px); }
.btn:focus-visible{ outline: 2px solid rgba(96,165,250,.75); outline-offset: 2px; }

/* Responsive tweaks */
@media (max-width: 720px){
  .header-wrap{
    flex-direction: row;        /* <- NO columna */
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .header-actions{
    width: auto;                /* <- no ocupa toda la línea */
    justify-content: flex-end;
    flex-shrink: 0;
  }

  .brand-subtitle{
    max-width: 55vw;            /* <- evita que empuje el botón */
  }
}
@media (max-width: 420px){
  #btnHeaderStats{ padding: 8px 10px; }
}

/* =========================
   Carteles (Poster System)
   ========================= */

#poster-root{
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
}
.poster-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(6px);
  pointer-events: none;
  opacity: 0;
  transition: opacity .16s ease;
}
.poster-body{
margin: 12px 0;
}
.poster-layer{
  position: absolute;
  inset: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 16px;
  pointer-events: none;
}
.poster{
  width: min(520px, 100%);
  background: rgba(16,24,39,.92);
  border: 1px solid rgba(148,163,184,.22);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow);
  pointer-events: none;
  transform: translateY(10px) scale(.99);
  opacity: 0;
  transition: transform .16s ease, opacity .16s ease;
}
#poster-root[data-open="1"]{ pointer-events: auto; }
#poster-root[data-open="1"] .poster-backdrop,
#poster-root[data-open="1"] .poster{ pointer-events: auto; }
#poster-root[data-open="1"] .poster-backdrop{ opacity: 1; }
#poster-root[data-open="1"] .poster{ opacity: 1; transform: translateY(0) scale(1); }

/* ===== Calendario scroll (mobile-first) ===== */
.calendar-card{
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.calendar-scroll{
  flex: 1;
  min-height: 0;
  overflow: auto;            /* <- único scroll */
  -webkit-overflow-scrolling: touch;
}
.calendar-list{
  display: grid;
  margin: 12px;
  grid-template-columns: 1fr;
  gap: 10px;
}
.calendar-end{
  margin-top: 10px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 10px 6px 2px;
}
@media (min-width: 680px){
  .calendar-list{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ===== Day screen ===== */
.day-view{
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(15,23,42,.35);
  padding: 14px;
  margin:12px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.day-view-head{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 0px;
  margin-bottom: 12px;
}
.day-view-title{
  font-weight: 900;
  letter-spacing: .2px;
}
.day-view-body{
  border: 1px dashed rgba(148,163,184,.25);
  border-radius: 12px;
  background: rgba(15,23,42,.25);
  padding: 12px;
  margin: 0px 12px;
}

/* ===== Day Row (botón bonito) ===== */
.day-row{
  width: 100%;
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;

  padding: 14px 14px;
  border-radius: 14px;
  border: 1px solid rgba(148,163,184,.18);
  background: rgba(15,23,42,.52);

  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;

  transition: transform .06s ease, filter .15s ease, border-color .15s ease;
}
.day-row:hover{
  filter: brightness(1.06);
  border-color: rgba(148,163,184,.30);
}
.day-row:active{ transform: translateY(1px); }
.day-row:focus-visible{
  outline: 2px solid rgba(96,165,250,.75);
  outline-offset: 2px;
}

.day-left{
  display:flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.day-iso{
  font-weight: 900;
  letter-spacing: .2px;
  font-size: 15px;
}
.day-sub{
  color: rgba(229,231,235,.72);
  font-size: 12px;
}

.day-right{
  display:flex;
  align-items:center;
  gap: 10px;
  flex-shrink: 0;
}
.day-badge{
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display:flex;
  align-items:center;
  justify-content:center;
  border: 1px solid rgba(148,163,184,.22);
  background: rgba(0,0,0,.22);
  color: rgba(229,231,235,.92);
  font-weight: 900;
}
.day-cta{
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(148,163,184,.20);
  background: rgba(15,23,42,.55);
  font-weight: 800;
  font-size: 13px;
}

/* Disabled pero legible */
.day-row:disabled{
  cursor: not-allowed;
  opacity: 1;
  filter: none;
  border-color: rgba(148,163,184,.12);
  background: rgba(15,23,42,.40);
}
.day-row:disabled .day-iso{ color: rgba(229,231,235,.72); }
.day-row:disabled .day-sub{ color: rgba(148,163,184,.60); }
.day-row:disabled .day-cta{ opacity: .65; }

/* Hoy */
.day-row[data-iso="__TODAY__"]{
  border-color: rgba(96,165,250,.35);
}
/* ===== STATS ===== */
.stats-screen{
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.stats-card{
  flex: 1;
  min-height: 0;
  margin: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(15,23,42,.35);
  padding: 14px;
  display:flex;
  flex-direction: column;
  gap: 14px;
}
.stats-head{
  display:flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.stats-title{
  font-weight: 900;
  letter-spacing: .2px;
}
.stats-sub{
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.stats-grid{
  display:grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 680px){
  .stats-grid{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.stat{
  border: 1px solid rgba(148,163,184,.18);
  background: rgba(15,23,42,.45);
  border-radius: 14px;
  padding: 12px;
}
.stat-k{
  color: rgba(148,163,184,.85);
  font-size: 12px;
  margin-bottom: 6px;
}
.stat-v{
  font-weight: 900;
  font-size: 18px;
}
.stats-actions{
  margin-top: auto;
  display:flex;
  justify-content: flex-end;
}
.day-topbar{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 10px;
  border: 1px solid rgba(148,163,184,.18);
  background: rgba(15,23,42,.45);
  border-radius: 14px;
  margin: 12px;
}

.day-topbar-left{
  display:flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.day-topbar-date{
  font-weight: 900;
  letter-spacing: .2px;
}

.day-topbar-author{
  font-size: 12px;
  color: rgba(229,231,235,.78);
  display:flex;
  gap: 6px;
  min-width: 0;
}

#dayTopbarAuthor{
  color: rgba(229,231,235,.92);
  text-decoration: none;
  border-bottom: 1px dashed rgba(148,163,184,.35);
  max-width: 58vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-topbar-btn{
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius: 12px;
  border: 1px solid rgba(148,163,184,.20);
  background: rgba(15,23,42,.55);
  color: rgba(229,231,235,.92);
  text-decoration: none;
}
/* ===== Day layout: header fuera + cuerpo scroll ===== */
.day-screen{
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.day-topbar{
  position: sticky; /* fijo dentro de la pantalla del día */
  top: 0;
  z-index: 5;
  padding: 12px;
  background: rgba(11,15,22,.35);
  backdrop-filter: blur(8px);
}

.day-topbar-inner{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 12px;
  padding: 10px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(148,163,184,.18);
  background: rgba(15,23,42,.45);
}

.day-topbar-date{
  font-weight: 900;
  letter-spacing: .2px;
}

.day-topbar-authorline{
  display: flex;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.day-topbar-author{
  color: rgba(229,231,235,.9);
  text-decoration: none;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}
.day-topbar-author:hover{ text-decoration: underline; }

.day-topbar-link{
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid rgba(148,163,184,.20);
  background: rgba(15,23,42,.55);
  color: rgba(229,231,235,.92);
  text-decoration: none;
  font-weight: 900;
}

.day-body{
  flex: 1;
  min-height: 0;
  overflow: auto;                 /* único scroll del día */
  -webkit-overflow-scrolling: touch;
  padding: 0 12px 12px;
}

.day-root{
  min-height: 200px;
}
.day-game-wrap{
  min-height: 0;
  margin:0px 12px; 
  display: flex;
  justify-content: center; /* centra horizontal */
}

.day-game{
  width: 100%;     /* “cuadradito” bonito en móvil */
  border-radius: 18px;
  padding:12px;
  border: 1px solid rgba(148,163,184,.18);
  background: rgba(15,23,42,.35);
  box-shadow: 0 10px 24px rgba(0,0,0,.25);
  position: relative;
}

/* Si el juego mete un canvas o algo grande, que no desborde */
.day-game canvas,
.day-game img,
.day-game video{
  display: block;
  max-width: 100%;
}
.day-topbar-btn:active{ transform: translateY(1px); }
/* ===== Pantallas: SOLO 1 visible (sin hidden attribute) ===== */
#viewCalendar, #viewDay, #viewStats{ display: none; }
body[data-screen="calendar"] #viewCalendar{ display: flex; }
body[data-screen="day"] #viewDay{ display: flex; }
body[data-screen="stats"] #viewStats{ display: flex; }

/* Animación al perder vida */
.heart.pop-off{
  animation: heartPopOff 420ms cubic-bezier(.2,.9,.2,1) both;
  transform-origin: center;
  filter: none;      /* fuerza estado “vivo” al inicio */
  opacity: 1;
}

@keyframes heartPopOff{
  0%   { transform: scale(1);    opacity: 1;   filter: none; }
  45%  { transform: scale(1.65); opacity: 1;   filter: none; }
  100% { transform: scale(1);    opacity: .18; filter: grayscale(1); }
}
.lives-hearts.shake{
  animation: livesShake 260ms cubic-bezier(.2,.9,.2,1);
}

@keyframes livesShake{
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-6px); }
  40%  { transform: translateX(6px); }
  60%  { transform: translateX(-4px); }
  80%  { transform: translateX(4px); }
  100% { transform: translateX(0); }
}