:root {
  --ink: #2b2238; --ink2: #54486a; --paper: #fff8ec; --cream: #f5e8cf; --line: #e3d3b6;
  --coral: #ee7650; --coral-d: #c95735; --teal: #2f9c90; --gold: #f2b84b; --plum: #4b3466;
  --smarts: #4f7fe0; --grit: #df5a3c; --charm: #c853a6; --energy: #f0b62e; --mood: #3fb37e; --bad: #d24a4a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2a2340; }
body { font-family: "Nunito", "Avenir Next", "Segoe UI", system-ui, -apple-system, Roboto, "DejaVu Sans", sans-serif; color: var(--ink); user-select: none; -webkit-user-select: none; }
#wrap { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, #3a3156, #211b33 70%); }
#stage { position: absolute; left: 0; top: 0; width: 360px; height: 640px; transform-origin: 0 0; overflow: hidden; background: #9cc58a; border-radius: 6px; }
#town { position: absolute; left: 0; top: 0; width: 360px; height: 640px; touch-action: none; }
#fx { position: absolute; left: 0; top: 0; width: 360px; height: 640px; pointer-events: none; z-index: 40; }
.hide { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 1px; }
.ico { display: inline-block; width: 16px; height: 16px; flex: none; }
.ico svg { width: 100%; height: 100%; display: block; }

/* ---------------- HUD */
#hud { position: absolute; left: 6px; right: 6px; top: 6px; height: 50px; z-index: 10; display: flex; align-items: center; gap: 6px;
  padding: 0 6px; background: rgba(255, 248, 236, 0.94); border-radius: 14px; box-shadow: 0 3px 0 rgba(43, 34, 56, 0.18), 0 6px 14px rgba(0, 0, 0, 0.12); }
.hcell { display: flex; align-items: center; gap: 3px; font-size: 13px; white-space: nowrap; }
.hcell.day { flex-direction: column; align-items: flex-start; gap: 0; line-height: 1.05; min-width: 58px; max-width: 72px; overflow: hidden; margin-right: 0; flex-shrink: 0; }
.hcell.day b { font-size: 13px; letter-spacing: -0.2px; }
.hcell.day b small { font-size: 10px; font-weight: 700; color: var(--ink2); margin-left: 1px; }
.hcell.day span { font-size: 10px; color: var(--ink2); }
.hcell.clock b { font-size: 14px; min-width: 50px; }
.hcell.money b { font-size: 15px; color: #2e7d4a; min-width: 38px; }
.hcell.money b.neg { color: var(--bad); }
.hcell.bars { flex: 1; flex-direction: column; align-items: stretch; gap: 4px; min-width: 50px; }
.bar { display: flex; align-items: center; gap: 2px; }
.bar .ico { width: 12px; height: 12px; }
.bar i { flex: 1; height: 7px; border-radius: 4px; background: #e6dac4; overflow: hidden; display: block; }
.bar em { display: block; height: 100%; width: 50%; border-radius: 4px; transition: width 0.45s ease, background 0.3s; }
.bar.en em { background: var(--energy); }
.bar.md em { background: var(--mood); }
.bar em.low { background: var(--bad); }
.hbtn { width: 30px; height: 30px; border-radius: 10px; background: var(--cream); display: flex; align-items: center; justify-content: center; }
.hbtn .ico { width: 16px; height: 16px; }
.pulse { animation: pulse 0.5s ease; }
@keyframes pulse { 30% { transform: scale(1.25); } }
#notice { position: absolute; left: 14px; right: 14px; top: 60px; z-index: 9; font-size: 11px; line-height: 1.25; padding: 4px 9px; border-radius: 9px;
  background: rgba(75, 52, 102, 0.88); color: #fff3d8; text-align: center; pointer-events: none; }

/* ---------------- footer */
#foot { position: absolute; left: 6px; right: 6px; bottom: 6px; height: 62px; z-index: 10; display: flex; align-items: stretch; gap: 5px; }
.stat { flex: 1; background: rgba(255, 248, 236, 0.95); border-radius: 13px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 3px 0 rgba(43, 34, 56, 0.18); position: relative; }
.stat .ico { width: 18px; height: 18px; }
.stat b { font-size: 18px; line-height: 1; margin-top: 1px; }
.stat small { font-size: 10px; color: var(--ink2); }
.stat.sm b { color: var(--smarts); } .stat.gr b { color: var(--grit); } .stat.ch b { color: var(--charm); }
#fGoal { flex: 1.35; background: var(--plum); color: #fff3d8; border-radius: 13px; display: flex; align-items: center; gap: 4px; padding: 0 6px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); }
#fGoal svg { width: 40px; height: 40px; transform: rotate(-90deg); flex: none; }
#fGoal .trk { fill: none; stroke: rgba(255, 255, 255, 0.18); stroke-width: 5; }
#fGoal .prog { fill: none; stroke: var(--gold); stroke-width: 5; stroke-linecap: round; stroke-dasharray: 94.25; stroke-dashoffset: 94.25; transition: stroke-dashoffset 0.6s ease; }
#fGoal .gtxt { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; min-width: 0; }
#fGoal b { font-size: 16px; }
#fGoal small { font-size: 9.5px; opacity: 0.85; line-height: 1.1; max-width: 76px; }
#fGoal.ready { background: var(--teal); animation: glow 1.4s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 4px rgba(242, 184, 75, 0.7); } }

/* ---------------- location sheet */
#sheet { position: absolute; left: 6px; right: 6px; bottom: 74px; height: 410px; z-index: 20; background: var(--paper); border-radius: 20px;
  box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.28); display: flex; flex-direction: column; transform: translateY(0); transition: transform 0.28s cubic-bezier(.2, .9, .3, 1.15); }
#sheet.off { transform: translateY(125%); }
.sh-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 12px 14px 4px; }
.sh-head h2 { margin: 0; font-size: 19px; line-height: 1.1; }
.sh-head p { margin: 3px 0 0; font-size: 11px; color: var(--ink2); line-height: 1.3; }
#shClose { background: var(--ink); color: var(--paper); font-weight: 700; font-size: 13px; padding: 8px 14px; border-radius: 12px; flex: none; }
#shPeople { padding: 0 14px; display: flex; gap: 6px; flex-wrap: wrap; }
#shPeople:empty { display: none; }
.person { display: flex; align-items: center; gap: 5px; font-size: 11px; background: #fbe6ef; color: #7a2d5c; padding: 3px 8px 3px 4px; border-radius: 10px; margin-top: 4px; }
.person .face { width: 18px; height: 18px; border-radius: 50%; }
.hearts { letter-spacing: 1px; color: #e04f8d; font-size: 11px; }
.hearts span { color: #e2c2d2; }
#shResult { margin: 6px 12px 2px; padding: 8px 10px; border-radius: 12px; background: var(--cream); font-size: 12.5px; line-height: 1.35; min-height: 36px; }
#shResult.empty { color: var(--ink2); font-style: italic; }
#shResult.bad { background: #f8dcd6; }
#shResult.flash { animation: flash 0.5s ease; }
@keyframes flash { 0% { background: #fff1b8; } }
#shResult .gain { display: inline-block; margin: 3px 4px 0 0; font-weight: 800; font-size: 11.5px; padding: 1px 6px; border-radius: 8px; background: rgba(255, 255, 255, 0.7); }
#shList { flex: 1; overflow-y: auto; padding: 4px 12px 14px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.act { width: 100%; display: flex; align-items: center; gap: 8px; text-align: left; background: #fff; border-radius: 14px; padding: 8px 10px; margin-top: 6px;
  box-shadow: 0 2px 0 var(--line), 0 0 0 1.5px var(--line) inset; transition: transform 0.08s; }
.act:active { transform: scale(0.98); }
.act .key { width: 20px; height: 20px; border-radius: 6px; background: var(--cream); font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex: none; color: var(--ink2); }
.act .main { flex: 1; min-width: 0; display: block; }
.act .lbl { font-weight: 800; font-size: 14px; display: flex; gap: 6px; align-items: center; }
.act .lbl .risk { font-size: 9px; font-weight: 800; color: #fff; background: var(--coral-d); padding: 1px 5px; border-radius: 6px; letter-spacing: 0.5px; }
.act .desc { display: block; font-size: 11px; color: var(--ink2); line-height: 1.25; margin-top: 1px; }
.act .why { display: block; font-size: 11px; color: var(--bad); font-weight: 700; margin-top: 2px; }
.act .chips { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.chip { font-size: 10.5px; font-weight: 800; padding: 1px 6px; border-radius: 7px; white-space: nowrap; background: var(--cream); display: flex; align-items: center; gap: 2px; }
.chip .ico { width: 11px; height: 11px; }
.chip.cost { background: #e0f0e3; color: #2e7d4a; }
.chip.en { background: #fdf0c9; color: #8a6510; }
.chip.en.plus { background: #d9f2e5; color: #1f7a50; }
.gives { display: flex; gap: 3px; margin-top: 3px; }
.gv { font-size: 9.5px; font-weight: 800; padding: 0 5px; border-radius: 6px; color: #fff; }
.gv.smarts { background: var(--smarts); } .gv.grit { background: var(--grit); } .gv.charm { background: var(--charm); }
.gv.money { background: #3d9a5f; } .gv.energy { background: #c99412; } .gv.mood { background: var(--mood); }
.gv.heart { background: #e04f8d; } .gv.fed { background: #a7713d; } .gv.item { background: var(--plum); }
.act.off { opacity: 0.62; box-shadow: 0 0 0 1.5px var(--line) inset; background: #f7f1e6; }
.act.off .lbl { color: var(--ink2); }
.act.go { background: var(--teal); color: #fff; box-shadow: 0 3px 0 #1d6b62; }
.act.go .desc { color: #e5fffb; }
.sh-section { font-size: 10px; font-weight: 800; letter-spacing: 1px; color: var(--ink2); margin: 10px 2px 0; text-transform: uppercase; }
#sheet.busy #shList { pointer-events: none; opacity: 0.55; }

/* ---------------- modal cards */
#modal { position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(33, 27, 51, 0.55); padding: 10px; }
#modal.clear { background: rgba(33, 27, 51, 0.15); }
.card { background: var(--paper); border-radius: 20px; padding: 14px 14px 12px; width: 100%; max-height: 620px; overflow-y: auto; box-shadow: 0 6px 0 rgba(0, 0, 0, 0.2), 0 12px 30px rgba(0, 0, 0, 0.3);
  animation: pop 0.32s cubic-bezier(.2, .9, .3, 1.3); }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } }
.card h1 { margin: 0; font-size: 40px; letter-spacing: -1px; line-height: 1; color: var(--plum); }
.card h2 { margin: 0 0 6px; font-size: 21px; line-height: 1.15; }
.card h3 { margin: 10px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--ink2); }
.card p { margin: 5px 0; font-size: 13px; line-height: 1.36; }
.card .small { font-size: 11.5px; color: var(--ink2); }
.btn { display: block; width: 100%; margin-top: 9px; padding: 12px; border-radius: 14px; background: var(--coral); color: #fff; font-weight: 800; font-size: 16px;
  box-shadow: 0 4px 0 var(--coral-d); transition: transform 0.08s; }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--coral-d); }
.btn.alt { background: var(--cream); color: var(--ink); box-shadow: 0 4px 0 var(--line); }
.btn.teal { background: var(--teal); box-shadow: 0 4px 0 #1d6b62; }
.btns2 { display: flex; gap: 8px; } .btns2 .btn { flex: 1; }
.title { text-align: center; background: linear-gradient(#fff8ec, #fbeed6); }
.title .lace { display: block; margin: 2px auto 0; width: 220px; height: 22px; }
.title .tag { font-size: 14px; font-weight: 700; color: var(--ink2); margin-top: 6px; }
.title .best { font-size: 12px; color: var(--ink2); margin-top: 8px; }
.goalcard { display: flex; gap: 9px; align-items: flex-start; width: 100%; text-align: left; background: #fff; border-radius: 14px; padding: 8px 9px; margin-top: 7px;
  box-shadow: 0 3px 0 var(--line), 0 0 0 1.5px var(--line) inset; }
.goalcard:active { transform: scale(0.98); }
.goalcard .gi { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex: none; }
.goalcard .gi .ico { width: 26px; height: 26px; }
.goalcard b { font-size: 15px; display: block; }
.goalcard span { font-size: 11px; color: var(--ink2); line-height: 1.3; display: block; margin-top: 2px; }
.goalcard em { font-style: normal; font-size: 10.5px; font-weight: 800; color: var(--plum); display: block; margin-top: 4px; }
.goalcard .won { color: var(--teal); }
.req { margin: 8px 0; }
.req .rl { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; }
.req .rb { height: 12px; background: #eadcc3; border-radius: 6px; overflow: hidden; margin-top: 3px; }
.req .rb i { display: block; height: 100%; width: 0; background: var(--gold); border-radius: 6px; transition: width 1s ease; }
.req.met .rb i { background: var(--teal); }
.lines p { padding: 5px 9px; background: var(--cream); border-radius: 10px; font-size: 12.5px; }
.lines p.bad { background: #f8dcd6; }
.lines p.big { background: var(--gold); font-weight: 800; }
.daybig { text-align: center; }
.daybig .dn { font-size: 46px; font-weight: 900; color: var(--plum); line-height: 1; }
.daybig .wd { font-size: 14px; font-weight: 700; color: var(--ink2); }
.daybig .wx { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; margin-top: 6px; }
.daybig .wx .ico { width: 26px; height: 26px; }
.notice-card { background: var(--plum); color: #fff3d8; border-radius: 12px; padding: 8px 10px; font-size: 12.5px; margin-top: 8px; }
.verdict { text-align: center; font-size: 26px; font-weight: 900; margin: 6px 0; }
.verdict.win { color: var(--teal); } .verdict.lose { color: var(--coral-d); }
.scoretab { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 6px; }
.scoretab td { padding: 2px 0; } .scoretab td:last-child { text-align: right; font-weight: 800; }
.scoretab tr.tot td { border-top: 2px solid var(--line); font-size: 16px; padding-top: 5px; }
.friendrow { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 12.5px; }
.friendrow .face { width: 28px; height: 28px; border-radius: 50%; flex: none; }
.friendrow .fi { flex: 1; line-height: 1.25; }
.friendrow small { color: var(--ink2); display: block; font-size: 11px; }
.itemlist { font-size: 12px; color: var(--ink2); }
.ducks { display: flex; gap: 6px; margin-top: 8px; }
.duckbtn { flex: 1; background: #fff; border-radius: 12px; padding: 6px 2px; font-size: 10.5px; font-weight: 800; box-shadow: 0 3px 0 var(--line), 0 0 0 1.5px var(--line) inset; text-align: center; line-height: 1.2; }
.duckbtn svg { width: 38px; height: 30px; display: block; margin: 0 auto 2px; }
#race { width: 100%; height: 150px; display: block; border-radius: 12px; margin-top: 8px; background: #6fb8d0; }
.heartbig { text-align: center; font-size: 30px; color: #e04f8d; letter-spacing: 3px; }
.heartbig span { color: #ead0dc; }
.hint { position: absolute; z-index: 12; pointer-events: none; background: var(--gold); color: var(--ink); font-weight: 800; font-size: 12px; padding: 5px 9px; border-radius: 10px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2); animation: bob 1s ease-in-out infinite; white-space: nowrap; }
@keyframes bob { 50% { transform: translateY(-4px); } }
#rotate { position: absolute; inset: 0; z-index: 60; background: rgba(33, 27, 51, 0.9); display: flex; align-items: center; justify-content: center; padding: 20px; }
