:root {
  --ink: #221C18;
  --cream: #FFF6E8;
  --paper: #E6DFD2;
  --blue: #09a5d9;
  --green: #09d95c;
  --orange: #f59e0b;
  --purple: #a78bfa;
  --red: #ff5039;
}

* { box-sizing: border-box; }

html { direction: rtl; }

body {
  margin: 0;
  direction: rtl;
  font-family: 'Rubik', Tahoma, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button, input { font-family: inherit; }
button { -webkit-tap-highlight-color: transparent; cursor: pointer; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--cream);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

.screen { display: none; flex: 1; flex-direction: column; }
.screen.active { display: flex; }

.hard-shadow { box-shadow: -4px 4px 0 var(--ink); }
.hard-border { border: 3px solid var(--ink); }

/* ---- onboarding ---- */
.onboard {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 32px 24px; gap: 22px;
}
.onboard h1 { font-size: 30px; font-weight: 900; margin: 0; }
.onboard-card {
  background: #fff; border: 3px solid var(--ink); border-radius: 20px;
  padding: 20px; box-shadow: -4px 4px 0 var(--ink);
}
.onboard-card h2 { margin: 0 0 12px; font-size: 16px; }
.onboard input {
  width: 100%; border: 3px solid var(--ink); border-radius: 14px;
  padding: 12px 14px; font-size: 16px; margin-bottom: 10px; outline: none;
}
.btn {
  border: 3px solid var(--ink); border-radius: 16px; padding: 13px;
  font-size: 16px; font-weight: 900; width: 100%; box-shadow: -4px 4px 0 var(--ink);
}
.btn-blue { background: var(--blue); color: #fff; }
.btn-orange { background: var(--orange); color: var(--ink); }
.btn-green { background: var(--green); color: var(--ink); }
.btn-ghost { background: #fff; color: var(--ink); }
.join-code-box {
  text-align: center; font-size: 30px; font-weight: 900; letter-spacing: .12em;
  background: var(--paper); border: 3px dashed var(--ink); border-radius: 14px;
  padding: 14px; margin-bottom: 14px;
}

/* ---- lock (avatar picker) ---- */
#lockScreen { background: var(--blue); }
.lock-head { padding: 52px 22px 26px; position: relative; border-bottom: 4px solid var(--ink); }
.lock-dots { position: absolute; top: 16px; left: 22px; display: flex; gap: 6px; }
.lock-dots span { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--ink); }
.lock-kicker { font-size: 13px; font-weight: 700; letter-spacing: .14em; color: #CDEDF9; }
.lock-title { font-size: 40px; font-weight: 900; color: #fff; margin-top: 8px; text-shadow: -3px 3px 0 var(--ink); }
.avatar-grid { flex: 1; overflow-y: auto; padding: 24px 22px 30px; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.avatar-tile {
  position: relative; border: 4px solid var(--ink); border-radius: 24px;
  padding: 16px 10px 14px; display: flex; flex-direction: column; align-items: center;
  gap: 8px; box-shadow: -5px 5px 0 var(--ink);
}
.avatar-tile:nth-child(odd) { transform: rotate(-1.4deg); }
.avatar-tile:nth-child(even) { transform: rotate(1.4deg); }
.avatar-circle {
  width: 62px; height: 62px; border-radius: 50%; background: var(--cream);
  border: 3px solid var(--ink); display: flex; align-items: center; justify-content: center;
  font-size: 34px; overflow: hidden;
}
.avatar-circle img { width: 100%; height: 100%; object-fit: cover; }
.avatar-name { font-size: 20px; font-weight: 900; }
.avatar-role { font-size: 12px; font-weight: 900; opacity: .85; }
.avatar-add-member { background: var(--paper); border: 4px dashed var(--ink); display: flex;
  flex-direction: column; align-items: center; justify-content: center; border-radius: 24px;
  gap: 6px; font-weight: 900; min-height: 130px; }

/* ---- pin ---- */
#pinScreen { flex: 1; display: flex; flex-direction: column; padding: 18px 20px 26px; }
.pin-back { align-self: flex-start; border: 3px solid var(--ink); background: var(--cream);
  color: var(--ink); font-size: 14px; font-weight: 900; padding: 8px 16px; border-radius: 999px;
  box-shadow: -3px 3px 0 var(--ink); }
.pin-user { display: flex; flex-direction: column; align-items: center; margin-top: 18px; }
.pin-avatar { width: 96px; height: 96px; border-radius: 50%; background: var(--cream);
  border: 4px solid var(--ink); display: flex; align-items: center; justify-content: center;
  font-size: 50px; box-shadow: -5px 5px 0 var(--ink); overflow: hidden; }
.pin-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pin-name { font-size: 24px; font-weight: 900; margin-top: 12px; }
.pin-hint { font-size: 14px; font-weight: 700; margin-top: 4px; background: rgba(255,255,255,.85);
  border-radius: 999px; padding: 4px 14px; }
.pin-hint.err { background: var(--ink); color: var(--red); }
.pin-dots { display: flex; gap: 14px; justify-content: center; margin: 26px 0; }
.pin-dots span { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--ink); background: rgba(255,255,255,.75); }
.pin-dots span.filled { background: var(--ink); }
.pin-dots.shake { animation: shake .4s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-9px)} 40%{transform:translateX(9px)} 60%{transform:translateX(-5px)} 80%{transform:translateX(5px)} }
.pin-keys { margin-top: auto; background: var(--cream); border: 4px solid var(--ink); border-radius: 28px;
  padding: 14px; display: grid; grid-template-columns: repeat(3,1fr); gap: 11px; box-shadow: -5px 5px 0 var(--ink); }
.pin-keys button { height: 62px; border-radius: 18px; border: 3px solid var(--ink); font-size: 26px; font-weight: 900; background: #fff; }
.pin-keys button.ok { background: var(--green); }
.pin-keys button.del { background: var(--paper); color: #7a6a52; }

/* ---- header shared ---- */
.board-header { padding: 26px 22px 22px; border-bottom: 4px solid var(--ink); }
.board-head-row { display: flex; align-items: center; gap: 12px; }
.head-avatar { width: 56px; height: 56px; border-radius: 50%; border: 3px solid var(--ink);
  background: var(--cream); display: flex; align-items: center; justify-content: center; font-size: 30px; overflow: hidden; }
.head-avatar img { width: 100%; height: 100%; object-fit: cover; }
.head-kicker { font-size: 12px; font-weight: 900; letter-spacing: .1em; }
.head-title { font-size: 27px; font-weight: 900; line-height: 1.1; text-shadow: -2px 2px 0 var(--ink); color: #fff; }
.counter-box { margin-top: 16px; background: var(--cream); border: 3px solid var(--ink); border-radius: 18px;
  padding: 12px 16px; display: flex; align-items: center; gap: 12px; box-shadow: -4px 4px 0 var(--ink); }
.counter-num { font-size: 38px; font-weight: 900; line-height: 1; }
.counter-txt { font-size: 14px; font-weight: 700; line-height: 1.2; }

/* ---- tasks ---- */
.tasks-body { padding: 22px; }
.section-label { font-size: 15px; font-weight: 900; margin-bottom: 12px; }
.task-list { display: flex; flex-direction: column; gap: 14px; }
.task-card { background: #fff; border: 3px solid var(--ink); border-radius: 20px; padding: 13px;
  display: flex; align-items: center; gap: 12px; box-shadow: -4px 4px 0 var(--ink); }
.task-toggle { flex: none; width: 58px; height: 58px; border-radius: 16px; border: 3px solid var(--ink);
  background: var(--cream); font-size: 30px; font-weight: 900; color: var(--paper); }
.task-toggle:active { background: var(--green); color: var(--ink); }
.task-title { font-size: 18px; font-weight: 700; line-height: 1.25; }
.task-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 900;
  border-radius: 999px; padding: 4px 11px; white-space: nowrap; border: 2.5px solid var(--ink); }
.badge-money { background: var(--orange); color: var(--ink); }
.badge-coupon { background: var(--purple); color: var(--ink); }
.badge-none { background: #fff; color: #7a6a52; }
.badge-type { background: var(--cream); color: #7a6a52; }
.badge-who { color: var(--ink); }
.task-actions { flex: none; display: flex; flex-direction: column; gap: 6px; }
.icon-btn { width: 34px; height: 34px; border-radius: 11px; border: 2.5px solid var(--ink); background: #fff;
  font-size: 15px; display: flex; align-items: center; justify-content: center; }
.icon-btn.danger { background: #FFE3DC; }
.empty-box { background: var(--green); border: 3px solid var(--ink); border-radius: 20px; padding: 26px;
  text-align: center; font-size: 19px; font-weight: 900; box-shadow: -4px 4px 0 var(--ink); }
.done-card { background: #DFF7E7; border: 3px solid var(--ink); border-radius: 20px; padding: 11px 13px;
  display: flex; align-items: center; gap: 12px; }
.done-toggle { flex: none; width: 48px; height: 48px; border-radius: 14px; border: 3px solid var(--ink);
  background: var(--green); color: var(--ink); font-size: 26px; font-weight: 900; }
.done-title { font-size: 16px; font-weight: 700; color: #5c6b60; text-decoration: line-through; }
.done-earned { font-size: 13px; font-weight: 700; color: #0f7a42; margin-top: 1px; }

/* ---- wallet ---- */
.wallet-head { background: var(--green); border-bottom: 4px solid var(--ink); padding: 26px 22px 24px; }
.wallet-kicker { font-size: 13px; font-weight: 900; letter-spacing: .12em; color: #0d5c2f; }
.wallet-balance { display: flex; align-items: baseline; gap: 8px; margin-top: 6px; }
.wallet-balance .num { font-size: 64px; font-weight: 900; color: #fff; text-shadow: -4px 4px 0 var(--ink); }
.wallet-balance .cur { font-size: 32px; font-weight: 900; }
.coupon-card { display: flex; align-items: center; gap: 12px; border-radius: 20px; padding: 12px; border: 3px solid var(--ink);
  background: #fff; box-shadow: -4px 4px 0 var(--ink); }
.coupon-card.redeemed { border-color: #B5AC9C; background: #EFE9DD; box-shadow: none; }
.coupon-stub { flex: none; width: 50px; height: 50px; border-radius: 14px; display: flex; align-items: center;
  justify-content: center; border: 3px solid var(--ink); background: var(--purple); }
.coupon-card.redeemed .coupon-stub { border-color: #B5AC9C; background: #E3DCCE; }
.coupon-stub span { display: block; width: 26px; height: 17px; border-radius: 4px; border: 2.5px dashed var(--ink); background: var(--cream); }
.coupon-card.redeemed .coupon-stub span { border-color: #8F8778; background: transparent; }
.coupon-text { font-size: 16px; font-weight: 900; }
.coupon-card.redeemed .coupon-text { color: #8F8778; text-decoration: line-through; }
.coupon-meta { font-size: 12px; font-weight: 700; margin-top: 2px; color: #7a6a52; }
.coupon-redeem { flex: none; border: 3px solid var(--ink); background: var(--orange); color: var(--ink);
  font-size: 14px; font-weight: 900; padding: 9px 14px; border-radius: 999px; box-shadow: -3px 3px 0 var(--ink); }

.field-input { width: 100%; border: 3px solid var(--ink); border-radius: 14px; padding: 12px 14px;
  font-size: 16px; outline: none; }

.goal-card { background: #fff; border: 3px solid var(--ink); border-radius: 20px; padding: 14px;
  box-shadow: -4px 4px 0 var(--ink); }
.goal-title-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.goal-title-row .title { font-size: 17px; font-weight: 900; }
.goal-title-row .remain { font-size: 13px; font-weight: 700; color: #7a6a52; white-space: nowrap; }
.goal-track { height: 18px; border-radius: 999px; background: var(--paper); border: 2.5px solid var(--ink);
  margin-top: 10px; overflow: hidden; }
.goal-fill { height: 100%; background: var(--orange); border-left: 2.5px solid var(--ink); transition: width .4s ease; }
.other-goal-item { display: flex; align-items: center; gap: 10px; background: #fff; border: 3px solid var(--ink);
  border-radius: 16px; padding: 10px 12px; }
.other-goal-item .title { flex: 1; min-width: 0; font-size: 15px; font-weight: 700; }
.other-goal-item .target { font-size: 13px; font-weight: 900; color: #7a4d05; white-space: nowrap; }

/* ---- kids tab ---- */
.kids-head { background: var(--purple); border-bottom: 4px solid var(--ink); padding: 26px 22px 22px; }
.kids-kicker { font-size: 13px; font-weight: 900; letter-spacing: .12em; color: #3d2b7a; }
.kids-title { font-size: 34px; font-weight: 900; color: #fff; margin-top: 4px; text-shadow: -3px 3px 0 var(--ink); }
.kid-card { background: #fff; border: 3px solid var(--ink); border-radius: 20px; padding: 13px;
  display: flex; align-items: center; gap: 12px; box-shadow: -4px 4px 0 var(--ink); }
.kid-balance { flex: none; text-align: center; background: var(--orange); border: 3px solid var(--ink);
  border-radius: 14px; padding: 8px 12px; }

/* ---- profile ---- */
.profile-head { display: flex; flex-direction: column; align-items: center; padding: 28px 22px 26px; border-bottom: 4px solid var(--ink); }
.profile-photo-wrap { position: relative; }
.photo-edit-btn { position: absolute; bottom: -2px; left: -8px; width: 36px; height: 36px; border-radius: 50%;
  background: var(--orange); border: 3px solid var(--ink); display: flex; align-items: center; justify-content: center; }
.stat-row { display: flex; gap: 12px; }
.stat-box { flex: 1; border: 3px solid var(--ink); border-radius: 20px; padding: 14px; text-align: center; box-shadow: -4px 4px 0 var(--ink); }
.stat-num { font-size: 30px; font-weight: 900; line-height: 1; }
.stat-label { font-size: 12px; font-weight: 900; margin-top: 3px; }

/* ---- bottom tabs ---- */
.tabbar { flex: none; display: flex; gap: 8px; background: var(--cream); border-top: 4px solid var(--ink);
  padding: 10px 14px 24px; }
.tab-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 0 8px;
  border-radius: 18px; border: 3px solid transparent; color: #9A9080; background: transparent; }
.tab-btn.active { border-color: var(--ink); box-shadow: -3px 3px 0 var(--ink); }
.tab-btn span { font-size: 11px; font-weight: 900; }

/* ---- toast ---- */
#toast { position: absolute; left: 20px; right: 20px; bottom: 104px; background: var(--ink); color: var(--cream);
  border-radius: 18px; padding: 14px 18px; font-size: 15px; font-weight: 700; text-align: center;
  box-shadow: -4px 4px 0 rgba(0,0,0,.25); display: none; z-index: 40; }
#toast.show { display: block; animation: rise .25s ease; }
@keyframes rise { from{transform:translateY(34px);opacity:0} to{transform:translateY(0);opacity:1} }

/* ---- modal ---- */
.modal-backdrop { position: absolute; inset: 0; background: rgba(34,28,24,.55); display: none; align-items: flex-end; z-index: 50; }
.modal-backdrop.show { display: flex; }
.modal-sheet { width: 100%; max-height: 92%; overflow-y: auto; background: var(--cream); border-top: 4px solid var(--ink);
  border-radius: 28px 28px 0 0; padding: 20px 20px 26px; animation: rise .28s ease; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-head h2 { font-size: 26px; font-weight: 900; margin: 0; }
.modal-close { border: 3px solid var(--ink); background: #fff; width: 38px; height: 38px; border-radius: 50%; font-size: 17px; font-weight: 900; }
.field-label { display: block; font-size: 13px; font-weight: 900; color: #7a6a52; margin: 20px 0 8px; }
.modal-sheet input[type=text] { width: 100%; border: 3px solid var(--ink); background: #fff; border-radius: 16px;
  padding: 14px; font-size: 17px; outline: none; }
.seg { display: flex; gap: 7px; background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 6px; }
.seg button { flex: 1; border-radius: 13px; padding: 12px 6px; font-size: 14px; font-weight: 900; background: transparent;
  border: 2.5px solid transparent; color: #7a6a52; }
.seg button.active { background: var(--ink); color: var(--cream); border-color: var(--ink); }
.stepper { display: flex; align-items: center; justify-content: space-between; background: #fff; border: 3px solid var(--ink);
  border-radius: 18px; padding: 9px 13px; margin-top: 11px; }
.stepper button { width: 42px; height: 42px; border-radius: 13px; border: 3px solid var(--ink); background: var(--cream); font-size: 22px; font-weight: 900; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border-radius: 999px; padding: 10px 16px; font-size: 14px; font-weight: 900; border: 3px solid var(--ink); background: #fff; }
.chip.active { background: var(--blue); color: #fff; box-shadow: -3px 3px 0 var(--ink); }
.preset-scroll { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.preset-chip { flex: none; border-radius: 999px; padding: 9px 14px; font-size: 13px; font-weight: 900; border: 2.5px solid var(--ink);
  background: #fff; white-space: nowrap; }
.preset-chip.active { background: var(--ink); color: var(--cream); }

.hidden { display: none !important; }
