/* Life Restart AI — Mobile-first styles */

:root {
  --bg: #0f0f14;
  --bg-card: #1a1a24;
  --bg-card-alt: #22222f;
  --text: #f0f0f5;
  --text-muted: #9898a8;
  --accent: #7c5cff;
  --accent-glow: rgba(124, 92, 255, 0.35);
  --accent-2: #ff6b9d;
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f87171;
  --border: #2e2e3e;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(124, 92, 255, 0.12) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 100%, rgba(255, 107, 157, 0.08) 0%, transparent 55%);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
  overflow-x: hidden;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 32px;
  min-height: 100dvh;
}

/* Screens */
.screen {
  display: none;
  flex-direction: column;
  gap: 16px;
  animation: fadeIn 0.35s ease;
}

.screen.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Hero / Start */
.hero {
  text-align: center;
  padding: 32px 0 24px;
}

.logo {
  font-size: 4rem;
  line-height: 1;
  margin-bottom: 8px;
  animation: spin-slow 6s linear infinite;
}

@keyframes spin-slow {
  0%, 90% { transform: rotate(0deg); }
  95% { transform: rotate(360deg); }
  100% { transform: rotate(360deg); }
}

.hero h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 16px;
  line-height: 1.6;
}

/* Buttons */
.btn {
  display: block;
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #9b7fff);
  color: #fff;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent-2), #ff8fb5);
  color: #fff;
}

.btn-large {
  padding: 18px 24px;
  font-size: 1.1rem;
  margin-top: 8px;
}

.btn-choice {
  text-align: left;
  background: var(--bg-card-alt);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 14px 16px;
  font-weight: 500;
  font-size: 0.95rem;
  line-height: 1.45;
}

.btn-choice:hover,
.btn-choice:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
  outline: none;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.birth-card h2 {
  font-size: 1.25rem;
  margin-bottom: 8px;
}

.birth-intro {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.birth-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.birth-item {
  background: var(--bg-card-alt);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.birth-item.full-width {
  grid-column: 1 / -1;
}

.birth-item .label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.birth-item .value {
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 2px;
}

/* Stat bars */
.stat-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.stat-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

.stat-bar-row .stat-name {
  width: 90px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.stat-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.stat-bar-row .stat-num {
  width: 28px;
  text-align: right;
  font-weight: 600;
  font-size: 0.75rem;
}

/* Game header */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stage-badge {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
}

.age-display {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.age-display span {
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
}

/* Stats panel (compact) */
.stats-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-pill {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  text-align: center;
}

.stat-pill .pill-icon {
  font-size: 1rem;
}

.stat-pill .pill-value {
  font-size: 1rem;
  font-weight: 700;
  display: block;
}

.stat-pill .pill-label {
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* Event card */
.event-card {
  flex: 1;
}

.event-year {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 8px;
}

.event-text {
  font-size: 1.05rem;
  line-height: 1.65;
  margin-bottom: 20px;
  min-height: 60px;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.event-counter {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Result card — shareable style */
.result-card {
  background: linear-gradient(160deg, #1e1e2e 0%, #16161f 100%);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: 0 0 40px var(--accent-glow), var(--shadow);
  position: relative;
  overflow: hidden;
}

.result-card::before {
  content: "";
  position: absolute;
  top: -50%;
  right: -30%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, var(--accent-glow), transparent 70%);
  pointer-events: none;
}

.result-header {
  text-align: center;
  margin-bottom: 16px;
  position: relative;
}

.result-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  font-size: 1.75rem;
  font-weight: 900;
  margin-bottom: 8px;
  border: 3px solid;
}

.result-rank.rank-s {
  background: linear-gradient(135deg, #ffd700, #ff8c00);
  color: #1a1000;
  border-color: #ffe566;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
}

.result-rank.rank-a {
  background: linear-gradient(135deg, #c0c0c0, #808080);
  color: #111;
  border-color: #e0e0e0;
}

.result-rank.rank-b {
  background: linear-gradient(135deg, #cd7f32, #8b4513);
  color: #fff;
  border-color: #daa520;
}

.result-rank.rank-c {
  background: var(--bg-card-alt);
  color: var(--text-muted);
  border-color: var(--border);
}

.result-rank.rank-d {
  background: #2a1515;
  color: var(--danger);
  border-color: var(--danger);
}

.result-header h2 {
  font-size: 1.2rem;
  line-height: 1.35;
}

.result-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.result-identity {
  background: var(--bg-card-alt);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 14px;
  font-size: 0.85rem;
  line-height: 1.7;
  position: relative;
}

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
  position: relative;
}

.result-stat-item {
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}

.result-stat-item .rs-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.result-stat-item .rs-value {
  font-size: 1.25rem;
  font-weight: 800;
}

.result-score-block {
  text-align: center;
  padding: 14px;
  background: rgba(124, 92, 255, 0.12);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  position: relative;
}

.score-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.score-value {
  font-size: 2.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-summary {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  text-align: center;
  position: relative;
}

.result-footer {
  text-align: center;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 12px;
  opacity: 0.7;
  position: relative;
}

/* Name input */
.name-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.name-input-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.name-input-group input {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
}

.name-input-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Leaderboard */
.leaderboard-sub {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.leaderboard-list {
  list-style: none;
  margin-bottom: 16px;
}

.leaderboard-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.leaderboard-list li:last-child {
  border-bottom: none;
}

.lb-rank-num {
  font-weight: 800;
  color: var(--accent);
  min-width: 24px;
}

.lb-rank-badge {
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  min-width: 22px;
  text-align: center;
}

.lb-info {
  flex: 1;
}

.lb-name {
  font-weight: 600;
}

.lb-title {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.lb-meta {
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-top: 2px;
}

.lb-score {
  font-weight: 800;
  font-size: 1rem;
  color: var(--accent-2);
}

.leaderboard-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 24px;
  font-size: 0.9rem;
}

/* Stat colors */
.fill-wealth { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.fill-happiness { background: linear-gradient(90deg, #f472b6, #ec4899); }
.fill-health { background: linear-gradient(90deg, #4ade80, #22c55e); }
.fill-knowledge { background: linear-gradient(90deg, #60a5fa, #3b82f6); }
.fill-relationship { background: linear-gradient(90deg, #c084fc, #a855f7); }
.fill-reputation { background: linear-gradient(90deg, #fb923c, #f97316); }

/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-card);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  z-index: 1000;
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Slightly larger screens */
@media (min-width: 400px) {
  .hero h1 {
    font-size: 2rem;
  }

  .event-text {
    font-size: 1.1rem;
  }
}
