/* ============ Elybean · Bean Playground (/play) ============ */
/* The Playground is the whole screen: no scrolling, the navbar floats over the sky. */
html:has(body[data-page="play"]), body[data-page="play"] { height: 100%; overflow: hidden; overscroll-behavior: none; }
body[data-page="play"] .site-header { position: fixed; left: 0; right: 0; }
body[data-page="play"] .site-header.at-top { background-color: transparent; border-bottom-color: transparent; }
.playmain { background: #8fd8fb; }
.pg { position: fixed; inset: 0; z-index: 1; --top: var(--header-h, 99px); }
.pg-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: linear-gradient(#5ec8f5, #b8ecff 55%, #e4f9ff);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.pg-stage canvas { position: absolute; inset: 0; display: block; outline: none; }
.pg svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- shared card ---------- */
.pg-card { background: var(--cream); border: var(--line); border-radius: 22px; box-shadow: var(--shadow); }

/* ---------- top-left: who + stats ---------- */
.pg-hud-left { position: absolute; top: calc(var(--top) + 12px); left: 18px; width: 290px; display: grid; gap: 10px; z-index: 3; pointer-events: none; }
.pg-hud-left > * { pointer-events: auto; }
.pg-who { padding: 12px 16px 12px; }
.pg-who-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pg-who-top b { font-size: 21px; font-weight: 900; letter-spacing: -.02em; margin-right: auto; }
.pg-who-pts { display: none; }
.pg-mood { font: 600 14px/1 var(--hand); padding: 6px 11px 7px; border: 2px solid var(--ink); border-radius: 999px; background: #b8ef8a; transition: background-color .4s; }
.pg-mood.m-sleeping { background: #cfc6ff; }
.pg-mood.m-hungry { background: #ffc27a; }
.pg-mood.m-sleepy { background: #ddd6ff; }
.pg-mood.m-lonely { background: #bfdcef; }
.pg-mood.m-overjoyed { background: var(--pink); }
.pg-level { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 10px; margin-top: 8px; font-size: 13px; font-weight: 800; }
.pg-level small { grid-column: 1 / -1; font-weight: 600; color: #29627a; font-size: 12px; }
.pg-level-track, .pg-bar-track { height: 12px; border: 2px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; }
.pg-level-track i, .pg-bar-track i { display: block; height: 100%; border-radius: 999px; background: var(--pink); transition: width .6s cubic-bezier(.3,1.3,.5,1); box-shadow: inset 0 3px 0 #ffffff66; }
.pg-bars { padding: 12px 14px; display: grid; gap: 9px; }
.pg-bar { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: center; }
.pg-bar-icon { width: 34px; height: 34px; display: grid; place-items: center; border: 2px solid var(--ink); border-radius: 12px; background: #fff; }
.pg-bar-icon svg { width: 19px; height: 19px; }
.pg-bar-top { display: flex; justify-content: space-between; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 3px; }
.pg-bar-top b { font-variant-numeric: tabular-nums; letter-spacing: 0; }
.b-happy .pg-bar-icon { background: #ffd9e6; } .b-happy i { background: #ff7fa8; }
.b-energy .pg-bar-icon { background: #fff1b8; } .b-energy i { background: var(--gold); }
.b-tummy .pg-bar-icon { background: #ffe1c9; } .b-tummy i { background: #ff9a52; }

/* ---------- top-right: points + toggles ---------- */
.pg-hud-right { position: absolute; top: calc(var(--top) + 12px); right: 18px; display: flex; gap: 8px; align-items: center; z-index: 3; }
.pg-points { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 16px 0 8px; background: var(--gold); border: var(--line); border-radius: 999px; box-shadow: 3px 4px 0 var(--ink); cursor: help; }
.pg-points img { width: 32px; height: 32px; object-fit: contain; }
.pg-points b { font-size: 21px; font-weight: 900; font-variant-numeric: tabular-nums; }
.pg-points span { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.pg-icon { width: 48px; height: 48px; display: grid; place-items: center; border: var(--line); border-radius: 50%; background: var(--cream); box-shadow: 3px 4px 0 var(--ink); padding: 0; transition: transform .18s cubic-bezier(.3,1.6,.5,1), box-shadow .18s; }
.pg-icon:hover { transform: translate(-1px, -2px) rotate(-4deg); box-shadow: 4px 6px 0 var(--ink); }
.pg-icon:active { transform: translate(2px, 2px) scale(.94); box-shadow: 1px 1px 0 var(--ink); }

/* ---------- speech bubble (positioned from the 3D head every frame) ---------- */
.pg-bubble { position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none; opacity: 0; transition: opacity .25s; will-change: transform; }
.pg-bubble.show { opacity: 1; }
.pg-bubble span {
  position: absolute; left: 0; bottom: 14px;
  width: max-content; max-width: min(250px, 64vw);
  transform: translateX(-50%);
  padding: 9px 16px 10px; background: #fff; border: var(--line); border-radius: 20px; box-shadow: 3px 4px 0 var(--ink);
  font-size: 18px; line-height: 1.2; text-align: center;
}
.pg-bubble span:empty { display: none; }
.pg-bubble span::after { content: ''; position: absolute; left: 50%; bottom: -10px; width: 16px; height: 16px; background: #fff; border: solid var(--ink); border-width: 0 2.5px 2.5px 0; transform: translateX(-50%) rotate(45deg); border-bottom-right-radius: 4px; }
.pg-bubble.show span { animation: pg-pop .35s cubic-bezier(.3,1.7,.5,1); }
@keyframes pg-pop { from { transform: translateX(-50%) scale(.5); opacity: 0; } }

/* ---------- toasts ---------- */
.pg-toasts { position: absolute; left: 50%; bottom: 112px; transform: translateX(-50%); display: flex; flex-direction: column-reverse; align-items: center; gap: 8px; z-index: 4; pointer-events: none; }
.pg-toast { display: grid; justify-items: center; padding: 8px 18px 9px; background: var(--cream); border: var(--line); border-radius: 18px; box-shadow: 3px 4px 0 var(--ink); animation: pg-toast .45s cubic-bezier(.3,1.6,.5,1); white-space: nowrap; }
.pg-toast b { font-size: 16px; font-weight: 900; }
.pg-toast span { font: 600 13px/1.2 var(--hand); color: #29627a; }
.pg-toast.t-points { background: var(--gold); padding: 6px 16px 7px; }
.pg-toast.t-points span { color: var(--ink); opacity: .7; }
.pg-toast.t-unlock { background: var(--pink); }
.pg-toast.t-unlock span, .pg-toast.t-level span { color: var(--ink); }
.pg-toast.t-level { background: var(--bean); }
@keyframes pg-toast { from { transform: translateY(18px) scale(.7); opacity: 0; } }

/* ---------- action dock ---------- */
.pg-dock { position: absolute; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 4px; padding: 7px; background: var(--cream); border: var(--line); border-radius: 26px; box-shadow: var(--shadow); z-index: 3; }
.pg-dock button { position: relative; display: grid; justify-items: center; gap: 3px; min-width: 76px; padding: 9px 12px 8px; border: 2px solid transparent; border-radius: 19px; background: transparent; font-size: 13px; font-weight: 800; transition: background-color .2s, transform .18s cubic-bezier(.3,1.6,.5,1); }
.pg-dock button:hover:not(:disabled) { background: #2fb6ea2e; transform: translateY(-2px); }
.pg-dock button:active:not(:disabled) { transform: scale(.92); }
.pg-dock button:disabled { opacity: .4; cursor: default; }
.pg-dock button.on { background: var(--gold); border-color: var(--ink); }
.pg-dock-unlocks { background: #ffd9e6 !important; border-color: var(--ink) !important; }
.pg-dock em { position: absolute; top: -6px; right: -4px; min-width: 22px; height: 22px; padding: 0 5px; display: grid; place-items: center; font: 900 12px/1 Rubik, sans-serif; font-style: normal; background: var(--bean); border: 2px solid var(--ink); border-radius: 999px; }

/* ---------- unlocks drawer ---------- */
.pg-drawer { position: absolute; top: calc(var(--top) + 74px); right: 18px; bottom: 112px; width: min(380px, calc(100% - 36px)); overflow: auto; overscroll-behavior: contain; padding: 18px 18px 14px; background: var(--cream); border: var(--line); border-radius: 26px; box-shadow: var(--shadow); z-index: 5; animation: pg-drawer .4s cubic-bezier(.2,1.2,.4,1); }
@keyframes pg-drawer { from { transform: translateX(30px) rotate(2deg); opacity: 0; } }
.pg-drawer-head { display: flex; align-items: center; justify-content: space-between; }
.pg-drawer h2 { margin: 0; font-size: 28px; font-weight: 900; letter-spacing: -.03em; }
.pg-drawer h3 { margin: 18px 0 8px; font-size: 12px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.pg-drawer .pg-icon { width: 40px; height: 40px; box-shadow: 2px 3px 0 var(--ink); }
.pg-drawer-pts { margin: 6px 0 0; font-size: 14px; color: #29627a; }
.pg-drawer-pts b { color: var(--ink); }
.pg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pg-item { position: relative; display: grid; gap: 2px; align-content: start; text-align: left; min-height: 64px; padding: 10px 12px; border: 2px solid var(--ink); border-radius: 16px; background: #fff; transition: transform .18s cubic-bezier(.3,1.6,.5,1), background-color .2s; }
.pg-item:hover:not(:disabled) { transform: translateY(-2px) rotate(-1deg); }
.pg-item.on { background: var(--gold); box-shadow: 2px 3px 0 var(--ink); }
.pg-item.locked { background: #e9f3f7; color: #4d7184; cursor: not-allowed; border-style: dashed; }
.pg-item-name { font-weight: 800; font-size: 15px; padding-right: 18px; }
.pg-item small { font: 600 13px/1.2 var(--hand); color: #29627a; }
.pg-lock { position: absolute; top: 9px; right: 9px; }
.pg-lock svg { width: 16px; height: 16px; }
.pg-note { margin: 16px 0 0; font-size: 13px; color: #29627a; line-height: 1.45; }

/* ---------- help ---------- */
.pg-help { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; padding: calc(var(--top) + 12px) 20px 20px; background: #092c4466; backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: pg-fade .3s; }
@keyframes pg-fade { from { opacity: 0; } }
.pg-help-card { width: min(440px, 100%); max-height: 100%; overflow: auto; padding: 24px 24px 22px; background: var(--cream); border: var(--line); border-radius: 28px; box-shadow: 6px 8px 0 var(--ink); animation: pg-drawer .45s cubic-bezier(.2,1.3,.4,1); }
.pg-help h2 { margin: 0 0 14px; font-size: 32px; font-weight: 900; letter-spacing: -.03em; transform: rotate(-1.5deg); }
.pg-help ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pg-help li { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: center; }
.pg-help li b { display: grid; place-items: center; height: 32px; border: 2px solid var(--ink); border-radius: 999px; background: var(--bean); font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }
.pg-help li:nth-child(2) b { background: #ffc27a; }
.pg-help li:nth-child(3) b { background: var(--gold); }
.pg-help li:nth-child(4) b { background: #cfc6ff; }
.pg-help li:nth-child(5) b { background: #b8ef8a; }
.pg-help li span { font-size: 15px; line-height: 1.35; }
.pg-help .button { margin-top: 18px; width: 100%; }

/* ---------- loading / fallback ---------- */
.pg-loading { position: absolute; inset: 0; z-index: 7; display: grid; place-content: center; justify-items: center; gap: 6px; text-align: center; padding: calc(var(--top) + 20px) 20px 20px; background: linear-gradient(#5ec8f5, #b8ecff 60%, #e4f9ff); }
.pg-loading img { width: clamp(150px, 22vw, 230px); animation: pg-bob 1.4s ease-in-out infinite; }
.pg-loading p { margin: 0; font-size: 20px; max-width: 30ch; }
@keyframes pg-bob { 50% { transform: translateY(-10px) rotate(-3deg); } }

/* ---------- more info inside the help card ---------- */
.pg-more { margin-top: 12px; font-size: 14px; }
.pg-more summary { cursor: pointer; font-weight: 800; color: var(--bean-deep); }
.pg-more dl { margin: 10px 0 0; display: grid; gap: 8px; }
.pg-more dt { font-weight: 800; }
.pg-more dd { margin: 0; color: #29627a; line-height: 1.45; }
.pg-fine { margin: 10px 0 0; font-size: 12px; color: #4d7184; line-height: 1.45; }
.pg-drawer .pg-reset { margin-top: 8px; }
.pg-reset { border: 0; background: none; padding: 0; color: #c02a63; font-weight: 800; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }


@media (prefers-reduced-motion: reduce) {
  .pg-loading img, .pg-toast, .pg-drawer, .pg-help-card, .pg-bubble.show span { animation: none; }
}
html[data-motion="off"] .pg-loading img { animation: none; }

/* ---------- tablet ---------- */
@media (max-width: 980px) {
  .pg-hud-left { width: 250px; }
}

/* ---------- phone ---------- */
@media (max-width: 700px) {
  .pg-hud-right { top: calc(var(--top) + 8px); right: 10px; gap: 6px; flex-direction: column; }
  .pg-hud-right .pg-points { display: none; }
  .pg-who-pts { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 8px 0 4px; background: var(--gold); border: 2px solid var(--ink); border-radius: 999px; font-weight: 900; font-size: 14px; font-variant-numeric: tabular-nums; }
  .pg-who-pts img { width: 20px; height: 20px; object-fit: contain; }
  .pg-icon { width: 40px; height: 40px; box-shadow: 2px 3px 0 var(--ink); }
  .pg-icon svg { width: 19px; height: 19px; }
  .pg-hud-left { top: calc(var(--top) + 8px); left: 10px; right: 60px; width: auto; gap: 8px; }
  .pg-who { padding: 9px 12px 10px; border-radius: 18px; box-shadow: 3px 4px 0 var(--ink); }
  .pg-who-top { gap: 6px; }
  .pg-who-top b { font-size: 17px; }
  .pg-mood { font-size: 12px; padding: 4px 8px 5px; }
  .pg-level { margin-top: 6px; font-size: 11px; gap: 3px 8px; }
  .pg-level small { display: none; }
  .pg-bars { position: absolute; top: calc(100% + 8px); left: 0; width: calc(100vw - 20px); grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 8px 10px; border-radius: 18px; box-shadow: 3px 4px 0 var(--ink); }
  .pg-bar { grid-template-columns: 26px 1fr; gap: 6px; }
  .pg-bar-icon { width: 26px; height: 26px; border-radius: 9px; }
  .pg-bar-icon svg { width: 15px; height: 15px; }
  .pg-bar-top { font-size: 9px; letter-spacing: .03em; margin-bottom: 2px; }
  .pg-bar-track { height: 10px; }
  .pg-dock { left: 10px; right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); transform: none; justify-content: space-between; border-radius: 22px; padding: 5px; }
  .pg-dock button { min-width: 0; flex: 1; padding: 8px 2px 7px; font-size: 12px; border-radius: 16px; }
  .pg-toasts { bottom: 92px; }
  .pg-drawer { top: auto; left: 10px; right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); width: auto; max-height: calc(100% - var(--top) - 24px); border-radius: 24px; animation-name: pg-sheet; }
  @keyframes pg-sheet { from { transform: translateY(40px); opacity: 0; } }
  .pg-bubble span { font-size: 16px; }
  .pg-help li { grid-template-columns: 58px 1fr; }
  .pg-help h2 { font-size: 27px; }
}

/* ---------- short, wide screens (phones in landscape) ---------- */
@media (max-height: 620px) and (min-width: 701px) {
  .pg-hud-left { width: auto; right: 236px; grid-template-columns: 210px minmax(0, 440px); align-items: start; top: calc(var(--top) + 8px); }
  .pg-hud-right { top: calc(var(--top) + 8px); }
  .pg-points span { display: none; }
  .pg-points { padding-right: 14px; }
  .pg-who { padding: 9px 12px; }
  .pg-who-top b { font-size: 18px; }
  .pg-bars { grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 9px 12px; }
  .pg-bar { grid-template-columns: 28px 1fr; gap: 6px; }
  .pg-bar-icon { width: 28px; height: 28px; border-radius: 9px; }
  .pg-bar-top { font-size: 9px; letter-spacing: .02em; gap: 4px; }
  .pg-level small { display: none; }
  .pg-dock { bottom: max(10px, env(safe-area-inset-bottom)); padding: 5px; }
  .pg-dock button { padding: 6px 10px 5px; }
  .pg-toasts { bottom: 86px; }
  .pg-drawer { top: calc(var(--top) + 64px); bottom: 86px; }
  .pg-help-card { padding: 18px 20px; }
  .pg-help ol { gap: 6px; }
}

.pg-closet-link { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; padding: 10px 14px; border: 2px solid var(--ink); border-radius: 18px; background: var(--gold); box-shadow: 3px 4px 0 var(--ink); transition: transform .18s cubic-bezier(.3,1.6,.5,1); }
.pg-closet-link:hover { transform: translate(-1px, -3px) rotate(-1deg); }
.pg-closet-link img { width: 48px; height: 48px; object-fit: contain; flex: none; }
.pg-closet-link span { display: grid; line-height: 1.25; }
.pg-closet-link small { font-size: 13px; color: #5a4a12; }

/* The 3D view fades in on its first frame instead of popping. */
.pg-stage > canvas { animation: pg-canvas-in .45s ease-out both; }
@keyframes pg-canvas-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pg-stage > canvas { animation: none; } }
