/* 🐷 Pig Life — bright, warm and chunky. Phone first (390 wide), then a
   tablet (768) and a desktop, where the life screen goes two columns. */

:root {
  --ink: #2b1b2e;
  --dim: #6d5a72;
  --bg1: #fff4e8;
  --bg2: #ffe1ec;
  --card: #ffffff;
  --line: #f0d6e2;
  --hot: #ff5f8f;
  --hot2: #e23d72;
  --sun: #ffd23f;
  --sky: #7fd3ff;
  --mint: #3fbf87;
  --shadow: 0 4px 0 rgba(90, 40, 70, .18);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg1), var(--bg2)) fixed;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.skip-link { position: absolute; left: -999px; top: 0; z-index: 40; background: var(--sun); color: var(--ink); padding: .5rem .8rem; border-radius: 0 0 .5rem 0; }
.skip-link:focus { left: 0; }

/* ---------- the bar along the top ---------- */
.bar {
  display: flex; align-items: center; gap: .6rem; padding: .45rem .8rem;
  background: linear-gradient(90deg, #ff7aa6, #ffa45c); color: #fff;
  box-shadow: 0 2px 0 rgba(120, 30, 60, .2);
}
.bar h1 { font-size: 1.15rem; margin: 0; flex: 1; text-shadow: 0 2px 0 rgba(120, 30, 60, .3); white-space: nowrap; }
.bar .home { color: #fff; text-decoration: none; font-weight: 700; white-space: nowrap; font-size: .92rem; display: inline-flex; align-items: center; min-height: 44px; padding: 0 .3rem; border-radius: 12px; }
.bar .build { font-size: .75rem; opacity: .9; }
.icon-btn {
  min-width: 44px; height: 44px; border-radius: 12px; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .85); color: var(--ink); font-size: 1.15rem; box-shadow: var(--shadow);
}
.icon-btn:active { transform: translateY(2px); box-shadow: none; }

main { max-width: 1120px; margin: 0 auto; padding: .7rem max(.7rem, env(safe-area-inset-right)) calc(2rem + env(safe-area-inset-bottom)) max(.7rem, env(safe-area-inset-left)); }
:root { --hdr: 58px; }
.bar { min-height: var(--hdr); padding-top: max(.3rem, env(safe-area-inset-top)); padding-bottom: .3rem; padding-left: max(.8rem, env(safe-area-inset-left)); padding-right: max(.8rem, env(safe-area-inset-right)); }
/* 📱 no double-tap zoom on anything you press; no pull-to-refresh while a game is running */
button, a, input, .act, .person, .pa, .tabbtn { touch-action: manipulation; }
html[data-screen="s-play"], html[data-screen="s-play"] body { overscroll-behavior: none; }
/* ⌨️ a ring for keyboards too (a TV remote gets tv.js's even bigger one) */
button:focus-visible, a:focus-visible, input:focus-visible, .story:focus-visible { outline: 3px solid #ffb800; outline-offset: 2px; }
.screen { animation: pop .25s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 44px; padding: .5rem .9rem; border-radius: 14px; cursor: pointer;
  border: 2px solid rgba(90, 40, 70, .15); background: #fff; font-weight: 800; box-shadow: var(--shadow);
}
.btn:active { transform: translateY(3px); box-shadow: none; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.hot { background: linear-gradient(180deg, #ff7aa6, var(--hot2)); color: #fff; border-color: #c12a5c; text-shadow: 0 1px 0 rgba(0, 0, 0, .2); }
.btn.sun { background: linear-gradient(180deg, #ffe37a, #ffc21f); border-color: #d19a00; }
.btn.mint { background: linear-gradient(180deg, #6fe0ac, #2fb07a); color: #fff; border-color: #1f8a5c; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.big { min-height: 54px; font-size: 1.15rem; padding: .6rem 1.2rem; }

/* ---------- title ---------- */
.title-art { position: relative; border-radius: 22px; overflow: hidden; box-shadow: 0 6px 0 rgba(90, 40, 70, .15); background: #bfe8ff; }
#title-cv { display: block; width: 100%; height: auto; }
.logo {
  position: absolute; left: 0; right: 0; top: 6%; text-align: center; font-weight: 900;
  font-size: clamp(2.6rem, 11vw, 5.2rem); letter-spacing: .02em; line-height: 1;
  color: #fff; text-shadow: 0 4px 0 #e23d72, 0 8px 0 rgba(120, 30, 60, .25);
}
.logo .l2 { color: var(--sun); text-shadow: 0 4px 0 #d18a00, 0 8px 0 rgba(120, 60, 0, .25); }
.lead { text-align: center; font-size: 1.02rem; margin: .8rem auto; max-width: 40rem; }
.slots-h { text-align: center; margin: .6rem 0 .5rem; font-size: 1.2rem; }
.slots { display: grid; grid-template-columns: 1fr; gap: .7rem; }
.slot {
  display: grid; grid-template-columns: 92px 1fr; gap: .6rem; align-items: center;
  background: var(--card); border: 3px solid var(--line); border-radius: 18px; padding: .6rem; box-shadow: var(--shadow);
}
.slot canvas { width: 92px; height: 92px; border-radius: 14px; background: linear-gradient(#bfe8ff, #e9f8ff); }
.slot h3 { margin: 0; font-size: 1.1rem; }
.slot p { margin: .1rem 0 .4rem; color: var(--dim); font-size: .9rem; }
.slot .row { display: flex; flex-wrap: wrap; gap: .4rem; }
.slot.empty { border-style: dashed; }
.pvsb-cookie-note { text-align: center; color: var(--dim); font-size: .85rem; margin: 1.2rem auto .5rem; max-width: 34rem; }

/* ---------- make your pig ---------- */
.make-h { text-align: center; margin: .2rem 0 .6rem; }
.make-grid { display: grid; grid-template-columns: 1fr; gap: .8rem; }
.make-pic { background: linear-gradient(#bfe8ff, #fff4e8); border-radius: 22px; box-shadow: var(--shadow); }
#make-cv { display: block; width: 100%; max-width: 360px; height: auto; margin: 0 auto; }
.make-form { background: var(--card); border-radius: 22px; padding: .8rem; box-shadow: var(--shadow); min-width: 0; }
.lab { font-weight: 800; margin: .55rem 0 .3rem; display: block; }
.name-row { display: flex; gap: .4rem; }
#name-dice, #ask-dice { min-width: 48px; }
#pig-name, .name-input {
  flex: 1; min-width: 0; min-height: 46px; font: inherit; font-size: 1.15rem; font-weight: 700;
  border: 3px solid var(--line); border-radius: 14px; padding: .3rem .7rem; color: var(--ink); background: #fffafc;
}
#pig-name:focus, .name-input:focus { outline: 3px solid var(--sun); border-color: var(--hot); }
.why { min-height: 1.3em; margin: .25rem 0 0; color: #c0285a; font-weight: 700; font-size: .9rem; }
.why.ok { color: var(--mint); }
.choice { display: flex; flex-wrap: wrap; gap: .4rem; }
.choice button {
  min-height: 44px; padding: .3rem .7rem; border-radius: 12px; border: 3px solid var(--line); background: #fff; cursor: pointer; font-weight: 700;
}
.choice button[aria-pressed="true"] { border-color: var(--hot); background: #fff0f5; box-shadow: 0 0 0 3px rgba(255, 95, 143, .25); }
.swatches button { width: 44px; height: 44px; padding: 0; border-radius: 50%; }
.make-go { display: flex; justify-content: space-between; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; }
.make-go .hot { flex: 1; }

/* ---------- a life, one year at a time (Pig Life 2, 8 November 2026) ----------
   Phone: the life card, the 📖 Life Story (or a tab's panel in its place),
   the four bars, and the dock with the round 🎂 +1 YEAR button in the middle.
   Desktop (900+): card, bars and home picture on the left, the story in the
   middle, the panel on the right. Pig Life's own warm pink-and-peach look. */
body[data-screen="s-life"] main, body[data-screen="s-play"] main { padding-bottom: calc(.4rem + env(safe-area-inset-bottom)); }
.life {
  display: grid; gap: .5rem;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "card" "mid" "bars" "bar";
  height: calc(100vh - var(--hdr) - 1.2rem - env(safe-area-inset-bottom)); height: calc(100dvh - var(--hdr) - 1.2rem - env(safe-area-inset-bottom));
  min-height: 500px;
}
.lifecard {
  grid-area: card; display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: .65rem; align-items: center;
  padding: .5rem .65rem; border-radius: 24px; border: 3px solid #ffd0e0;
  background: radial-gradient(circle at 12% 30%, #fff 0, #fff 18%, transparent 40%), linear-gradient(135deg, #fff6fa 0%, #ffe6f0 55%, #fff0d6 100%);
  box-shadow: var(--shadow); min-width: 0;
}
.lc-face {
  width: 96px; height: 96px; border-radius: 50%; overflow: hidden;
  background: radial-gradient(circle at 50% 38%, #fffaf3 0, #ffe3ec 58%, #ffc4d8 100%);
  border: 4px solid #fff; box-shadow: 0 0 0 3px #ff8fb4, 0 5px 0 rgba(90, 40, 70, .18);
}
#portrait { display: block; width: 100%; height: 100%; }
.lc-txt { min-width: 0; display: flex; flex-direction: column; gap: .12rem; }
.lc-name { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.lc-name b { flex: 1; min-width: 0; font-size: 1.35rem; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-name .icon-btn { min-width: 44px; height: 44px; font-size: 1.05rem; }
.lc-what { font-weight: 800; font-size: .9rem; color: #8a2d5c; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-chips { display: flex; flex-wrap: wrap; gap: .25rem; }
.lc-chips .chip { font-size: .74rem; padding: 0 .45rem; }
.lc-money { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .45rem; font-size: .82rem; font-weight: 700; color: var(--dim); min-width: 0; }
.lc-money .coins { font-size: .85rem; padding: .05rem .5rem; color: var(--ink); }
.lc-home { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; max-width: 100%; }
.chip { background: #fff; border-radius: 999px; padding: .08rem .55rem; font-size: .82rem; font-weight: 800; border: 2px solid var(--line); white-space: nowrap; }
.chip.stage { background: #fff4c2; border-color: #f3d36a; }
.chip.gen { background: #e5f6ff; border-color: #a9daf3; }
.coins { font-weight: 900; background: #fff4c2; border: 2px solid #f3d36a; padding: .2rem .6rem; border-radius: 999px; white-space: nowrap; }
.year { display: flex; align-items: center; gap: .4rem; font-weight: 800; min-width: 0; }
.acts { font-size: .95rem; letter-spacing: .05em; white-space: nowrap; }
.acts-n { color: var(--dim); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* 📖 the Life Story */
.story-wrap {
  grid-area: mid; min-height: 0; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #fffdf8, #fff8ef); border: 3px solid #f6dfc9; border-radius: 22px;
  box-shadow: var(--shadow); padding: .1rem .2rem .2rem .55rem;
}
.story-h { margin: .3rem 0 .1rem; font-size: .92rem; color: #a2603a; letter-spacing: .02em; }
.story { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 .45rem .4rem 0; outline: none; }
.story:focus-visible { box-shadow: inset 0 0 0 3px var(--sun); border-radius: 12px; }
.yr { margin: 0 0 .35rem; }
.age-h {
  position: relative; display: inline-block; margin: .35rem 0 .15rem; padding: .08rem .7rem;
  font-size: .86rem; font-weight: 900; color: #fff; border-radius: 999px;
  background: linear-gradient(90deg, #ff6f9f, #ffa45c); box-shadow: 0 2px 0 rgba(120, 30, 60, .22);
}
.ln { display: flex; gap: .4rem; margin: .12rem 0; font-size: .9rem; line-height: 1.35; padding: .05rem .25rem; }
.ln .em { flex: 0 0 1.35rem; text-align: center; }
.ln .tx { min-width: 0; overflow-wrap: anywhere; }
.ln.hl { background: #fff1b8; border-radius: 10px; }
.ln.hl .tx { font-weight: 800; }
.ln.quiet { color: var(--dim); font-style: italic; }
.ln.old { color: var(--dim); font-size: .78rem; }
.dd { display: inline; }
.dd i { font-style: normal; font-size: .7rem; font-weight: 900; padding: 0 .32rem; border-radius: 999px; margin-left: .25rem; white-space: nowrap; display: inline-block; line-height: 1.5; }
.dd .up { background: #dcf7e8; color: #17804f; }
.dd .dn { background: #ffe1e4; color: #c0285a; }

/* the four bars */
.bars { grid-area: bars; display: grid; grid-template-columns: 1fr 1fr; gap: .2rem .7rem; background: #fff; border-radius: 16px; padding: .3rem .65rem .4rem; box-shadow: var(--shadow); }
.bar-stat { font-size: .78rem; font-weight: 800; min-width: 0; }
.bar-stat .lbl { display: flex; justify-content: space-between; }
.bar-stat.low .v { color: #c0285a; }
.track { height: 9px; border-radius: 6px; background: rgba(90, 40, 70, .12); overflow: hidden; }
.fill { height: 100%; border-radius: 6px; transition: width .4s; }

/* the dock: four tabs round the big round button */
.lifebar {
  grid-area: bar; display: grid; grid-template-columns: 1fr 1fr 96px 1fr 1fr; align-items: end; gap: .2rem;
  background: linear-gradient(180deg, #fff, #ffeef5); border: 3px solid #ffd0e0; border-radius: 24px;
  padding: .25rem .3rem .3rem; box-shadow: var(--shadow); margin-top: 26px;
}
.tabbtn {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  min-height: 56px; min-width: 0; padding: .15rem .1rem; border: 0; border-radius: 16px; background: transparent;
  font-weight: 800; font-size: .76rem; cursor: pointer; color: var(--ink);
}
.tabbtn .ti { font-size: 1.45rem; line-height: 1.15; }
.tabbtn .tl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tabbtn[aria-selected="true"] { background: var(--ink); color: #fff; }
.tabbtn .dot { position: absolute; top: 0; right: 10%; background: var(--hot); color: #fff; border-radius: 999px; font-size: .64rem; padding: 0 .32rem; }
.ageup {
  justify-self: center; width: 94px; height: 94px; margin-top: -40px; border-radius: 50%; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .05rem;
  border: 5px solid #fff; color: #6a2a00; font-weight: 900;
  background: radial-gradient(circle at 34% 28%, #fff7c4 0, #ffd23f 46%, #ff9f1c 100%);
  box-shadow: 0 0 0 4px #ff6f9f, 0 7px 0 rgba(120, 30, 60, .3);
}
.ageup .cake { font-size: 1.9rem; line-height: 1; }
.ageup b { font-size: .82rem; letter-spacing: .02em; white-space: nowrap; }
.ageup:active { transform: translateY(3px) scale(.97); box-shadow: 0 0 0 4px #ff6f9f, 0 3px 0 rgba(120, 30, 60, .3); }
.ageup.ready { animation: wiggle 1.6s ease-in-out infinite; }
.ageup:disabled { filter: grayscale(.7); opacity: .6; cursor: default; }
@keyframes wiggle { 0%, 80%, 100% { transform: none; } 85% { transform: rotate(-4deg); } 90% { transform: rotate(4deg); } 95% { transform: rotate(-2deg); } }

/* the home picture (desktop: left column; phone: inside 🏠 Stuff) */
.side-scene { grid-area: scene; display: none; min-height: 0; }
#scene, #home-cv { display: block; width: 100%; height: auto; border-radius: 18px; box-shadow: 0 4px 0 rgba(90, 40, 70, .15); background: #bfe8ff; }
.home-pic { margin: .1rem 0 .4rem; }
.where { color: var(--dim); font-size: .84rem; margin: .4rem 0 0; }

/* a tab's panel */
.panel { grid-area: mid; min-height: 0; overflow-y: auto; overscroll-behavior: contain; background: #fff; border: 3px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); padding: 0 .65rem .9rem; }
.panel-open .story-wrap { display: none; }
.ph { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: .5rem; background: #fff; padding: .45rem 0 .3rem; }
.ph h2 { flex: 1; margin: 0; font-size: 1.2rem; min-width: 0; }
.pv { display: block; width: 100%; height: auto; border-radius: 14px; margin: 0 0 .45rem; }
.pinfo { background: #fff6fa; border: 2px solid #ffe0ec; border-radius: 14px; padding: .35rem .6rem; margin-bottom: .3rem; font-size: .88rem; }
.pinfo p { margin: .15rem 0; }
.mini { margin: .25rem 0; }
.mini .lbl { display: flex; justify-content: space-between; font-size: .78rem; font-weight: 800; }
.dim { color: var(--dim); }
.sec-h { margin: .75rem 0 .35rem; font-size: .95rem; color: #8a2d5c; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.act {
  text-align: left; display: flex; flex-direction: column; gap: .1rem; min-height: 86px; padding: .5rem .55rem; border-radius: 16px; cursor: pointer;
  border: 3px solid var(--line); background: #fff; box-shadow: var(--shadow); position: relative; min-width: 0;
}
.act:active { transform: translateY(3px); box-shadow: none; }
.act:disabled { opacity: .5; cursor: default; }
.act.tired { opacity: .55; }
.act .ic { font-size: 1.45rem; line-height: 1.1; }
.act .nm { font-weight: 900; font-size: .93rem; line-height: 1.15; padding-right: 1.6rem; }
.act .ds { font-size: .76rem; color: var(--dim); line-height: 1.2; }
.act .cost { position: absolute; top: .4rem; right: .45rem; font-size: .7rem; font-weight: 900; background: #fff4c2; border-radius: 999px; padding: 0 .4rem; }
.act .cost.free { background: #dff7ea; }
.act.special { border-color: #ffb3c9; background: linear-gradient(180deg, #fff, #fff0f5); }
.act.boar { border-color: #b9a1d6; background: linear-gradient(180deg, #fff, #f3ebff); }
.act .new { position: absolute; top: -8px; left: .5rem; background: var(--hot); color: #fff; font-size: .66rem; font-weight: 900; border-radius: 999px; padding: 0 .4rem; }

/* 🐷 People */
.people-n { font-size: .82rem; margin: .2rem 0 0; }
.people { display: grid; grid-template-columns: 1fr; gap: .35rem; }
.person {
  display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: .55rem; align-items: center; text-align: left;
  min-height: 62px; padding: .3rem .5rem; border-radius: 16px; border: 3px solid var(--line); background: #fff; cursor: pointer; min-width: 0;
}
.person:active { transform: translateY(2px); }
.person canvas { width: 52px; height: 52px; border-radius: 50%; background: radial-gradient(circle at 50% 40%, #fff, #ffe1ec); }
.person.away { background: #f1faff; }
.pp { display: flex; flex-direction: column; gap: .12rem; min-width: 0; }
.pn { font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pr { font-size: .76rem; color: var(--dim); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.close-t { height: 8px; }
.phead { display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: .65rem; align-items: center; margin: .55rem 0 .5rem; }
.phead h3 { margin: 0; font-size: 1.25rem; overflow-wrap: anywhere; }
.phead p { margin: .1rem 0; font-size: .86rem; }
.pbig { width: 108px; height: 108px; border-radius: 50%; background: radial-gradient(circle at 50% 38%, #fffaf3, #ffd9e6); border: 4px solid #fff; box-shadow: 0 0 0 3px #ff8fb4; }
.pas { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.pa { display: flex; flex-direction: column; align-items: flex-start; gap: .05rem; min-height: 58px; padding: .4rem .55rem; border-radius: 14px; border: 3px solid var(--line); background: #fff; font-weight: 800; cursor: pointer; text-align: left; min-width: 0; font-size: .86rem; }
.pa .ic { font-size: 1.3rem; }
.pa small { color: var(--mint); font-weight: 800; }
.pa:disabled { opacity: .5; cursor: default; }

/* 🃏 pop-up cards */
.modal.event .card { width: min(100%, 430px); }
.ev-body { display: flex; flex-direction: column; align-items: center; }
.modal-body canvas.ev-pic { width: 150px; height: 150px; border-radius: 26px; background: #fff; box-shadow: 0 0 0 4px #ffe1ec, 0 5px 0 rgba(90, 40, 70, .15); margin: .1rem auto .4rem; }
.ev-text { text-align: center; font-size: 1.02rem; margin: .2rem 0; }
.modal.event .modal-btns, .modal.choose .modal-btns { flex-direction: column; }
.modal.event .modal-btns .btn, .modal.choose .modal-btns .btn { width: 100%; justify-content: flex-start; text-align: left; }
.modal.event.result .modal-btns .btn { justify-content: center; }
.opts .wide-p { grid-column: 1 / -1; margin: 0 0 .2rem; }

.pause-btns { display: flex; flex-direction: column; gap: .5rem; }

/* 📖 the Life Summary */
.summary { max-width: 880px; margin: 0 auto; }
.sum-top { border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); background: #fff; }
#sum-cv { display: block; width: 100%; height: auto; }
.sum-title { text-align: center; padding: .45rem .7rem .55rem; }
.sum-title h2 { margin: 0; font-size: 1.5rem; overflow-wrap: anywhere; }
.sum-title p { margin: .1rem 0 0; color: var(--dim); font-weight: 700; }
.sum-facts { display: grid; grid-template-columns: 1fr; gap: .4rem; margin: .75rem 0; }
.fact { display: grid; grid-template-columns: 1.8rem 5.2rem minmax(0, 1fr); gap: .3rem; align-items: center; background: #fff; border-radius: 14px; padding: .45rem .6rem; box-shadow: var(--shadow); font-size: .92rem; }
.fact .ic { font-size: 1.3rem; }
.fact span:last-child { overflow-wrap: anywhere; }
.sum-best { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .3rem; }
.sum-best li { display: flex; gap: .5rem; background: #fff6cf; border-radius: 12px; padding: .4rem .6rem; font-weight: 700; font-size: .92rem; }
.sum-btns { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0 .5rem; }
.sum-btns .btn { flex: 1 1 14rem; }

/* ---------- the mini-game stage ---------- */
#s-play { display: flex; flex-direction: column; align-items: center; }
#s-play[hidden] { display: none !important; }
.mg-top { width: 100%; max-width: 760px; display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.mg-title { font-weight: 900; font-size: 1.1rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-info { font-weight: 800; color: var(--dim); white-space: nowrap; }
.mg-wrap { position: relative; width: 100%; max-width: 760px; display: flex; justify-content: center; }
#mg-cv { display: block; border-radius: 18px; box-shadow: 0 5px 0 rgba(90, 40, 70, .2); background: #222; touch-action: none; user-select: none; -webkit-user-select: none; max-width: 100%; }
.mg-over {
  position: absolute; inset: 0; margin: auto; width: min(92%, 380px); height: fit-content; max-height: 96%; overflow: auto;
  background: rgba(255, 255, 255, .97); border-radius: 22px; padding: 1rem; text-align: center; box-shadow: 0 8px 0 rgba(90, 40, 70, .2);
}
.mg-over h3 { margin: .2rem 0 .4rem; font-size: 1.35rem; }
.mg-over p { margin: .3rem 0 .7rem; }
.keys { font-size: .85rem; color: var(--dim); background: #f7eff4; border-radius: 10px; padding: .35rem .5rem; }
.stars { font-size: 2.6rem; letter-spacing: .1em; }
.stars .st { color: #e3d6dd; text-shadow: 0 2px 0 rgba(0, 0, 0, .1); }
.stars .st.on { color: #ffc21f; text-shadow: 0 3px 0 #d18a00; }
.gain { font-weight: 800; color: var(--mint); }
.pad { display: flex; justify-content: center; gap: .5rem; flex-wrap: wrap; margin-top: .55rem; width: 100%; max-width: 760px; touch-action: none; }
.padbtn {
  min-width: 64px; min-height: 58px; padding: .2rem .7rem; border-radius: 16px; border: 3px solid rgba(90, 40, 70, .2); background: #fff;
  font-weight: 900; font-size: 1.15rem; box-shadow: var(--shadow); cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: none;
}
.padbtn.main { background: linear-gradient(180deg, #ffe37a, #ffc21f); min-width: 96px; }
.padbtn.wide { flex: 1; max-width: 160px; }
.padbtn.on { transform: translateY(3px); box-shadow: none; filter: brightness(.95); }

/* ---------- the modal ---------- */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(43, 27, 46, .55); display: flex; align-items: center; justify-content: center; padding: .7rem; }
.modal .card {
  background: #fff; border-radius: 22px; padding: 1rem; width: min(100%, 460px); max-height: calc(100vh - 1.4rem); overflow-y: auto; overflow-x: hidden;
  box-shadow: 0 10px 0 rgba(90, 40, 70, .25); animation: pop .2s ease-out;
}
.modal.wide .card { width: min(100%, 760px); }
.modal h3 { margin: 0 0 .5rem; font-size: 1.3rem; }
.modal-body { min-width: 0; }
.modal-body p { margin: .35rem 0; }
.modal-body canvas { display: block; max-width: 100%; height: auto; margin: .3rem auto; border-radius: 16px; }
.modal-btns { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; justify-content: flex-end; }
.modal-btns .btn { flex: 1 1 auto; }
.opts { display: grid; grid-template-columns: 1fr; gap: .45rem; }
.opt { text-align: left; display: flex; gap: .55rem; align-items: center; padding: .5rem .6rem; border-radius: 14px; border: 3px solid var(--line); background: #fff; cursor: pointer; font-weight: 700; min-height: 54px; }
.opt .ic { font-size: 1.6rem; }
.opt small { display: block; color: var(--dim); font-weight: 600; }
.opt[aria-pressed="true"] { border-color: var(--hot); background: #fff0f5; }
.opt:disabled { opacity: .5; cursor: default; }
.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; }
.shop-item { display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .5rem; border-radius: 14px; border: 3px solid var(--line); background: #fff; cursor: pointer; font-weight: 800; text-align: center; min-width: 0; }
.shop-item .ic { font-size: 1.7rem; }
.shop-item small { color: var(--dim); font-weight: 700; }
.shop-item.owned { border-color: var(--mint); background: #effbf4; }
.shop-item:disabled { opacity: .5; cursor: default; }
.shop-item.owned:disabled { opacity: 1; }
.shop-h { margin: .7rem 0 .35rem; font-size: 1rem; }
.report { width: 100%; border-collapse: collapse; margin: .3rem 0; }
.report td { padding: .3rem .4rem; border-bottom: 2px dashed var(--line); font-weight: 700; }
.report td.gr { font-size: 1.4rem; font-weight: 900; text-align: center; width: 3rem; }
.gr.A { color: #1f9a5c; } .gr.B { color: #2f7fd8; } .gr.C { color: #d19a00; } .gr.D, .gr.E { color: #c0285a; }
.book { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .45rem; }
.trophy { text-align: center; padding: .45rem .3rem; border-radius: 14px; background: #f7eff4; border: 2px solid var(--line); font-size: .75rem; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.trophy .ic { font-size: 1.7rem; display: block; filter: grayscale(1); opacity: .35; }
.trophy.got { background: #fff8d8; border-color: #f3d36a; }
.trophy.got .ic { filter: none; opacity: 1; }
.tree { display: flex; flex-direction: column; gap: .5rem; }
.gen-card { display: grid; grid-template-columns: 76px 1fr; gap: .6rem; align-items: center; background: #f9f3f7; border-radius: 16px; padding: .5rem; border: 2px solid var(--line); min-width: 0; }
.gen-card canvas { width: 76px; height: 76px; margin: 0; border-radius: 12px; background: linear-gradient(#bfe8ff, #e9f8ff); }
.gen-card h4 { margin: 0; }
.gen-card p { margin: .1rem 0; font-size: .85rem; color: var(--dim); overflow-wrap: anywhere; }
.gen-card ul { margin: .2rem 0 0; padding-left: 1.1rem; font-size: .82rem; }
.art-wall { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.art-wall img { width: 100%; border-radius: 10px; border: 4px solid #8a5a34; background: #fff; }
.toasts { position: fixed; left: 50%; transform: translateX(-50%); top: 3.9rem; z-index: 40; display: flex; flex-direction: column; gap: .35rem; align-items: center; pointer-events: none; width: min(94vw, 420px); }
.toast { background: var(--ink); color: #fff; padding: .45rem .9rem; border-radius: 999px; font-weight: 800; box-shadow: 0 4px 0 rgba(0, 0, 0, .2); transition: opacity .4s, transform .4s; text-align: center; max-width: 100%; }
.toast.gold { background: linear-gradient(90deg, #ffb21c, #ff5f8f); }
.toast.gone { opacity: 0; transform: translateY(8px); }

/* ---------- tablets and desktops ---------- */
@media (min-width: 640px) {
  .slots { grid-template-columns: repeat(3, 1fr); }
  .slot { grid-template-columns: 1fr; text-align: center; }
  .slot canvas { margin: 0 auto; width: 120px; height: 120px; }
  .slot .row { justify-content: center; }
  .cards { grid-template-columns: repeat(3, 1fr); }
  .opts { grid-template-columns: 1fr 1fr; }
  .shop-grid { grid-template-columns: repeat(3, 1fr); }
  .sum-facts { grid-template-columns: 1fr 1fr; }
  .people { grid-template-columns: 1fr 1fr; }
  .pas { grid-template-columns: repeat(3, 1fr); }
  .lifecard { grid-template-columns: 110px minmax(0, 1fr); }
  .lc-face { width: 110px; height: 110px; }
  .bars { grid-template-columns: repeat(4, 1fr); }
  .lifebar { max-width: 620px; width: 100%; justify-self: center; }
}
@media (min-width: 900px) {
  .make-grid { grid-template-columns: 380px 1fr; align-items: start; }
  /* the life: card, bars and home on the left · the story · the panel on the right */
  .life {
    grid-template-columns: 300px minmax(0, 1fr) minmax(330px, 390px);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "card mid panel" "bars mid panel" "scene mid panel" "scene bar panel";
    height: calc(100vh - var(--hdr) - 1.4rem); height: calc(100dvh - var(--hdr) - 1.4rem); min-height: 560px; column-gap: .8rem;
  }
  .lifecard { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; padding: .8rem; }
  .lc-face { width: 150px; height: 150px; }
  .lc-name { justify-content: center; width: 100%; }
  .lc-name b { flex: 0 1 auto; }
  .lc-chips, .lc-money, .year { justify-content: center; }
  .lc-txt { width: 100%; align-items: stretch; }
  .lc-what { white-space: normal; }
  .bars { grid-template-columns: 1fr 1fr; }
  .side-scene { display: block; }
  .panel-open .story-wrap { display: flex; }
  .panel { grid-area: panel; }
  #panel-x { display: none; }
  .lifebar { max-width: none; justify-self: stretch; }
  .cards { grid-template-columns: 1fr 1fr; }
  .people { grid-template-columns: 1fr; }
  .pas { grid-template-columns: 1fr 1fr; }
  .story .ln { font-size: .95rem; }
}
@media (max-width: 380px) {
  .bar .home { font-size: .8rem; }
  .bar h1 { font-size: 1rem; }
}
@media (max-height: 700px) and (max-width: 899px) {
  .lc-face { width: 76px; height: 76px; }
  .lifecard { grid-template-columns: 76px minmax(0, 1fr); }
  .life { min-height: 520px; }
}
/* ---------- 📱 a phone on its side (844×390 and friends) ----------
   The life goes two columns: card, bars and the dock on the left, the
   story (or the open tab) on the right. A mini-game puts its touch buttons
   BESIDE the canvas and the site bar steps aside while you play. */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --hdr: 48px; }
  .bar { padding-top: max(.2rem, env(safe-area-inset-top)); padding-bottom: .2rem; }
  .bar h1 { font-size: 1rem; }
  main { padding-top: .4rem; }
  .life {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "card mid" "bars mid" ". mid" "bar mid";
    height: calc(100dvh - var(--hdr) - .9rem - env(safe-area-inset-bottom)); min-height: 280px; gap: .35rem .6rem;
  }
  .lifecard { grid-template-columns: 64px minmax(0, 1fr); padding: .3rem .5rem; gap: .45rem; }
  .lc-face { width: 64px; height: 64px; border-width: 3px; }
  .lc-chips { display: none; }
  .lc-name b { font-size: 1.1rem; }
  .bars { grid-template-columns: 1fr 1fr; padding: .2rem .55rem .3rem; }
  .lifebar { margin-top: 22px; max-width: none; justify-self: stretch; }
  .tabbtn { min-height: 48px; }
  .tabbtn .ti { font-size: 1.25rem; }
  .tabbtn .tl { font-size: .68rem; }
  .ageup { width: 80px; height: 80px; margin-top: -32px; }
  .ageup .cake { font-size: 1.5rem; }
  .story-h { display: none; }
  /* the mini-game: canvas left, buttons right, no site bar */
  body[data-screen="s-play"] header.bar { display: none; }
  body[data-screen="s-play"] main { padding-top: .3rem; padding-bottom: .3rem; }
  #s-play:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "top top" "wrap pad"; align-items: center; justify-items: center; column-gap: .6rem; }
  #s-play .mg-top { grid-area: top; margin-bottom: .2rem; max-width: none; }
  #s-play .mg-wrap { grid-area: wrap; justify-self: end; max-width: none; width: auto; }
  #s-play .pad { grid-area: pad; justify-self: start; align-content: center; max-width: 340px; margin: 0; }
  .padbtn { min-height: 52px; }
  .mg-over { position: fixed; inset: 0; margin: auto; width: min(92vw, 460px); max-height: 92dvh; z-index: 5; }
  .modal .card { max-height: calc(100dvh - 1rem); }
}
@media (max-width: 380px) and (max-height: 700px) {
  .lc-chips { display: none; }
  .lifecard { grid-template-columns: 70px minmax(0, 1fr); }
  .lc-face { width: 70px; height: 70px; }
  .tabbtn .tl { font-size: .7rem; }
}
/* a short phone (360×640) gives the game more room by hiding the site bar while you play */
@media (max-height: 700px) and (orientation: portrait) {
  body[data-screen="s-play"] header.bar { display: none; }
}

/* ---------- 📺 a television (tv.js puts html.pvsb-tv on with the remote) ----------
   Everything gets bigger, to be read from the sofa, and the page uses the
   whole wide screen. A remote has its own buttons, so the touch pad under a
   mini-game steps aside and the game itself gets the room. */
@media (min-width: 1280px) {
  main { max-width: 1840px; }
  .life { grid-template-columns: minmax(17rem, 22%) minmax(0, 1fr) minmax(21rem, 30%); }
}
html.pvsb-tv { font-size: 19px; }
@media (min-width: 1600px) { html.pvsb-tv { font-size: 23px; } }
html.pvsb-tv { --hdr: 3.4rem; }
html.pvsb-tv .bar h1 { font-size: 1.3rem; }
html.pvsb-tv .icon-btn { min-width: 2.6rem; height: 2.6rem; }
html.pvsb-tv .pad { display: none; }
html.pvsb-tv .lc-face { width: 9rem; height: 9rem; }
html.pvsb-tv .ageup { width: 6rem; height: 6rem; margin-top: -2.2rem; }
html.pvsb-tv .lifebar { grid-template-columns: 1fr 1fr 6.4rem 1fr 1fr; }
html.pvsb-tv .tabbtn { min-height: 3.6rem; font-size: .85rem; }
html.pvsb-tv .story .ln { font-size: 1rem; }
html.pvsb-tv .act { min-height: 6rem; }
html.pvsb-tv .person canvas { width: 3.4rem; height: 3.4rem; }
html.pvsb-tv .person { grid-template-columns: 3.4rem minmax(0, 1fr); }
html.pvsb-tv .modal .card { width: min(100%, 40rem); }
html.pvsb-tv .modal.wide .card { width: min(100%, 64rem); }
html.pvsb-tv .modal-body canvas.ev-pic { width: 12rem; height: 12rem; }
/* The page's own text is 16px; on a TV everything inside a pop-up grows with the rem size, so the
   choices are as big as the question above them and read from the sofa (8 Nov 2026). */
html.pvsb-tv .modal-body, html.pvsb-tv .modal .btn { font-size: 1rem; }
html.pvsb-tv #mg-cv { box-shadow: 0 0 0 4px #fff, 0 8px 0 rgba(90, 40, 70, .2); }
html.pvsb-tv .mg-wrap, html.pvsb-tv .mg-top { max-width: 1200px; }

@media (prefers-reduced-motion: reduce) {
  .screen, .modal .card { animation: none; }
  .ageup.ready { animation: none; }
}
