/* ============================================================
   Fun-Budget — the storybook's clothing
   Calm, peaceful, curved, warm. Nothing that reads office.
   ============================================================ */

:root {
  --sky:        #cfe8f3;   /* soft morning sky */
  --sky-deep:   #a8d4e6;
  --meadow:     #dcedc8;   /* gentle green */
  --meadow-deep:#aed581;
  --parchment:  #fdf6e3;   /* storybook page */
  --parchment-2:#f7edd2;
  --sunset:     #ffe0b2;   /* warm peach */
  --berry:      #ce93d8;   /* soft purple */
  --ink:        #5d4e37;   /* warm brown ink, never harsh black */
  --ink-soft:   #8d7b60;
  --rose:       #f8bbd0;
  --gold:       #f9d976;
  --teal:       #b2dfdb;
  --paid:       #81c784;   /* vanquished green */
  --owed:       #ffcc80;   /* waiting orange — calm, not alarming */
  --radius: 26px;
  --shadow: 0 6px 20px rgba(93, 78, 55, 0.13);
}

* { box-sizing: border-box; }

/* The book's cover is locked to the screen; only the open PAGE scrolls.
   This keeps the ribbon truly nailed to the bottom on iPhone — when the
   body itself scrolls, Safari's collapsing toolbar makes "fixed" bars float. */
html, body {
  margin: 0;
  padding: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: -apple-system, "Comic Sans MS", "Segoe UI", "Chalkboard SE", "Marker Felt", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky) 0%, var(--parchment) 45%, var(--meadow) 100%);
  font-size: 17px;
  line-height: 1.55;
}

h1, h2, h3 { font-weight: 700; line-height: 1.25; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.12rem; }

/* ---------- the book itself ---------- */
.page {
  display: none;
  height: 100%;
  max-width: 720px;
  margin: 0 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 18px 16px 120px;
  animation: pageTurn 0.45s ease;
  box-sizing: border-box;
}
.page.open { display: block; }

@keyframes pageTurn {
  from { opacity: 0; transform: translateY(14px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.card {
  background: var(--parchment);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px;
  margin: 14px 0;
  border: 2px solid rgba(93,78,55,0.08);
}

.card.soft   { background: var(--parchment-2); }
.card.sky    { background: linear-gradient(160deg, #e3f2fd, var(--parchment)); }
.card.meadow { background: linear-gradient(160deg, #e8f5e9, var(--parchment)); }
.card.sunset { background: linear-gradient(160deg, var(--sunset), var(--parchment)); }

.whisper { color: var(--ink-soft); font-size: 0.92rem; }
.center  { text-align: center; }

/* ---------- title page ---------- */
#page-title { text-align: center; padding-top: 30px; }

.adventure-title {
  font-size: 2.1rem;
  margin: 10px 8px 4px;
  color: var(--ink);
  text-shadow: 0 2px 0 rgba(255,255,255,0.7);
}

.scene {
  margin: 14px auto;
  max-width: 460px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #fff;
}
.scene svg { display: block; width: 100%; height: auto; }

.story-box {
  font-size: 1.08rem;
  max-width: 520px;
  margin: 14px auto;
}

.big-btn {
  display: inline-block;
  background: linear-gradient(180deg, var(--gold), #f6c453);
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: 999px;
  padding: 15px 36px;
  margin: 12px 4px;
  cursor: pointer;
  box-shadow: 0 5px 0 #d9a83f, var(--shadow);
  transition: transform 0.12s ease;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #d9a83f; }

/* ---------- Today's Tiny Quest (home card) ---------- */
#tinyQuestCard { text-align: left; }
.quest-line {
  background: rgba(255,255,255,0.7);
  border-radius: 16px;
  padding: 10px 14px;
  margin: 8px 0;
  font-size: 0.98rem;
}
.quest-line.gold { background: #fffbe8; }
.quest-peek {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  line-height: 1.7;
}
.quest-peek b { color: var(--ink); }

/* ---------- the 15-minute family council ---------- */
.council-card { text-align: left; }
.council-questions {
  list-style: none;
  padding: 0;
  margin: 12px 0 6px;
  counter-reset: quest;
}
.council-questions li {
  background: rgba(255,255,255,0.7);
  border-radius: 16px;
  padding: 11px 15px;
  margin: 8px 0;
  font-size: 1rem;
}

/* ---------- navigation: the book's ribbon ---------- */
nav.ribbon {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-around;
  background: rgba(253, 246, 227, 0.96);
  backdrop-filter: blur(8px);
  border-top: 2px solid rgba(93,78,55,0.12);
  padding: 8px 4px calc(10px + env(safe-area-inset-bottom));
  z-index: 50;
}
nav.ribbon button {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.72rem;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 8px;
  border-radius: 16px;
  min-width: 62px;
}
nav.ribbon button .nav-icon { font-size: 1.55rem; }
nav.ribbon button.here {
  background: var(--meadow);
  color: var(--ink);
  font-weight: 700;
}

/* ---------- bills to vanquish ---------- */
.bill-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--parchment);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin: 10px 0;
  border-left: 8px solid var(--owed);
  transition: opacity 0.3s, border-color 0.3s;
}
.bill-row.vanquished {
  border-left-color: var(--paid);
  opacity: 0.62;
}
.bill-row.income {
  border-left-color: var(--gold);
  background: #fffcf0;
}
.vanquish-btn.gather { background: var(--gold); }
.bill-row.vanquished .bill-name { text-decoration: line-through; }

.bill-icon { font-size: 1.7rem; }
.bill-info { flex: 1; min-width: 0; }
.bill-name { font-weight: 700; }
.bill-sub  { font-size: 0.85rem; color: var(--ink-soft); }
.bill-amount { font-weight: 700; font-size: 1.05rem; white-space: nowrap; }

.vanquish-btn {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  border: none;
  border-radius: 999px;
  padding: 9px 13px;
  cursor: pointer;
  background: var(--sunset);
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(93,78,55,0.15);
  white-space: nowrap;
}
.bill-row.vanquished .vanquish-btn { background: var(--paid); color: #fff; }

.bill-link {
  font-size: 1.25rem;
  text-decoration: none;
  padding: 6px;
}

.week-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- calendar ---------- */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin-top: 10px;
}
.cal-dow {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-soft);
  padding: 4px 0;
}
.cal-day {
  background: rgba(255,255,255,0.75);
  border-radius: 14px;
  min-height: 58px;
  padding: 4px 3px;
  font-size: 0.75rem;
  text-align: center;
  border: 2px solid transparent;
}
.cal-day.today {
  border-color: var(--gold);
  background: #fffbe8;
  box-shadow: 0 0 0 2px rgba(249, 217, 118, 0.5);
}
.cal-day.empty { background: transparent; }
.cal-daynum { font-weight: 700; color: var(--ink-soft); }
.cal-icons { font-size: 0.95rem; line-height: 1.3; word-break: break-all; }

.mini-months { display: flex; gap: 10px; overflow-x: auto; padding: 6px 2px; }
.mini-month {
  min-width: 150px;
  background: rgba(255,255,255,0.7);
  border-radius: 18px;
  padding: 10px;
  font-size: 0.72rem;
}
.mini-month h4 { margin: 0 0 6px; text-align: center; font-size: 0.8rem; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; text-align: center; }
.mini-cell { padding: 1px 0; border-radius: 5px; }
.mini-cell.has-bill { background: var(--rose); font-weight: 700; }

.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; font-size: 0.8rem; }
.legend span {
  background: rgba(255,255,255,0.8);
  border-radius: 999px;
  padding: 3px 11px;
}

/* ---------- treasure room ---------- */
.scales-wrap { text-align: center; }

/* the three numbers that matter most — big and unmissable */
.stat-tiles {
  display: flex;
  gap: 8px;
  margin: 4px 0 10px;
}
.stat-tile {
  flex: 1;
  background: rgba(255,255,255,0.75);
  border-radius: 18px;
  padding: 12px 6px 10px;
  text-align: center;
}
.stat-tile.in    { background: #fffbe8; }
.stat-tile.out   { background: #fdeede; }
.stat-tile.room  { background: #e8f5e9; }
.stat-tile.over  { background: #fff2e0; }
.stat-label { font-size: 0.72rem; color: var(--ink-soft); font-weight: 700; }
.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.15;
  margin: 3px 0;
  color: var(--ink);
}
.stat-tile.room .stat-value { color: #4a8a3f; }
.stat-tile.over .stat-value { color: #b26a00; }  /* amber, never a red siren */
.stat-note { font-size: 0.64rem; color: var(--ink-soft); line-height: 1.25; }
@media (min-width: 500px) {
  .stat-value { font-size: 1.85rem; }
  .stat-note { font-size: 0.7rem; }
}

.treasure-chest-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 12px 0;
}
.chest {
  text-align: center;
  padding: 8px 6px;
  border-radius: 16px;
  background: rgba(255,255,255,0.65);
  min-width: 86px;
}
.chest .chest-icon { display: block; }
.chest .chest-name { font-size: 0.68rem; color: var(--ink-soft); }
.chest .chest-amt  { font-size: 0.8rem; font-weight: 700; }

.pouch {
  margin: 14px 0;
}
.pouch-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.pouch-name { font-weight: 700; }
.pouch-nums { font-size: 0.85rem; color: var(--ink-soft); }
.pouch-bar {
  height: 22px;
  background: var(--owed);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
  position: relative;
}
.pouch-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--paid), #66bb6a);
  border-radius: 999px;
  transition: width 0.5s ease;
  min-width: 0;
}
.pouch-fill.overflow { background: linear-gradient(90deg, #ef9a9a, #e57373); }
.pouch-add {
  font-family: inherit;
  border: none;
  background: var(--teal);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
  box-shadow: 0 2px 0 rgba(93,78,55,0.15);
}

.dragon-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}
.dragon-bar {
  flex: 1;
  height: 18px;
  background: #efebe9;
  border-radius: 999px;
  overflow: hidden;
}
.dragon-fill {
  height: 100%;
  background: linear-gradient(90deg, #bcaaa4, #a1887f);
  border-radius: 999px;
}

/* ---------- sprouts (data entry) ---------- */
form.sprout label {
  display: block;
  font-weight: 700;
  margin: 12px 0 4px;
  font-size: 0.95rem;
}
form.sprout input, form.sprout select {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: rgba(255,255,255,0.85);
  border: 2px solid rgba(93,78,55,0.15);
  border-radius: 16px;
  padding: 11px 14px;
}
form.sprout input:focus, form.sprout select:focus {
  outline: none;
  border-color: var(--meadow-deep);
}

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip {
  font-family: inherit;
  border: 2px solid rgba(93,78,55,0.15);
  background: rgba(255,255,255,0.8);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--ink);
}
.chip.picked {
  background: var(--meadow);
  border-color: var(--meadow-deep);
  font-weight: 700;
}

.small-btn {
  font-family: inherit;
  border: none;
  background: var(--rose);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
}

.sound-toggle {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 60;
  background: rgba(253,246,227,0.9);
  border: none;
  border-radius: 999px;
  font-size: 1.2rem;
  padding: 8px 10px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

/* gentle celebratory sparkle */
.sparkle {
  position: fixed;
  pointer-events: none;
  font-size: 1.6rem;
  animation: floatUp 1.2s ease forwards;
  z-index: 100;
}
@keyframes floatUp {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-70px) scale(1.6); }
}

/* ---------- the First Adventure (onboarding veil) ---------- */
#adventureVeil {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: linear-gradient(180deg, var(--sky) 0%, var(--parchment) 50%, var(--meadow) 100%);
  overflow-y: auto;
  padding: 24px 14px 40px;
}
.veil-book {
  max-width: 560px;
  margin: 0 auto;
  animation: pageTurn 0.5s ease;
}
.veil-book h2 { margin-top: 4px; }
.veil-book .scene { margin: 10px auto; max-width: 380px; }
.veil-step-dots { text-align: center; font-size: 0.9rem; letter-spacing: 4px; color: var(--ink-soft); }
.veil-book input, .veil-book select {
  width: 100%;
  font-family: inherit;
  font-size: 1.05rem;
  color: var(--ink);
  background: rgba(255,255,255,0.9);
  border: 2px solid rgba(93,78,55,0.15);
  border-radius: 16px;
  padding: 12px 14px;
  margin: 6px 0;
}
.veil-book input:focus { outline: none; border-color: var(--meadow-deep); }
.veil-row { display: flex; gap: 8px; align-items: center; }
.veil-row input { flex: 1; }
.enemy-list { margin: 10px 0; }
.enemy-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  background: rgba(255,255,255,0.75);
  border-radius: 14px;
  padding: 8px 12px;
  margin: 6px 0;
  font-size: 0.92rem;
}
.veil-actions { text-align: center; margin-top: 14px; }
.ghost-btn {
  font-family: inherit;
  background: none;
  border: 2px solid rgba(93,78,55,0.25);
  border-radius: 999px;
  color: var(--ink-soft);
  padding: 10px 18px;
  font-size: 0.9rem;
  cursor: pointer;
  margin: 4px;
}

/* ---------- the quill: editor & day-view modal ---------- */
#modalVeil {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(93, 78, 55, 0.35);
  backdrop-filter: blur(3px);
  overflow-y: auto;
  padding: 28px 14px 60px;
}
.modal-book {
  max-width: 520px;
  margin: 0 auto;
  animation: pageTurn 0.3s ease;
}
.modal-book label {
  display: block;
  font-weight: 700;
  margin: 10px 0 3px;
  font-size: 0.9rem;
}
.modal-book input, .modal-book select {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: rgba(255,255,255,0.9);
  border: 2px solid rgba(93,78,55,0.15);
  border-radius: 14px;
  padding: 10px 12px;
}
.modal-book input:focus, .modal-book select:focus { outline: none; border-color: var(--meadow-deep); }

.edit-btn {
  border: none;
  background: rgba(255,255,255,0.85);
  border-radius: 999px;
  padding: 4px 9px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  box-shadow: 0 2px 0 rgba(93,78,55,0.12);
}

/* ---------- the royal ledger ---------- */
.ledger-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.75);
  border-radius: 14px;
  margin: 6px 0;
  font-size: 0.88rem;
}
.ledger-day {
  min-width: 54px;
  font-weight: 700;
  color: var(--ink-soft);
  text-align: center;
  background: rgba(249,217,118,0.35);
  border-radius: 10px;
  padding: 3px 4px;
  font-size: 0.75rem;
}
.ledger-name { flex: 1; min-width: 0; }
.ledger-sub { display: block; font-size: 0.72rem; color: var(--ink-soft); }
.ledger-amt { font-weight: 700; white-space: nowrap; }

/* the ghostly "today" marker that walks down the ledger */
.ledger-today {
  text-align: center;
  font-size: 0.74rem;
  letter-spacing: 2px;
  color: var(--ink-soft);
  opacity: 0.6;
  margin: 6px 0;
  font-style: italic;
}

/* ---------- The Tide of Gold (checking forecast) ---------- */
#tideCard { text-align: left; }
.tide-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 7px 12px;
  margin: 4px 0;
  background: rgba(255,255,255,0.6);
  border-radius: 12px;
  font-size: 0.84rem;
}
.tide-row.today { background: #fffbe8; font-weight: 700; }
.tide-row.underwater { background: #fff2e0; }
.tide-row.underwater b { color: #b26a00; }   /* amber caution, never a red siren */
.tide-row b { white-space: nowrap; }
.tide-summary { margin-top: 10px; }
.tide-warn {
  background: #fff2e0;
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 0.9rem;
}
.tide-ok {
  background: #e8f5e9;
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 0.9rem;
}

/* ---------- the dungeon of Morgrim ---------- */
.card.dungeon { background: linear-gradient(160deg, #e8eaf6, #ede7f6); }
.wizard-row { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; }
.wizard { font-size: 2.6rem; line-height: 1; }
.speech {
  background: #fff;
  border-radius: 16px;
  border-top-left-radius: 4px;
  padding: 10px 14px;
  flex: 1;
  font-size: 0.95rem;
  font-style: italic;
  box-shadow: var(--shadow);
}

/* ---------- the vault picker: where the gold marches from ---------- */
.vault-pick {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: rgba(255,255,255,0.85);
  border: 2px solid rgba(93,78,55,0.15);
  border-radius: 16px;
  padding: 12px 14px;
  margin: 6px 0;
  cursor: pointer;
  text-align: left;
  gap: 8px;
}
.vault-pick:active { transform: scale(0.98); }
.vault-pick.preferred {
  border-color: var(--meadow-deep);
  background: var(--meadow);
  font-weight: 700;
}

/* ---------- the map's key & clickable days ---------- */
.map-key summary {
  cursor: pointer;
  font-weight: 700;
  margin: 10px 0 4px;
  font-size: 0.95rem;
}
.key-row { font-size: 0.8rem; margin: 4px 0; color: var(--ink-soft); }
.key-row b { color: var(--ink); }
.cal-day.has-bills { cursor: pointer; }
.cal-day.has-bills:active { transform: scale(0.96); }

@media (min-width: 700px) {
  body { font-size: 18px; }
}
