:root {
  --bg-app: #090d16;
  --bg-card: #131a2a;
  --bg-card-hover: #1c263c;
  --border-card: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --color-happy: #f59e0b;
  --color-health: #10b981;
  --color-smarts: #3b82f6;
  --color-looks: #ec4899;
  --color-gold: #fbbf24;

  --radius-xl: 20px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-app);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-primary);
}

#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 680px;
  height: 100%;
  margin: 0 auto;
  position: relative;
  background-color: var(--bg-app);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.6);
}

/* Header Profile */
#profile-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-card);
  z-index: 10;
}

.profile-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-badge {
  font-size: 32px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-card);
}

.char-name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.char-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.bank-pill {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 6px 12px;
  border-radius: var(--radius-md);
}

.bank-label {
  font-size: 10px;
  font-weight: 800;
  color: #34d399;
  letter-spacing: 0.5px;
}

.bank-val {
  font-size: 15px;
  font-weight: 800;
  color: #10b981;
  font-variant-numeric: tabular-nums;
}

/* Stats Section */
#stats-section {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 18px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-card);
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
}

.stat-header strong {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.35s ease;
}

.fill-happy { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.fill-health { background: linear-gradient(90deg, #10b981, #34d399); }
.fill-smarts { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.fill-looks { background: linear-gradient(90deg, #ec4899, #f472b6); }

/* Main Chronicle Feed */
#chronicle {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 18px;
  -webkit-overflow-scrolling: touch;
}

#chronicle::-webkit-scrollbar {
  width: 5px;
}
#chronicle::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

#chronicle-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.year-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 6px;
  animation: fadeIn 0.25s ease;
}

.year-badge {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 3px 10px;
  border-radius: 12px;
}

.event-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  line-height: 1.45;
  font-size: 13.5px;
}

.event-icon {
  font-size: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.event-text {
  flex: 1;
  color: #e2e8f0;
}

.event-stat-delta {
  display: block;
  font-size: 11.5px;
  margin-top: 4px;
  font-weight: 600;
}

.delta-pos { color: #34d399; }
.delta-neg { color: #f87171; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Modals & Dialogs */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(4, 7, 13, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.hidden {
  display: none !important;
}

.decision-card, .obituary-card, .drawer-card {
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-xl);
  padding: 24px 20px;
  width: 100%;
  max-width: 440px;
  text-align: center;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.7);
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.decision-icon {
  font-size: 38px;
  margin-bottom: 8px;
}

.decision-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 8px;
}

.decision-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 20px;
}

.decision-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.opt-btn {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, transform 0.1s ease;
}

.opt-btn:hover {
  background: rgba(255, 255, 255, 0.13);
}

.opt-btn:active {
  transform: scale(0.98);
}

/* Activities Drawer */
.drawer-card {
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  text-align: left;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-card);
}

.drawer-header h2 {
  font-size: 18px;
  font-weight: 800;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}

.activities-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.act-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.act-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.act-icon {
  font-size: 24px;
}

.act-info strong {
  display: block;
  font-size: 14px;
  color: #fff;
}

.act-info small {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Obituary Card */
.tombstone-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.obit-title {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.obit-age {
  font-size: 15px;
  color: var(--color-gold);
  font-weight: 800;
  margin-bottom: 12px;
}

.obit-summary {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 20px;
}

.obit-stats {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 20px;
  text-align: left;
}

.obit-stat-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 13px;
}

.obit-stat-row:last-child {
  border-bottom: none;
}

.ribbon-badge {
  color: var(--color-gold);
}

.start-life-cta {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
}

/* Toolbar Footer */
#toolbar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 16px 14px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-card);
  z-index: 10;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
}

.tool-btn:hover {
  color: var(--text-primary);
}

.tool-icon {
  font-size: 20px;
}

.tool-label {
  font-size: 11px;
  font-weight: 700;
}

.age-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 30px;
  padding: 10px 24px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
  transform: translateY(-8px);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.age-btn:hover {
  transform: translateY(-10px) scale(1.03);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.5);
}

.age-btn:active {
  transform: translateY(-6px) scale(0.97);
}

.age-icon {
  font-size: 18px;
  font-weight: 900;
}

.age-text {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 1px;
}

