:root {
  --bg: #fff6ec;
  --card: #ffffff;
  --card-2: #fdeee0;
  --ink: #2b1a14;
  --muted: #8a6f63;
  --line: #f0dccb;
  --brand: #d7382b;
  --brand-2: #f28c28;
  --brand-ink: #ffffff;
  --good: #2e9e5b;
  --warn: #e0a100;
  --shadow: 0 6px 20px rgba(120, 40, 20, 0.12);
  --radius: 20px;
  --tabbar: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a110f;
    --card: #2a1c18;
    --card-2: #35241f;
    --ink: #fbede3;
    --muted: #b89a8c;
    --line: #3d2a24;
    --brand: #f0523f;
    --brand-2: #ffa040;
    --good: #4cc27a;
    --warn: #ffc83d;
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  -webkit-user-select: none;
  user-select: none;
}
input, select, textarea { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100%;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(var(--tabbar) + env(safe-area-inset-bottom) + 24px);
}
#app.no-tabs { padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }

/* --- Buttons --------------------------------------------------------------- */
.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  background: var(--card-2);
  transition: transform .08s ease, filter .15s;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.good { background: var(--good); color: #fff; }
.btn.ghost { background: transparent; border: 2px solid var(--line); }
.btn.block { display: block; width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 14px; border-radius: 12px; }

.mega {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 28px;
  padding: 26px 20px;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: .3px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  box-shadow: 0 10px 0 #9e2219, 0 18px 30px rgba(215, 56, 43, .35);
  transform: translateY(0);
  transition: transform .08s, box-shadow .08s;
}
.mega:active { transform: translateY(8px); box-shadow: 0 2px 0 #9e2219, 0 6px 12px rgba(215, 56, 43, .3); }
.mega:disabled { filter: grayscale(.8); opacity: .55; }
.mega .sub { display: block; font-size: 14px; font-weight: 600; opacity: .9; margin-top: 4px; }

/* --- Cards ----------------------------------------------------------------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.section-title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin: 22px 4px 10px;
  display: flex;
  justify-content: space-between;
}

/* --- Header ---------------------------------------------------------------- */
.hero { display: flex; align-items: center; gap: 12px; margin: 6px 0 14px; }
.avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 26px;
  flex: none;
  background: var(--av, var(--brand));
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.15);
}
.avatar.sm { width: 30px; height: 30px; font-size: 16px; }
.avatar.lg { width: 84px; height: 84px; font-size: 46px; }
.hero .who { flex: 1; min-width: 0; }
.hero .who h1 { font-size: 22px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 800;
  background: var(--card);
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.pill.points { color: var(--brand); font-size: 18px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.stat { background: var(--card); border-radius: 16px; padding: 10px; text-align: center; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); font-weight: 700; }
.bar { height: 10px; border-radius: 99px; background: var(--card-2); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-2), var(--brand)); border-radius: 99px; }

/* --- Chore cards ----------------------------------------------------------- */
.chore {
  display: flex; gap: 14px; align-items: center;
}
.chore .em { font-size: 40px; line-height: 1; }
.chore h3 { font-size: 19px; }
.chore .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.chore-actions { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; margin-top: 14px; }
.chore-actions .btn { padding: 12px 6px; font-size: 14px; }
.tag {
  display: inline-block;
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px;
  padding: 2px 8px; border-radius: 99px;
  background: var(--card-2); color: var(--muted);
}
.tag.hot { background: var(--brand); color: #fff; }
.tag.meh { background: var(--muted); color: var(--bg); }

.empty { text-align: center; padding: 26px 10px; color: var(--muted); }
.empty .big { font-size: 48px; }

/* --- House board ----------------------------------------------------------- */
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row .em { font-size: 24px; width: 32px; text-align: center; }
.row .name { flex: 1; min-width: 0; font-weight: 600; }
.row.done .name { text-decoration: line-through; color: var(--muted); }
.row button.linklike { background: none; border: 0; padding: 0; text-align: left; width: 100%; display: flex; align-items: center; gap: 12px; }

/* --- Scores ---------------------------------------------------------------- */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin: 10px 0 18px; }
.podium .spot { flex: 1; max-width: 140px; text-align: center; }
.podium .block {
  margin-top: 8px;
  border-radius: 16px 16px 6px 6px;
  background: linear-gradient(180deg, var(--brand-2), var(--brand));
  color: #fff; font-weight: 900; font-size: 22px;
  display: grid; place-items: center;
}
.podium .name { font-weight: 800; margin-top: 4px; }
.feed .item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.feed .item:last-child { border-bottom: 0; }
.feed .when { color: var(--muted); font-size: 12px; white-space: nowrap; margin-left: auto; }

/* --- Tab bar --------------------------------------------------------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  display: flex; justify-content: center;
  z-index: 10;
}
.tabbar .inner { display: flex; width: 100%; max-width: 560px; }
.tabbar button {
  flex: 1; background: none; border: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 800; color: var(--muted);
}
.tabbar button .i { font-size: 24px; filter: grayscale(1); opacity: .7; transition: transform .15s; }
.tabbar button.on { color: var(--brand); }
.tabbar button.on .i { filter: none; opacity: 1; transform: scale(1.12); }

/* --- Login / setup --------------------------------------------------------- */
.brand { text-align: center; margin: 30px 0 24px; }
.brand .logo { width: 96px; height: 96px; border-radius: 24px; box-shadow: var(--shadow); }
.brand h1 { font-size: 40px; font-weight: 900; color: var(--brand); margin-top: 10px; letter-spacing: -.5px; }
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 14px; }
.person { background: var(--card); border: 0; border-radius: 22px; padding: 18px 8px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 8px; font-weight: 800; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 20px 0; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); }
.pin-dots i.on { background: var(--brand); border-color: var(--brand); }
.pin-dots.shake { animation: shake .4s; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 300px; margin: 0 auto; }
.keypad button { height: 66px; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--shadow); font-size: 26px; font-weight: 700; }
.keypad button:active { background: var(--card-2); }
.keypad button.blank { visibility: hidden; }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; font-weight: 800; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=password], input[type=tel], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 17px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--ink);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand-2); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; margin: 10px 0; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.swatches, .emojis { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 32px; height: 32px; border-radius: 50%; border: 3px solid transparent; }
.swatches button.on { border-color: var(--ink); }
.emojis button { width: 40px; height: 40px; border-radius: 12px; border: 2px solid transparent; background: var(--card-2); font-size: 22px; padding: 0; }
.emojis button.on { border-color: var(--brand); }

/* --- Offer overlay --------------------------------------------------------- */
#overlay {
  position: fixed; inset: 0; z-index: 50;
  background: radial-gradient(circle at 50% 30%, #f6a04a 0%, #d7382b 55%, #7a1b14 100%);
  color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 20px) 22px calc(env(safe-area-inset-bottom) + 24px);
  text-align: center;
  animation: fadein .2s;
}
#overlay .kicker { font-weight: 900; text-transform: uppercase; letter-spacing: 2px; opacity: .85; font-size: 14px; }
.reel {
  width: 100%; max-width: 420px;
  height: 190px;
  margin: 18px 0;
  background: rgba(255,255,255,.14);
  border-radius: 28px;
  border: 3px solid rgba(255,255,255,.35);
  display: grid; place-items: center;
  overflow: hidden;
  padding: 10px 14px;
}
.reel .em { font-size: 72px; line-height: 1; }
.reel .nm { font-size: 26px; font-weight: 900; margin-top: 8px; text-shadow: 0 2px 0 rgba(0,0,0,.2); }
.reel.spinning .slot { animation: blur .09s linear infinite; }
.reel.landed .slot { animation: land .45s cubic-bezier(.2, 1.6, .4, 1); }
.reel .desc { font-size: 14px; opacity: .9; margin-top: 4px; }
.ring { position: relative; width: 120px; height: 120px; margin: 4px 0 18px; }
.ring svg { transform: rotate(-90deg); }
.ring .num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 44px; font-weight: 900; }
.ring.urgent .num { animation: pulse .5s infinite; }
.offer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; max-width: 420px; }
.offer-actions .btn { padding: 18px 10px; font-size: 20px; border-radius: 20px; font-weight: 900; }
.offer-actions .btn small { display: block; font-size: 13px; font-weight: 700; opacity: .9; }
.btn.accept { background: #fff; color: var(--good); box-shadow: 0 6px 0 rgba(0,0,0,.2); }
.btn.decline { background: rgba(0,0,0,.25); color: #fff; box-shadow: 0 6px 0 rgba(0,0,0,.2); }
.result .em { font-size: 90px; }
.result h2 { font-size: 30px; font-weight: 900; margin: 6px 0; }
.result p { font-size: 17px; opacity: .95; margin: 6px 0 22px; }

/* --- Sheet & toast --------------------------------------------------------- */
#sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; animation: fadein .2s; }
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-width: 560px; margin: 0 auto;
  max-height: 88vh; overflow-y: auto;
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  padding: 10px 18px calc(env(safe-area-inset-bottom) + 20px);
  animation: slideup .25s cubic-bezier(.2, .9, .3, 1);
}
#sheet::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 14px; }
#sheet h2 { font-size: 22px; margin-bottom: 12px; }
#sheet .actions { display: grid; gap: 10px; margin-top: 16px; }
#toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 12px); transform: translateX(-50%);
  z-index: 60;
  background: var(--ink); color: var(--bg);
  padding: 12px 18px; border-radius: 16px; font-weight: 800;
  box-shadow: var(--shadow);
  max-width: calc(100% - 32px);
  animation: dropin .3s cubic-bezier(.2, 1.4, .4, 1);
}
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; width: 100%; height: 100%; }

@keyframes fadein { from { opacity: 0; } }
@keyframes slideup { from { transform: translateY(100%); } }
@keyframes dropin { from { transform: translate(-50%, -120%); } }
@keyframes pulse { 50% { transform: scale(1.15); } }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
@keyframes blur { 0% { transform: translateY(-30%); opacity: .4; } 50% { opacity: 1; } 100% { transform: translateY(30%); opacity: .4; } }
@keyframes land { 0% { transform: translateY(-40%) scale(.9); } 100% { transform: none; } }
@keyframes wiggle { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
.wiggle { display: inline-block; animation: wiggle .5s ease-in-out 2; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* --- ¡Hizo! completion stamp ---------------------------------------------- */
.hizo {
  position: fixed; inset: 0; z-index: 65;
  display: grid; place-items: center;
  background: rgba(26, 17, 15, .35);
  animation: fadein .15s;
  transition: opacity .4s;
}
.hizo.out { opacity: 0; }
.hizo .stamp {
  text-align: center; color: #fff;
  background: linear-gradient(135deg, var(--good), #1f7a45);
  border: 6px solid #fff;
  border-radius: 32px;
  padding: 22px 38px 18px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
  transform: rotate(-6deg);
  animation: stamp .45s cubic-bezier(.2, 1.6, .4, 1);
}
.hizo .word { font-size: 56px; font-weight: 900; letter-spacing: -1px; line-height: 1; text-shadow: 0 3px 0 rgba(0,0,0,.2); }
.hizo .plus { font-size: 30px; font-weight: 900; margin-top: 4px; }
.hizo .extra { font-size: 16px; font-weight: 800; margin-top: 6px; opacity: .95; }
@keyframes stamp { 0% { transform: rotate(-20deg) scale(2.2); opacity: 0; } 100% { transform: rotate(-6deg) scale(1); opacity: 1; } }
