* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: #e8ecff;
  user-select: none;
  -webkit-user-select: none;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  background: radial-gradient(circle at top, #1b2150 0%, #0b0e24 70%) fixed;
}

input { user-select: text; -webkit-user-select: text; }
button { font: inherit; }

.app-container {
  margin: 0 auto;
  min-height: 100vh;
  max-width: 1440px;
  width: 96vw;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.mute-btn {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 1200;
  width: 2.6rem;
  height: 2.6rem;
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(6px);
}
.mute-btn:hover { background: rgba(129, 140, 248, 0.35); }

.topbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.75rem; }
.topbar h1 {
  margin: 0;
  font-size: 1.6rem;
  background: linear-gradient(90deg, #5eead4, #818cf8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.time-badge {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-weight: 600;
}
.time-badge .age { color: #5eead4; }
.time-badge .job-search { color: #fca5a5; font-weight: 700; }

.back-btn {
  padding: 0.4rem 0.9rem;
  color: #e8ecff;
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
}
.back-btn:hover { background: rgba(129, 140, 248, 0.35); }

.finish-btn {
  padding: 0.3rem 0.8rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #10b981, #059669);
}

.select-subtitle { margin: 0; color: #aab3d6; }

.menu-options { flex: 1; display: flex; justify-content: center; align-items: center; gap: 1.5rem; }
.menu-options .action-item { width: min(240px, 40vw); aspect-ratio: 1; font-size: 1.5rem; border-radius: 20px; }

/* ---- Carrusel de personajes ---- */
.carousel { position: relative; }
.character-select {
  display: flex;
  gap: 1rem;
  padding: 0.5rem 0.25rem 0.75rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}
.char-card {
  flex: 0 0 min(290px, 78vw);
  scroll-snap-align: center;
  padding: 1.5rem 1.25rem;
  text-align: left;
  color: #e8ecff;
  cursor: pointer;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.char-card:hover { transform: translateY(-4px); border-color: #818cf8; }
.char-card.special { background: linear-gradient(160deg, rgba(34, 197, 94, 0.28), rgba(21, 128, 61, 0.2)); border-color: rgba(74, 222, 128, 0.55); }
.char-card.violet { background: linear-gradient(160deg, rgba(168, 85, 247, 0.3), rgba(109, 40, 217, 0.22)); border-color: rgba(192, 132, 252, 0.6); }
.char-emoji { font-size: 3rem; text-align: center; }
.char-name { font-size: 1.3rem; font-weight: 700; text-align: center; }
.char-role { color: #aab3d6; text-align: center; margin-bottom: 0.4rem; }
.char-desc { font-size: 0.85rem; color: #c8cfee; text-align: center; margin-bottom: 0.8rem; min-height: 4.2em; }

.carousel-btn {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 2.6rem;
  height: 2.6rem;
  margin-top: -1.3rem;
  font-size: 1.8rem;
  line-height: 1;
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(20, 24, 58, 0.85);
}
.carousel-btn:hover { background: rgba(129, 140, 248, 0.6); }
.carousel-btn.prev { left: -0.4rem; }
.carousel-btn.next { right: -0.4rem; }

/* ---- Tarjetas ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; }
.goal-card { grid-column: 1 / -1; }

.card {
  padding: 1.1rem 1.25rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.card-title { font-weight: 700; margin-bottom: 0.75rem; color: #c7d2fe; }
.card-title .card-summary { display: none; }

.stat { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.35rem 0; color: #aab3d6; }
.stat strong { color: #fff; text-align: right; }
.stat .pos, .pos { color: #4ade80 !important; }
.stat .neg, .neg { color: #f87171 !important; }
.stat.total { margin-top: 0.4rem; padding-top: 0.6rem; border-top: 1px dashed rgba(255, 255, 255, 0.2); }
.stat.total strong { color: #5eead4; font-size: 1.1rem; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 0.4rem; }
.dot.invest, .seg.invest { background: #10b981; }
.dot.fixed, .seg.fixed { background: #f59e0b; }
.dot.save, .seg.save { background: #3b82f6; }
.dot.free { background: #64748b; }
.dot.debt, .seg.debt { background: #ef4444; }

.alloc-bar { display: flex; height: 8px; margin-top: 0.6rem; border-radius: 999px; overflow: hidden; background: #64748b; position: relative; }
.alloc-bar .seg { transition: width 0.3s ease; }
.alloc-bar.goal-bar { height: 12px; background: rgba(255, 255, 255, 0.12); }
.goal-tick { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(255, 255, 255, 0.5); }
.goal-tick.reached { background: #fde68a; }
.goal-ticks-labels { position: relative; height: 1rem; margin-bottom: 0.2rem; font-size: 0.7rem; color: #aab3d6; }
.goal-ticks-labels span { position: absolute; transform: translateX(-50%); }
.goal-ticks-labels span.reached { color: #fde68a; font-weight: 700; }
.alloc-bar.stress-bar { background: rgba(255, 255, 255, 0.12); }
.seg.stress { background: linear-gradient(90deg, #f59e0b, #ef4444); }

/* ---- Botones ---- */
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; }
.advance-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }

.action-item {
  padding: 0.8rem;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease, filter 0.15s ease;
}
.action-item:hover { transform: translateY(-2px); filter: brightness(1.12); }
.action-item:active { transform: translateY(0) scale(0.98); }
.action-item.invest { background: linear-gradient(135deg, #10b981, #059669); }
.action-item.save { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.action-item.hours { background: linear-gradient(135deg, #f59e0b, #d97706); }
.action-item.business { background: linear-gradient(135deg, #a855f7, #7e22ce); }
.action-item:disabled { cursor: not-allowed; opacity: 0.45; filter: grayscale(1); box-shadow: none; transform: none; }
.next-month { font-size: 1.15rem; padding: 0.9rem; background: linear-gradient(135deg, #6366f1, #ec4899); }

.pay-debt-btn {
  width: 100%;
  margin: 0.4rem 0;
  padding: 0.55rem 0.8rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #ef4444, #b91c1c);
}
.pay-debt-btn:hover:not(:disabled) { filter: brightness(1.12); }
.pay-debt-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.clear-stats {
  align-self: flex-start;
  padding: 0.4rem 0.8rem;
  color: #fca5a5;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid rgba(248, 113, 113, 0.4);
  background: transparent;
}
.clear-stats:hover { background: rgba(248, 113, 113, 0.15); }

/* ---- Modales ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 25, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fade 0.2s ease;
}
.notice-overlay { z-index: 1100; }
.modal { position: relative; width: 90%; max-width: 420px; }
.summary-modal { max-width: 760px; }

.modal-content {
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.75rem;
  color: #fff;
  background: linear-gradient(160deg, #1e2347, #14183a);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  animation: pop 0.2s ease;
}
.modal-content h2 { margin: 0 0 0.25rem; }
.modal-content p { color: #aab3d6; margin: 0 0 1rem; }
.modal-content .close { position: absolute; top: 10px; right: 16px; cursor: pointer; font-size: 1.6rem; color: #aab3d6; }
.modal-content .close:hover { color: #fff; }

.modal-content input, .modal-content select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  font-size: 1rem;
  color: #fff;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}
.modal-content input:focus, .modal-content select:focus { border-color: #818cf8; box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.3); }
.modal-content option { color: #111; }
.modal-content input[type=number] { appearance: textfield; -moz-appearance: textfield; }
.modal-content input::-webkit-outer-spin-button, .modal-content input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.accept {
  width: 100%;
  padding: 0.8rem;
  font-weight: 700;
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}
.accept:hover { filter: brightness(1.15); }
.accept:disabled { opacity: 0.45; cursor: not-allowed; }
.accept.secondary { margin-top: 0.6rem; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.25); }

.fill-all {
  padding: 0 0.5rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.1);
}
.fill-all:hover { background: rgba(129, 140, 248, 0.4); }

.input-row { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.manage-row { display: grid; grid-template-columns: 1fr 6rem; gap: 0.5rem; align-items: stretch; margin: 0.5rem 0; }
.manage-row label { align-self: center; line-height: 1.25; }
.manage-row.has-actions { grid-template-columns: 1fr 5.5rem 4rem 4rem; }
.modal-content .accept { margin-top: 0.6rem; }

.alloc-info { margin: 0 0 1rem; padding: 0.6rem 0.9rem 0.6rem 1.8rem; font-size: 0.9rem; color: #aab3d6; border-radius: 10px; background: rgba(255, 255, 255, 0.05); border: 1px dashed rgba(255, 255, 255, 0.2); }
.alloc-info li { margin: 0.15rem 0; }
.alloc-info li:last-child { color: #5eead4; font-weight: 600; }
.alloc-info .neg { color: #f87171; }

.modal-content.notice { text-align: center; }
.notice-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.death-note { font-style: italic; color: #fca5a5 !important; }
.modal-content.notice.success { border-color: #4ade80; box-shadow: 0 20px 50px rgba(74, 222, 128, 0.25); }
.modal-content.notice.success h2 { color: #4ade80; }
.modal-content.notice.success .accept:not(.secondary) { background: linear-gradient(135deg, #10b981, #059669); }
.modal-content.notice.warning { border-color: #fbbf24; box-shadow: 0 20px 50px rgba(251, 191, 36, 0.25); }
.modal-content.notice.warning h2 { color: #fbbf24; }
.modal-content.notice.warning .accept:not(.secondary) { background: linear-gradient(135deg, #f59e0b, #d97706); }
.modal-content.notice.error { border-color: #f87171; box-shadow: 0 20px 50px rgba(248, 113, 113, 0.25); }
.modal-content.notice.error h2 { color: #f87171; }
.modal-content.notice.error .accept:not(.secondary) { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.notice-list { text-align: left; color: #aab3d6; margin: 0 0 1rem; padding-left: 1.2rem; }

.purchase-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px dashed rgba(255, 255, 255, 0.15); }
.purchase-row small { display: block; color: #aab3d6; }
.purchase-row .accept { width: auto; margin: 0; padding: 0.4rem 0.9rem; }

/* ---- Resumen ---- */
.detail-toggle { margin-bottom: 0.8rem; padding: 0.45rem 0.9rem; font-weight: 600; color: #e8ecff; cursor: pointer; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.08); }
.detail-toggle:hover { background: rgba(129, 140, 248, 0.35); }
.interruption { display: flex; gap: 0.7rem; align-items: flex-start; margin-bottom: 0.8rem; padding: 0.7rem 0.9rem; border-radius: 12px; font-size: 0.92rem; border: 2px solid #fbbf24; background: rgba(251, 191, 36, 0.12); text-align: left; }
.interruption.business { border-color: #a855f7; background: rgba(168, 85, 247, 0.16); }
.interruption.raise { border-color: #4ade80; background: rgba(74, 222, 128, 0.14); }
.interruption.layoff { border-color: #f87171; background: rgba(248, 113, 113, 0.16); }
.interruption-icon { font-size: 1.8rem; }
.summary-month { padding: 0.7rem 0.9rem; margin-bottom: 0.7rem; border-radius: 12px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); }
.summary-month-title { font-weight: 700; margin-bottom: 0.4rem; color: #c7d2fe; }
.summary-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.4rem; }
.chip { padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.85rem; background: rgba(255, 255, 255, 0.08); }
.chip.invest { color: #6ee7b7; } .chip.salary { color: #86efac; } .chip.save { color: #93c5fd; } .chip.spent { color: #fca5a5; } .chip.debt { color: #fdba74; }
.summary-event { display: flex; gap: 0.6rem; align-items: flex-start; margin-top: 0.4rem; padding: 0.45rem 0.6rem; border-radius: 10px; border-left: 4px solid #64748b; background: rgba(255, 255, 255, 0.04); font-size: 0.9rem; color: #aab3d6; text-align: left; }
.summary-event.warning { border-left-color: #fbbf24; }
.summary-event.success { border-left-color: #4ade80; }
.summary-event strong { color: #fff; }
.summary-icon { font-size: 1.5rem; }
.summary-totals { margin: 1rem 0; padding: 0.8rem 1rem; border-radius: 12px; background: rgba(99, 102, 241, 0.15); border: 1px solid rgba(129, 140, 248, 0.4); }
.summary-totals h3 { margin: 0 0 0.4rem; }

.stats-box { margin: 1rem 0; padding: 0.9rem 1.1rem; text-align: left; border-radius: 14px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.12); }
.stats-box h3 { margin: 0 0 0.5rem; color: #c7d2fe; }
.stats-empty { margin: 0; color: #aab3d6; font-size: 0.9rem; }
.stats-characters { margin-top: 0.5rem; padding-top: 0.4rem; border-top: 1px dashed rgba(255, 255, 255, 0.2); font-size: 0.88rem; }
.game-result { font-weight: 600; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Redibujado con el mismo modal abierto: sin animación ni desenfoque para evitar el parpadeo. */
.still .modal-overlay, .still .modal-content { animation: none; }

/* Pantallas grandes: bloques compactos. */
@media (min-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); gap: 0.75rem; }
  .card { padding: 0.8rem 1rem; }
  .card-title { margin-bottom: 0.4rem; }
  .stat { padding: 0.2rem 0; }
}

/* Celulares: paneles reducidos que se expanden al tocar. */
@media (max-width: 700px) {
  .app-container { width: 100%; padding: 0.75rem; gap: 0.8rem; }
  .topbar { padding-right: 3rem; }
  .topbar h1 { font-size: 1.25rem; }
  .time-badge { flex-wrap: wrap; justify-content: center; gap: 0.3rem 0.75rem; padding: 0.4rem 0.8rem; font-size: 0.9rem; }
  .menu-options { flex-direction: column; }
  .menu-options .action-item { width: min(260px, 70vw); font-size: 1.25rem; }
  .stat-grid { grid-template-columns: 1fr; gap: 0.5rem; }
  .card { padding: 0.7rem 1rem; }
  .card-title { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; cursor: pointer; }
  .card-title .card-summary { display: inline; margin-left: auto; font-weight: 600; color: #5eead4; }
  .card-title::after { content: '▾'; color: #aab3d6; }
  .card:not(.collapsed) .card-summary { display: none; }
  .card.collapsed .card-title { margin-bottom: 0; }
  .card.collapsed .card-title::after { content: '▸'; }
  .card.collapsed > :not(.card-title):not(.keep) { display: none; }
  .actions { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
  .advance-row { gap: 0.4rem; }
  .advance-row .action-item { padding: 0.7rem 0.2rem; font-size: 0.8rem; }
  .action-item { padding: 0.8rem 0.5rem; font-size: 0.95rem; }
  .carousel-btn { width: 2.2rem; height: 2.2rem; font-size: 1.5rem; margin-top: -1.1rem; }
  .carousel-btn.prev { left: 0; } .carousel-btn.next { right: 0; }
  .manage-row { grid-template-columns: 1fr 5rem; }
  .manage-row.has-actions { grid-template-columns: 1fr auto auto; }
  .manage-row.has-actions label { grid-column: 1 / -1; }
  .modal { width: 94%; }
  .modal-content { padding: 1.25rem; }
  .purchase-row { flex-wrap: wrap; }
  .mute-btn { width: 2.3rem; height: 2.3rem; font-size: 1.05rem; }
}
