/* Neko Companion. Mobile-first, sized for iPhone 13 Pro Max (428 x 926 pt) and safe areas. */
:root {
  --bg: #fbf5ec; --card: #ffffff; --ink: #3b2f36; --muted: #8d7b84; --line: #eadfd3;
  --accent: #e8668f; --accent-ink: #ffffff; --accent-soft: #fde4ec; --green: #6fbf5a;
  --her: #f0e6da; --her-ink: #3b2f36; --glass: rgba(255, 255, 255, .72); --glass-ink: #3b2f36;
  --shadow: 0 6px 24px rgba(80, 50, 60, .14);
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --tabs-h: 58px;
  --font: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --hand: "Bradley Hand", "Noteworthy", "Segoe Print", "Comic Sans MS", cursive;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #17131c; --card: #231c2a; --ink: #f3eaef; --muted: #a798ab; --line: #342b3c;
  --accent: #f07a9f; --accent-soft: #3a2533; --her: #2d2535; --her-ink: #f3eaef;
  --glass: rgba(30, 24, 38, .72); --glass-ink: #f3eaef; --shadow: 0 6px 24px rgba(0, 0, 0, .4);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Sizing. An installed iPhone web app that draws under the status bar gets a layout viewport that is
   shorter than the screen by the height of the status bar. Anything position:fixed is clipped to that
   shorter box, which is the dark strip at the bottom. So nothing here is fixed: the page itself is made
   as tall as the display (--app-h, set in shell.js) and #app is laid out inside it. */
html { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--bg); }
body { margin: 0; position: relative; height: var(--app-h, 100%); min-height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--bg); }
:root[data-tall] { min-height: calc(100% + env(safe-area-inset-top, 0px)); }
body { font: 16px/1.4 var(--font); color: var(--ink); -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
.muted { color: var(--muted); }

/* --app-h is set by the app (Settings > Screen fit) because an installed iOS app can report a window
   that is shorter than the display, which leaves a strip at the bottom. */
#app { position: absolute; top: 0; left: 0; width: 100%; height: calc(var(--app-h, 100%) + var(--app-nudge, 0px)); overflow: hidden; }
:root { --sab: calc(env(safe-area-inset-bottom, 0px) * 0.62); }      /* 'normal': a little lower than the full inset, like a native tab bar's labels */
:root[data-bar="high"] { --sab: env(safe-area-inset-bottom, 0px); }
:root[data-bar="compact"] { --sab: calc(env(safe-area-inset-bottom, 0px) * 0.3); }
:root[data-bar="flush"] { --sab: 0px; }
#sky { position: absolute; inset: 0; background: linear-gradient(var(--sky-top, #bfe3ff), var(--sky-bottom, #fdf3e3)); transition: opacity .6s; }
#sky .stars { position: absolute; inset: 0; opacity: var(--stars, 0); transition: opacity 1s;
  background-image: radial-gradient(1.5px 1.5px at 12% 14%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 28% 30%, #fff 50%, transparent 51%), radial-gradient(1.5px 1.5px at 44% 9%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 62% 22%, #fff 50%, transparent 51%), radial-gradient(2px 2px at 78% 12%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 88% 34%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 8% 40%, #fff 50%, transparent 51%), radial-gradient(1.5px 1.5px at 53% 38%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 35% 48%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 70% 46%, #fff 50%, transparent 51%), radial-gradient(1.5px 1.5px at 20% 6%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 94% 6%, #fff 50%, transparent 51%); }
#sky .orb { position: absolute; width: 64px; height: 64px; left: var(--orb-x, 70%); top: var(--orb-y, 12%); border-radius: 50%; background: var(--orb, #fff6c8); box-shadow: 0 0 50px 14px var(--orb-glow, rgba(255, 240, 170, .55)); image-rendering: pixelated; transition: top 2s, left 2s; }
#sky .haze { position: absolute; left: 0; right: 0; bottom: 0; height: 45%; background: linear-gradient(transparent, var(--haze, rgba(255, 255, 255, .35))); }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#hearts { position: absolute; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.heart { position: absolute; width: 22px; height: 22px; margin: -11px; background: var(--accent); -webkit-mask: var(--i-heart) center/contain no-repeat; mask: var(--i-heart) center/contain no-repeat; animation: floatUp 1.1s ease-out forwards; }
.heart.big { width: 34px; height: 34px; margin: -17px; }
@keyframes floatUp { 0% { transform: translate(0, 0) scale(.3) rotate(var(--r, 0deg)); opacity: 0; } 15% { opacity: 1; transform: translate(0, -8px) scale(1) rotate(var(--r, 0deg)); } 100% { transform: translate(var(--dx, 0), -110px) scale(.8) rotate(var(--r, 0deg)); opacity: 0; } }
.plus { position: absolute; font-weight: 800; font-size: 15px; color: var(--accent); text-shadow: 0 1px 0 #fff, 0 0 8px #fff; animation: floatUp 1.3s ease-out forwards; white-space: nowrap; transform-origin: center; }

/* ---- screens ---------------------------------------------------------- */
.screen { position: absolute; inset: 0; z-index: 10; display: flex; flex-direction: column; padding: var(--sat) var(--sar) calc(var(--tabs-h) + var(--sab)) var(--sal); pointer-events: none; }
.screen > * { pointer-events: auto; }
.screen.solid { background: var(--bg); pointer-events: auto; }
.screen, .overlay { animation: fadeIn .22s ease-out; }
/* ---- moving around ----------------------------------------------------- */
.screen.from-right { animation: slideFromRight .34s cubic-bezier(.2, .9, .25, 1); }
.screen.from-left { animation: slideFromLeft .34s cubic-bezier(.2, .9, .25, 1); }
@keyframes slideFromRight { from { transform: translateX(28%); opacity: 0; } }
@keyframes slideFromLeft { from { transform: translateX(-28%); opacity: 0; } }
#home.arrive .hud { animation: dropIn .42s cubic-bezier(.2, 1.2, .3, 1) backwards; }
#home.arrive .actions button { animation: riseIn .4s cubic-bezier(.2, 1.3, .3, 1) backwards; }
#home.arrive .actions button:nth-child(2) { animation-delay: .04s; } #home.arrive .actions button:nth-child(3) { animation-delay: .08s; }
#home.arrive .actions button:nth-child(4) { animation-delay: .12s; } #home.arrive .actions button:nth-child(5) { animation-delay: .16s; }
#home.arrive .hud-side > * { animation: riseIn .4s cubic-bezier(.2, 1.3, .3, 1) backwards; animation-delay: .1s; }
@keyframes dropIn { from { transform: translateY(-40px); opacity: 0; } }
@keyframes riseIn { from { transform: translateY(26px) scale(.9); opacity: 0; } }
.settings-body > *, .letters-grid > * { animation: riseIn .36s cubic-bezier(.2, 1, .3, 1) backwards; }
.settings-body > *:nth-child(n+3) { animation-delay: .04s; } .settings-body > *:nth-child(n+5) { animation-delay: .08s; } .settings-body > *:nth-child(n+7) { animation-delay: .12s; }
.letters-grid > *:nth-child(2) { animation-delay: .04s; } .letters-grid > *:nth-child(3) { animation-delay: .08s; } .letters-grid > *:nth-child(4) { animation-delay: .12s; } .letters-grid > *:nth-child(n+5) { animation-delay: .16s; }
/* the paw wipe used for bigger changes of scene */
#wipe { position: absolute; inset: 0; z-index: 96; pointer-events: none; display: grid; place-items: center; background: radial-gradient(circle at 50% 45%, #f7a0bb, var(--accent)); clip-path: circle(0% at var(--wx, 50%) var(--wy, 60%)); }
#wipe.cover { animation: wipeIn .3s cubic-bezier(.5, 0, .3, 1) forwards; pointer-events: auto; }
#wipe.reveal { animation: wipeOut .38s cubic-bezier(.5, 0, .3, 1) forwards; }
@keyframes wipeIn { from { clip-path: circle(0% at var(--wx, 50%) var(--wy, 60%)); } to { clip-path: circle(150% at var(--wx, 50%) var(--wy, 60%)); } }
@keyframes wipeOut { from { clip-path: circle(150% at 50% 42%); } to { clip-path: circle(0% at 50% 42%); } }
#wipe i { width: 74px; height: 74px; background: #fff; border-radius: 50% 50% 46% 46%; box-shadow: -40px -36px 0 -22px #fff, 40px -36px 0 -22px #fff, -16px -54px 0 -21px #fff, 16px -54px 0 -21px #fff; margin-top: 50px; opacity: .92; }
#wipe.cover i { animation: pawPop .3s cubic-bezier(.2, 1.4, .4, 1) .08s backwards; }
@keyframes pawPop { from { transform: scale(.3) rotate(-18deg); opacity: 0; } }
:root[data-motion="off"] .screen, :root[data-motion="off"] .screen *, :root[data-motion="off"] #wipe, :root[data-motion="off"] #wipe * { animation-duration: .01s !important; animation-delay: 0s !important; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---- home ------------------------------------------------------------- */
#home { justify-content: space-between; }
.hud { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px 0; }
.hud-main { flex: 1; min-width: 0; background: var(--glass); color: var(--glass-ink); -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3); border-radius: 20px; padding: 10px 14px; box-shadow: var(--shadow); }
.hud-name { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; letter-spacing: .01em; }
.hud-name > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.love { display: flex; align-items: center; gap: 7px; margin-top: 6px; font-size: 13px; font-weight: 700; }
.love-heart { width: 16px; height: 16px; fill: var(--accent); flex: none; }
.love .bar { flex: 1; height: 8px; background: rgba(120, 90, 100, .16); border-radius: 99px; overflow: hidden; }
.love .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #f7a0bb, var(--accent)); border-radius: 99px; transition: width .5s cubic-bezier(.2, .9, .3, 1.2); }
.streak { background: var(--glass); color: var(--glass-ink); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); padding: 9px 12px; font-size: 15px; box-shadow: var(--shadow); min-height: 44px; }
.flame { width: 14px; height: 18px; background: linear-gradient(#ffb347, #ff6a3d); -webkit-mask: var(--i-flame) center/contain no-repeat; mask: var(--i-flame) center/contain no-repeat; }

.bubble { align-self: center; max-width: min(82%, 340px); background: var(--card); color: var(--ink); padding: 11px 15px; border-radius: 18px; box-shadow: var(--shadow); font-size: 16px; line-height: 1.35; text-align: center; position: relative; animation: pop .28s cubic-bezier(.2, 1.3, .4, 1); pointer-events: none; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -7px; width: 16px; height: 16px; margin-left: -8px; background: inherit; transform: rotate(45deg); border-radius: 3px; }
#home-bubble { position: absolute; left: 50%; top: calc(var(--sat) + 96px); transform: translateX(-50%); width: max-content; }
#home-bubble.out, .call-bubble.out { animation: fadeOut .3s forwards; }
@keyframes pop { from { opacity: 0; scale: .8; } to { opacity: 1; scale: 1; } }
@keyframes fadeOut { to { opacity: 0; } }
.pat-hint { position: absolute; left: 50%; bottom: calc(var(--tabs-h) + var(--sab) + 104px); transform: translateX(-50%); font-size: 13px; font-weight: 700; color: var(--glass-ink); background: var(--glass); padding: 6px 12px; border-radius: 99px; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); transition: opacity .5s; pointer-events: none; white-space: nowrap; }
.pat-hint.gone { opacity: 0; }

.actions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; padding: 0 12px 12px; }
.actions button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 2px 8px; min-height: 64px; min-width: 0; border-radius: 18px; background: var(--glass); color: var(--glass-ink); -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3); box-shadow: var(--shadow); font-size: 12.5px; font-weight: 700; transition: transform .12s; }
.actions button:active, .tabs button:active, .btn:active, .round:active { transform: scale(.94); }
.hud-side { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.round-chip { width: 44px; height: 44px; padding: 0; justify-content: center; }
.round-chip .ico { width: 22px; height: 22px; }
.work-bar { display: flex; align-items: center; gap: 10px; margin: 0 12px 12px; padding: 10px 12px; border-radius: 20px; background: var(--glass); color: var(--glass-ink); -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3); box-shadow: var(--shadow); }
.work-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.work-info b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.work-info span { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.work-bar .seg button { padding: 6px 9px; font-size: 13px; }
.work-bar .btn { min-height: 42px; padding: 0 16px; font-size: 15px; }
#home.working .actions, #home.working .pat-hint { display: none; }
#boop { position: absolute; inset: 0; pointer-events: none; z-index: 31; overflow: hidden; }
.boop-ring { position: absolute; width: 90px; height: 90px; margin: -45px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .9); box-shadow: 0 0 0 2px rgba(232, 102, 143, .5); animation: boopRing .6s ease-out forwards; }
.boop-ring.two { animation-delay: .12s; opacity: 0; }
.boop-print { position: absolute; width: 64px; height: 64px; margin: -32px; border-radius: 50%; background: radial-gradient(rgba(255, 255, 255, .5), rgba(255, 255, 255, .12) 60%, transparent 70%); animation: boopPrint 1.8s ease-out forwards; }
@keyframes boopRing { from { transform: scale(.2); opacity: 1; } to { transform: scale(2.2); opacity: 0; } }
@keyframes boopPrint { 0% { opacity: 0; transform: scale(.6); } 10% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.1); } }
#stage.bump { animation: bump .28s ease-out; }
@keyframes bump { 30% { transform: scale(1.025); } }
.scenes { display: grid; gap: 10px; margin-top: 14px; }
.scenes button { display: flex; align-items: center; gap: 14px; padding: 10px; border-radius: 16px; background: var(--card); border: 2.5px solid transparent; text-align: left; }
.scenes button.on { border-color: var(--accent); }
.scenes i { width: 84px; height: 60px; border-radius: 10px; flex: none; }
.scenes b { display: block; font-size: 17px; } .scenes small { color: var(--muted); }
.sw-room { background: linear-gradient(#f3e3d3 0 62%, #c79a66 62%); box-shadow: inset 18px 12px 0 -8px #bfe3ff, inset 0 0 0 0 #000; }
.sw-garden { background: linear-gradient(#bfe3ff 0 40%, #fffaf2 40% 62%, #79c05a 62%); }
.sw-meadow { background: linear-gradient(#bfe3ff 0 62%, #79c05a 62%); }
.actions small { position: absolute; top: 6px; right: 10px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; line-height: 18px; text-align: center; padding: 0 4px; }
.actions small.zero { background: var(--muted); }

/* icons: one-colour masks so they follow the text colour */
.ico { display: inline-block; width: 24px; height: 24px; background: currentColor; -webkit-mask: var(--i) center/contain no-repeat; mask: var(--i) center/contain no-repeat; flex: none; }
:root {
  --i-heart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21.3l-1.4-1.3C5.4 15.4 2 12.3 2 8.5 2 5.4 4.4 3 7.5 3c1.7 0 3.4.8 4.5 2.1C13.1 3.8 14.8 3 16.5 3 19.6 3 22 5.4 22 8.5c0 3.8-3.4 6.9-8.6 11.5L12 21.3z'/%3E%3C/svg%3E");
  --i-flame: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 18'%3E%3Cpath d='M7 0c1 3 5 5 5 10a5 5 0 01-10 0c0-2 1-3 2-4 0 2 1 3 2 3 0-3-1-5 1-9z'/%3E%3C/svg%3E");
}
.ico-home { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 11.5L12 4l9 7.5V20a1 1 0 01-1 1h-5v-6H9v6H4a1 1 0 01-1-1z'/%3E%3C/svg%3E"); }
.ico-chat { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3c5.5 0 10 3.8 10 8.5S17.5 20 12 20c-1.2 0-2.4-.2-3.5-.5L4 21.5l1.3-3.9C3.3 16 2 13.9 2 11.5 2 6.8 6.5 3 12 3z'/%3E%3C/svg%3E"); }
.ico-letter { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 5h18a1 1 0 011 1v.6l-10 6.6L2 6.6V6a1 1 0 011-1zm-1 4l10 6.6L22 9v9a1 1 0 01-1 1H3a1 1 0 01-1-1z'/%3E%3C/svg%3E"); }
.ico-gear { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M10.3 2h3.4l.5 2.6 1.7.7 2.2-1.5 2.4 2.4-1.5 2.2.7 1.7 2.6.5v3.4l-2.6.5-.7 1.7 1.5 2.2-2.4 2.4-2.2-1.5-1.7.7-.5 2.6h-3.4l-.5-2.6-1.7-.7-2.2 1.5-2.4-2.4 1.5-2.2-.7-1.7L2 13.7v-3.4l2.6-.5.7-1.7-1.5-2.2 2.4-2.4 2.2 1.5 1.7-.7zM12 8.5a3.5 3.5 0 100 7 3.5 3.5 0 000-7z'/%3E%3C/svg%3E"); }
.ico-call { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 6.5A2.5 2.5 0 015.5 4h8A2.5 2.5 0 0116 6.5v2.7l4.4-2.9a1 1 0 011.6.8v9.8a1 1 0 01-1.6.8L16 14.8v2.7a2.5 2.5 0 01-2.5 2.5h-8A2.5 2.5 0 013 17.5z'/%3E%3C/svg%3E"); }
.ico-hang { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 8c-4 0-7.6 1.3-10.3 3.5a1.5 1.5 0 00-.2 2.1l1.7 2.2a1.5 1.5 0 001.9.4l3-1.6a1.5 1.5 0 00.8-1.3v-1.8a11 11 0 016.2 0v1.8c0 .5.3 1 .8 1.3l3 1.6a1.5 1.5 0 001.9-.4l1.7-2.2a1.5 1.5 0 00-.2-2.1C19.6 9.3 16 8 12 8z'/%3E%3C/svg%3E"); }
.ico-moon { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20.5 14.5A8.5 8.5 0 019.5 3.5a.6.6 0 00-.8-.7A10 10 0 1021.2 15.3a.6.6 0 00-.7-.8z'/%3E%3C/svg%3E"); }
.ico-cookie { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1010 10 4 4 0 01-4-4 4 4 0 01-4-4 4 4 0 01-2-2zM8 8.5a1.5 1.5 0 110 3 1.5 1.5 0 010-3zm5 5a1.5 1.5 0 110 3 1.5 1.5 0 010-3zm-6 2a1 1 0 110 2 1 1 0 010-2zm10-1a1 1 0 110 2 1 1 0 010-2z'/%3E%3C/svg%3E"); }
.ico-outfit { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8.5 3l3.5 2 3.5-2L21 6l-2 4-2-1v11a1 1 0 01-1 1H8a1 1 0 01-1-1V9l-2 1-2-4z'/%3E%3C/svg%3E"); }
.ico-sound { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 9.5h3.5L12 5v14l-5.5-4.5H3zM15 8.5a5 5 0 010 7l-1.2-1.2a3.3 3.3 0 000-4.6zm2.6-2.6a8.6 8.6 0 010 12.2l-1.2-1.2a6.9 6.9 0 000-9.8z'/%3E%3C/svg%3E"); }
.ico-desk { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 4h14a1 1 0 011 1v9a1 1 0 01-1 1H5a1 1 0 01-1-1V5a1 1 0 011-1zm-3 13h20v1.5a1.5 1.5 0 01-1.5 1.5h-17A1.5 1.5 0 012 18.5z'/%3E%3C/svg%3E"); }
.ico-scene { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M4 4h16a2 2 0 012 2v12a2 2 0 01-2 2H4a2 2 0 01-2-2V6a2 2 0 012-2zm0 13.5V18h16v-2.5l-4.500-5-4 4.500-2.500-2.500zM8 7a2 2 0 100 4 2 2 0 000-4z'/%3E%3C/svg%3E"); }
.ico-spark { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l2.2 6.3L20.500 10.500l-6.300 2.200L12 19l-2.200-6.300L3.500 10.500l6.300-2.200zM19 16l.9 2.100L22 19l-2.100.9L19 22l-.9-2.100L16 19l2.100-.9z'/%3E%3C/svg%3E"); }
.ico-cam { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M9 4h6l1.5 2H20a2 2 0 012 2v10a2 2 0 01-2 2H4a2 2 0 01-2-2V8a2 2 0 012-2h3.5zm3 4.5a4.5 4.5 0 100 9 4.5 4.5 0 000-9z'/%3E%3C/svg%3E"); }

/* ---- tab bar ----------------------------------------------------------- */
.tabs { position: absolute; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr); height: calc(var(--tabs-h) + var(--sab)); padding: 0 var(--sar) var(--sab) var(--sal); background: var(--glass); -webkit-backdrop-filter: blur(20px) saturate(1.4); backdrop-filter: blur(20px) saturate(1.4); border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.tabs::before { content: ""; position: absolute; top: 5px; left: var(--sal); width: calc((100% - var(--sal) - var(--sar)) / 4); height: calc(var(--tabs-h) - 10px); border-radius: 16px; background: var(--accent-soft); opacity: .7; transform: translateX(calc(var(--tab-i, 0) * 100%)) scaleX(.72); transition: transform .38s cubic-bezier(.3, 1.3, .4, 1); }
.tabs button.on .ico { animation: tabPop .4s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes tabPop { 0% { transform: scale(.7) translateY(4px); } 60% { transform: scale(1.18) translateY(-3px); } }
.tabs button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 700; color: var(--muted); transition: transform .12s, color .15s; }
.tabs button.on { color: var(--accent); }
.badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font: 700 11px/18px var(--font); font-style: normal; text-align: center; }
#app[data-screen="call"] .tabs, #app[data-screen="sleep"] .tabs, #app[data-screen="game"] .tabs, #app[data-kb] .tabs { display: none; }
#app[data-kb] .screen { padding-bottom: 0; }

/* ---- top bars ----------------------------------------------------------- */
.bar-top { display: flex; align-items: center; gap: 10px; padding: 8px 14px 10px; border-bottom: 1px solid var(--line); background: var(--bg); flex: none; }
.bar-top.plain { border: 0; padding: 14px 18px 6px; justify-content: space-between; }
.bar-top h1 { font-size: 28px; font-weight: 800; letter-spacing: -.01em; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(#ffe3ee, #fff6e0); object-fit: cover; image-rendering: pixelated; flex: none; }
.avatar.big { width: 124px; height: 124px; box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
.who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.who b { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who small { color: var(--muted); font-size: 12.5px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--accent); }
.seg { display: inline-flex; background: color-mix(in srgb, var(--line) 70%, transparent); border-radius: 12px; padding: 3px; gap: 2px; }
.seg.wrap { display: flex; flex-wrap: wrap; }
.seg button { padding: 7px 12px; min-height: 36px; border-radius: 9px; font-size: 14px; font-weight: 700; color: var(--muted); flex: 1; white-space: nowrap; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .1); }

/* ---- chat --------------------------------------------------------------- */
.thread { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 12px 12px 6px; display: flex; flex-direction: column; gap: 3px; }
.day { align-self: center; font-size: 12px; font-weight: 700; color: var(--muted); margin: 12px 0 6px; }
.day b { color: var(--ink); font-weight: 700; }
.msg { max-width: 78%; padding: 8px 13px; border-radius: 19px; font-size: 16.5px; line-height: 1.32; white-space: pre-wrap; overflow-wrap: anywhere; -webkit-user-select: text; user-select: text; }
.msg.her { align-self: flex-start; background: var(--her); color: var(--her-ink); border-bottom-left-radius: 6px; }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.msg.her + .msg.me, .msg.me + .msg.her { margin-top: 7px; }
.msg.new { animation: msgIn .26s cubic-bezier(.2, 1.2, .4, 1); transform-origin: bottom left; }
.msg.me.new { transform-origin: bottom right; }
@keyframes msgIn { from { opacity: 0; scale: .7; translate: 0 10px; } to { opacity: 1; scale: 1; translate: 0 0; } }
.msg.sys { align-self: center; background: none; color: var(--muted); font-size: 13px; font-weight: 700; padding: 4px 8px; }
.msg .act { display: block; margin-top: 6px; padding: 7px 12px; border-radius: 12px; background: var(--card); color: var(--accent); font-weight: 800; font-size: 14.5px; text-align: center; }
.stamp { align-self: flex-start; font-size: 11px; color: var(--muted); margin: 1px 6px 4px; }
.stamp.me { align-self: flex-end; }
.typing { align-self: flex-start; background: var(--her); border-radius: 19px; border-bottom-left-radius: 6px; padding: 13px 15px; display: flex; gap: 4px; margin-top: 4px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: dot 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { opacity: .35; translate: 0 0; } 30% { opacity: 1; translate: 0 -3px; } }
.quick { display: flex; gap: 8px; padding: 4px 12px 6px; overflow-x: auto; scrollbar-width: none; flex: none; }
.quick::-webkit-scrollbar { display: none; }
.quick:empty { display: none; }
.quick button { flex: none; padding: 8px 14px; min-height: 38px; border-radius: 99px; border: 1.5px solid var(--accent); color: var(--accent); font-weight: 700; font-size: 15px; background: var(--bg); animation: pop .25s backwards; }
.quick button:active { background: var(--accent-soft); }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 6px 12px 10px; flex: none; }
.composer textarea { flex: 1; resize: none; border: 1.5px solid var(--line); background: var(--card); border-radius: 21px; padding: 9px 15px; font-size: 16.5px; line-height: 1.3; max-height: 120px; outline: none; -webkit-user-select: text; user-select: text; }
.composer textarea:focus { border-color: var(--accent); }
.send { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; transition: opacity .15s, transform .12s; }
.send svg { width: 22px; height: 22px; }
.send:disabled { opacity: .35; }

/* ---- letters -------------------------------------------------------------- */
.letters-grid { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 10px 16px 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-content: start; }
.env { position: relative; aspect-ratio: 4 / 3; border-radius: 10px; background: #fffaf2; color: #5a4640; box-shadow: var(--shadow); padding: 30px 12px 10px; display: flex; flex-direction: column; justify-content: flex-end; text-align: left; overflow: hidden; border: 1px solid #eadcc9; }
.env::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 52%; background: linear-gradient(to bottom right, #f6ead9 49.5%, transparent 50.5%), linear-gradient(to bottom left, #f6ead9 49.5%, transparent 50.5%); background-size: 50.5% 100%; background-position: left, right; background-repeat: no-repeat; opacity: .9; }
.env::after { content: ""; position: absolute; left: 50%; top: 40%; width: 26px; height: 26px; margin: -13px; background: var(--accent); -webkit-mask: var(--i-heart) center/contain no-repeat; mask: var(--i-heart) center/contain no-repeat; }
.env.read::after { opacity: .3; }
.env b { position: relative; font: 700 17px/1.15 var(--hand); }
.env small { position: relative; font-size: 11.5px; color: #9a8478; margin-top: 3px; }
.env .new { position: absolute; top: 8px; right: 8px; background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 800; padding: 2px 7px; border-radius: 99px; z-index: 1; }
.env .kept { position: absolute; top: 8px; left: 8px; width: 16px; height: 16px; background: #e0a437; clip-path: polygon(50% 0, 62% 35%, 100% 38%, 70% 60%, 80% 100%, 50% 76%, 20% 100%, 30% 60%, 0 38%, 38% 35%); z-index: 1; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 60px 30px; font-size: 16px; }
.empty b { display: block; color: var(--ink); font-size: 19px; margin-bottom: 6px; }

.reader { position: absolute; inset: 0; z-index: 60; background: rgba(30, 20, 25, .55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); display: flex; flex-direction: column; padding: calc(var(--sat) + 14px) 18px calc(var(--sab) + 14px); animation: fadeIn .25s; }
.paper { flex: 1; min-height: 0; background: #fffaf0 repeating-linear-gradient(transparent 0 33px, #eadfcd 33px 34px); background-position: 0 26px; color: #4a3a3a; border-radius: 6px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); padding: 30px 26px 20px; font: 23px/34px var(--hand); white-space: pre-wrap; overflow-y: auto; -webkit-overflow-scrolling: touch; animation: paperIn .4s cubic-bezier(.2, 1, .3, 1); position: relative; }
@keyframes paperIn { from { translate: 0 40px; opacity: 0; rotate: 1.5deg; } }
.paper h3 { margin: 0 0 34px; font: 700 28px/34px var(--hand); color: var(--accent); }
.paper .pg { transition: opacity .2s; }
.reader-bar { display: flex; align-items: center; gap: 10px; padding-top: 12px; color: #fff; }
.reader-bar .dots { flex: 1; display: flex; gap: 6px; justify-content: center; }
.reader-bar .dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, .4); }
.reader-bar .dots i.on { background: #fff; }
.reader-bar button { min-width: 78px; min-height: 44px; padding: 0 14px; border-radius: 99px; background: rgba(255, 255, 255, .18); color: #fff; font-weight: 700; font-size: 15px; }
.reader-bar button.keep.on { background: #e0a437; }

/* ---- settings --------------------------------------------------------------- */
.settings-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 16px 30px; }
.group { background: var(--card); border-radius: 16px; margin: 0 0 18px; overflow: hidden; box-shadow: 0 1px 0 var(--line); }
.group-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 6px 7px; }
.group-note { font-size: 13px; color: var(--muted); margin: -10px 8px 18px; line-height: 1.4; }
.row { display: flex; align-items: center; gap: 10px; text-align: left; min-height: 50px; padding: 8px 14px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row > label, .row > .t { flex: 1; min-width: 0; font-weight: 600; }
.row .t small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; line-height: 1.3; }
.row input[type=text], .row input[type=url], .row input[type=date] { border: 0; background: none; text-align: right; outline: none; min-width: 0; flex: 1.3; -webkit-user-select: text; user-select: text; color: var(--accent); font-weight: 700; }
.row input[type=time], .row select { border: 0; background: color-mix(in srgb, var(--line) 60%, transparent); border-radius: 9px; padding: 6px 9px; font-weight: 700; outline: none; max-width: 150px; }
.row input[type=range] { flex: 1.1; min-width: 0; max-width: 170px; accent-color: var(--accent); height: 30px; }
.sw { position: relative; width: 51px; height: 31px; flex: none; }
.sw input { position: absolute; inset: 0; opacity: 0; margin: 0; width: 100%; height: 100%; }
.sw i { position: absolute; inset: 0; border-radius: 99px; background: color-mix(in srgb, var(--muted) 35%, transparent); transition: background .2s; pointer-events: none; }
.sw i::after { content: ""; position: absolute; left: 2px; top: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .25); transition: translate .2s; }
.sw input:checked + i { background: var(--green); }
.sw input:checked + i::after { translate: 20px 0; }
.sub { padding: 2px 14px 10px 14px; display: grid; gap: 8px; background: color-mix(in srgb, var(--line) 25%, transparent); border-top: 1px solid var(--line); }
.sub .f { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 15px; min-height: 40px; }
.sub .f:first-child { padding-top: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 20px; border-radius: 15px; font-weight: 800; font-size: 16px; transition: transform .12s; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: color-mix(in srgb, var(--line) 70%, transparent); color: var(--ink); }
.btn.danger { color: #d6453d; background: color-mix(in srgb, #d6453d 12%, transparent); }
.btn.dim { background: rgba(255, 255, 255, .07); color: #9c8672; }
.btn.block { display: flex; width: 100%; }
.row-btns { display: flex; gap: 10px; margin-top: 16px; }
.row-btns .btn { flex: 1; }
.outfit-row { display: flex; align-items: center; gap: 12px; }
.outfit-row img { width: 46px; height: 46px; border-radius: 12px; background: linear-gradient(#ffe3ee, #fff6e0); image-rendering: pixelated; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); }
.stats div { background: var(--card); padding: 12px 6px; text-align: center; }
.stats b { display: block; font-size: 21px; font-weight: 800; color: var(--accent); }
.stats small { color: var(--muted); font-size: 12px; }
.about { text-align: center; color: var(--muted); font-size: 12.5px; padding: 6px 20px 0; line-height: 1.5; }

/* ---- sheet ------------------------------------------------------------------- */
.sheet { position: absolute; inset: 0; z-index: 50; display: flex; flex-direction: column; justify-content: flex-end; }
.sheet-back { position: absolute; inset: 0; background: rgba(20, 12, 18, .35); animation: fadeIn .2s; }
.sheet-card { position: relative; background: var(--bg); color: var(--ink); border-radius: 26px 26px 0 0; padding: 20px 18px calc(var(--sab) + 18px); box-shadow: 0 -10px 40px rgba(0, 0, 0, .2); animation: sheetUp .32s cubic-bezier(.2, 1, .3, 1); max-height: 82%; overflow-y: auto; -webkit-overflow-scrolling: touch; }
@keyframes sheetUp { from { translate: 0 100%; } }
.sheet-card h2 { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.lbl { display: block; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 2px 7px; }
.lbl .hint { text-transform: none; letter-spacing: 0; font-weight: 600; opacity: .8; }
.sleep-setup .row-check { margin-top: 10px; }
.row-check { display: flex; align-items: center; gap: 10px; margin-top: 16px; font-weight: 600; min-height: 44px; }
.row-check input { width: 22px; height: 22px; accent-color: var(--accent); }
.outfits { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.outfits button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 9px; border-radius: 16px; background: var(--card); border: 2.5px solid transparent; font-size: 13px; font-weight: 700; line-height: 1.15; }
.outfits button.on { border-color: var(--accent); }
.outfits img { width: 76px; height: 76px; image-rendering: pixelated; border-radius: 12px; }
.more-toggle { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 46px; margin-top: 14px; border-radius: 14px; background: color-mix(in srgb, var(--line) 70%, transparent); font-weight: 800; font-size: 15px; }
.more-toggle span { min-width: 22px; padding: 1px 7px; border-radius: 99px; background: var(--card); color: var(--muted); font-size: 12.5px; }
.more-toggle::after { content: ""; width: 8px; height: 8px; border-right: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor; rotate: 45deg; translate: 0 -2px; transition: rotate .2s, translate .2s; }
.more-toggle[aria-expanded="true"]::after { rotate: 225deg; translate: 0 3px; }
.outfits small { font-weight: 500; color: var(--muted); font-size: 11px; }

/* ---- call ----------------------------------------------------------------------- */
.overlay { position: absolute; inset: 0; z-index: 40; }
.call-ring { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; align-items: center; padding: calc(var(--sat) + 70px) 30px calc(var(--sab) + 54px); background: linear-gradient(160deg, rgba(60, 34, 60, .86), rgba(22, 16, 34, .94)); -webkit-backdrop-filter: blur(22px); backdrop-filter: blur(22px); color: #fff; }
.ring-top { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.ring-top h2 { font-size: 34px; font-weight: 800; }
.ring-top p { opacity: .75; font-size: 18px; }
.ring-top .avatar { animation: ringPulse 1.6s ease-out infinite; }
@keyframes ringPulse { 0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .45), 0 10px 40px rgba(0, 0, 0, .3); } 100% { box-shadow: 0 0 0 34px rgba(255, 255, 255, 0), 0 10px 40px rgba(0, 0, 0, .3); } }
.ring-actions { display: flex; justify-content: space-evenly; width: 100%; max-width: 300px; }
.round { display: flex; flex-direction: column; align-items: center; gap: 7px; color: #fff; font-size: 13px; font-weight: 700; transition: transform .12s; }
.round .ico { width: 68px; height: 68px; border-radius: 50%; -webkit-mask-size: 32px; mask-size: 32px; background: #fff; }
.round::before { content: ""; position: absolute; }
.round { position: relative; }
.round .ico { position: relative; z-index: 1; }
.round small { font-size: 13px; opacity: .9; }
.round.accept, .round.decline, .round.ghost { --c: #34c759; }
.round.decline { --c: #ff3b30; }
.round.ghost { --c: rgba(255, 255, 255, .22); }
.round::after { content: ""; position: absolute; top: 0; left: 50%; width: 68px; height: 68px; margin-left: -34px; border-radius: 50%; background: var(--c); }
.round.ghost[aria-pressed="true"]::after { background: #fff; }
.round.ghost[aria-pressed="true"] .ico { background: #222; }
.round.accept .ico { animation: wiggle 1s infinite; }
@keyframes wiggle { 0%, 60%, 100% { rotate: 0deg; } 10%, 30%, 50% { rotate: -12deg; } 20%, 40% { rotate: 12deg; } }
.call-live { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; padding: calc(var(--sat) + 10px) 16px calc(var(--sab) + 22px); pointer-events: none; }
.call-live > * { pointer-events: auto; }
.call-top { position: absolute; top: calc(var(--sat) + 10px); left: 16px; display: flex; flex-direction: column; background: rgba(20, 14, 26, .45); color: #fff; padding: 8px 14px; border-radius: 16px; -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); pointer-events: none; }
.call-top b { font-size: 18px; } .call-top span { font-size: 13.5px; opacity: .85; font-variant-numeric: tabular-nums; }
#selfview { position: absolute; top: calc(var(--sat) + 10px); right: 14px; width: 104px; height: 150px; object-fit: cover; border-radius: 16px; background: #222; box-shadow: 0 6px 24px rgba(0, 0, 0, .35); transform: scaleX(-1); border: 2px solid rgba(255, 255, 255, .5); }
#call-zoom { position: absolute; right: 14px; top: calc(var(--sat) + 10px); background: rgba(20, 14, 26, .45); color: #fff; }
#call-live.has-self #call-zoom { top: calc(var(--sat) + 172px); }
.round-chip b { font-size: 14px; font-weight: 800; }
#tv { position: absolute; background: #000; overflow: hidden; }
#tv iframe { width: 100%; height: 100%; border: 0; display: block; }
#app.tv-on #stage { pointer-events: none; }      /* taps go through to the video behind the canvas */
#app.tv-on #call { pointer-events: none; }
#app.tv-on #call .call-live > * { pointer-events: auto; }
#tv-pat { position: absolute; border-radius: 50%; }
.watch-bar { display: flex; gap: 8px; justify-content: center; margin-bottom: 10px; }
.watch-bar button { padding: 7px 14px; min-height: 36px; border-radius: 99px; background: rgba(20, 14, 26, .55); color: #fff; font-size: 13.5px; font-weight: 700; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
#call-live.watching #call-zoom { display: none; }
.watch-bar { flex-wrap: wrap; }
#watch-zout, #watch-zin { width: 36px; padding: 0; font-size: 20px; line-height: 1; }
/* The call buttons step out of the way after a few seconds; a small handle brings them back. */
.call-controls, .watch-bar, .call-top, #call-zoom { transition: opacity .35s ease, transform .35s ease; }
#call-live.quiet .call-controls, #call-live.quiet .watch-bar { opacity: 0; pointer-events: none !important; transform: translateY(24px); }
#call-live.quiet .call-top, #call-live.quiet #call-zoom { opacity: 0; pointer-events: none !important; }
#call-show { position: absolute; left: 50%; bottom: calc(var(--sab) + 6px); width: 96px; height: 34px; margin-left: -48px; display: grid; place-items: center; }
#call-show i { width: 44px; height: 5px; border-radius: 9px; background: rgba(255, 255, 255, .6); box-shadow: 0 1px 4px rgba(0, 0, 0, .4); }
.modes { display: grid; gap: 8px; margin-top: 14px; }
.modes button { display: flex; flex-direction: column; padding: 12px 14px; border-radius: 16px; background: var(--card); border: 2.5px solid transparent; text-align: left; }
.modes button.on { border-color: var(--accent); }
.modes b { font-size: 16.5px; } .modes small { color: var(--muted); font-size: 13.5px; }
.call-controls .round small { white-space: nowrap; }
.flash { position: absolute; inset: 0; z-index: 95; background: #fff; pointer-events: none; animation: flash .45s ease-out forwards; }
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }
.call-bubble { margin-bottom: 12px; pointer-events: none; font-size: 17.5px; max-width: 92%; }
.call-bubble::after { top: -7px; bottom: auto; }
.call-quick { justify-content: center; padding: 0 0 12px; }
.call-quick button { background: rgba(255, 255, 255, .92); border-color: transparent; color: #c2406b; box-shadow: var(--shadow); }
.call-controls { display: flex; justify-content: space-around; padding: 14px 10px; border-radius: 28px; background: rgba(20, 14, 26, .5); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.call-controls .round .ico, .call-controls .round::after { width: 58px; height: 58px; }
.call-controls .round::after { margin-left: -29px; }
.call-controls .round .ico { -webkit-mask-size: 28px; mask-size: 28px; }

/* ---- games ----------------------------------------------------------------------------- */
#games { display: flex; flex-direction: column; justify-content: flex-end; pointer-events: none; }
#games > * { pointer-events: auto; }
.game-bubble { margin: 0 auto 10px; pointer-events: none; }
.game-panel { background: var(--bg); color: var(--ink); border-radius: 28px 28px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .22); padding: 8px 14px calc(var(--sab) + 14px); height: 54%; min-height: 400px; display: flex; flex-direction: column; animation: sheetUp .4s cubic-bezier(.2, 1, .3, 1); }
.game-panel header { display: flex; align-items: center; gap: 4px; min-height: 48px; }
.game-panel h2 { flex: 1; font-size: 19px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-panel .icon-btn { font-size: 28px; line-height: 1; color: var(--muted); }
.game-score { display: flex; gap: 6px; align-items: center; font-size: 14px; color: var(--muted); white-space: nowrap; }
.game-score b { color: var(--accent); }
.game-board > :first-child { margin-top: auto; } .game-board > :last-child { margin-bottom: auto; }
.game-board { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: flex-start; gap: 12px; overflow-y: auto; }
.game-menu { grid-template-columns: 1fr 1fr; }
.game-menu button { padding: 9px 10px; gap: 10px; } .game-menu i { width: 42px; height: 42px; font-size: 24px; flex: none; } .game-menu b { font-size: 15px; } .game-menu small { font-size: 12px; line-height: 1.25; display: block; }
.chess { display: grid; grid-template-columns: repeat(8, 1fr); align-self: center; width: min(100%, 352px, 46vh); border-radius: 10px; overflow: hidden; box-shadow: 0 0 0 3px var(--card); flex: none; }
.chess button { aspect-ratio: 1; display: grid; place-items: center; position: relative; padding: 0; border-radius: 0; }
.chess .lt { background: #f6e3d3; } .chess .dk { background: #d99aae; }
.chess .last { box-shadow: inset 0 0 0 99px rgba(255, 221, 120, .42); }
.chess .sel { box-shadow: inset 0 0 0 99px rgba(120, 200, 255, .55); }
.chess .chk { box-shadow: inset 0 0 0 99px rgba(255, 80, 80, .55); }
.chess .tgt::after { content: ''; position: absolute; width: 30%; height: 30%; border-radius: 50%; background: rgba(60, 40, 70, .35); }
.chess .cap::after { content: ''; position: absolute; inset: 6%; border-radius: 50%; border: 3px solid rgba(60, 40, 70, .45); }
.chess i { font-style: normal; font-size: min(8.2vw, 36px, 4.6vh); line-height: 1; font-family: "Apple Symbols", "Segoe UI Symbol", "Noto Sans Symbols2", "DejaVu Sans", serif; }
.chess i.w { color: #fffdf8; text-shadow: 0 0 1.5px #2b2030, 0 0 1.5px #2b2030, 0 1px 2px #2b2030, 1px 0 1px #2b2030, -1px 0 1px #2b2030; }
.chess i.b { color: #2b2030; text-shadow: 0 0 1.5px rgba(255, 255, 255, .7); }
.chess-level { display: flex; align-self: center; } .chess-level button { min-height: 32px; padding: 0 14px; font-size: 13.5px; }
.quiz-q { font-size: 18px; font-weight: 800; text-align: center; padding: 0 6px; }
.quiz-a { display: grid; gap: 8px; } .quiz-a button { min-height: 48px; border-radius: 16px; background: var(--card); font-size: 16px; font-weight: 700; padding: 6px 12px; }
.quiz-a .ok { background: #bfe8b4; color: #1f5a22; } .quiz-a .no { background: #f8b9b9; color: #7a1f1f; } .quiz-a .dim { opacity: .5; }
.quiz-fact { text-align: center; font-size: 14.5px; color: var(--muted); padding: 0 8px; }
.four { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; align-self: center; width: min(100%, 340px, 52vh); padding: 8px; border-radius: 18px; background: var(--accent-soft); flex: none; }
.four button { aspect-ratio: 1; border-radius: 50%; background: var(--bg); font-size: min(6vw, 26px, 3.4vh); display: grid; place-items: center; padding: 0; }
.four button.set { animation: pop .25s cubic-bezier(.2, 1.4, .4, 1); } .four button.win { box-shadow: 0 0 0 3px var(--accent); }
.num-range { display: flex; align-items: center; gap: 10px; justify-content: center; font-size: 22px; color: var(--accent); } .num-range i { width: 40%; height: 6px; border-radius: 9px; background: var(--accent-soft); }
.num-row { display: flex; gap: 10px; } .num-row .field { flex: 1; min-width: 0; text-align: center; font-size: 22px; } .num-row .btn { flex: none; padding: 0 22px; }
.word-w { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; } .word-w b { width: 28px; height: 38px; border-bottom: 3px solid var(--accent); font-size: 24px; text-transform: uppercase; text-align: center; }
.word-keys { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; } .word-keys button { min-height: 38px; border-radius: 10px; background: var(--card); font-size: 16px; font-weight: 700; text-transform: uppercase; padding: 0; }
.word-keys .ok { background: #bfe8b4; color: #1f5a22; } .word-keys .no { opacity: .3; }
.game-hint { text-align: center; color: var(--muted); font-size: 14.5px; }
.game-menu { display: grid; gap: 9px; }
.game-menu button { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 18px; background: var(--card); text-align: left; animation: riseIn .4s cubic-bezier(.2, 1.3, .3, 1) backwards; transition: transform .12s; }
.game-menu button:nth-child(2) { animation-delay: .05s; } .game-menu button:nth-child(3) { animation-delay: .1s; } .game-menu button:nth-child(4) { animation-delay: .15s; }
.game-menu button:active { transform: scale(.96); }
.game-menu i { font-style: normal; font-size: 30px; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 14px; background: var(--accent-soft); flex: none; }
.game-menu b { display: block; font-size: 16.5px; } .game-menu small { color: var(--muted); font-size: 13.5px; }
.game-again { display: flex; gap: 10px; animation: riseIn .4s .5s backwards; }
.game-again .btn { flex: 1; }
.jk-stage { display: flex; align-items: center; justify-content: space-around; }
.jk-hand { font-size: 62px; width: 96px; height: 96px; display: grid; place-items: center; border-radius: 24px; background: var(--card); }
#jk-her { transform: scaleX(-1); background: var(--accent-soft); }
.jk-hand.shake { animation: jkShake .38s ease-in-out; }
@keyframes jkShake { 0%, 100% { translate: 0 0; } 50% { translate: 0 -16px; } }
.jk-vs { font-weight: 800; font-size: 15px; color: var(--muted); text-align: center; flex: 1; padding: 0 6px; }
.jk-picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.jk-picks button, .hands button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 4px; border-radius: 20px; background: var(--card); border: 2.5px solid transparent; transition: transform .12s; }
.jk-picks button:active, .hands button:active, .three button:active, .pairs button:active { transform: scale(.92); }
.jk-picks span { font-size: 42px; } .jk-picks small { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: capitalize; }
.hands { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hands button { padding: 22px 4px; } .hands span { font-size: 64px; }
.hands button:first-child span { display: inline-block; transform: scaleX(-1); }
.hands button.right { border-color: var(--green); } .hands button.wrong { border-color: #d6453d; }
.pairs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; align-self: center; width: min(100%, 330px); }
.pairs button { aspect-ratio: 1; border-radius: 14px; background: linear-gradient(135deg, #f7a0bb, var(--accent)); font-size: 30px; display: grid; place-items: center; transition: transform .25s, background .25s, opacity .3s; }
.pairs button.up { background: var(--card); transform: rotateY(180deg); } .pairs button.up span { transform: rotateY(180deg); display: block; }
.pairs button.done { opacity: .45; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; align-self: center; width: min(78%, 280px); }
.three button { aspect-ratio: 1; border-radius: 18px; background: var(--card); font-size: 40px; display: grid; place-items: center; transition: transform .12s; }
.three button.set { animation: pop .25s cubic-bezier(.2, 1.4, .4, 1); } .three button.win { background: var(--accent-soft); }

/* ---- bedtime ------------------------------------------------------------------------ */
#app[data-screen="sleep"] #sky { opacity: 0; }
#app[data-screen="sleep"] { background: #05040a; }
#sleep { display: flex; flex-direction: column; justify-content: flex-end; }
.sleep-setup { background: #17131f; color: #eaddd0; --muted: #9a8c96; --line: #2c2535; --card: #2a2333; --ink: #eaddd0; }
.sleep-setup .seg button.on { background: #e8668f; color: #fff; }
.sleep-setup .btn.ghost { background: #2a2333; color: #eaddd0; }
.sleep-live { position: absolute; inset: 0; }
.sleep-dim { position: absolute; inset: 0; background: #000; opacity: .3; transition: opacity 6s ease; pointer-events: none; }
.sleep-whisper { position: absolute; left: 30px; right: 30px; top: calc(var(--sat) + 76px); text-align: center; font: 600 19px/1.4 var(--font); color: #a58f78; opacity: 0; transition: opacity 1.8s ease; pointer-events: none; text-shadow: 0 0 20px #000; }
.sleep-whisper.on { opacity: .9; }
.sliders { display: grid; gap: 4px; }
.sliders label { display: flex; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 600; min-height: 38px; }
.sliders span { width: 96px; flex: none; }
.sliders input { flex: 1; min-width: 0; accent-color: var(--accent); height: 30px; }
.sleep-call-top { position: absolute; top: calc(var(--sat) + 12px); left: 16px; display: flex; flex-direction: column; padding: 8px 14px; border-radius: 16px; background: rgba(255, 255, 255, .06); color: #a08a74; transition: opacity 1.2s ease; pointer-events: none; }
.sleep-call-top b { font-size: 17px; } .sleep-call-top span { font-size: 13px; } .sleep-call-top i { font-style: normal; font-variant-numeric: tabular-nums; }
.sleep-call-top.hide { opacity: .25; }
.btn.endcall { background: rgba(255, 59, 48, .22); color: #ff8d86; }
.sleep-ui .row-btns { gap: 8px; } .sleep-ui .btn { padding: 0 10px; font-size: 15px; }
.sleep-ui { position: absolute; left: 22px; right: 22px; bottom: calc(var(--sab) + 26px); text-align: center; color: #8f7a66; transition: opacity 1.2s ease; }
.sleep-ui.hide { opacity: 0; pointer-events: none; }
.sleep-clock span { display: block; font-size: 44px; font-weight: 300; font-variant-numeric: tabular-nums; letter-spacing: .02em; color: #a08a74; }
.sleep-clock small { font-size: 13px; }

/* ---- banner, toast, install, onboarding, boot ------------------------------------------ */
.banner { position: absolute; z-index: 70; left: 10px; right: 10px; top: calc(var(--sat) + 8px); display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 20px; background: var(--glass); color: var(--glass-ink); -webkit-backdrop-filter: blur(22px) saturate(1.5); backdrop-filter: blur(22px) saturate(1.5); box-shadow: 0 10px 34px rgba(0, 0, 0, .22); animation: bannerIn .4s cubic-bezier(.2, 1.2, .3, 1); }
.banner.out { animation: bannerOut .3s forwards; }
@keyframes bannerIn { from { translate: 0 -130%; } }
@keyframes bannerOut { to { translate: 0 -130%; opacity: 0; } }
.banner .txt { flex: 1; min-width: 0; line-height: 1.25; }
.banner .txt b { display: block; font-size: 14.5px; }
.banner .txt span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14.5px; }
.toast { position: absolute; z-index: 80; left: 50%; bottom: calc(var(--tabs-h) + var(--sab) + 18px); translate: -50% 0; max-width: 86%; padding: 10px 16px; border-radius: 99px; background: rgba(30, 22, 30, .9); color: #fff; font-size: 14.5px; font-weight: 600; text-align: center; animation: pop .25s; }
.install { position: absolute; z-index: 35; left: 12px; right: 12px; bottom: calc(var(--tabs-h) + var(--sab) + 88px); padding: 14px 16px; border-radius: 20px; background: var(--card); color: var(--ink); box-shadow: 0 10px 40px rgba(0, 0, 0, .25); font-size: 15px; line-height: 1.4; animation: sheetUp .4s cubic-bezier(.2, 1, .3, 1); }
.install b { display: block; font-size: 16.5px; margin-bottom: 3px; }
.install .share { display: inline-block; width: 18px; height: 22px; vertical-align: -5px; margin: 0 2px; background: var(--accent); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 22'%3E%3Cpath d='M9 0l4.5 4.5-1.4 1.4L10 3.8V14H8V3.8L5.9 5.9 4.5 4.5zM2 8h4v2H3v10h12V10h-3V8h4a1 1 0 011 1v12a1 1 0 01-1 1H2a1 1 0 01-1-1V9a1 1 0 011-1z'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 22'%3E%3Cpath d='M9 0l4.5 4.5-1.4 1.4L10 3.8V14H8V3.8L5.9 5.9 4.5 4.5zM2 8h4v2H3v10h12V10h-3V8h4a1 1 0 011 1v12a1 1 0 01-1 1H2a1 1 0 01-1-1V9a1 1 0 011-1z'/%3E%3C/svg%3E") center/contain no-repeat; }
.install button { position: absolute; top: 6px; right: 6px; width: 40px; height: 40px; font-size: 22px; color: var(--muted); }
.onboard { position: absolute; inset: 0; z-index: 90; display: flex; flex-direction: column; justify-content: flex-end; padding: 0 0 0; pointer-events: none; }
.onboard .sheet-card { pointer-events: auto; }
.onboard p.say { font-size: 19px; line-height: 1.4; font-weight: 600; margin-bottom: 14px; min-height: 54px; }
.field { width: 100%; border: 2px solid var(--line); background: var(--card); border-radius: 15px; padding: 13px 16px; font-size: 18px; font-weight: 700; outline: none; -webkit-user-select: text; user-select: text; }
.field:focus { border-color: var(--accent); }
.steps { display: flex; gap: 6px; margin-bottom: 14px; }
.steps i { width: 22px; height: 5px; border-radius: 3px; background: var(--line); } .steps i.on { background: var(--accent); }
.boot { position: absolute; inset: 0; z-index: 100; background: var(--bg); display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); font-weight: 700; transition: opacity .5s; }
.boot.done { opacity: 0; pointer-events: none; }
.boot-paw { width: 54px; height: 54px; background: var(--accent); border-radius: 50% 50% 46% 46%; box-shadow: -30px -26px 0 -16px var(--accent), 30px -26px 0 -16px var(--accent), -12px -40px 0 -15px var(--accent), 12px -40px 0 -15px var(--accent); margin-top: 40px; animation: bob 1s ease-in-out infinite alternate; }
@keyframes bob { to { translate: 0 -8px; } }

/* ---- landscape (phone on its side) ------------------------------------------------------ */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --tabs-h: 44px; }
  .tabs button > span:not(.ico) { display: none; }
  .tabs::before { height: calc(var(--tabs-h) - 8px); top: 4px; }
  .hud { max-width: 420px; }
  #home .actions { position: absolute; right: calc(var(--sar) + 10px); top: calc(var(--sat) + 8px); bottom: calc(var(--tabs-h) + var(--sab) + 8px); width: 78px; grid-template-columns: 1fr; padding: 0; align-content: center; }
  #home .actions button { min-height: 0; padding: 6px 2px 5px; font-size: 11.5px; }
  .hud-side { flex-direction: row; }
  .pat-hint { display: none; }
  #home-bubble { max-width: 260px; left: 27%; top: calc(var(--sat) + 70px); }
  #home-bubble::after { display: none; }
  .sheet-card { max-width: 560px; margin: 0 auto; width: 100%; max-height: 94%; }
  .onboard .sheet-card { max-width: 560px; }
  /* calls: controls stack down the right edge and stay out of the picture */
  .call-live { padding-bottom: calc(var(--sab) + 10px); align-items: center; }
  .call-controls { position: absolute; right: calc(var(--sar) + 10px); top: 50%; transform: translateY(-50%); flex-direction: column; gap: 10px; padding: 10px 8px; border-radius: 24px; }
  .call-controls .round .ico, .call-controls .round::after { width: 44px; height: 44px; }
  .call-controls .round::after { margin-left: -22px; }
  .call-controls .round .ico { -webkit-mask-size: 22px; mask-size: 22px; }
  .call-controls .round small { display: none; }
  #call-live.quiet .call-controls, #call-live.quiet .watch-bar { transform: translateY(-50%) translateX(30px); }
  #call-live.quiet .watch-bar { transform: translateX(30px); }
  #call-show { left: auto; right: calc(var(--sar) + 2px); bottom: 50%; margin: 0 0 -48px; width: 34px; height: 96px; }
  #call-show i { width: 5px; height: 44px; }
  .call-bubble { max-width: 46%; margin-bottom: 4px; }
  .call-quick { padding-bottom: 6px; }
  .ring-top { gap: 6px; } .call-ring { padding-top: calc(var(--sat) + 14px); padding-bottom: calc(var(--sab) + 14px); } .avatar.big { width: 84px; height: 84px; }
  /* games: board on the right, her on the left */
  #games { flex-direction: row; justify-content: flex-end; align-items: stretch; }
  .game-panel { width: 54%; height: 100%; min-height: 0; border-radius: 28px 0 0 28px; padding-right: calc(var(--sar) + 12px); animation: none; }
  .chess { width: min(100%, calc(100vh - 128px)); } .four { width: min(100%, calc(100vh - 120px)); }
  #games.tall .game-hint { display: none; } .chess-level { position: absolute; right: calc(var(--sar) + 56px); top: 14px; } .chess-level button { min-height: 28px; padding: 0 9px; }
  .game-panel { position: relative; }
  .game-bubble { position: absolute; left: 4%; bottom: calc(var(--sab) + 12px); max-width: 38%; margin: 0; }
  .sleep-ui { left: auto; right: calc(var(--sar) + 18px); bottom: calc(var(--sab) + 14px); width: 300px; }
  .sleep-clock span { font-size: 30px; }
  .sleep-whisper { top: calc(var(--sat) + 16px); }
  .reader { padding: 10px calc(var(--sar) + 60px) 10px calc(var(--sal) + 60px); }
  .work-bar { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + var(--sab) + 6px); margin: 0; width: min(92%, 520px); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01s !important; transition-duration: .01s !important; } }
@media (max-height: 700px) { #home-bubble { top: calc(var(--sat) + 84px); } .avatar.big { width: 96px; height: 96px; } }
