:root {
  --ink: #f6f2ea;
  --muted: #cfcbdc;
  --panel: rgba(28, 29, 37, 0.84);
  --panel-solid: #23242c;
  --go: #3ddc84;
  --go-ink: #05260f;
  --focus: #a8ccff;
  --sat: var(--discord-safe-area-inset-top, env(safe-area-inset-top, 0px));
  --sab: var(--discord-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --sal: var(--discord-safe-area-inset-left, env(safe-area-inset-left, 0px));
  --sar: var(--discord-safe-area-inset-right, env(safe-area-inset-right, 0px));
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #17181e; color: var(--ink); overflow: hidden; overscroll-behavior: none; }
body { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
button { font: inherit; color: inherit; }

/* the room */
.viewport { position: fixed; inset: 0; overflow: hidden; background: #1c1d26; }
.world { position: absolute; left: 50%; top: 50%; transform-origin: center center; overflow: visible; }
.group { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.group.hidden { display: none; }
.world img { position: absolute; max-width: none; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.fill { position: absolute; transition: background-color 0.9s ease; }
.bg { opacity: 0; transition: opacity 0.9s ease; }
.bg.on { opacity: 1; }
.prop, .glow, .shelf-item, .fx { opacity: 0; transition: opacity 0.55s ease; }
.prop.on, .glow.on, .shelf-item, .fx.on { opacity: 1; }
.shelf-item { transform: translate(-50%, -100%); }
.fx-zzz.on { animation: drift 3.2s ease-in-out infinite; }
.nap-art { left: 0; top: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 0.6s ease; }
.nap-art.on { opacity: 1; }
.plank { position: absolute; border-radius: 6px; background: #b8814e; box-shadow: 0 3px 0 #7d5232; opacity: 0; transition: opacity 0.4s; }
.plank.on { opacity: 1; }

/* Kit */
.kit { position: absolute; width: 0; height: 0; transition: opacity 0.45s ease; }
.kit.gone { opacity: 0; pointer-events: none; }
.kit-body { position: absolute; left: 0; bottom: 0; transform: translateX(-50%); transform-origin: 50% 100%; display: grid; margin: 0; padding: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; border-radius: 28px; }
.kit-body:focus-visible { outline: 4px solid var(--focus); outline-offset: 8px; }
.kit-body .pose { grid-area: 1 / 1; position: static; visibility: hidden; width: auto; }
.kit-body .pose.on { visibility: visible; }
.kit-body[data-pose="idle"], .kit-body[data-pose="ready"] { animation: breathe 4.4s ease-in-out infinite; }
.kit-body[data-pose="sleep"] { animation: breathe 6.5s ease-in-out infinite; }
.kit-body[data-pose="wave"], .kit-body[data-pose="pet"] { animation: hop 0.75s ease-out 2; }
.hearts { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.heart { position: absolute; opacity: 0; animation: floatup 1.55s ease-out forwards; transform-origin: 50% 100%; }

@keyframes breathe { 0%, 100% { transform: translateX(-50%) scale(1, 1); } 50% { transform: translateX(-50%) scale(1.012, 0.99); } }
@keyframes hop { 0% { transform: translateX(-50%) translateY(0); } 35% { transform: translateX(-50%) translateY(-3.5%) scale(1.02, 1.03); } 100% { transform: translateX(-50%) translateY(0); } }
@keyframes floatup { 0% { opacity: 0; transform: translateY(0) scale(0.6); } 18% { opacity: 1; } 100% { opacity: 0; transform: translateY(-130px) scale(1.05); } }
@keyframes drift { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes fadehold { 0% { opacity: 0; } 20%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* chrome */
.bar { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: calc(var(--sat) + 12px) calc(var(--sar) + 16px) 0 calc(var(--sal) + 16px); pointer-events: none; }
.bar > * { pointer-events: auto; }
.chip { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: 8px 16px; border-radius: 18px; background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.chip-title { font-weight: 800; font-size: 17px; letter-spacing: 0.01em; white-space: nowrap; }
.chip-sub:empty { display: none; }
.chip-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1em; }
.bar-actions { display: flex; align-items: center; gap: 10px; }
.btn { min-height: 44px; padding: 0 20px; border: 0; border-radius: 999px; font-weight: 800; font-size: 16px; cursor: pointer; background: var(--panel); color: var(--ink); -webkit-tap-highlight-color: transparent; }
.btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.btn-go { background: var(--go); color: var(--go-ink); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.28); }
.btn-go:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.28); }
.btn-icon { width: 44px; padding: 0; font-family: Georgia, "Times New Roman", serif; font-style: italic; font-size: 20px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.btn-quiet { background: rgba(255, 255, 255, 0.1); }
.btn[disabled] { opacity: 0.5; cursor: default; }

.note { position: fixed; z-index: 20; left: 50%; width: max-content; bottom: calc(var(--sab) + 20px); transform: translateX(-50%); margin: 0; max-width: min(92vw, 600px); padding: 10px 18px; border-radius: 18px; background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); color: var(--muted); font-size: 14.5px; line-height: 1.35; text-align: center; pointer-events: none; transition: opacity 0.3s; }
.note:empty { opacity: 0; }

.bubble { position: fixed; z-index: 25; transform: translateX(-50%); max-width: min(78vw, 360px); padding: 10px 18px; border: 3px solid #1d1b26; border-radius: 22px; background: #fffdf6; color: #1d1b26; font-weight: 800; font-size: 20px; line-height: 1.25; text-align: center; pointer-events: none; animation: pop 0.22s ease-out; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -13px; width: 18px; height: 18px; background: #fffdf6; border-right: 3px solid #1d1b26; border-bottom: 3px solid #1d1b26; transform: translateX(-50%) rotate(45deg); }
.bubble[hidden] { display: none; }
@keyframes pop { from { opacity: 0; transform: translateX(-50%) scale(0.85); } to { opacity: 1; transform: translateX(-50%) scale(1); } }

.screen { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: calc(var(--sat) + 16px) calc(var(--sar) + 16px) calc(var(--sab) + 16px) calc(var(--sal) + 16px); background: radial-gradient(ellipse at center, rgba(12, 12, 20, 0.35), rgba(12, 12, 20, 0.7)); }
.screen[hidden] { display: none; }
.panel { width: min(100%, 420px); padding: 26px 24px; border-radius: 24px; background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); text-align: center; }
.panel h1 { margin: 0 0 8px; font-size: 24px; line-height: 1.15; text-wrap: balance; }
.panel p { margin: 0 0 18px; font-size: 16px; line-height: 1.45; color: var(--muted); }
.panel p:last-child { margin-bottom: 0; }
.panel .btn { min-width: 150px; }
/* with the nap illustration the words sit in the art's own text zone */
.screen.zoned { display: block; background: none; padding: 0; }
.screen.zoned .panel { position: fixed; width: auto; padding: 0; background: none; backdrop-filter: none; -webkit-backdrop-filter: none; text-align: left; color: var(--zone-ink, #fff6e0); display: flex; flex-direction: column; justify-content: center; gap: 0.35em; }
.screen.zoned .panel h1 { margin: 0; text-wrap: balance; font-size: var(--zone-title, 34px); color: inherit; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.28); }
.screen.zoned .panel p { margin: 0 0 0.6em; font-size: var(--zone-text, 18px); color: inherit; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3); }
.screen.zoned .panel .btn { align-self: flex-start; }

.about { width: min(92vw, 460px); max-height: 86vh; overflow: auto; padding: 22px 22px 18px; border: 0; border-radius: 24px; background: var(--panel-solid); color: var(--ink); }
.about::backdrop { background: rgba(5, 5, 10, 0.6); }
.about h2 { margin: 0 0 10px; font-size: 22px; }
.about p { margin: 0 0 12px; font-size: 15.5px; line-height: 1.5; color: var(--muted); }
.about p strong { color: var(--ink); }
.about-actions { display: flex; justify-content: flex-end; margin-top: 14px; }
.trouble { margin-top: 4px; font-size: 14px; color: var(--muted); }
.trouble summary { cursor: pointer; padding: 6px 0; }
.trouble pre { margin: 8px 0 0; white-space: pre-wrap; font: 13px/1.4 ui-monospace, Menlo, Consolas, monospace; color: var(--ink); }

/* small windows (picture-in-picture, grid tiles): only Kit */
body.mini .bar, body.mini .note { display: none; }
body.mini .bubble { display: none; }

body[data-phase="loading"] .btn-go#hi, body[data-phase="nap"] #hi, body[data-phase="off"] #hi, body[data-phase="not_set_up"] #hi,
body[data-phase="error"] #hi, body[data-phase="denied"] #hi, body[data-phase="outside"] #hi { display: none; }
body[data-phase="outside"] .bar, body[data-phase="outside"] .note { display: none; }

@media (max-width: 520px) {
  .chip { padding: 7px 13px; }
  .chip-title { font-size: 16px; }
  .btn { padding: 0 16px; }
  .bubble { font-size: 18px; }
}
@media (max-width: 520px) and (max-height: 420px), (max-height: 380px) { .note { display: none; } }

/* stillness: the system asks for less motion, the phone is hot (body.calm), or a test wants a steady picture (body.still) */
@media (prefers-reduced-motion: reduce) {
  .kit-body, .fx-zzz.on, .bubble { animation: none !important; }
  .bg, .prop, .glow, .shelf-item, .fx, .nap-art, .kit { transition: none; }
  .heart { animation: fadehold 1.4s linear forwards; }
}
body.calm .kit-body, body.calm .fx-zzz.on, body.calm .bubble, body.still .kit-body, body.still .fx-zzz.on, body.still .bubble { animation: none !important; }
body.calm .heart { animation: fadehold 1.4s linear forwards; }
body.still .fill, body.still .bg, body.still .prop, body.still .glow, body.still .nap-art, body.still .kit, body.still .shelf-item { transition: none; }
body.still .heart { animation: none; opacity: 1; }
