/* RealtyPop. Twilight cul-de-sac: indigo night, pastel pop houses, chunky sticker UI.
   Layout: one portrait column (max 430px) centered on desktop; top bar + screen area. */
:root {
  --night: #171a3a;
  --night-2: #232858;
  --night-3: #2f3570;
  --ink: #12132b;
  --text: #f5f2ff;
  --muted: #bdb9e6;
  --mint: #73e2c0;
  --coral: #ff8b7b;
  --butter: #ffd56b;
  --sky: #8ec9ff;
  --lilac: #b7a2ff;
  --pop: #ff5fa2;
  --paper: #fff6e3;
  --paper-ink: #2a2547;
  --paper-muted: #6b6488;
  --bad: #c2412f;
  --display: 'Fredoka', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --body: 'Nunito', system-ui, -apple-system, sans-serif;
  --mono: 'DM Mono', ui-monospace, Menlo, monospace;
  --topbar: 52px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: #0d0f24; }
body {
  color: var(--text); font-family: var(--body); font-size: 15px; line-height: 1.35;
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
  overscroll-behavior: none; touch-action: manipulation;
}
button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--butter); outline-offset: 2px; }

#shell {
  position: relative; max-width: 430px; margin: 0 auto; height: 100%; height: 100dvh;
  display: flex; flex-direction: column; overflow: hidden;
  background: linear-gradient(180deg, #151836 0%, #252a63 55%, #4a3b7c 82%, #b8668a 100%);
  box-shadow: 0 0 80px rgba(0,0,0,.5);
}
.topbar {
  flex: none; height: calc(var(--topbar) + env(safe-area-inset-top, 0px)); display: flex; align-items: center; gap: 8px;
  padding: env(safe-area-inset-top, 0px) 68px 0 max(10px, env(safe-area-inset-left, 0px)); /* right 68px keeps clear of the arcade fullscreen button */
  position: relative; z-index: 20;
}
.back-link {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: 12px;
  background: rgba(10,12,34,.55); border: 2px solid rgba(245,242,255,.16); color: var(--text); text-decoration: none;
  font-family: var(--display); font-weight: 600; font-size: 14px;
}
.topbtn {
  width: 40px; height: 40px; border-radius: 12px; border: 2px solid rgba(245,242,255,.16); background: rgba(10,12,34,.55);
  font-size: 18px; cursor: pointer; display: inline-grid; place-items: center;
}
#app { flex: 1 1 auto; min-height: 0; position: relative; }

/* every screen fills #app; content screens scroll, game stages do not */
.screen {
  position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  padding: 6px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 12px;
}
.screen.with-nav { padding-bottom: 0; scroll-padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
.screen.fixed { overflow: hidden; }
.screen.flat { background: linear-gradient(180deg, #171a3a 0%, #20255a 100%); }
@media (prefers-reduced-motion: no-preference) {
  .screen.enter { animation: rp-in .22s ease-out; }
  @keyframes rp-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

h1, h2, h3, .disp { font-family: var(--display); margin: 0; letter-spacing: .2px; text-wrap: balance; }
p { margin: 0; }
.eyebrow { font-family: var(--display); font-weight: 600; font-size: 12px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.center { text-align: center; align-items: center; }
.spacer { flex: 1 1 auto; }
.emo { line-height: 1; display: inline-block; }
.star { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #fff; opacity: .7; pointer-events: none; }

/* sticker buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 54px; padding: 0 22px; border-radius: 18px; border: 3px solid var(--ink);
  background: var(--butter); color: var(--ink); font-family: var(--display); font-weight: 600; font-size: 19px;
  box-shadow: 0 5px 0 var(--ink); cursor: pointer; text-decoration: none; transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.block { width: 100%; }
.btn.big { min-height: 60px; font-size: 22px; }
.btn.mint { background: var(--mint); }
.btn.coral { background: var(--coral); }
.btn.sky { background: var(--sky); }
.btn.ghost { background: transparent; color: var(--text); border-color: rgba(245,242,255,.35); box-shadow: none; font-size: 16px; min-height: 46px; }
.paper .btn.ghost { color: var(--ink); border-color: rgba(42,37,71,.45); }
.btn.sm { min-height: 44px; font-size: 15px; padding: 0 14px; border-radius: 14px; box-shadow: 0 4px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: 0 5px 0 var(--ink); }

.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: 999px; white-space: nowrap;
  font-family: var(--display); font-weight: 600; font-size: 12px; letter-spacing: .4px;
  border: 2px solid var(--ink); color: var(--ink); background: var(--mint);
}
.chip.seller { background: var(--coral); }
.chip.buyer { background: var(--sky); }
.chip.quirk { background: var(--lilac); }
.chip.gold { background: var(--butter); }
.chip.dark { background: rgba(255,255,255,.08); color: var(--text); border-color: rgba(245,242,255,.25); }

.card { background: var(--night-2); border: 2px solid rgba(245,242,255,.14); border-radius: 20px; padding: 14px; }
button.card { text-align: left; width: 100%; cursor: pointer; }
button.card:active { transform: scale(.985); }
.paper { background: var(--paper); color: var(--paper-ink); border: 3px solid var(--ink); border-radius: 18px; box-shadow: 0 5px 0 var(--ink); padding: 14px; }
.paper .muted { color: var(--paper-muted); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 999px; white-space: nowrap;
  background: rgba(10,12,34,.55); border: 2px solid rgba(245,242,255,.16); font-family: var(--display); font-weight: 600; font-size: 15px;
}
.pill.cash { background: var(--mint); color: var(--ink); border-color: var(--ink); }
.iconbtn {
  width: 44px; height: 44px; flex: none; border-radius: 14px; border: 2px solid rgba(245,242,255,.2); background: rgba(10,12,34,.5);
  color: var(--text); display: inline-flex; align-items: center; justify-content: center; font-size: 20px; cursor: pointer; font-family: var(--display); font-weight: 700;
}
.meter { height: 12px; border-radius: 999px; background: rgba(10,12,34,.6); border: 2px solid var(--ink); overflow: hidden; }
.meter > i { display: block; height: 100%; width: 0; background: var(--mint); border-radius: 999px; transition: width .3s ease; }
.meter.coral > i { background: var(--coral); }
.meter.butter > i { background: var(--butter); }
.keys { display: inline-flex; gap: 2px; font-size: 16px; white-space: nowrap; }
.key-off { opacity: .28; filter: grayscale(1); }
.banner {
  font-family: var(--display); font-weight: 700; font-size: 24px; text-align: center; color: var(--ink);
  background: var(--butter); border: 3px solid var(--ink); border-radius: 16px; padding: 6px 14px;
  box-shadow: 0 5px 0 var(--ink); transform: rotate(-2deg); display: inline-block;
}
.bubble {
  position: relative; background: var(--paper); color: var(--paper-ink); border: 3px solid var(--ink);
  border-radius: 18px; padding: 10px 14px; font-weight: 700; box-shadow: 0 4px 0 var(--ink);
}
.face { width: 56px; height: 56px; border-radius: 50%; overflow: hidden; border: 3px solid var(--ink); flex: none; background: var(--sky); }
.face svg { display: block; width: 100%; height: 100%; }
.face.md { width: 44px; height: 44px; }
.face.lg { width: 140px; height: 140px; border-width: 4px; box-shadow: 0 6px 0 var(--ink); }

/* bottom nav */
.nav {
  /* sticky inside the scrolling screen: pinned to the bottom, never scrolls away */
  position: sticky; bottom: 0; margin: auto -16px 0; flex: none; z-index: 10; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: rgba(10,12,34,.94); border-top: 2px solid rgba(245,242,255,.12);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px)); gap: 4px;
}
.nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 58px; color: var(--muted);
  background: transparent; border: 0; border-radius: 14px; font-family: var(--display); font-weight: 600; font-size: 12px; cursor: pointer;
}
.nav button.on { color: var(--ink); background: var(--butter); }
.nav svg { width: 24px; height: 24px; }

/* segmented toggle */
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 5px; border-radius: 16px; background: rgba(10,12,34,.55); border: 2px solid rgba(245,242,255,.16); }
.seg button { min-height: 44px; border-radius: 12px; border: 2px solid transparent; background: transparent; color: var(--muted); font-family: var(--display); font-weight: 600; font-size: 16px; cursor: pointer; }
.seg button[aria-pressed="true"] { border-color: var(--ink); background: var(--mint); color: var(--ink); }
.seg button.hustle[aria-pressed="true"] { background: var(--coral); }

/* switch row (settings) */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; width: 100%; padding: 8px 14px; border-radius: 16px; background: var(--night-2); border: 2px solid rgba(245,242,255,.14); cursor: pointer; text-align: left; }
.switch .knob { width: 52px; height: 30px; border-radius: 999px; background: rgba(10,12,34,.7); border: 2px solid var(--ink); position: relative; flex: none; transition: background .15s; }
.switch .knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch[aria-checked="true"] .knob { background: var(--mint); }
.switch[aria-checked="true"] .knob::after { transform: translateX(22px); background: var(--ink); }

/* toast + overlays */
.toast {
  position: absolute; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60;
  background: var(--paper); color: var(--paper-ink); border: 3px solid var(--ink); border-radius: 14px; padding: 8px 14px;
  font-weight: 800; box-shadow: 0 4px 0 var(--ink); max-width: 90%; text-align: center; pointer-events: none;
}
.overlay {
  position: absolute; inset: 0; z-index: 50; background: rgba(8,9,26,.72); display: grid; place-items: center; padding: 20px;
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.overlay > .sheet { width: 100%; max-width: 360px; }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 40; }
.confetti i { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; border: 1.5px solid var(--ink); }
@media (prefers-reduced-motion: no-preference) {
  .confetti i { animation: rp-fall linear forwards; }
  @keyframes rp-fall { to { transform: translateY(110vh) rotate(720deg); } }
  .pulse { animation: rp-pulse 1.6s ease-in-out infinite; }
  @keyframes rp-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
  .pop { animation: rp-pop .35s ease-out; }
  .toast.pop { animation-name: rp-toast; }
  @keyframes rp-toast { 0% { transform: translateX(-50%) scale(.6); opacity: 0; } 70% { transform: translateX(-50%) scale(1.08); } 100% { transform: translateX(-50%) scale(1); opacity: 1; } }
  @keyframes rp-pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
  .shake { animation: rp-shake .3s; }
  @keyframes rp-shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
}

/* ---------- stage chrome (all mini-games) ---------- */
.stage { position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden; background: linear-gradient(180deg, #171a3a 0%, #20255a 100%); }
.stage-hud { flex: none; display: flex; align-items: center; gap: 8px; padding: 4px 14px 0; }
.stage-hud .title { font-family: var(--display); font-weight: 600; font-size: 18px; line-height: 1.1; }
.stage-hud .sub { font-size: 12px; color: var(--muted); }
.stage-meta { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 14px 0; }
.stage-meta .count { font-family: var(--display); font-weight: 600; font-size: 14px; white-space: nowrap; }
.timer { flex: none; margin: 6px 14px 0; height: 8px; border-radius: 99px; background: rgba(10,12,34,.6); overflow: hidden; }
.timer > i { display: block; height: 100%; background: var(--coral); width: 100%; }
.stage-banner { position: absolute; left: 0; right: 0; top: 92px; z-index: 30; text-align: center; pointer-events: none; transition: opacity .4s; }
.stage-body { flex: 1 1 auto; min-height: 0; position: relative; margin: 8px 0 0; }
.stage-foot { flex: none; padding: 8px 14px calc(14px + env(safe-area-inset-bottom, 0px)); }
.floater {
  position: absolute; z-index: 35; pointer-events: none; padding: 3px 10px; border-radius: 999px; border: 2px solid var(--ink);
  font-family: var(--display); font-weight: 700; font-size: 14px; color: var(--ink); background: var(--mint); white-space: nowrap;
  transform: translate(-50%, -100%);
}
.floater.bad { background: var(--coral); }
@media (prefers-reduced-motion: no-preference) {
  .floater { animation: rp-float .9s ease-out forwards; }
  @keyframes rp-float { to { transform: translate(-50%, -190%); opacity: 0; } }
}
.floater.combo { background: var(--butter); font-size: 16px; z-index: 36; }
.surprise {
  position: absolute; left: 50%; top: 96px; transform: translateX(-50%); z-index: 45; display: flex; align-items: center; gap: 8px;
  max-width: 92%; padding: 8px 14px; border-radius: 16px; border: 3px solid var(--ink); background: var(--pop); color: #fff;
  font-family: var(--display); font-weight: 600; font-size: 16px; box-shadow: 0 5px 0 var(--ink); pointer-events: none; text-align: left;
}
@media (prefers-reduced-motion: no-preference) {
  .surprise { animation: rp-surprise .35s ease-out; }
  @keyframes rp-surprise { from { transform: translateX(-50%) translateY(-12px) scale(.85); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
}
.surprise { width: max-content; }
.surprise-tag { flex: none; background: var(--butter); color: var(--ink); border: 2px solid var(--ink); border-radius: 8px; padding: 1px 6px; font-size: 11px; letter-spacing: 1px; }
.end-card { max-height: calc(100dvh - 140px); overflow-y: auto; }
.payoff { align-self: stretch; display: flex; justify-content: center; }
.end-keys .keys { font-size: 42px; gap: 8px; }

/* ---------- screens ---------- */
.title-logo { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; margin-top: 18px; }
.title-logo h1 { font-size: 64px; font-weight: 700; line-height: .95; color: #fff; text-shadow: 0 5px 0 var(--ink); }
.title-logo .pop-word {
  font-family: var(--display); font-weight: 700; font-size: 54px; line-height: 1; color: var(--ink); background: var(--coral);
  border: 4px solid var(--ink); border-radius: 22px; padding: 2px 22px 6px; transform: rotate(-4deg); box-shadow: 0 6px 0 var(--ink);
}
.scene { position: relative; width: calc(100% + 32px); margin: 0 -16px; flex: 1 1 auto; min-height: 180px; }
.scene svg { position: absolute; left: 0; bottom: 0; width: 100%; height: 100%; }
.title-foot { position: relative; z-index: 1; margin: -28px -6px 0; padding: 12px 10px; border-radius: 20px; background: rgba(18,19,43,.86); }
.credit { color: var(--muted); font-size: 13px; text-decoration: none; }
.credit:hover { color: var(--text); }

.journey-map { position: relative; flex: 1 1 auto; min-height: 230px; }
@media (max-height: 700px) { .journey-map .stop .dot { width: 50px; height: 50px; font-size: 24px; } .journey-map .stop .dot.now { width: 58px; height: 58px; } }
.journey-map svg.road { position: absolute; inset: 0; width: 100%; height: 100%; }
.stop { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 120px; transform: translate(-50%, -30px); text-align: center; }
.stop .dot { width: 60px; height: 60px; border-radius: 50%; border: 3px solid var(--ink); display: grid; place-items: center; font-size: 28px; box-shadow: 0 4px 0 var(--ink); }
.stop .dot.done { background: var(--mint); }
.stop .dot.now { background: var(--butter); width: 70px; height: 70px; font-size: 32px; box-shadow: 0 0 0 6px rgba(255,213,107,.3), 0 5px 0 var(--ink); }
.stop .dot.lock { background: var(--night-3); border-color: rgba(245,242,255,.35); box-shadow: none; opacity: .85; }
.stop .lbl { font-family: var(--display); font-weight: 600; font-size: 13px; background: rgba(10,12,34,.75); padding: 2px 8px; border-radius: 999px; }
.stop .lbl.now { background: var(--butter); color: var(--ink); }

.chat-in { align-self: flex-start; max-width: 84%; background: #2b3070; border: 2px solid rgba(245,242,255,.14); padding: 9px 13px; border-radius: 18px 18px 18px 6px; font-size: 15.5px; font-weight: 700; }
.reply {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 54px; padding: 8px 14px; border-radius: 16px; border: 3px solid var(--ink);
  background: var(--paper); color: var(--paper-ink); font-family: var(--body); font-weight: 800; font-size: 15.5px; text-align: left; box-shadow: 0 4px 0 var(--ink); cursor: pointer;
}
.reply:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.reply .k { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 14px; border: 2px solid var(--ink); }
.phone-sheet { background: #11143a; border: 3px solid var(--ink); border-radius: 28px; padding: 14px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 -10px 40px rgba(0,0,0,.35); }

.receipt .ln { display: flex; justify-content: space-between; gap: 10px; font-family: var(--mono); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.receipt .neg { color: var(--bad); }
.receipt .ln.bonus { font-weight: 800; }
.receipt .ln.bonus .pos { color: #1f7a5c; }
.chip.pay { background: rgba(115,226,192,.14); color: var(--mint); border-color: rgba(115,226,192,.45); }
@media (prefers-reduced-motion: no-preference) {
  .receipt .ln { animation: rp-in .3s ease-out backwards; }
}
.stars { font-size: 28px; letter-spacing: 4px; color: var(--butter); }
.stars .off { color: rgba(245,242,255,.2); }
.shop-row { display: flex; align-items: center; gap: 12px; }
.shop-row .emo { font-size: 34px; width: 44px; text-align: center; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }

/* ---------- onboarding, coach, goal, awards ---------- */
.coach {
  flex: none;
  display: flex; gap: 10px; align-items: flex-start; background: var(--paper); color: var(--paper-ink);
  border: 3px solid var(--ink); border-radius: 18px; padding: 12px; box-shadow: 0 5px 0 var(--ink);
}
.coach .muted { color: var(--paper-muted); }
.goal { border-color: rgba(255,213,107,.45); background: linear-gradient(180deg, #2a2c63, var(--night-2)); gap: 8px; }
.dotstep { width: 9px; height: 9px; border-radius: 50%; background: rgba(245,242,255,.25); }
.dotstep.on { background: var(--butter); width: 24px; border-radius: 99px; }
.intro-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; text-align: center; }
.intro-step { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; font-size: 30px; background: var(--paper); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); }
.billboard { display: flex; flex-direction: column; align-items: center; }
.bb-board {
  display: flex; align-items: center; gap: 12px; width: 100%; max-width: 330px; padding: 12px 14px; border-radius: 12px;
  background: linear-gradient(135deg, #ff8b7b, #ffd56b); color: var(--ink); border: 4px solid var(--ink); box-shadow: 0 6px 0 var(--ink);
}
.bb-board b { font-family: var(--display); font-size: 22px; line-height: 1.05; }
.bb-board span { font-weight: 800; font-size: 12.5px; }
.bb-posts { display: flex; gap: 120px; }
.bb-posts i { display: block; width: 10px; height: 34px; background: var(--paper); border: 3px solid var(--ink); border-top: 0; }
.podium { gap: 0; margin: 6px 0; }
.podium-stand { margin-top: -8px; padding: 10px 18px; border-radius: 10px 10px 0 0; background: var(--paper); color: var(--paper-ink); border: 3px solid var(--ink); font-family: var(--display); font-weight: 700; font-size: 14px; letter-spacing: 1px; box-shadow: 0 5px 0 var(--ink); }
