/* 3D board shell around the v7 engine panels. The engine injects its own CSS (cards, modals, buttons,
   player cards, achievements). These rules place the panels as overlays round the full-screen 3D board:
   pinned side rails on wide screens, slide-out drawers on phones (landscape first). "body #id" selectors
   win over the engine's 2D-layout rules. */
:root {
  --ink: #3A2E39; --pink: #E0559A; --pink2: #F26CA7; --gold: #D4A537; --gold-ink: #A87F22;
  --purple: #8E6BB8; --blue: #2A63A8; --panel: rgba(255, 255, 255, .94); --line: #e6d4e0;
  --rail-w: 272px; --gap: 8px; --top-h: 54px;
  --shadow: 0 6px 18px rgba(160, 48, 96, .16);
}
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font-family: 'Nunito', Verdana, sans-serif; color: var(--ink);
  background: linear-gradient(160deg, #fdeef6, #eee6fa 45%, #e2f3ec); }
#board3d { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; z-index: 0; }

/* ---------- setup screen over the board ---------- */
#p3dSetupWrap { position: fixed; inset: 0; z-index: 20; overflow-y: auto; pointer-events: none; padding: 0 12px; }
#p3dSetupWrap #setup { pointer-events: auto; position: relative; background: rgba(255, 255, 255, .95) !important;
  backdrop-filter: blur(6px); margin: 18px auto !important; }
body.phase-game #p3dSetupWrap { display: none; }
#addP:disabled, #addC:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- shared panel look (v7 cards) ---------- */
.p3d-card { background: var(--panel); border: 2.5px solid var(--gold); border-radius: 14px; box-shadow: var(--shadow); }
.p3d-card h2 { font: 800 13px 'Baloo 2', sans-serif; color: var(--pink); letter-spacing: 1px; margin: 0 0 6px; }
.p3d-card h2.gold { color: var(--gold-ink); letter-spacing: .5px; }
.p3d-lbl { font-size: 10px; font-weight: 900; color: #8a7a86; letter-spacing: 1px; margin: 6px 0 3px; }
.p3d-small { font-size: 10.5px; font-weight: 800; color: #8a7a86; margin-top: 4px; }
.p3d-btn { font: 800 14px 'Baloo 2', sans-serif; color: #fff; border: 0; border-radius: 11px; padding: 8px 15px; cursor: pointer;
  min-height: 38px; transition: transform .12s ease, filter .12s ease; }
.p3d-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.p3d-btn:active { transform: translateY(1px); }
.p3d-btn:focus-visible, .p3d-tab:focus-visible { outline: 3px solid var(--pink2); outline-offset: 2px; }
.p3d-btn.purple { background: linear-gradient(180deg, #a98ad4, var(--purple)); box-shadow: 0 4px 12px rgba(142, 107, 184, .35); }
.p3d-btn.blue { background: linear-gradient(180deg, #7cc3f0, var(--blue)); box-shadow: 0 4px 12px rgba(42, 99, 168, .35); }
.p3d-btn.gold { background: linear-gradient(180deg, #e7bd55, var(--gold-ink)); box-shadow: 0 4px 12px rgba(168, 127, 34, .35); }
.p3d-btn.pink { background: linear-gradient(180deg, var(--pink2), #c2437e); box-shadow: 0 4px 12px rgba(217, 79, 142, .35); }
.p3d-btn.spin { background: linear-gradient(180deg, #ffe08a, #f0b913); color: #5a3a00; box-shadow: 0 4px 12px rgba(240, 185, 19, .4); }
.p3d-btn.ghost, .p3d-btn.bell { background: #fff; color: var(--ink); border: 2px solid #e8d9e2; padding: 6px 10px; }
.p3d-btn[aria-pressed="true"] { background: #ffd1e6; }
.p3d-btn.bell { position: relative; }
#bellBtn .bdg { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; border-radius: 9px; background: #E03A3E;
  color: #fff; font: 900 11px 'Nunito', sans-serif; align-items: center; justify-content: center; padding: 0 4px; box-sizing: border-box; }

/* ---------- top bar ---------- */
body #p3dTop { position: fixed; z-index: 12; top: calc(var(--gap) + env(safe-area-inset-top)); left: calc(var(--gap) + env(safe-area-inset-left));
  right: calc(var(--gap) + env(safe-area-inset-right)); display: flex; align-items: center; gap: 8px; padding: 6px 12px; flex-wrap: nowrap; }
#p3dTitle #tbTitle { font: 800 19px/1 'Baloo 2', cursive; color: var(--pink); letter-spacing: 1px; }
#p3dTitle #tbSub { font-size: 9px; letter-spacing: 2.5px; color: var(--gold-ink); font-weight: 900; }
.p3d-grow { flex: 1; }
.p3d-pill { display: flex; align-items: center; gap: 5px; background: #fff; border: 2px solid #e8d9e2; border-radius: 11px; padding: 5px 10px;
  font: 800 14px 'Baloo 2', sans-serif; white-space: nowrap; }
.p3d-tgl { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 800; cursor: pointer; white-space: nowrap; }
.p3d-tgl input { accent-color: var(--pink2); width: 16px; height: 16px; }
body #musicVol { width: 52px; accent-color: var(--pink2); }

/* ---------- side rails ---------- */
.p3d-rail { position: fixed; z-index: 11; top: calc(var(--top-h) + var(--gap) * 2); bottom: var(--gap); width: var(--rail-w);
  display: flex; flex-direction: column; gap: var(--gap); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  transition: transform .28s cubic-bezier(.2, .8, .2, 1); }
.p3d-rail.left { left: calc(var(--gap) + env(safe-area-inset-left)); }
.p3d-rail.right { right: calc(var(--gap) + env(safe-area-inset-right)); }
.p3d-rail > .p3d-card { padding: 10px 12px; flex: 0 0 auto; }
body #log { max-height: 30vh; min-height: 70px; font-size: 12px; }
body #marketFeed { max-height: 22vh; overflow-y: auto; background: rgba(255, 255, 255, .72); border-radius: 10px; padding: 2px 6px; }
body #marketNews { max-height: 14vh; overflow-y: auto; font-size: 11px; font-weight: 600; color: #5d4a55; background: rgba(255, 255, 255, .72);
  border-radius: 10px; padding: 6px 8px; line-height: 1.5; }
#marketCard.mkt { background: linear-gradient(180deg, #FFF9EE, #FDF0F6); cursor: pointer; }
body #mktBtns { display: flex; gap: 6px; margin-bottom: 7px; }
body #mktBtns .p3d-btn { flex: 1; font-size: 12.5px; padding: 8px 4px; }
body #players { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
body #players .pcard { padding: 7px 9px; }
body #p3dAch .achgrid { grid-template-columns: repeat(3, 1fr) !important; gap: 5px; margin-top: 4px !important; }
body #p3dAch .achchip { padding: 5px 2px !important; }
body #p3dAch .achchip .v { font-size: 13px !important; white-space: nowrap !important; }
body #p3dAch .achchip .l { font-size: 7.5px !important; }
#p3dQr { text-align: center; }
#p3dQr h2 { font-size: 12px; letter-spacing: .3px; }
#qrImg { display: block; margin: 2px auto 0; width: 132px; height: 132px; border-radius: 10px; background: #fff; border: 2px solid #eadfe7; }
body #logTicker, body #newsTicker { display: none !important; }

/* ---------- dice dock (engine #diceDock: turn bar + controls; the 3D dice replace the 2D ones) ---------- */
body #p3dDock { position: fixed; z-index: 12; left: 50%; transform: translateX(-50%); bottom: calc(var(--gap) + env(safe-area-inset-bottom));
  padding: 6px 12px; max-width: min(720px, calc(100vw - 2 * var(--rail-w) - 6 * var(--gap))); }
body #p3dDock { display: flex; align-items: center; gap: 8px; }
body #diceDock .die3d { display: none; }
#followBtn.follow { flex: 0 0 auto; white-space: nowrap; }
body #diceStrip { gap: 8px; }
body #turnbar { font-size: 14px; }

/* the engine's 2D board: kept for its rules and effects, never shown */
#p3dBoard2d { position: fixed; left: 50%; top: 50%; width: 2px; height: 2px; overflow: hidden; visibility: hidden; pointer-events: none; }
body #wgboard { width: 600px; height: 424px; }
#fps { position: fixed; z-index: 30; bottom: 8px; left: 8px; font: 12px monospace; background: #0008; color: #fff; padding: 2px 6px; border-radius: 4px; }

/* drawer tabs (hidden while the rails are pinned) */
.p3d-tab { position: fixed; z-index: 13; top: calc(var(--top-h) + var(--gap) * 3); width: 40px; padding: 8px 0; border: 2.5px solid var(--gold);
  background: var(--panel); box-shadow: var(--shadow); font-size: 17px; line-height: 1.5; cursor: pointer; display: none; }
.p3d-tab.left { left: 0; border-left: 0; border-radius: 0 12px 12px 0; }
.p3d-tab.right { right: 0; border-right: 0; border-radius: 12px 0 0 12px; }
.p3d-tab[aria-expanded="true"] { background: #ffd1e6; }

/* ---------- wide screens: rails pinned ---------- */
@media (min-width: 1180px) and (min-height: 600px) {
  body #p3dDock { max-width: calc(100vw - 2 * var(--rail-w) - 6 * var(--gap)); }
}

/* ---------- phones & small tablets: rails become drawers ---------- */
@media (max-width: 1179px), (max-height: 599px) {
  :root { --rail-w: min(300px, 46vw); }
  .p3d-tab { display: block; }
  .p3d-rail { z-index: 14; top: calc(var(--top-h) + var(--gap) * 2); }
  .p3d-rail.left { transform: translateX(calc(-100% - 20px)); }
  .p3d-rail.right { transform: translateX(calc(100% + 20px)); }
  .p3d-rail.open { transform: none; }
  body #p3dDock { max-width: calc(100vw - 120px); }
}
@media (max-height: 520px) {
  :root { --top-h: 42px; --gap: 6px; }
  body #p3dTop { padding: 3px 8px; gap: 6px; }
  #p3dTitle #tbSub { display: none; }
  #p3dTitle #tbTitle { font-size: 15px; }
  .p3d-btn { font-size: 12.5px; padding: 5px 10px; min-height: 32px; }
  .p3d-tgl .lbl { display: none; }
  .p3d-pill { padding: 3px 8px; font-size: 13px; }
  body #p3dDock { padding: 3px 8px; }
  body #turnbar { font-size: 12px !important; padding: 3px 10px !important; }
  body #controls .diceroll { padding: 6px 14px !important; font-size: 14px !important; }
  body #log { max-height: 40vh; }
  .p3d-tab { font-size: 15px; width: 36px; }
}
@media (max-width: 760px) {
  #p3dTitle { display: none; }
  body #musicVol { display: none; }
}
@media (prefers-reduced-motion: reduce) { .p3d-rail { transition: none; } }

/* ---------- 3D character picker cards ---------- */
#p3dPickPop { position: fixed; inset: 0; z-index: 340; display: none; align-items: center; justify-content: center; padding: 14px;
  background: rgba(58, 46, 57, .55); }
.p3d-pick-in { background: #fff; border: 3px solid var(--gold); border-radius: 16px; padding: 12px 14px; max-width: 640px; width: 100%;
  max-height: 88vh; overflow-y: auto; box-shadow: 0 18px 60px rgba(0, 0, 0, .35); text-align: center; }
.p3d-pick-in h3 { margin: 0 0 8px; font: 800 18px 'Baloo 2', sans-serif; color: var(--pink); }
.p3d-pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin-bottom: 10px; }
.p3d-pick { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px 7px;
  background: linear-gradient(180deg, #fff, #FDF6FB); border: 2px solid #eadfe7; border-bottom: 5px solid var(--pc); border-radius: 12px;
  cursor: pointer; font: 800 13px 'Baloo 2', sans-serif; color: var(--ink); transition: transform .12s ease, box-shadow .12s ease; }
.p3d-pick:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(160, 48, 96, .18); }
.p3d-pick:focus-visible { outline: 3px solid var(--pink2); outline-offset: 2px; }
.p3d-pick.sel { border-color: var(--pink2); background: #FFE9F3; }
.p3d-pick[data-used] { opacity: .6; }
.p3d-pick img { width: 96px; height: 96px; object-fit: contain; }
.p3d-pick em { position: absolute; top: 4px; right: 6px; font: 800 9px 'Nunito', sans-serif; color: #8a7a86; font-style: normal; }
#prows .nm[readonly] { background: #FDF6FB; color: var(--ink); }

/* the 2D card pop-up waits for the 3D card to fly out and flip */
#wgoverlay.p3d-after-card { animation: p3dDim .3s ease 1.25s both; }
#wgoverlay.p3d-after-card #wgmodal { animation: p3dCardIn .35s ease 1.3s both; }
@keyframes p3dDim { from { background: transparent; } }
@keyframes p3dCardIn { from { opacity: 0; transform: scale(.92); } }
/* wide screens: setup card on the right so the 3D podium shows on the left */
@media (min-width: 1100px) {
  #p3dSetupWrap #setup { margin: 18px 3vw 18px auto !important; max-width: 640px !important; }
}

/* ---------- Kiara's Kingdom HUD ---------- */
body.kingdom-on #game > :not(#fps), body.kingdom-on #p3dSetupWrap,
body.kingdom-on #winbanner, body.kingdom-on #wgoverlay, body.kingdom-on #wgpop, body.kingdom-on #annBadge { display: none !important; }
#kHud[hidden] { display: none; }
#kTop { position: fixed; z-index: 30; top: calc(8px + env(safe-area-inset-top)); left: 8px; right: 8px; display: flex; align-items: center; gap: 10px; padding: 6px 12px; }
#kTitle { display: flex; flex-direction: column; font: 800 17px/1.1 'Baloo 2', sans-serif; color: var(--pink); }
#kLeague { font: 900 10px 'Nunito', sans-serif; color: #fff; border-radius: 8px; padding: 1px 8px; margin-top: 2px; align-self: flex-start; letter-spacing: .5px; }
.kres { flex: 1; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.kres span { background: #fff; border: 2px solid #eadfe7; border-radius: 11px; padding: 4px 10px; font: 800 14px 'Baloo 2', sans-serif; }
#kBar { position: fixed; z-index: 30; bottom: calc(8px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; gap: 6px;
  padding: 6px 8px; flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 16px); }
#kBar[hidden] { display: none; }
#kVisit { position: fixed; z-index: 30; bottom: calc(8px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; gap: 8px; align-items: center; padding: 8px 12px; flex-wrap: wrap; justify-content: center; }
#kVisit[hidden] { display: none; }
#kPanel { position: fixed; z-index: 31; right: 8px; top: 70px; bottom: 70px; width: min(340px, 44vw); overflow-y: auto; padding: 12px 14px; }
#kPanel[hidden] { display: none; }
#kPanel h3 { margin: 0 34px 6px 0; font: 800 18px 'Baloo 2', sans-serif; color: var(--pink); }
#kPanel h4 { margin: 12px 0 4px; font: 800 14px 'Baloo 2', sans-serif; color: var(--gold-ink); }
#kPanel p { font-size: 13px; font-weight: 700; margin: 4px 0 8px; }
.kclose { position: absolute; top: 8px; right: 8px; min-height: 48px !important; min-width: 48px; padding: 2px 9px !important; }
.ksmall { color: #8a7a86; font-size: 11.5px !important; }
.krow { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid #f0e3ec; font-size: 13px; font-weight: 700; }
.krow small { color: #8a7a86; font-weight: 800; }
.krow .p3d-btn { min-height: 48px; padding: 4px 12px; font-size: 13px; }
#kPanel .p3d-btn:disabled { opacity: .5; cursor: default; transform: none; }
.kgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; margin-bottom: 8px; }
.kitem { display: flex; flex-direction: column; align-items: center; gap: 2px; background: #fff; border: 2px solid #eadfe7; border-radius: 10px; padding: 4px; cursor: pointer; font: 800 11px 'Nunito', sans-serif; }
.kitem img { width: 100%; aspect-ratio: 1 / 1.4; object-fit: cover; border-radius: 6px; }
.kitem.sel { border-color: var(--pink2); background: #FFE9F3; }
.kchest { display: flex; gap: 10px; justify-content: center; font: 800 22px 'Baloo 2', sans-serif; margin: 8px 0 10px; }
.kchest span { background: #FFF9EE; border: 2px solid var(--gold); border-radius: 12px; padding: 6px 12px; }
.kroad { display: flex; gap: 4px; margin: 6px 0 8px; }
.kroad span { flex: 1; text-align: center; border: 2px solid; border-radius: 10px; padding: 4px 2px; font: 800 10px 'Nunito', sans-serif; opacity: .5; display: flex; flex-direction: column; }
.kroad span.on { opacity: 1; background: #FFF9EE; }
.kstickers { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0; }
.kstickers button { font-size: 20px; background: #fff; border: 2px solid #eadfe7; border-radius: 10px; padding: 3px 7px; cursor: pointer; font-family: 'Nunito', sans-serif; }
.kstickers button.sel { border-color: var(--pink2); }
.kchat { max-height: 150px; overflow-y: auto; background: #FDF6FB; border-radius: 10px; padding: 6px 8px; font-size: 13px; }
.kchat span { font-size: 18px; }
#kFlash { position: fixed; z-index: 40; left: 50%; top: 84px; transform: translateX(-50%); background: #3A2E39; color: #fff; font: 800 15px 'Baloo 2', sans-serif;
  border-radius: 999px; padding: 6px 16px; opacity: 0; pointer-events: none; }
#kFlash.on { animation: kflash 2.2s ease; }
@keyframes kflash { 10%, 75% { opacity: 1; } }
@media (max-height: 520px) {
  #kTop { padding: 3px 8px; } #kTitle { font-size: 14px; } .kres span { padding: 2px 7px; font-size: 12px; }
  #kBar .p3d-btn { font-size: 12px; padding: 4px 8px; min-height: 48px; }
  #kPanel { top: 52px; bottom: 52px; }
}

/* ---------- Phase 4: online rooms, sticker chat, turn timer ---------- */
#p3dOnline { background: #EEF5FC; border: 2px solid #c7daf0; border-radius: 12px; padding: 10px 14px; margin: 0 0 14px; }
#p3dOnline .on-h { font: 900 13px 'Nunito', sans-serif; color: var(--blue); letter-spacing: 1px; text-align: center; margin-bottom: 6px; }
#p3dOnline .on-row { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
#p3dOnline .on-or { font-weight: 800; color: #7d8aa5; font-size: 12px; }
#p3dOnline #joinCode { width: 78px; text-transform: uppercase; letter-spacing: 4px; font: 800 16px 'Baloo 2', sans-serif; text-align: center;
  padding: 6px 8px; border: 2px solid #c7daf0; border-radius: 9px; }
#p3dOnline .on-status { margin-top: 8px; font-size: 13px; font-weight: 800; text-align: center; }
#p3dOnline .on-link { margin-top: 6px; font-size: 11.5px; font-weight: 700; text-align: center; word-break: break-all; }
#p3dOnline .on-link code { background: #fff; border-radius: 6px; padding: 1px 5px; }
#p3dOnline .on-note { margin-top: 6px; font-size: 10.5px; color: #7d8aa5; font-weight: 700; text-align: center; }
#p3dChat { position: fixed; z-index: 11; left: calc(var(--gap) + env(safe-area-inset-left)); bottom: 86px; width: 236px; padding: 8px 10px; }
#p3dChat .ch-h { font: 800 12px 'Baloo 2', sans-serif; color: var(--blue); }
#p3dChatLines { font-size: 12px; min-height: 40px; max-height: 72px; overflow: hidden; margin: 2px 0 6px; }
#p3dChatLines .ch-empty { color: #9aa7c4; }
#p3dStickers { display: flex; flex-wrap: wrap; gap: 4px; }
#p3dStickers .stk { border: 1.5px solid #cfd9ee; background: #fff; border-radius: 9px; padding: 2px 6px; font: 800 12px 'Nunito', sans-serif; cursor: pointer; }
#p3dStickers .stk:hover { background: #eef5fc; }
#p3dTurnTimer.low { background: #ffe1e1; border-color: #f3a3a3; }
body.rails-pinned #p3dChat { left: calc(var(--rail-w) + var(--gap) * 2); }

/* ---------- Phase 4: story mode ---------- */
#p3dStory { position: fixed; inset: 0; z-index: 40; display: none; align-items: center; justify-content: center; background: rgba(58, 46, 57, .45); }
#p3dStory .st-in { background: #fff; border: 3px solid var(--gold); border-radius: 18px; padding: 16px 18px; width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 40px); overflow: auto; box-sizing: border-box; }
#p3dStory h3 { font: 800 20px 'Baloo 2', sans-serif; color: var(--purple); margin: 0 0 10px; text-align: center; }
#p3dStory .st-worlds { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
#p3dStory .st-w { flex: none; border: 2px solid #e2d6f0; background: #faf6ff; border-radius: 10px; padding: 6px 10px; font: 800 12.5px 'Nunito', sans-serif; cursor: pointer; }
#p3dStory .st-w.sel { background: #e9ddfa; border-color: var(--purple); }
#p3dStory .st-w.locked { opacity: .6; }
#p3dStory .st-chapters { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; margin: 10px 0; }
#p3dStory .st-ch { text-align: left; border: 2px solid #f0d3e2; background: #fff8fb; border-radius: 12px; padding: 9px 11px; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px; font: 700 12px 'Nunito', sans-serif; color: var(--ink); }
#p3dStory .st-ch b { font: 800 14px 'Baloo 2', sans-serif; color: var(--pink); }
#p3dStory .st-ch.locked { opacity: .5; cursor: not-allowed; }
#p3dStory .st-soon { padding: 22px; text-align: center; font-weight: 800; color: var(--purple); }
#p3dStoryChip { position: fixed; z-index: 11; top: calc(var(--top-h) + var(--gap) * 2 + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  padding: 6px 14px; min-width: 220px; max-width: calc(100vw - 32px); text-align: center; }
#p3dStoryChip .sc-t { font: 800 13px 'Baloo 2', sans-serif; color: var(--purple); }
#p3dStoryChip .sc-g { font-size: 11.5px; font-weight: 800; }
#p3dStoryChip .sc-bar { height: 7px; background: #f0e6f5; border-radius: 4px; margin-top: 4px; overflow: hidden; }
#p3dStoryChip .sc-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--pink2), var(--gold)); }
#p3dStoryChip.won { border-color: #43B649; }

/* ---------- Phase 4: photo mode + AR ---------- */
#p3dPhotoBar { display: none; position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom));
  padding: 8px 12px; width: max-content; max-width: calc(100vw - 32px); box-sizing: border-box; text-align: center; }
#p3dPhotoBar .ph-poses, #p3dPhotoBar .ph-main { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 6px; }
#p3dPhotoBar .ph-tip { font-size: 11px; font-weight: 700; color: #8a7a86; }
body.photo-mode #p3dPhotoBar { display: block; }
body.photo-mode #p3dTop, body.photo-mode .p3d-rail, body.photo-mode .p3d-tab, body.photo-mode #p3dDock, body.photo-mode #p3dChat,
body.photo-mode #p3dStoryChip { display: none !important; }
#p3dArOverlay { display: none; position: fixed; inset: auto 0 24px 0; z-index: 50; flex-direction: column; align-items: center; gap: 10px; }
#p3dArOverlay .ar-tip { background: rgba(255,255,255,.92); border-radius: 12px; padding: 8px 14px; font-weight: 800; }

/* ---------- Phase 4: your name's world + grown-up gate ---------- */
#p3dMyWorld { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 7px; }
#p3dMyWorld .mw-l { font-size: 11.5px; font-weight: 800; color: #9a8a96; }
#p3dMyWorld .mw-c { width: 24px; height: 24px; border-radius: 50%; border: 3px solid #fff; background: var(--c); box-shadow: 0 0 0 2px #e8d9e2; cursor: pointer; padding: 0; }
#p3dMyWorld .mw-c[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--ink); }
#p3dMyWorld .mw-order { margin-left: auto; padding: 5px 12px; font-size: 13px; }
#p3dGate { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; background: rgba(58, 46, 57, .5); }
#p3dGate .gt-in { background: #fff; border: 3px solid var(--gold); border-radius: 16px; padding: 16px 20px; width: min(380px, calc(100vw - 32px)); box-sizing: border-box; text-align: center; }
#p3dGate h3 { font: 800 20px 'Baloo 2', sans-serif; color: var(--pink); margin: 0 0 6px; }
#p3dGate p { font-size: 14px; font-weight: 700; }
#p3dGate .gt-ch { display: flex; gap: 8px; justify-content: center; margin: 10px 0; }
#p3dGate .gt-ch .p3d-btn { font-size: 18px; min-width: 64px; }

/* ---------- Phase 5: pop-ups, abilities, streaks, mini-games, boss, coach ---------- */
.p5-pop { position: fixed; inset: 0; z-index: 45; display: none; align-items: center; justify-content: center; background: rgba(58, 46, 57, .45); }
.p5-pop .p5-in { background: #fff; border: 3px solid var(--gold); border-radius: 18px; padding: 14px 18px; width: min(560px, calc(100vw - 32px)); box-sizing: border-box; text-align: center; }
.p5-pop h3 { font: 800 20px 'Baloo 2', sans-serif; color: var(--pink); margin: 0 0 4px; }
.p5-note { font-size: 12px; font-weight: 800; color: #8a7a86; margin: 0 0 10px; }
.p5-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; margin-bottom: 10px; }
.p5-card { border: 2px solid #f0d3e2; background: #fff8fb; border-radius: 12px; padding: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 3px;
  font: 700 11.5px 'Nunito', sans-serif; color: var(--ink); align-items: center; }
.p5-card .p5-ic { font-size: 30px; }
.p5-card b { font: 800 13px 'Baloo 2', sans-serif; color: var(--purple); }
.p5-card.sel { border-color: var(--pink); background: #ffe6f2; }
.p5-card:disabled { opacity: .55; cursor: not-allowed; }
#abilityBtn { margin-right: 6px; }
#p3dStreak { position: fixed; z-index: 25; left: 50%; top: 22%; transform: translate(-50%, -10px) scale(.8); opacity: 0; pointer-events: none;
  font: 800 30px 'Baloo 2', sans-serif; color: #fff; text-shadow: 0 3px 0 #c2437e, 0 6px 18px rgba(160, 48, 96, .45); transition: opacity .25s, transform .35s cubic-bezier(.3, 1.6, .5, 1); white-space: nowrap; }
#p3dStreak.on { opacity: 1; transform: translate(-50%, 0) scale(1); }
#p3dBonusChip { position: fixed; z-index: 13; left: 50%; transform: translateX(-50%); bottom: 96px; animation: p5pulse 1.2s ease-in-out infinite; }
@keyframes p5pulse { 50% { transform: translateX(-50%) scale(1.06); } }
#firstGameBtn.pulse { animation: p5pulse2 1.3s ease-in-out infinite; }
@keyframes p5pulse2 { 50% { transform: scale(1.06); } }
#bossBtn small { font-size: 10px; opacity: .85; }
#p3dMini { position: fixed; inset: 0; z-index: 46; display: none; align-items: center; justify-content: center; background: rgba(58, 46, 57, .5); }
#p3dMini .mg-in { position: relative; background: #fff; border: 3px solid var(--gold); border-radius: 18px; width: min(520px, calc(100vw - 32px)); height: min(560px, calc(100vh - 40px));
  box-sizing: border-box; padding: 12px; display: flex; flex-direction: column; }
#p3dMini .mg-top { display: flex; align-items: center; gap: 10px; }
#p3dMini h3 { font: 800 19px 'Baloo 2', sans-serif; color: var(--pink); margin: 0; flex: 1; }
#p3dMini .mg-time, #p3dMini .mg-score { font: 800 15px 'Baloo 2', sans-serif; background: #FDF0F6; border-radius: 9px; padding: 3px 9px; }
#p3dMini .mg-area { position: relative; flex: 1; margin-top: 8px; border-radius: 12px; overflow: hidden; background: linear-gradient(#e9e4ff, #ffe6f2); }
#p3dMini .mg-area.stars { background: linear-gradient(#2a2a6a, #6a4aa8); }
.mg-star { position: absolute; top: -48px; font-size: 40px; background: none; border: 0; cursor: pointer; animation: mgfall 3s linear forwards; padding: 4px; }
@keyframes mgfall { to { top: 100%; transform: rotate(200deg); } }
.mg-area.memory { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 6px; }
.mg-card { border: 0; border-radius: 10px; background: linear-gradient(135deg, var(--pink2), var(--purple)); padding: 0; cursor: pointer; overflow: hidden; }
.mg-card img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .2s; }
.mg-card.up img { opacity: 1; }
.mg-card.done { box-shadow: 0 0 0 3px #43B649 inset; }
.mg-area.maths { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.mg-q { font: 800 42px 'Baloo 2', sans-serif; color: var(--purple); }
.mg-balloons { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.mg-balloon { width: 74px; height: 92px; border-radius: 50% 50% 46% 46%; border: 0; background: var(--c); color: #fff; font: 800 30px 'Baloo 2', sans-serif;
  cursor: pointer; box-shadow: inset -8px -10px 0 rgba(0, 0, 0, .12); transition: transform .25s, opacity .25s; }
.mg-balloon.pop { transform: scale(1.5); opacity: 0; }
.mg-balloon.wobble { animation: mgw .35s; }
@keyframes mgw { 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
#p3dMini .mg-end { position: absolute; inset: 0; background: rgba(255, 255, 255, .94); border-radius: 15px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font-weight: 800; }
#p3dMini .mg-end[hidden] { display: none; }
#p3dMini .mg-big { font: 800 30px 'Baloo 2', sans-serif; color: var(--pink); }
#p3dBoss { position: fixed; z-index: 11; top: calc(var(--top-h) + var(--gap) * 2 + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  width: min(420px, calc(100vw - 32px)); box-sizing: border-box; padding: 6px 12px; }
#p3dBoss .bs-row { display: flex; gap: 10px; align-items: center; }
#p3dBoss .bs-dragon { font-size: 40px; }
#p3dBoss .bs-dragon.hit { animation: bshit .4s; }
@keyframes bshit { 30% { transform: translateX(-6px) rotate(-10deg); } 60% { transform: translateX(6px) rotate(8deg); } }
#p3dBoss .bs-main { flex: 1; }
#p3dBoss .bs-t { font: 800 14px 'Baloo 2', sans-serif; color: #b3122e; display: flex; justify-content: space-between; }
#p3dBoss .bs-t span { color: #8a7a86; font-size: 12px; }
#p3dBoss .bs-hp { position: relative; height: 16px; background: #f6dce4; border-radius: 9px; overflow: hidden; }
#p3dBoss .bs-hp i { display: block; height: 100%; background: linear-gradient(90deg, #ff4b3e, #ff9a3d); transition: width .4s; }
#p3dBoss .bs-hp b { position: absolute; inset: 0; font: 800 11px/16px 'Nunito', sans-serif; text-align: center; color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.4); }
#p3dBoss .bs-n { font-size: 11.5px; font-weight: 800; margin-top: 2px; }
#p3dBoss.won { border-color: #43B649; }
body.phase-game #p3dStoryChip:not([hidden]) ~ #p3dBoss { top: calc(var(--top-h) + 80px); }
#p3dCoach { position: fixed; z-index: 24; left: 50%; transform: translateX(-50%); bottom: 100px; padding: 10px 16px; font: 800 17px 'Nunito', sans-serif;
  max-width: calc(100vw - 32px); box-sizing: border-box; border-color: var(--pink2); text-align: center; }
#p3dCoach .ch-k { display: block; font: 800 11px 'Nunito', sans-serif; color: var(--purple); letter-spacing: 1px; text-transform: uppercase; }
body.lite #p3dStreak { transition: none; }

/* ======================================================================================================
   Phase 5 Batch A (2026-11-02): kid-size UI. Every control is at least 48 px (primary 56 px), text 14-16 px or
   more, the top bar holds 4 controls (Menu, Photo, Kingdom, Sound); portrait phones play (no rotate wall).
   ====================================================================================================== */
html body #rotateOverlay { display: none !important; }
.p3d-btn, .wg-btn, #p3dTop button, .p5-pop button, #wgmodal button, #p3dMini button, #p3dJunior button { min-height: 48px; min-width: 48px; font-size: 16px; }
@media (max-width: 1179px), (max-height: 599px) { .p3d-btn { font-size: 15px; padding: 8px 12px; min-height: 48px; } }
.wg-btn.small { min-height: 48px; padding: 8px 14px; font-size: 15px; }
.p3d-lbl { font-size: 14px; }
.p3d-small, #p3dOnline .on-note, #p3dPhotoBar .ph-tip, #bossBtn small { font-size: 14px; }
#p3dTitle #tbSub { display: none; }
body #log { font-size: 14px; }
body #marketNews { font-size: 14px; }
body #p3dAch .achchip .l { font-size: 13px !important; }
#p3dChatLines { font-size: 14px; }
#p3dStickers .stk { min-height: 48px; min-width: 48px; font-size: 16px; }
#wgmodal, #wgmodal p, #wgmodal .bn { font-size: 16px; }
#p3dTop { gap: 8px; }
#p3dTop .kid-top { font-size: 17px; }
#p3dTop .lbl { font-size: 15px; }
@media (max-width: 700px) { #p3dTop .lbl { display: none; } #p3dTitle #tbTitle { font-size: 16px; } }
#p3dTimer[hidden], #p3dTop label[hidden] { display: none !important; }
#annBadge { font-size: 22px; }

/* the menu: everything that left the top bar */
#p3dMenu .menu-in { width: min(520px, calc(100vw - 32px)); }
#p3dMenu .menu-lang { display: flex; justify-content: center; margin-bottom: 10px; }
#p3dMenu .menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 10px; }
#p3dMenu .menu-grid > * { width: 100%; min-height: 56px; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 16px;
  background: #fff; color: var(--ink); border: 2px solid #e8d9e2; border-radius: 14px; box-shadow: none; }
#p3dMenu .menu-cap { font: 800 15px "Nunito", sans-serif; }
#p3dMenu .menu-grid .lbl, #p3dMenu .menu-grid #spinTopCnt { display: none; }
#p3dMenu .menu-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; align-items: center; }
#p3dMenu .menu-music label { display: flex; gap: 6px; align-items: center; font-size: 16px; font-weight: 800; min-height: 48px; }
#p3dMenu .menu-music input[type=checkbox] { width: 28px; height: 28px; }
#p3dMenu #musicVol { width: 160px; height: 32px; }

/* the language switch: English | Hindi */
.p3d-lang { display: inline-flex; border: 2px solid var(--gold); border-radius: 14px; overflow: hidden; background: #fff; }
.p3d-lang button { min-height: 48px; min-width: 96px; border: 0; background: #fff; font: 800 16px "Nunito", sans-serif; color: var(--ink); cursor: pointer; padding: 0 14px; }
.p3d-lang button[aria-pressed="true"] { background: var(--pink2); color: #fff; }

/* grown-ups lock */
.p3d-parent { position: fixed; z-index: 35; right: calc(var(--gap) + env(safe-area-inset-right)); bottom: calc(var(--gap) + env(safe-area-inset-bottom)); }
body.phase-game .p3d-parent { display: none; }
.p3d-kidnote { position: fixed; z-index: 70; left: 50%; top: 40%; transform: translateX(-50%); background: #fff; border: 3px solid var(--gold);
  border-radius: 18px; padding: 16px 22px; font: 800 18px "Nunito", sans-serif; box-shadow: var(--shadow); text-align: center; max-width: calc(100vw - 32px); }
.p3d-kidnote span { font-size: 30px; display: block; }

/* the grown-up gate */
#p3dGate .gt-in { width: min(440px, calc(100vw - 32px)); }
#p3dGate .gt-why { font-size: 15px; }
#p3dGate .gt-q { font: 800 22px "Baloo 2", sans-serif; color: var(--purple); margin: 6px 0; }
#p3dGate .gt-ch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
#p3dGate .gt-opt { position: relative; overflow: hidden; min-height: 56px; border: 2px solid #e8d9e2; border-radius: 12px; background: #fff;
  font: 800 20px "Nunito", sans-serif; cursor: pointer; touch-action: none; user-select: none; }
#p3dGate .gt-opt i { position: absolute; left: 0; bottom: 0; height: 5px; width: 0; background: var(--pink2); }
#p3dGate .gt-opt.holding i { width: 100%; transition: width 1.5s linear; }
#p3dGate .gt-msg { min-height: 22px; font-size: 15px; font-weight: 800; color: #b3122e; }

/* Parent Corner */
#p3dParent .pc-in { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; text-align: left; }
#p3dParent h3 { text-align: center; }
#p3dParent .pc-lang { display: flex; justify-content: center; margin-bottom: 8px; }
#p3dParent section { border-top: 1.5px solid #f0e3ec; padding: 10px 0; }
#p3dParent h4 { margin: 0 0 6px; font: 800 17px "Baloo 2", sans-serif; color: var(--purple); }
#p3dParent .pc-row { display: flex; gap: 6px; flex-wrap: wrap; }
#p3dParent .pc-chip { min-height: 48px; border: 2px solid #e8d9e2; border-radius: 12px; background: #fff; font: 800 15px "Nunito", sans-serif; padding: 0 12px; cursor: pointer; }
#p3dParent .pc-chip[aria-pressed="true"] { border-color: var(--pink); background: #ffe6f2; }
#p3dParent .pc-tg { display: flex; gap: 8px; align-items: center; font-size: 15px; font-weight: 700; min-height: 48px; }
#p3dParent .pc-tg input { width: 26px; height: 26px; }
#p3dParent .pc-small { font-size: 14px; color: #6d5d68; font-weight: 700; }
#p3dParent .pc-report { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; font-size: 15px; }
#p3dParent .pc-report b { color: var(--pink); font-size: 18px; }
#p3dParent .pc-buy { display: flex; gap: 10px; align-items: center; justify-content: space-between; font-size: 15px; margin: 6px 0; }
#p3dParent [data-close] { display: block; margin: 10px auto 0; }
.pledge { list-style: none; padding: 0; margin: 0; }
.pledge li { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; }
.pledge .pl-ic { font-size: 26px; min-width: 40px; text-align: center; }
.pledge b { font: 800 16px "Baloo 2", sans-serif; color: var(--ink); }
.pledge p { margin: 2px 0 0; font-size: 15px; color: #6d5d68; font-weight: 600; }
#p3dPledge .p5-in { text-align: left; max-height: calc(100vh - 32px); overflow-y: auto; }

/* playtime rest screen */
#p3dRest { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(170deg, #2b2b6b, #6a4aa8); color: #fff; text-align: center; padding: 24px; }
#p3dRest[hidden] { display: none; }
#p3dRest .rest-moon { font-size: 90px; animation: p5pulse2 3s ease-in-out infinite; }
#p3dRest h2 { font: 800 28px "Baloo 2", sans-serif; margin: 10px 0; }
#p3dRest p { font-size: 20px; font-weight: 700; }

/* ---------- Junior mode (Little Explorers) ---------- */
#p3dJunior { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(12px + env(safe-area-inset-bottom)); pointer-events: none;
  background: linear-gradient(180deg, rgba(253, 238, 246, 0) 40%, rgba(253, 238, 246, .55)); }
#p3dJunior[hidden] { display: none; }
#p3dJunior > * { pointer-events: auto; }
body.junior-first #p3dSetupWrap, body.junior-first .p3d-parent { display: none; }
#p3dJunior .jr-top { display: flex; gap: 10px; align-items: center; }
#p3dJunior .jr-stage { display: flex; flex-direction: column; align-items: center; width: 100%; }
#p3dJunior .jr-play { width: min(260px, 70vw); height: 140px; border-radius: 40px; border: 6px solid #fff; cursor: pointer;
  background: linear-gradient(180deg, #ff8cc6, #e0559a); color: #fff; font: 800 56px/1 "Baloo 2", sans-serif; box-shadow: 0 12px 30px rgba(217, 79, 142, .45);
  display: flex; align-items: center; justify-content: center; gap: 12px; animation: p5pulse2 1.6s ease-in-out infinite; }
#p3dJunior .jr-play[hidden], #p3dJunior .jr-pick[hidden] { display: none; }
#p3dJunior .jr-play span { font-size: 44px; letter-spacing: 2px; }
#p3dJunior .jr-pick { background: rgba(255, 255, 255, .94); border: 3px solid var(--gold); border-radius: 24px; padding: 12px; width: min(720px, 100%); box-sizing: border-box; text-align: center; }
#p3dJunior .jr-pick h2 { font: 800 26px "Baloo 2", sans-serif; color: var(--pink); margin: 0 0 8px; }
#p3dJunior .jr-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
#p3dJunior .jr-card { min-height: 160px; border: 4px solid var(--pc); border-radius: 22px; background: #fff; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; padding: 6px; font: 800 20px "Baloo 2", sans-serif; color: var(--ink); }
#p3dJunior .jr-card img { width: 110px; height: 110px; object-fit: contain; }
#p3dJunior .jr-card.sel { background: #ffe6f2; transform: scale(1.04); }
#p3dJunior .jr-card.go { background: linear-gradient(180deg, #8ee07a, #43B649); color: #fff; font-size: 44px; }
#p3dJunior .jr-family { margin-top: 10px; min-height: 56px; border-radius: 16px; border: 2px solid #e8d9e2; background: #fff; font: 800 18px "Nunito", sans-serif; padding: 0 16px; }
#p3dJunior .jr-foot { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
#p3dJunior .jr-link { min-height: 48px; border-radius: 14px; border: 2px solid #e8d9e2; background: rgba(255, 255, 255, .92); font: 800 15px "Nunito", sans-serif; padding: 0 14px; }
body.junior .p3d-rail, body.junior .p3d-tab, body.junior #p3dDock, body.junior #p3dChat, body.junior #abilityBtn, body.junior #p3dBonusChip { display: none !important; }
#p3dJrHud { position: fixed; z-index: 14; left: 50%; transform: translateX(-50%); top: calc(var(--top-h) + var(--gap) * 2 + env(safe-area-inset-top));
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; width: calc(100vw - 32px); pointer-events: none; }
#p3dJrHud[hidden] { display: none; }
.jr-jar { background: rgba(255, 255, 255, .94); border: 3px solid var(--pc); border-radius: 18px; padding: 4px 10px; display: flex; flex-direction: column; align-items: center; }
.jr-jar.cur { box-shadow: 0 0 0 4px #ffd04d; }
.jr-jar .jr-who { font: 800 15px "Baloo 2", sans-serif; }
.jr-jar .jr-glass { font-size: 16px; letter-spacing: -2px; line-height: 1.2; }
.jr-jar .jr-glass i { display: inline-block; width: 12px; height: 12px; margin: 0 2px; border-radius: 50%; border: 2px dashed #d9c9d4; }
#jrRoll { position: fixed; z-index: 15; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom)); width: 160px; height: 120px;
  border-radius: 36px; border: 6px solid #fff; background: linear-gradient(180deg, #ffe08a, #f0b913); font: 800 52px/1 "Baloo 2", sans-serif; color: #5a3a00;
  box-shadow: 0 10px 26px rgba(240, 185, 19, .5); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#jrRoll span { font-size: 20px; }
#jrRoll[hidden] { display: none; }
.jr-big { font-size: 20px !important; min-height: 64px !important; margin-top: 12px; }

/* Junior: PLAY sits low so Kiara on the podium shows above it */
#p3dJunior .jr-stage { margin-top: auto; margin-bottom: 10px; }

#p3dTop .p3d-pill[hidden] { display: none !important; }
#menuBtn { background: linear-gradient(180deg, var(--pink2), #c2437e); color: #fff; font-size: 20px; }
#soundBtn { background: #fff; color: var(--ink); border: 2px solid #e8d9e2; }

.p3d-tab { min-width: 48px; }
#p3dMenu .menu-music label { display: none; }
#p3dMenu .menu-music #musicBtn { min-height: 48px; }

/* grandparent mode (Phase 5 item 26): everything larger */
body.grand .p3d-card, body.grand .p5-pop .p5-in, body.grand #wgmodal, body.grand #p3dJrHud, body.grand #p3dJunior .jr-pick { zoom: 1.15; }
body.grand #p3dTop .lbl { display: inline; }
body.grand .p3d-btn, body.grand #wgmodal, body.grand #wgmodal p { font-size: 19px; }

/* ---------- Phase 5 Batch B: wait toy, picture buy cards, stickers, fair dice, counting, episode, pets ---------- */
#p3dSparkleToy { position: fixed; inset: 0; z-index: 9; pointer-events: none; overflow: hidden; }
#p3dSparkleToy .toy-spark { position: absolute; bottom: -60px; pointer-events: auto; min-width: 56px; min-height: 56px; border: 0; background: none;
  font-size: 40px; cursor: pointer; animation: toyrise 5s linear forwards; filter: drop-shadow(0 0 8px rgba(255, 220, 120, .9)); }
#p3dSparkleToy .toy-spark.pop { transform: scale(1.8); opacity: 0; transition: transform .25s, opacity .25s; }
@keyframes toyrise { to { bottom: 110%; transform: translateX(30px) rotate(160deg); } }
.bc-hidden { display: none !important; }
.p3d-buycard { text-align: center; position: relative; }
.p3d-buycard img { width: min(280px, 70vw); aspect-ratio: 1 / 1.4; object-fit: cover; border-radius: 18px; border: 5px solid var(--gold); box-shadow: var(--shadow); }
.p3d-buycard .bc-name { font: 800 26px "Baloo 2", sans-serif; color: var(--pink); margin-top: 6px; }
.p3d-buycard .bc-price { font-size: 22px; margin: 2px 0; }
.p3d-buycard .bc-price b { color: #2e8b4f; }
.p3d-buycard .bc-q { font: 800 18px "Nunito", sans-serif; }
.p3d-buycard .bc-have { font-size: 14px; color: #8a7a86; }
.p3d-buycard .bc-btns { display: flex; gap: 18px; justify-content: center; margin: 10px 0 4px; }
.p3d-buycard .bc-btns button { width: 96px; height: 80px; border-radius: 22px; font-size: 44px; border: 4px solid #fff; cursor: pointer; box-shadow: var(--shadow); }
.p3d-buycard .bc-yes { background: linear-gradient(180deg, #8ee07a, #43B649); }
.p3d-buycard .bc-no { background: linear-gradient(180deg, #ffd1e6, #f29ac4); }
.p3d-buycard .bc-info { position: absolute; top: 4px; right: 4px; width: 48px; height: 48px; border-radius: 50%; border: 2px solid #e8d9e2; background: #fff; font-size: 20px; }
#p3dStickerBook .sb-in { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; }
#p3dStickerBook .sb-n { font-size: 15px; color: var(--purple); }
#p3dStickerBook .sb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 6px; margin-bottom: 10px; }
#p3dStickerBook .sb-st { aspect-ratio: 1; border-radius: 14px; background: #f3eef3; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 30px; color: #c9b9c6; border: 2px dashed #e0d0dc; overflow: hidden; }
#p3dStickerBook .sb-st.got { background: #fff; border: 3px solid var(--gold); color: var(--ink); }
#p3dStickerBook .sb-st img { width: 70%; height: 60%; object-fit: contain; }
#p3dStickerBook .sb-st i { font: 800 11px "Nunito", sans-serif; font-style: normal; text-align: center; padding: 0 2px; }
.p3d-sticker-toast { position: fixed; z-index: 60; right: 16px; top: 30%; background: #fff; border: 4px solid var(--gold); border-radius: 20px; padding: 10px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; box-shadow: var(--shadow); animation: sttoast 2.6s ease forwards; font: 800 15px "Nunito", sans-serif; }
.p3d-sticker-toast img { width: 72px; height: 72px; object-fit: contain; }
.p3d-sticker-toast span { font-size: 48px; }
@keyframes sttoast { 0% { transform: translateX(140%) rotate(8deg); } 15%, 85% { transform: translateX(0) rotate(-3deg); } 100% { transform: translateX(140%); } }
#p3dFairDice .fd-chart { display: flex; gap: 8px; align-items: flex-end; justify-content: center; height: 150px; margin: 10px 0; }
#p3dFairDice .fd-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; width: 40px; }
#p3dFairDice .fd-bar { display: block; width: 32px; min-height: 4px; background: linear-gradient(180deg, var(--pink2), var(--purple)); border-radius: 8px 8px 2px 2px; }
#p3dFairDice .fd-col b { font: 800 18px "Baloo 2", sans-serif; }
#p3dFairDice .fd-col i { font-size: 14px; font-style: normal; font-weight: 800; color: #8a7a86; }
#p3dCount { position: fixed; z-index: 16; left: 50%; transform: translateX(-50%); top: 34%; background: rgba(255, 255, 255, .95); border: 3px solid var(--gold);
  border-radius: 18px; padding: 8px 16px; display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
#p3dCount[hidden] { display: none; }
#p3dCount .ct-l { font: 800 30px "Baloo 2", sans-serif; }
#p3dCount.get .ct-l, #p3dCount.get .ct-n { color: #2e8b4f; }
#p3dCount.pay .ct-l, #p3dCount.pay .ct-n { color: #b3122e; }
#p3dCount .ct-coins { font-size: 24px; letter-spacing: -6px; }
#p3dCount .ct-coins i { font-style: normal; display: inline-block; animation: ctpop .25s ease; }
@keyframes ctpop { from { transform: translateY(-14px) scale(.4); } }
#p3dCount .ct-n { font: 800 30px "Baloo 2", sans-serif; min-width: 70px; }
#p3dEpisode { position: fixed; z-index: 36; left: 50%; transform: translateX(-50%); top: 38%; padding: 10px 16px; text-align: center; width: min(460px, calc(100vw - 32px)); box-sizing: border-box; }
#p3dEpisode .ep-t { font: 800 14px "Nunito", sans-serif; color: var(--purple); letter-spacing: 1px; }
#p3dEpisode .ep-n { font: 800 20px "Baloo 2", sans-serif; color: var(--pink); margin: 2px 0 6px; }
#p3dEpisode .ep-b { display: flex; gap: 8px; justify-content: center; }
#p3dPets .pet-in { width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; }
#p3dPets .p5-card img { width: 86px; height: 86px; object-fit: contain; }
#p3dPets .pet-hearts { font-size: 14px; letter-spacing: -1px; }
#p3dPets .pet-row { display: flex; justify-content: center; margin: 6px 0; }
#p3dPets .pet-outfits .p5-card img { width: 56px; height: 56px; }
.p5-pers { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 10px; background: #f4efe6; font: 800 13px "Nunito", sans-serif; color: #5d4a55; }

#p3dMyWorld .mw-c { width: 48px; height: 48px; }

/* ---------- Phase 5 item 8: pass-and-play hand-over card ---------- */
#p3dPass { position: fixed; inset: 0; z-index: 44; display: flex; align-items: center; justify-content: center; background: rgba(58, 46, 57, .55); }
#p3dPass[hidden] { display: none; }
#p3dPass .pp-in { background: #fff; border: 5px solid var(--pc, var(--pink)); border-radius: 26px; padding: 18px 22px; text-align: center; width: min(360px, calc(100vw - 32px)); box-sizing: border-box; box-shadow: var(--shadow); }
#p3dPass img { width: 120px; height: 120px; object-fit: contain; border-radius: 50%; background: #fdf3f8; }
#p3dPass .pp-t { font: 800 18px "Nunito", sans-serif; color: var(--purple); margin-top: 6px; }
#p3dPass .pp-n { font: 800 34px "Baloo 2", sans-serif; color: var(--pc, var(--pink)); margin: 2px 0 10px; }
#p3dPass .pp-go { min-height: 56px; font-size: 20px; padding: 0 22px; }

/* menu tiles: one icon + one caption (the gift dot shows via .ready) */
.menu-item #spinTopCnt { display: none; }
.menu-item.ready { box-shadow: 0 0 0 3px var(--gold) inset; }
#p3dQr #qrChip { min-height: 48px; font-size: 14px; width: 100%; }
#qrBody[hidden] { display: none; }

/* ---------- Kingdom HUD on portrait phones (Phase 5 island pass): compact top strip, 4x2 button grid ---------- */
@media (max-width: 600px) and (orientation: portrait) {
  #kTop { flex-wrap: wrap; flex-direction: row; gap: 4px 6px; padding: 4px 8px; align-items: center; }
  #kTitle { font-size: 14px; flex: 1 1 auto; flex-direction: row; align-items: center; gap: 6px; }
  #kLeague { margin-top: 0; }
  #kTop .kres { order: 3; flex: 1 1 100%; display: flex; flex-direction: row; flex-wrap: nowrap; justify-content: space-between; gap: 4px; }
  #kTop .kres span { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; font-size: 14px; min-height: 0; }
  #kTop .p3d-btn { min-width: 48px; min-height: 48px; padding: 0 8px; font-size: 14px; white-space: nowrap; }
  #kTop .p3d-btn .lbl { display: none; }
  #kBar { display: grid; grid-template-columns: repeat(4, 1fr); width: calc(100vw - 16px); box-sizing: border-box; gap: 4px; padding: 4px; }
  #kBar .p3d-btn { min-height: 48px; font-size: 12.5px; padding: 2px 4px; line-height: 1.15; white-space: normal; text-align: center; }
  #kBar { bottom: calc(64px + env(safe-area-inset-bottom)); }      /* the grown-ups lock sits below it */
}
#p3dPets .pet-empty { opacity: .85; }
#p3dPets .pet-msg { min-height: 20px; margin: 2px 0 6px; font: 800 15px "Nunito", sans-serif; color: #b3122e; }
#p3dPets .shake { animation: petshake .45s ease; }
@keyframes petshake { 20% { transform: translateX(-6px) rotate(-3deg); } 40% { transform: translateX(6px) rotate(3deg); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
#p3dPets .pet-in > [data-close] { position: sticky; bottom: 0; z-index: 2; min-width: 120px; min-height: 52px; box-shadow: 0 -6px 14px rgba(255,255,255,.95); }
#p3dOnline .on-row[hidden] { display: none; }

/* ---------- Kingdom island editor (🔨 Edit) ---------- */
body[data-k-edit="1"] #kBar, body[data-k-edit="1"] #kPanel { display: none !important; }
#kEdit { position: fixed; z-index: 32; left: 50%; transform: translateX(-50%); bottom: calc(8px + env(safe-area-inset-bottom)); width: min(760px, calc(100vw - 16px));
  box-sizing: border-box; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
#kEdit[hidden] { display: none; }
#kEdit .ke-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font: 800 15px "Baloo 2", sans-serif; color: var(--pink); }
#kEdit .ke-count { background: #fff3c4; border: 2px solid var(--gold); border-radius: 10px; padding: 1px 8px; color: #6b4a00; font-size: 14px; }
#kEdit .ke-msg { flex: 1; font: 800 14px "Nunito", sans-serif; color: #5d4a55; min-height: 18px; }
#kEdit .ke-btns { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; }
#kEdit .ke-btns .p3d-btn { min-height: 52px; font-size: 20px; padding: 2px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; }
#kEdit .ke-btns .p3d-btn span { font-size: 12px; }
#kEdit .ke-btns .p3d-btn:disabled { opacity: .45; }
#kEdit .ke-note { margin: 0; font: 700 12px "Nunito", sans-serif; color: #8a7a86; text-align: center; }
#kEdit .ke-tray { max-height: 40vh; overflow-y: auto; border-top: 2px dashed #eadfe7; padding-top: 6px; }
/* category tabs (2026-11-04 tidy): each tab sizes to its full name; a locked tab shows its level as a small chip
   after the label; the row scrolls sideways with a thin scrollbar and soft fade edges */
#kEdit .ke-tabs { display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-x: contain; padding: 2px 14px 8px 2px;
  scrollbar-width: thin; scrollbar-color: #e3cfdc transparent;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent); }
#kEdit .ke-tabs::-webkit-scrollbar { height: 4px; }
#kEdit .ke-tabs::-webkit-scrollbar-thumb { background: #e3cfdc; border-radius: 4px; }
#kEdit .ke-tabs::-webkit-scrollbar-track { background: transparent; }
#kEdit .ke-tabs .ke-tab { flex: 0 0 auto; min-width: max-content; white-space: nowrap; min-height: 44px; padding: 6px 14px; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px; line-height: 1.1; }
#kEdit .ke-tabs .ke-tab .ke-tl { white-space: nowrap; }
#kEdit .ke-tabs .ke-tab .ke-lv { flex: none; font: 800 10.5px 'Nunito', sans-serif; padding: 2px 6px; border-radius: 8px;
  background: #efe5ec; color: #6b5a66; white-space: nowrap; }
#kEdit .ke-wallet { font: 800 14px "Nunito", sans-serif; margin: 4px 0; }
#kEdit .ke-wallet span { font-size: 12px; color: #8a7a86; }
#kEdit .ke-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
#kEdit .ke-item { min-height: 112px; display: flex; flex-direction: column; align-items: center; gap: 2px; background: #fff; border: 2px solid #eadfe7; border-radius: 12px;
  padding: 4px; cursor: pointer; font: 800 12px "Nunito", sans-serif; }
#kEdit .ke-item img { width: 64px; height: 64px; object-fit: contain; }
#kEdit .ke-item.locked { background: #f5f0f4; }
#kEdit .ke-item.locked img { filter: grayscale(.7) opacity(.7); }
#kEdit .ke-item span { font-size: 11px; color: #6b5a66; }
#keModal .ke-lgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 8px 0; }
#keModal .ke-litem { min-height: 120px; border: 3px solid #eadfe7; border-radius: 14px; background: #fff; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; cursor: pointer; font: 800 14px "Nunito", sans-serif; }
#keModal .ke-litem img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 8px; }
#keModal .btns { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }
#keModal .btns .p3d-btn { min-width: 110px; min-height: 52px; }
@media (max-width: 600px) { #kEdit .ke-btns { grid-template-columns: repeat(4, 1fr); } }

/* ---------- re-audit 2026-11-03 fixes ---------- */
/* M4: one overlay at a time: a paused mini-game hides under the open layer; nothing of the board shows in the Kingdom */
#p3dMini.mg-paused { visibility: hidden; }
body.kingdom-on #p3dMini, body.kingdom-on #p3dJrHud, body.kingdom-on #jrRoll, body.kingdom-on #p3dBonusChip, body.kingdom-on #p3dJrWin,
body.kingdom-on #p3dPass, body.kingdom-on #p3dCount, body.kingdom-on #p3dEpisode, body.kingdom-on #p3dSparkleToy { display: none !important; }
#p3dMenu { z-index: 110; }                     /* the menu is always above the end screens */
/* M7: the Junior menu is pictures only; New game, Finish game and Save live behind Grown-ups */
body.junior #p3dMenu .menu-cap, body.junior #p3dMenu .menu-row #mFollow span, body.junior #p3dMenu .menu-row #mWhole span { display: none; }
body.junior #p3dMenu #saveBtn, body.junior #p3dMenu #restartBtn, body.junior #p3dMenu #endBtn,
body.junior #p3dMenu #bellBtn, body.junior #p3dMenu #fairDiceTop, body.junior #p3dMenu #p5DiceTop { display: none !important; }
body.junior #p3dMenu .menu-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
body.junior #p3dMenu .menu-grid > * { min-height: 92px; font-size: 40px; }
body.junior #p3dMenu .menu-music #musicBtn { font-size: 26px; }
/* Junior end screen (star jars, no money) */
#p3dJrWin { position: fixed; inset: 0; z-index: 98; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: radial-gradient(circle at 50% 40%, rgba(255, 246, 210, .97), rgba(255, 220, 238, .97)); text-align: center; padding: 16px; box-sizing: border-box; }
#p3dJrWin[hidden] { display: none; }
#p3dJrWin .jw-crown { font-size: 64px; animation: jwbounce 1.2s ease-in-out infinite; }
#p3dJrWin .jw-who { font: 800 30px "Baloo 2", sans-serif; color: var(--pink); }
#p3dJrWin .jw-jars { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
#p3dJrWin .jw-jar { background: #fff; border: 4px solid var(--pc, var(--gold)); border-radius: 22px; padding: 8px 12px; min-width: 130px; }
#p3dJrWin .jw-jar img { width: 72px; height: 72px; object-fit: contain; }
#p3dJrWin .jw-jar b { display: block; font: 800 18px "Baloo 2", sans-serif; }
#p3dJrWin .jw-jar span { font-size: 22px; letter-spacing: -2px; }
#p3dJrWin .jw-gift { font: 800 18px "Nunito", sans-serif; color: #5d4a55; }
#p3dJrWin .jw-btns { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
#p3dJrWin .jw-btns .p3d-btn { min-height: 64px; min-width: 150px; font-size: 20px; }
@keyframes jwbounce { 50% { transform: translateY(-10px) rotate(-6deg); } }

/* ---- Trophy Level, Trophy Road, layout locks, star vs gem chips (2026-11-04) ---- */
.kres .res-chip { display: inline-flex; align-items: center; gap: 4px; }
.kres .res-chip .ri, .ke-wallet .ri { width: 18px; height: 18px; flex: none; }
.kres .res-star { background: #fff6cf; border-color: #f2c94c; color: #8a5a00; }
.kres .res-gem { background: #e3f6ff; border-color: #6cc8f5; color: #0f4e8f; }
.kres .res-coin { background: #fff1e2; border-color: #f0b97a; }
.kres .res-trophy { background: linear-gradient(#ffe28a, #ffc531); border: 2px solid #d99a00; border-radius: 11px; padding: 4px 10px;
  font: 900 14px 'Baloo 2', sans-serif; color: #6b3d00; cursor: pointer; min-height: 36px; }
.kres .res-trophy:focus-visible { outline: 3px solid #ff5fa2; outline-offset: 2px; }
#kEdit .ke-wallet .res-chip { font-size: 14px; color: inherit; border-radius: 9px; padding: 1px 7px; }
#kEdit .ke-wallet .res-star { background: #fff6cf; } #kEdit .ke-wallet .res-coin { background: #fff1e2; }
.tr-head { display: flex; align-items: center; gap: 10px; margin: 4px 0 6px; }
.tr-badge { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(#fff3b0, #ffc531 70%);
  border: 3px solid #d99a00; font: 900 16px 'Baloo 2', sans-serif; color: #6b3d00; flex: none; }
.tr-bar { height: 14px; border-radius: 8px; background: #f1e7ee; overflow: hidden; border: 2px solid #eadfe7; }
.tr-bar i { display: block; height: 100%; background: linear-gradient(90deg, #ff8cc6, #ffc531); border-radius: 6px; }
.tr-roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; margin: 4px 0 8px; }
.tr-war { min-height: 104px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px; background: #fff; border: 3px solid #eadfe7;
  border-radius: 12px; font: 800 12px 'Nunito', sans-serif; cursor: pointer; }
.tr-war img { width: 56px; height: 56px; object-fit: contain; border-radius: 10px; background: #f7f1f6; }
.tr-war small { font-size: 10px; color: #6b5a66; }
.tr-war.sel { border-color: #ff5fa2; background: #fff0f7; }
.tr-war.locked { background: #f5f0f4; } .tr-war.locked img { filter: grayscale(1) opacity(.55); }
.tr-list { display: flex; flex-direction: column; gap: 4px; }
.tr-row { display: flex; gap: 8px; align-items: flex-start; padding: 5px 6px; border-radius: 10px; background: #f7f1f6; opacity: .7; font: 700 12px 'Nunito', sans-serif; }
.tr-row.on { opacity: 1; background: #fff9ee; } .tr-row.cur { outline: 2px solid #ffc531; }
.tr-row .tr-lv { flex: none; width: 46px; font: 900 13px 'Baloo 2', sans-serif; }
.tr-row small { color: #8a7a86; }
#kEdit .ke-tabs .ke-lock .ke-tl { opacity: .6; }
#keModal .ke-litem { position: relative; }
#keModal .ke-litem.locked img { filter: grayscale(1) opacity(.55); } #keModal .ke-litem.locked { background: #f5f0f4; }
#keModal .ke-litem.soon img { filter: saturate(.75); }
#keModal .ke-ltag { position: absolute; top: 10px; left: 10px; padding: 2px 8px; border-radius: 9px; font: 900 12px 'Nunito', sans-serif; }
#keModal .ke-ltag.lock { background: #4a3a46; color: #fff; } #keModal .ke-ltag.soon { background: #ffc531; color: #5a3300; }
#keModal .ke-lay { max-height: 86vh; overflow-y: auto; }
/* phones: Kingdom panels (Trophy Road, quests...) use the full width under the top bar, not a 44vw strip */
@media (max-width: 600px) { #kPanel { left: 8px; right: 8px; width: auto; top: 152px; bottom: 8px; z-index: 32; } }

/* ---- Underwater Kingdom (2026-11-04) ---- */
#kDiveBtn { white-space: nowrap; }
body[data-k-under="1"] #kBar, body[data-k-under="diving"] #kBar, body[data-k-under="surfacing"] #kBar,
body[data-k-under="1"] #kVisit, body[data-k-under="diving"] #kPanel, body[data-k-under="1"] #kPanel,
body[data-k-under="1"] #kCine, body[data-k-under="diving"] #kCine { display: none !important; }
#kUnderBar { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: calc(10px + env(safe-area-inset-bottom));
  display: flex; gap: 8px; align-items: center; padding: 6px 10px; flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 16px); }
#kUnderBar[hidden] { display: none; }
#kUnderBar .p3d-btn { min-height: 48px; font-size: 15px; }
#kUnderBar .ku-tip { font: 800 13px 'Nunito', sans-serif; color: #1d5f86; }
#kBubbles { position: fixed; inset: 0; z-index: 29; pointer-events: none; opacity: 0; overflow: hidden; }
#kBubbles.on { opacity: 1; background: radial-gradient(ellipse at 50% 60%, rgba(120,210,255,.55), rgba(30,110,170,.75)); animation: kbFade 1.3s ease forwards; }
#kBubbles.calm { animation-duration: .9s; }
#kBubbles i { position: absolute; bottom: -40px; border-radius: 50%; border: 2px solid rgba(255,255,255,.85); background: rgba(255,255,255,.18); animation: kbRise 1.2s ease-in forwards; }
@keyframes kbRise { to { transform: translateY(-115vh); opacity: .2; } }
@keyframes kbFade { 0% { opacity: 0; } 25% { opacity: 1; } 70% { opacity: .9; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #kBubbles i { display: none; } }
#kUnderBar.complete { border-color: #ffc531; box-shadow: 0 0 0 3px rgba(255,197,49,.45), 0 6px 18px rgba(0,0,0,.2); }
#kUnderBar.complete .ku-tip { color: #8a5a00; font-size: 14px; }
body[data-k-edit="1"] #kUnderBar { display: none !important; }
#uwSay { position: fixed; z-index: 31; transform: translate(-50%, -100%); max-width: min(260px, 70vw); padding: 8px 12px; border-radius: 14px;
  background: #fff; color: #3d2a36; font: 800 14px 'Nunito', sans-serif; box-shadow: 0 6px 18px rgba(0,0,0,.25); pointer-events: none; }
#uwSay[hidden] { display: none; }
#uwSay::after { content: ""; position: absolute; left: 50%; bottom: -8px; border: 8px solid transparent; border-top-color: #fff; border-bottom: 0; transform: translateX(-50%); }
#uwSay.pop { animation: uwPop .35s ease; }
#uwSay.pop::before { content: "✨"; position: absolute; right: -10px; top: -14px; font-size: 20px; }
@keyframes uwPop { from { transform: translate(-50%, -80%) scale(.6); opacity: 0; } to { transform: translate(-50%, -100%) scale(1); opacity: 1; } }

/* ---- Safari drive (2026-11-04) ---- */
body[data-k-safari="1"] #kBar, body[data-k-safari="1"] #kPanel, body[data-k-safari="1"] #kCine { display: none !important; }
#kSafariBar { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: calc(10px + env(safe-area-inset-bottom));
  display: flex; gap: 8px; align-items: center; padding: 6px 10px; flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 16px); }
#kSafariBar[hidden] { display: none; }
#kSafariBar .p3d-btn { min-height: 48px; font-size: 15px; }
#kSafariBar .ku-tip { font: 800 13px 'Nunito', sans-serif; color: #7a4a00; }
#kSafariSay { position: fixed; z-index: 31; transform: translate(-50%, -100%); padding: 8px 14px; border-radius: 14px; background: #fff7d6;
  color: #5a3300; font: 900 18px 'Baloo 2', sans-serif; box-shadow: 0 6px 18px rgba(0,0,0,.25); pointer-events: none; border: 3px solid #ffc531; }
#kSafariSay[hidden] { display: none; }
#kSafariSay.pop { animation: uwPop .35s ease; }

/* ---- phase6 A (2026-11-04): every Kingdom HUD label is at least 14 px (kid-readable) ---- */
#kLeague, #kPanel p, .krow, .krow .p3d-btn, .kitem, .kroad span, .kchat, .ksmall,
#kEdit .ke-btns .p3d-btn span, #kEdit .ke-note, #kEdit .ke-tabs .ke-tab, #kEdit .ke-tabs .ke-tab .ke-lv, #kEdit .ke-wallet span, #kEdit .ke-item span,
.tr-war, .tr-war small, .tr-row, .tr-row small, .tr-row .tr-lv, #keModal .ke-ltag, #kUnderBar .ku-tip, #kSafariBar .ku-tip { font-size: 14px !important; }
#kBar .p3d-btn, .kres span, .kres .res-chip, #kTop .kres span { font-size: 14px !important; }
@media (max-width: 600px) { #kBar .p3d-btn { font-size: 14px !important; line-height: 1.1; } #kTop .kres span { padding: 2px 6px; } }
#kPanel small, .kroad span small, #kEdit .ke-item b, #kEdit .ke-item small, .tr-war b, .tr-what small, .kitem span, .kitem b { font-size: 14px !important; }

/* ---- phase6 B (2026-11-04): Junior roll choices, catch-up chest, team play ---- */
#jrChoice { position: fixed; z-index: 45; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #fff;
  border: 4px solid #ffc531; border-radius: 22px; padding: 10px 14px 14px; box-shadow: 0 10px 26px rgba(0,0,0,.25); width: min(420px, calc(100vw - 24px)); text-align: center; }
#jrChoice[hidden] { display: none; }
#jrChoice .jc-q { font: 900 20px 'Baloo 2', sans-serif; color: #5a3300; margin-bottom: 8px; }
#jrChoice .jc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#jrChoice .jc-opt { min-height: 120px; border-radius: 18px; border: 3px solid #eadfe7; background: #fff8fb; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; font: 900 18px 'Baloo 2', sans-serif; color: #3d2a36; cursor: pointer; }
#jrChoice .jc-opt:focus-visible { outline: 4px solid #ff5fa2; }
#jrChoice .jc-pic { font-size: 54px; line-height: 1; }
#jrCatchup { position: fixed; z-index: 44; right: 14px; bottom: 160px; min-height: 64px; padding: 8px 14px; border-radius: 18px; border: 3px solid #d99a00;
  background: linear-gradient(#ffe28a, #ffc531); font: 900 18px 'Baloo 2', sans-serif; color: #5a3300; animation: jrBob 1.2s ease-in-out infinite; }
#jrCatchup[hidden] { display: none; }
@keyframes jrBob { 50% { transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { #jrCatchup { animation: none; } }
.jr-power { font-size: 14px; }
#jrTeam.sel { outline: 4px solid #ffc531; }

/* ---- phase6 D (2026-11-04): episode sticker pages + the magic-word keypad ---- */
#p3dEpisodes .ep-in { max-width: min(560px, calc(100vw - 20px)); max-height: 90vh; overflow-y: auto; }
#p3dEpisodes .ep-tabs { display: flex; gap: 6px; margin-bottom: 6px; }
#p3dEpisodes .ep-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
#p3dEpisodes .ep-st { min-height: 92px; border: 3px dashed #eadfe7; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; background: #faf6f9; font: 800 14px 'Nunito', sans-serif; color: #8a7a86; text-align: center; padding: 4px; }
#p3dEpisodes .ep-st span { font-size: 34px; }
#p3dEpisodes .ep-st.got { border-style: solid; border-color: #ffc531; background: #fff9e6; color: #5a3300; }
#p3dEpisodes .ep-done { font: 800 14px 'Nunito', sans-serif; color: #6b3d00; }
#p3dEpisodes .ep-typed { font: 900 28px 'Baloo 2', sans-serif; letter-spacing: 6px; text-align: center; color: #e0245e; min-height: 38px; }
#p3dEpisodes .ep-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 10px; }
#p3dEpisodes .ep-key { min-height: 72px; border-radius: 16px; border: 3px solid #eadfe7; background: #fff; display: flex; flex-direction: column; align-items: center;
  justify-content: center; font: 900 18px 'Baloo 2', sans-serif; color: #3d2a36; cursor: pointer; }
#p3dEpisodes .ep-key span { font-size: 30px; line-height: 1; }
#p3dEpisodes .ep-key.hint { border-color: #ffc531; box-shadow: 0 0 0 3px rgba(255,197,49,.5); }
.ep-toast i { display: block; font: 700 12px 'Nunito', sans-serif; }

/* ---- phase6 host (2026-11-04): Kiara's callout card + coming-soon character tiles ---- */
#p3dHost { position: fixed; z-index: 42; left: 12px; bottom: calc(150px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 10px;
  max-width: min(360px, calc(100vw - 24px)); padding: 8px 14px 8px 8px; background: #fff; border: 3px solid #ff8cc6; border-radius: 22px;
  box-shadow: 0 8px 22px rgba(0,0,0,.22); cursor: pointer; }
#p3dHost[hidden] { display: none; }
#p3dHost img { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; border: 3px solid #ffd6ea; flex: none; background: #fde7f2; }
#p3dHost .hb { display: flex; flex-direction: column; gap: 2px; font: 800 16px 'Nunito', sans-serif; color: #3d2a36; line-height: 1.25; }
#p3dHost .hb b { font: 900 14px 'Baloo 2', sans-serif; color: #e0559a; }
#p3dHost.on { animation: hostIn .35s ease-out; }
@keyframes hostIn { from { transform: translateX(-30px) scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #p3dHost.on { animation: none; } }
@media (max-width: 600px) { #p3dHost { bottom: calc(170px + env(safe-area-inset-bottom)); left: 8px; max-width: calc(100vw - 96px); } #p3dHost img { width: 64px; height: 64px; } #p3dHost .hb { font-size: 15px; } }
.jr-card.soon, .p3d-pick-card.soon { opacity: .75; filter: saturate(.8); cursor: default; position: relative; }
.jr-card.soon i, .p3d-pick-card.soon small { display: block; font: 900 12px 'Nunito', sans-serif; color: #fff; background: #8E6BB8; border-radius: 8px; padding: 1px 6px; margin-top: 2px; }
.jr-card.soon img, .p3d-pick-card.soon img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; }

/* ---- phase6 E (2026-11-04): "Kiara says" learning quest card ---- */
#p3dQuest { position: fixed; z-index: 44; right: 12px; bottom: calc(150px + env(safe-area-inset-bottom)); width: min(340px, calc(100vw - 24px));
  background: #fff; border: 4px solid #8E6BB8; border-radius: 20px; padding: 10px 12px 12px; box-shadow: 0 8px 22px rgba(0,0,0,.22); }
#p3dQuest[hidden] { display: none; }
#p3dQuest .lq-top { display: flex; align-items: center; gap: 8px; font: 900 16px 'Baloo 2', sans-serif; color: #8E6BB8; }
#p3dQuest .lq-top span { font-size: 14px; color: #6b5a66; flex: 1; }
#p3dQuest .lq-x { min-width: 40px; min-height: 40px; border-radius: 12px; border: 2px solid #eadfe7; background: #fff; font-size: 16px; }
#p3dQuest .lq-q { font: 800 16px 'Nunito', sans-serif; color: #3d2a36; margin: 6px 0; }
#p3dQuest .lq-pics { font-size: 30px; letter-spacing: 4px; text-align: center; margin: 4px 0 8px; word-break: break-all; }
#p3dQuest .lq-pics.hint { outline: 3px dashed #ffc531; border-radius: 12px; }
#p3dQuest .lq-row { display: flex; gap: 8px; justify-content: center; }
#p3dQuest .lq-opt { min-width: 76px; min-height: 64px; border-radius: 16px; border: 3px solid #eadfe7; background: #faf6ff; font: 900 24px 'Baloo 2', sans-serif; color: #3d2a36; }
#p3dQuest .lq-opt.big { font-size: 38px; }
@media (max-width: 600px) { #p3dQuest { bottom: calc(260px + env(safe-area-inset-bottom)); } }
.pc-today { font: 800 15px 'Nunito', sans-serif; color: #3d2a36; background: #fff9e6; border-radius: 12px; padding: 8px 10px; }
/* phones (phase6 F): the host and quest cards sit in the strip under the star jars, never over the piece (lower
   third) or the dice; they take turns */
@media (max-width: 600px) {
  #p3dHost { top: calc(200px + env(safe-area-inset-top)); bottom: auto; }
  #p3dQuest { top: calc(200px + env(safe-area-inset-top)); bottom: auto; right: 8px; left: 8px; width: auto; }
  body:not(.junior) #p3dHost, body:not(.junior) #p3dQuest { top: calc(80px + env(safe-area-inset-top)); }
}
#p3dQuest .lq-face { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; border: 3px solid #e9dcff; margin-right: 2px; }
/* cast sizes on the pick screens (2026-11-05): the picture stands on the card's floor at its true relative height */
#p3dJunior .jr-card img, .p3d-pick img { transform: scale(var(--sz, 1)); transform-origin: 50% 100%; }

/* episode feed (2026-11-05): the grown-ups' 🆕 dot and the gated Parent Corner episode tile */
.p3d-parent .pc-new { position: absolute; top: -8px; right: -8px; font-size: 14px; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,.3)); }
.pc-eps .pc-ep-new { display: flex; gap: 10px; align-items: center; background: #fff6d8; border: 2px solid #f2c14e; border-radius: 14px; padding: 8px; margin: 6px 0; }
.pc-eps .pc-ep-new img, .pc-ep-list img { border-radius: 10px; object-fit: cover; background: #f4e9ff; }
.pc-eps .pc-ep-new b { display: block; margin-bottom: 4px; }
.pc-ep-list { list-style: none; padding: 0; margin: 6px 0; display: grid; gap: 6px; }
.pc-ep-list li { display: flex; gap: 8px; align-items: center; }
#mParent, #restParent { position: relative; }
#mParent .pc-new, #restParent .pc-new { position: absolute; top: -8px; right: -8px; font-size: 14px; line-height: 1; }

/* 📺 Kiara's Stories room (2026-11-05) */
#p3dStories { z-index: 60; }
.st-room, .st-player { width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; }
.st-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 10px 0 14px; }
.st-card { display: flex; flex-direction: column; gap: 4px; text-align: left; background: #fff; border: 2px solid #f3c8e3; border-radius: 16px; padding: 8px; cursor: pointer; font: inherit; }
.st-card.soon { opacity: .75; cursor: pointer; }
.st-card .st-img { position: relative; display: block; }
.st-card img { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 12px; background: #f4e9ff; }
.st-card .st-new { position: absolute; top: 8px; left: -4px; background: #ff4f9a; color: #fff; font-style: normal; font-weight: 800; font-size: 12px; padding: 3px 10px; border-radius: 0 10px 10px 0; box-shadow: 0 2px 4px rgba(0,0,0,.25); }
.st-card .st-n { font-size: 13px; color: #8a6aa0; }
.st-off { background: #f4f0ff; border-radius: 12px; padding: 10px 14px; }
.st-player video { width: 100%; max-height: 70vh; border-radius: 14px; background: #000; }
.st-player .st-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.st-msg { margin: 8px 0 0; font-weight: 700; }
.st-glow { animation: stGlow 1.2s ease-in-out 4; }
@keyframes stGlow { 50% { box-shadow: 0 0 0 4px #ffd24a, 0 0 18px 6px rgba(255, 210, 74, .8); } }
@media (prefers-reduced-motion: reduce) { .st-glow { animation: none; box-shadow: 0 0 0 4px #ffd24a; } }
.ep-in .ep-still { display: block; width: min(320px, 100%); height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 12px; margin: 6px auto; }
/* Kiara's tour (2026-11-05): Next / Skip on her card, and a gentle highlight on what she talks about */
#p3dHost .hb-act { display: flex; gap: 6px; margin-top: 6px; }
#p3dHost .hb-act[hidden] { display: none; }
#p3dHost .hb-act .p3d-btn { padding: 4px 12px; min-height: 34px; font-size: 14px; }
.kiara-spot { outline: 4px solid #ffd24a !important; outline-offset: 3px; border-radius: 14px; animation: kiaraSpot 1.4s ease-in-out infinite; }
@keyframes kiaraSpot { 50% { outline-color: #ff7bc8; box-shadow: 0 0 18px 6px rgba(255, 210, 74, .7); } }
@media (prefers-reduced-motion: reduce) { .kiara-spot { animation: none; } }
/* festival event card (phase6-trophies) */
.kfest { background: #fff6d8; border: 2px solid #f2c14e; border-radius: 14px; padding: 8px 10px; margin: 6px 0 10px; display: grid; gap: 4px; }
.kfest p { margin: 2px 0; }
/* family sticker gifting on the pass-and-play card (phase6-trophies) */
#p3dPass .pp-gift { display: grid; gap: 6px; justify-items: center; margin: 6px 0 10px; font: 800 15px 'Nunito', sans-serif; }
#p3dPass .pp-st { display: flex; gap: 8px; }
#p3dPass .pp-sb { font-size: 26px; width: 52px; height: 52px; border-radius: 50%; border: 3px solid #ffd6ea; background: #fff; cursor: pointer; }
#p3dPass .pp-done { color: #e0559a; }
