/* ==========================================
   LifeLine v5 — BitLife-Style Layout
   ========================================== */

:root {
  --happiness: #f59e0b;
  --health: #ef4444;
  --smarts: #3b82f6;
  --looks: #ec4899;
  --money: #22c55e;
  --bg-dark: #0a0a0f;
  --bg-card: #12121a;
  --bg-surface: #1a1a26;
  --accent: #8b5cf6;
  --tab-height: 60px;
  --topbar-height: 56px;
  --text-primary: #e2e2e8;
  --text-secondary: rgba(160, 160, 176, 0.6);
  --text-muted: #6b7280;
  --border-color: rgba(255,255,255,0.05);
  --border-hover: rgba(139, 92, 246, 0.2);
  --input-bg: var(--bg-surface);
  --input-border: rgba(255,255,255,0.08);
  --glow-bg: rgba(139, 92, 246, 0.06);
  --glow-bg2: rgba(59, 130, 246, 0.04);
}

[data-theme="light"] {
  --bg-dark: #f0f2f5;
  --bg-card: #ffffff;
  --bg-surface: #f5f5f7;
  --text-primary: #1a1a2e;
  --text-secondary: rgba(80, 80, 100, 0.7);
  --text-muted: #555566;
  --border-color: rgba(0,0,0,0.10);
  --border-hover: rgba(139, 92, 246, 0.3);
  --input-bg: #f0f0f5;
  --input-border: rgba(0,0,0,0.15);
  --glow-bg: rgba(139, 92, 246, 0.04);
  --glow-bg2: rgba(59, 130, 246, 0.03);
}

/* Light mode text overrides for Tailwind and inline styles */
[data-theme="light"] .text-gray-500,
[data-theme="light"] .text-gray-400 {
  color: #555566 !important;
}

[data-theme="light"] .text-xs,
[data-theme="light"] .text-sm,
[data-theme="light"] .text-lg,
[data-theme="light"] .text-xl,
[data-theme="light"] .font-semibold,
[data-theme="light"] .font-bold {
  color: inherit;
}

[data-theme="light"] {
  color: #1a1a2e;
}

[data-theme="light"] .card,
[data-theme="light"] .card-inner,
[data-theme="light"] .stats-panel,
[data-theme="light"] .top-bar,
[data-theme="light"] #settings-menu {
  color: #1a1a2e;
}

[data-theme="light"] .action-btn {
  color: #1a1a2e;
  border-color: rgba(0,0,0,0.08);
}

[data-theme="light"] .action-btn:hover {
  border-color: rgba(139, 92, 246, 0.3);
  background: rgba(139, 92, 246, 0.05);
}

[data-theme="light"] .action-meta {
  color: #666677 !important;
}

[data-theme="light"] .btn-secondary {
  color: #444455;
  background: #ebebf0;
  border-color: rgba(0,0,0,0.10);
}

[data-theme="light"] .feed-text,
[data-theme="light"] .feed-body {
  color: #1a1a2e;
}

[data-theme="light"] .label-mono {
  color: #666688;
}

[data-theme="light"] .stage-badge {
  background: rgba(139, 92, 246, 0.10);
  color: #7c3aed;
}

[data-theme="light"] .tab-item {
  color: #888899;
}

[data-theme="light"] .tab-item.active {
  color: #7c3aed;
}

[data-theme="light"] .stat-bar-bg,
[data-theme="light"] .mini-stat-bar {
  background: rgba(0,0,0,0.06);
}

[data-theme="light"] input[type="text"],
[data-theme="light"] select {
  background: #f0f0f5 !important;
  color: #1a1a2e !important;
  border-color: rgba(0,0,0,0.12) !important;
}

[data-theme="light"] .event-card {
  border-left-color: rgba(139, 92, 246, 0.4);
}

[data-theme="light"] .death-screen {
  background: #f0f2f5;
}

[data-theme="light"] .ach-item.ach-locked {
  opacity: 0.5;
}

[data-theme="light"] #age-btn {
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.2);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse at 20% 0%, var(--glow-bg) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, var(--glow-bg2) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* === Layout === */
.game-container {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 1.5rem 1rem;
}

.game-screen {
  padding-bottom: 140px; /* space for tab bar + age btn */
}

/* === Typography === */
.logo {
  font-family: 'Space Mono', monospace;
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #8b5cf6, #3b82f6, #8b5cf6);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 4s ease-in-out infinite;
}

.tagline {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 0.5rem;
}

.label-mono {
  display: block;
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

/* === Top Bar === */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 0.5rem;
}

.top-bar:hover {
  border-color: var(--border-hover);
}

.avatar {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border-radius: 10px;
  font-size: 1.2rem;
}

.stage-badge {
  font-family: 'Space Mono', monospace;
  font-size: 0.55rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
  display: inline-block;
}

.money-text {
  font-family: 'Space Mono', monospace;
  color: var(--money);
}

/* === Stats Panel (collapsible) === */
.stats-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: 0.5rem;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; max-height: 0; padding: 0 1rem; }
  to { opacity: 1; max-height: 300px; }
}

/* === Mini Stats === */
.mini-stats {
  display: flex;
  gap: 4px;
  margin-bottom: 0.75rem;
  padding: 0 2px;
}

.mini-stat-bar {
  flex: 1;
  height: 4px;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
  position: relative;
}

.mini-stat-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

/* === Cards === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  backdrop-filter: blur(10px);
}

.card-inner {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
}

/* === Main Content === */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 200px;
}

/* === Buttons === */
.btn-primary {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  border: none;
  color: white;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.85rem 2rem;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
  letter-spacing: 0.5px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(139, 92, 246, 0.45);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-surface);
  border: 1px solid var(--input-border);
  color: var(--text-muted);
  font-family: 'Outfit', sans-serif;
  font-weight: 500;
  font-size: 0.85rem;
  padding: 0.6rem 1.2rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.06);
  color: #e2e2e8;
}

.gender-btn {
  background: var(--bg-surface);
  border: 2px solid rgba(255,255,255,0.06);
  color: #a0a0b0;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  padding: 0.8rem 1.5rem;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.25s ease;
  flex: 1;
}

.gender-btn:hover { border-color: rgba(139, 92, 246, 0.4); color: #e2e2e8; }

.gender-btn.selected {
  border-color: #8b5cf6;
  background: rgba(139, 92, 246, 0.12);
  color: #fff;
}

/* === Action Buttons (in tabs) === */
.action-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  color: #e2e2e8;
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.action-btn:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.25);
  transform: translateX(3px);
}

.action-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.action-btn .action-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  font-size: 1rem;
  flex-shrink: 0;
}

.action-btn .action-meta {
  font-family: 'Space Mono', monospace;
  font-size: 0.6rem;
  color: rgba(160, 160, 176, 0.5);
}

/* === Choice Buttons === */
.choice-btn {
  background: var(--bg-surface);
  border: 1px solid rgba(255,255,255,0.08);
  color: #e2e2e8;
  font-family: 'Outfit', sans-serif;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
}

.choice-btn:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.3);
  transform: translateX(4px);
}

.choice-btn:disabled {
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.35;
}

/* === Floating Age Button === */
.age-btn-floating {
  position: fixed;
  bottom: calc(var(--tab-height) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  max-width: 480px;
  width: calc(100% - 2rem);
}

.btn-age-float {
  width: 100%;
  font-size: 1rem;
  padding: 0.8rem;
  border-radius: 12px;
}

/* === Bottom Tab Bar === */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  max-width: 480px;
  width: 100%;
  height: var(--tab-height);
  background: var(--bg-card);
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 30;
  padding: 0 0.25rem;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: none;
  border: none;
  color: rgba(160, 160, 176, 0.5);
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 8px;
  min-width: 56px;
  font-family: 'Outfit', sans-serif;
}

.tab-item:hover { color: rgba(160, 160, 176, 0.8); }

.tab-item.active {
  color: #a78bfa;
}

.tab-icon { font-size: 1.2rem; line-height: 1; }
.tab-label { font-size: 0.6rem; font-weight: 600; letter-spacing: 0.3px; }

/* === Stat Bars === */
.stat-bar-bg {
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.stat-change {
  animation: popIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  font-weight: 700;
}

/* === Input === */
input[type="text"] {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  outline: none;
  width: 100%;
  transition: border-color 0.2s ease;
}

input[type="text"]:focus { border-color: rgba(139, 92, 246, 0.5); }

/* === Event Log === */
.event-log {
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(139, 92, 246, 0.3) transparent;
}

.event-log::-webkit-scrollbar { width: 3px; }
.event-log::-webkit-scrollbar-track { background: transparent; }
.event-log::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.3); border-radius: 4px; }

/* === Section Headers in Tabs === */
.section-header {
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(160, 160, 176, 0.4);
  padding: 0.5rem 0 0.25rem 0;
}

/* === Animations === */
@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.5) translateY(8px); }
  60% { transform: scale(1.2) translateY(-2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.event-card { animation: slideUp 0.3s cubic-bezier(0.22, 1, 0.36, 1); }
.fade-in { animation: fadeIn 0.6s ease; }
.death-screen { animation: fadeIn 1.5s ease; }

#event-area .card + .card { margin-top: 0.5rem; }
#tab-content .card + .card { margin-top: 0.5rem; }

/* === Year Summary Feed === */
.year-header {
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: #c4c4d0;
  padding: 0.5rem 0;
  line-height: 1.4;
}

.feed-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 12px;
  margin-bottom: 0.4rem;
}

.feed-icon {
  font-size: 1rem;
  line-height: 1.4;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.feed-body {
  flex: 1;
  min-width: 0;
}

.feed-text {
  font-size: 0.82rem;
  color: #c8c8d4;
  line-height: 1.45;
}

.feed-badge {
  display: inline-block;
  font-family: 'Space Mono', monospace;
  font-size: 0.55rem;
  letter-spacing: 1px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-bottom: 3px;
}

/* ===== CHOICE MODAL ===== */
.choice-modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: calc(var(--tab-height) + 16px);
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.choice-modal-overlay.visible { opacity: 1; pointer-events: all; }
.choice-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.72); backdrop-filter: blur(5px);
}
.choice-modal-card {
  position: relative; z-index: 1;
  background: var(--bg-card); border: 1px solid rgba(255,255,255,0.08);
  border-top: 3px solid #8b5cf6; border-radius: 20px 20px 14px 14px;
  padding: 1.5rem 1.25rem 1.25rem; max-width: 460px; width: calc(100% - 2rem);
  box-shadow: 0 -8px 40px rgba(0,0,0,0.55);
  animation: slideUpModal 0.35s cubic-bezier(0.22,1,0.36,1);
}
@keyframes slideUpModal {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.choice-modal-icon { font-size: 2rem; text-align: center; margin-bottom: 0.6rem; }
.choice-modal-text { font-size: 1rem; font-weight: 600; color: #e8e8f0; text-align: center; line-height: 1.5; margin-bottom: 1rem; }
.choice-modal-divider { height: 1px; background: rgba(255,255,255,0.06); margin-bottom: 0.75rem; }
.choice-modal-choices { display: flex; flex-direction: column; gap: 0.45rem; }
.choice-modal-btn {
  display: flex; flex-direction: column; gap: 2px; width: 100%;
  padding: 0.8rem 1rem; background: var(--bg-surface);
  border: 1px solid rgba(255,255,255,0.07); border-radius: 14px;
  cursor: pointer; text-align: left; transition: all 0.18s ease;
}
.choice-modal-btn:hover {
  background: rgba(139,92,246,0.1); border-color: var(--btn-accent, #8b5cf6);
  transform: translateX(4px);
}
.choice-modal-btn:active { transform: translateX(2px) scale(0.99); }
.choice-modal-btn-text { font-family: 'Outfit', sans-serif; font-size: 0.9rem; font-weight: 600; color: #e2e2e8; }
.choice-modal-btn-effect { font-family: 'Space Mono', monospace; font-size: 0.58rem; color: rgba(160,160,176,0.5); }
.choice-modal-hint { font-family: 'Space Mono', monospace; font-size: 0.52rem; letter-spacing: 1px; text-transform: uppercase; color: rgba(160,160,176,0.28); text-align: center; margin-top: 0.8rem; }

/* ===== ACHIEVEMENT TOAST ===== */
.ach-toast {
  position: fixed; top: 16px; left: 50%;
  transform: translateX(-50%) translateY(-90px); z-index: 200;
  max-width: 360px; width: calc(100% - 2rem);
  background: var(--bg-card); border: 1px solid rgba(139,92,246,0.35);
  border-radius: 14px; box-shadow: 0 4px 24px rgba(139,92,246,0.25);
  transition: transform 0.4s cubic-bezier(0.22,1,0.36,1), opacity 0.4s ease;
  opacity: 0; pointer-events: none;
}
.ach-toast.visible { transform: translateX(-50%) translateY(0); opacity: 1; }
.ach-toast-inner { display: flex; align-items: center; gap: 0.75rem; padding: 0.85rem 1rem; }
.ach-toast-icon { font-size: 1.6rem; flex-shrink: 0; }
.ach-toast-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.ach-toast-label { font-family: 'Space Mono', monospace; font-size: 0.52rem; letter-spacing: 1.5px; text-transform: uppercase; color: #a78bfa; }
.ach-toast-name { font-size: 0.9rem; font-weight: 700; color: #e8e8f0; }
.ach-toast-sparkle { font-size: 1.2rem; animation: spinY 1.5s linear infinite; }
@keyframes spinY { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ===== ACHIEVEMENTS TAB ===== */
.ach-grid { display: flex; flex-direction: column; gap: 0.45rem; }
.ach-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.7rem 0.9rem; border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.05); position: relative;
}
.ach-earned { background: rgba(139,92,246,0.07); border-color: rgba(139,92,246,0.18); }
.ach-locked { background: var(--bg-card); opacity: 0.38; }
.ach-icon-wrap {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  background: var(--bg-surface); border-radius: 10px; font-size: 1.2rem; flex-shrink: 0;
}
.ach-details { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.ach-name { font-size: 0.85rem; font-weight: 600; color: #e2e2e8; }
.ach-desc { font-size: 0.72rem; color: rgba(160,160,176,0.6); line-height: 1.3; }
.ach-check { font-family: 'Space Mono', monospace; font-size: 0.7rem; color: #a78bfa; font-weight: 700; }