/* Life Ranked — PWA styles
   Cool minimal modern, Pinterest-inspired: stone palette, one teal accent,
   clean cards, soft shadows, generous whitespace, rounded corners. */

:root {
  --bg: #f5f4f2;
  --card: #ffffff;
  --ink: #1c1917;
  --ink-soft: #57534e;
  --ink-faint: #a8a29e;
  --line: #e7e5e4;
  --accent: #0f766e;
  --accent-bright: #14b8a6;
  --dark: #141311;
  --dark-card: #201d1a;
  --gold: #d4af37;
  --red: #dc2626;
  --radius: 18px;
  --shadow: 0 2px 10px rgba(28, 25, 23, 0.06), 0 10px 30px rgba(28, 25, 23, 0.05);
  --tier-iron: #8a8d91;
  --tier-bronze: #b0793f;
  --tier-silver: #aeb6bd;
  --tier-gold: #e3b341;
  --tier-platinum: #43b3a2;
  --tier-emerald: #2fa84f;
  --tier-diamond: #5ea8e8;
  --tier-master: #a55eea;
  --tier-grandmaster: #e84e4e;
  --tier-challenger: #f5c542;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ---------- Header ---------- */
#app-header {
  background: var(--dark);
  color: #fafaf9;
  padding: calc(10px + env(safe-area-inset-top)) 18px 12px;
  flex: 0 0 auto;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
  z-index: 5;
}
.header-row { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { color: var(--gold); font-size: 13px; letter-spacing: -2px; }
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: 0.2px; }
.streak {
  background: var(--dark-card);
  border: 1px solid #3a3630;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
}
.season-banner {
  margin-top: 7px;
  font-size: 12px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: #d6d3cd;
}
.season-banner b { color: var(--gold); }

/* ---------- Screens ---------- */
#screens { flex: 1 1 auto; position: relative; min-height: 0; }
.screen {
  display: none;
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 28px;
}
.screen.active { display: block; }
.section-title { font-size: 15px; font-weight: 800; letter-spacing: 0.4px; margin: 18px 2px 10px; }
.screen > .section-title:first-child { margin-top: 2px; }
.muted { color: var(--ink-soft); font-size: 13px; line-height: 1.45; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

/* ---------- Hero (overall rank) ---------- */
.hero {
  background: linear-gradient(160deg, #262320 0%, var(--dark) 60%, #0d0c0b 100%);
  color: #fafaf9;
  border-radius: 24px;
  padding: 22px 18px 18px;
  text-align: center;
  box-shadow: 0 14px 34px rgba(20, 19, 17, 0.35);
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  inset: auto -30% -70% -30%;
  height: 75%;
  background: radial-gradient(ellipse at center, rgba(212, 175, 55, 0.22), transparent 70%);
  pointer-events: none;
}
.hero-kicker { font-size: 11px; letter-spacing: 2.4px; text-transform: uppercase; color: #d6d3cd; }
.hero-rank { font-size: 30px; font-weight: 900; margin: 6px 0 2px; }
.hero-sub { font-size: 13px; color: #d6d3cd; }
.hero .lp-bar { margin: 14px auto 6px; max-width: 320px; }
.hero .lp-meta { font-size: 12px; color: #d6d3cd; }

/* ---------- Emblems ---------- */
.emblem { margin: 0 auto; width: 92px; height: 100px; }
.emblem.small { width: 46px; height: 50px; margin: 0; }
.emblem svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.35)); }
.pips { display: flex; gap: 5px; justify-content: center; margin-top: 7px; }
.pip { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.22); }
.pip.lit { background: var(--gold); box-shadow: 0 0 6px rgba(212,175,55,0.8); }
.lane-card .pip { background: var(--line); }
.lane-card .pip.lit { background: var(--accent); box-shadow: none; }

/* ---------- LP bars ---------- */
.lp-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(128, 128, 128, 0.25);
  overflow: hidden;
}
.lane-card .lp-bar, .quest-card .lp-bar { background: var(--line); }
.lp-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  min-width: 0;
}
.lp-meta { font-size: 12px; color: var(--ink-soft); margin-top: 5px; }

/* ---------- Lane cards ---------- */
.lane-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.lane-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  position: relative;
}
.lane-card.decaying { opacity: 0.55; filter: grayscale(0.6); }
.lane-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.lane-name { font-weight: 800; font-size: 15px; margin-top: 8px; }
.lane-rank { font-size: 13px; font-weight: 700; }
.lane-rank .lp-num { color: var(--ink-soft); font-weight: 600; }
.shield-badge {
  display: inline-block;
  margin-top: 7px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: #ccfbf1;
  border-radius: 999px;
  padding: 3px 8px;
}
.decay-badge {
  display: inline-block;
  margin-top: 7px;
  font-size: 11px;
  font-weight: 700;
  color: #b91c1c;
  background: #fee2e2;
  border-radius: 999px;
  padding: 3px 8px;
}

/* ---------- Check-in card ---------- */
.checkin-card { border: 1px solid #99f6e4; background: linear-gradient(180deg, #f0fdfa, #ffffff); }
.checkin-card h3 { margin: 0 0 4px; font-size: 16px; }
.checkin-done { color: var(--accent); font-weight: 800; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.block { width: 100%; margin-top: 10px; }

/* ---------- Quests ---------- */
.quest-group-title { font-size: 12px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--ink-faint); margin: 16px 2px 8px; }
.quest-card { position: relative; }
.quest-card.boss {
  border: 2px solid var(--red);
  background: linear-gradient(180deg, #fff5f5, #ffffff);
  box-shadow: 0 6px 22px rgba(220, 38, 38, 0.16);
}
.quest-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e7e5e4;
  color: var(--ink-soft);
}
.badge.daily { background: #e0f2fe; color: #0369a1; }
.badge.weekly { background: #ede9fe; color: #6d28d9; }
.badge.boss { background: var(--red); color: #fff; }
.badge.lane { background: #f5f5f4; border: 1px solid var(--line); }
.lp-chip {
  margin-left: auto;
  font-weight: 900;
  font-size: 13px;
  color: var(--accent);
  background: #ccfbf1;
  padding: 4px 10px;
  border-radius: 999px;
}
.quest-card.boss .lp-chip { background: var(--red); color: #fff; font-size: 15px; padding: 6px 13px; }
.quest-title { font-weight: 700; font-size: 15px; margin-top: 9px; line-height: 1.35; }
.quest-actions { display: flex; gap: 8px; margin-top: 11px; flex-wrap: wrap; }
.quest-status { margin-top: 9px; font-size: 13px; font-weight: 700; }
.quest-status.done { color: var(--accent); }
.quest-status.ghosted { color: #b91c1c; }
.quest-card.is-done { opacity: 0.72; }
.quest-card.is-ghosted { opacity: 0.6; filter: grayscale(0.5); }
.quest-delete { margin-left: auto; }

/* ---------- Forms ---------- */
.form-card h3 { margin: 0 0 6px; font-size: 16px; }
.form-card label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-top: 11px; }
.form-card select, .form-card input[type="text"], .sheet select, .sheet input[type="text"] {
  width: 100%;
  margin-top: 5px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafaf9;
}
.form-card .btn { margin-top: 14px; }

/* ---------- Quick actions ---------- */
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-btn {
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  font: inherit;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.quick-btn:active { transform: scale(0.97); }
.quick-btn .q-lane { font-size: 11px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); }
.quick-btn .q-title { display: block; font-weight: 700; font-size: 14px; margin-top: 3px; line-height: 1.3; }
.quick-btn .q-lp { display: block; font-size: 12px; font-weight: 800; color: var(--ink-faint); margin-top: 4px; }

/* ---------- History ---------- */
.chart { display: flex; align-items: flex-end; gap: 4px; height: 110px; padding-top: 8px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.chart-bar { width: 100%; max-width: 20px; border-radius: 4px 4px 0 0; background: var(--accent-bright); min-height: 2px; }
.chart-bar.neg { background: #f87171; }
.chart-bar.zero { background: var(--line); }
.chart-day { font-size: 9px; color: var(--ink-faint); margin-top: 4px; }
.filter-row { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 10px; }
.filter-chip {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.filter-chip.active { background: var(--dark); color: #fff; border-color: var(--dark); }
.event-row { display: flex; gap: 10px; align-items: baseline; padding: 11px 14px; }
.event-delta { font-weight: 900; font-size: 14px; min-width: 44px; text-align: right; }
.event-delta.pos { color: var(--accent); }
.event-delta.neg { color: #dc2626; }
.event-main { flex: 1; }
.event-reason { font-size: 14px; font-weight: 600; line-height: 1.35; }
.event-meta { font-size: 12px; color: var(--ink-faint); }
.empty-note { text-align: center; color: var(--ink-faint); font-size: 14px; padding: 22px 0; }

/* ---------- Tab bar ---------- */
#tab-bar {
  flex: 0 0 auto;
  display: flex;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  backdrop-filter: blur(10px);
  z-index: 5;
}
.tab {
  flex: 1;
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-faint);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0 2px;
  cursor: pointer;
  position: relative;
}
.tab-icon { font-size: 20px; line-height: 1; }
.tab.active { color: var(--accent); }
.tab-badge {
  position: absolute;
  top: 0;
  right: calc(50% - 22px);
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  min-width: 17px;
  height: 17px;
  border-radius: 999px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.tab-badge.show { display: flex; }

/* ---------- Check-in sheet ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 19, 17, 0.55);
  z-index: 40;
  display: flex;
  align-items: flex-end;
}
.sheet {
  background: var(--card);
  width: 100%;
  border-radius: 24px 24px 0 0;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 88dvh;
  overflow-y: auto;
  animation: sheet-up 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0.4; } to { transform: none; opacity: 1; } }
.sheet h3 { margin: 0 0 4px; font-size: 18px; }
.kind-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 13px 0 6px; }
.kind-btn {
  border: 2px solid var(--line);
  background: #fafaf9;
  border-radius: 14px;
  padding: 13px 8px;
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
}
.kind-btn.selected { border-color: var(--accent); background: #f0fdfa; color: var(--accent); }
.toggle-row { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; margin-top: 12px; }
.sheet label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-top: 11px; }
.sheet input[type="range"] { width: 100%; accent-color: var(--accent); }
.range-val { color: var(--accent); font-weight: 900; }
.sheet-actions { display: flex; gap: 9px; margin-top: 17px; }
.sheet-actions .btn { flex: 1; }

/* ---------- Promotion ceremony ---------- */
#ceremony {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(13, 12, 11, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}
.ceremony-rays {
  position: absolute;
  width: 150vmax;
  height: 150vmax;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from 0deg, rgba(212, 175, 55, 0.13) 0deg 9deg, transparent 9deg 18deg);
  animation: rays-spin 24s linear infinite;
  pointer-events: none;
}
@keyframes rays-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
.ceremony-card {
  position: relative;
  text-align: center;
  color: #fafaf9;
  animation: ceremony-in 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: 320px;
}
@keyframes ceremony-in { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.ceremony-emblem { width: 120px; height: 130px; margin: 0 auto; }
.ceremony-emblem svg { width: 100%; height: 100%; }
.ceremony-kicker { letter-spacing: 3.5px; font-size: 12px; color: var(--gold); font-weight: 800; margin-top: 14px; }
.ceremony-title { font-size: 34px; font-weight: 900; margin-top: 4px; }
.ceremony-sub { color: #d6d3cd; font-size: 14px; margin-top: 5px; }
.ceremony-shield { margin: 14px 0 18px; font-size: 13px; font-weight: 700; color: #5eead4; }

/* ---------- Floating LP pills ---------- */
#float-layer { position: fixed; inset: 0; pointer-events: none; z-index: 70; }
.float-pill {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translateX(-50%);
  background: var(--dark);
  color: #5eead4;
  font-weight: 900;
  font-size: 17px;
  padding: 9px 18px;
  border-radius: 999px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  border: 1px solid var(--accent-bright);
  animation: float-up 1.5s ease-out forwards;
  white-space: nowrap;
}
.float-pill.neg { color: #fca5a5; border-color: #f87171; }
@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, 16px) scale(0.85); }
  15% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -56px) scale(1); }
}
