:root {
  --bg: #fff8ec;
  --bg-2: #fff2da;
  --panel: #ffffff;
  --panel-2: #fffaf1;
  --ink: #232733;
  --muted: #7a7f8c;
  --green: var(--jn-green, #a0e747);
  --green-deep: #4c9a1a;
  --green-dim: #edfad6;
  --coral: #ff6b6b;
  --coral-dim: #ffe4e4;
  --blue: #3ea8ff;
  --blue-dim: #e3f3ff;
  --yellow: #ffb020;
  --yellow-dim: #fff1d6;
  --purple: #9b7bff;
  --juniora-h: 38px;
  --shadow: 0 14px 30px rgba(35,39,51,0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html, body {
  background: var(--bg); color: var(--ink); font-family: var(--jn-font);
  overflow-x: hidden;
}
body { padding-bottom: var(--juniora-h); position: relative; }
button { cursor: pointer; border: none; font-family: var(--jn-font); color: var(--ink); }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }

/* ============ BACKGROUND BLOBS ============ */
.blob { position: fixed; border-radius: 50%; filter: blur(60px); opacity: 0.35; z-index: 0; animation: floatBlob 12s ease-in-out infinite; pointer-events: none; }
.blob-1 { width: 300px; height: 300px; background: var(--yellow); top: -80px; right: -60px; }
.blob-2 { width: 260px; height: 260px; background: var(--blue); top: 40vh; left: -100px; animation-delay: -4s; }
.blob-3 { width: 260px; height: 260px; background: var(--coral); bottom: -60px; right: -60px; animation-delay: -8s; }
@keyframes floatBlob { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(16px,-18px) scale(1.07); } }

/* ============ SHARED ============ */
section { position: relative; z-index: 2; max-width: 640px; margin: 0 auto; padding: 60px 22px; }
#sim { padding-top: 54px; }
.section-title { text-align: center; font-size: clamp(21px, 4.6vw, 27px); margin-bottom: 10px; }
.section-sub { text-align: center; color: var(--muted); font-size: 14.5px; line-height: 1.95; margin-bottom: 28px; }
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .5s ease, transform .5s ease; }
.reveal.in-view { opacity: 1; transform: translateY(0); }

.btn-primary {
  display: block; width: 100%;
  background: var(--ink); color: #fff; font-weight: 900; font-size: 14.5px;
  padding: 15px 28px; border-radius: 16px; box-shadow: 0 12px 26px rgba(35,39,51,0.22);
  transition: transform .18s ease, box-shadow .18s ease;
}
.btn-primary:hover { transform: translateY(-2px) scale(1.02); }
.btn-primary:active { transform: translateY(0) scale(0.97); }

/* ============ WALLET CARD ============ */
.wallet-card {
  background: var(--panel); border-radius: 28px; padding: 26px 22px 22px;
  box-shadow: var(--shadow); border: 1px solid rgba(35,39,51,0.05);
}
.wallet-card.shake { animation: shake .5s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-8px) rotate(-1deg); }
  40% { transform: translateX(7px) rotate(1deg); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

.bars { display: flex; flex-direction: column; gap: 14px; }
.bar-row { display: flex; flex-direction: column; gap: 6px; }
.bar-label { font-size: 13px; font-weight: 800; }
.bar-track {
  height: 34px; border-radius: 12px; background: var(--panel-2);
  border: 1px dashed rgba(35,39,51,0.12); overflow: hidden;
}
.bar-fill { display: flex; height: 100%; transition: width .6s cubic-bezier(.2,.8,.2,1); }
.seg {
  height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 15px; transition: width .6s cubic-bezier(.2,.8,.2,1); overflow: hidden; white-space: nowrap;
  border-left: 2px solid var(--panel);
}
.seg:last-child { border-left: none; }
.seg-budget  { background: var(--yellow); }
.seg-income  { background: var(--green); }
.seg-savings { background: var(--blue); }
.seg-food    { background: #ffd27a; }
.seg-movie   { background: var(--purple); }
.seg-school  { background: #7fd1c7; }
.seg-surprise {
  background: repeating-linear-gradient(-45deg, var(--coral), var(--coral) 8px, #ff8b8b 8px, #ff8b8b 16px);
}

.legend {
  display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 14px;
  font-size: 11.5px; color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.status {
  margin: 18px 0 14px; text-align: center; font-weight: 900; font-size: 15px;
  padding: 12px; border-radius: 16px; transition: background .3s ease, color .3s ease;
}
.status.ok  { background: var(--green-dim); color: #234512; }
.status.bad { background: var(--coral-dim); color: #b3261e; }

.surprise { overflow: hidden; max-height: 0; transition: max-height .4s ease; }
.surprise.show { max-height: 160px; }
.surprise-inner {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
  background: var(--yellow-dim); border-radius: 18px; padding: 12px 14px;
  font-size: 13.5px; line-height: 1.9;
}
.surprise-inner .s-emoji { font-size: 32px; flex-shrink: 0; }

/* ============ RESCUE ============ */
.rescue-section { padding-top: 10px; transition: opacity .5s ease, transform .5s ease; }
.rescue-section.hidden { display: none; }
.rescue-section.enter { animation: rise .5s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }

.rescue-grid { display: flex; flex-direction: column; gap: 12px; }
.rescue-btn {
  display: flex; align-items: center; gap: 14px; text-align: right;
  background: var(--panel); border-radius: 20px; padding: 14px 16px;
  box-shadow: var(--shadow); border: 2px solid transparent;
  transition: transform .15s ease, border-color .15s ease, opacity .2s ease;
}
.rescue-btn:hover:not(:disabled) { transform: translateY(-2px); border-color: rgba(35,39,51,0.12); }
.rescue-btn:active:not(:disabled) { transform: scale(0.98); }
.rescue-btn .r-emoji {
  width: 48px; height: 48px; flex-shrink: 0; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.rescue-btn .r-text { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.rescue-btn .r-title { font-size: 14px; font-weight: 900; }
.rescue-btn .r-desc { font-size: 12px; color: var(--muted); line-height: 1.8; }
.rescue-btn .r-amount { font-size: 12.5px; font-weight: 900; white-space: nowrap; }
.rescue-btn.used { border-color: var(--green); background: var(--green-dim); }
.rescue-btn:disabled { cursor: default; }
.rescue-btn:disabled:not(.used) { opacity: .45; }
.r-0 .r-emoji { background: var(--yellow-dim); }
.r-1 .r-emoji { background: var(--green-dim); }
.r-2 .r-emoji { background: var(--blue-dim); }

.piggy {
  display: flex; align-items: center; gap: 12px; margin-top: 18px;
  background: var(--panel); border-radius: 18px; padding: 12px 16px; box-shadow: var(--shadow);
}
.piggy-emoji { font-size: 28px; }
.piggy-body { flex: 1; }
.piggy-top { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 800; margin-bottom: 6px; }
.piggy-top span:last-child { color: var(--muted); font-weight: 700; }
.piggy-track { height: 10px; border-radius: 99px; background: var(--blue-dim); overflow: hidden; }
.piggy-fill { height: 100%; background: var(--blue); border-radius: 99px; transition: width .6s ease, background .3s ease; }
.piggy-fill.low { background: var(--coral); }

.tip { overflow: hidden; max-height: 0; transition: max-height .4s ease; }
.tip.show { max-height: 420px; }
.tip-inner {
  margin-top: 16px; border-radius: 18px; padding: 14px 16px;
  font-size: 13.5px; line-height: 1.95;
}
.tip-inner.good { background: var(--green-dim); color: #234512; }
.tip-inner.warn { background: var(--coral-dim); color: #8f1f19; }

.retry { margin-top: 16px; }

/* ============ REFLECTION ============ */
.reflect-section { padding-top: 20px; }
.reflect-card {
  background: var(--panel); border-radius: 28px; padding: 30px 24px; box-shadow: var(--shadow);
  border: 1px solid rgba(35,39,51,0.05); text-align: center;
}
.reflect-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 22px; }
.reflect-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.reflect-opt {
  background: var(--panel-2); border: 2px solid transparent; border-radius: 16px;
  padding: 13px 16px; font-size: 13.5px; font-weight: 700;
  text-align: right; transition: all .15s ease;
}
.reflect-opt:hover { border-color: rgba(35,39,51,0.12); transform: translateY(-1px); }
.reflect-opt.selected { border-color: var(--ink); }
.reflect-opt.selected.right { background: var(--green-dim); }
.reflect-opt.selected.wrong { background: var(--coral-dim); }

.reflect-answer { overflow: hidden; max-height: 0; transition: max-height .4s ease; }
.reflect-answer.show { max-height: 280px; }
.reflect-answer-inner {
  margin-top: 18px; border-radius: 18px; padding: 16px 18px;
  font-size: 13.5px; line-height: 1.95; text-align: right;
  opacity: 0; transform: scale(0.95); transition: opacity .3s ease .1s, transform .3s ease .1s;
}
.reflect-answer-inner.right { background: var(--green-dim); color: #234512; }
.reflect-answer-inner.wrong { background: var(--yellow-dim); color: #6b4700; }
.reflect-answer.show .reflect-answer-inner { opacity: 1; transform: scale(1); }

.particle { position: fixed; border-radius: 50%; pointer-events: none; z-index: 60; animation: particleBurst .7s ease-out forwards; }
@keyframes particleBurst {
  0% { transform: translate(0,0) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--px), var(--py)) scale(0.4) rotate(180deg); opacity: 0; }
}

@media (max-width: 380px) {
  .rescue-btn { gap: 10px; padding: 12px; }
  .rescue-btn .r-emoji { width: 42px; height: 42px; font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) {
  .blob { animation: none !important; }
  .wallet-card.shake, .rescue-section.enter { animation: none; }
  * { transition-duration: 0.01ms !important; }
}

/* ============ BRAND BAR ============ */
.juniora-overlay {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center;
  padding: 8px 14px; background: rgba(13, 15, 19, 0.92); backdrop-filter: blur(6px);
  border-top: 1px solid rgba(255, 255, 255, 0.06); z-index: 1000;
}
.juniora-link { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: #cfd6cf; font-family: var(--jn-font); font-size: 10.5px; font-weight: 600; line-height: 1; opacity: 0.9; }
.juniora-link:hover { opacity: 1; }
.juniora-logo { width: 13px; height: auto; display: block; flex-shrink: 0; }
