:root {
  --bg:#f5f4ed; --paper:#fffcf6; --ink:#213c32; --text:#283e35; --muted:#5e6b60;
  --line:#d7dbcf; --dark:#263f35; --mint:#e4ecdf; --orange:#f1a578;
  --max:1160px; --radius:22px; color-scheme:light;
  font:16px/1.5 "Inter","Arial",system-ui,sans-serif; -webkit-text-size-adjust:100%;
}
*{box-sizing:border-box}
body{margin:0;color:var(--text);background:var(--bg);min-height:100vh}
button,select,input,textarea{font:inherit;color:inherit}
button,a,input,select,textarea{-webkit-tap-highlight-color:transparent}
button,a{touch-action:manipulation}
button,.button{border:0;cursor:pointer;background:none}
button:disabled, input:disabled, textarea:disabled {cursor:wait;opacity:.5}
button:focus-visible,a:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:3px solid #cf814d;outline-offset:3px}
button:active:not(:disabled),.button:active{transform:translateY(1px)}
a{color:inherit;text-decoration:none}
h1,h2,h3,p{margin:0}
svg{display:block;flex-shrink:0}
[hidden]{display:none!important}
:disabled[aria-disabled=true]{cursor:default}
.topbar{border-bottom:1px solid var(--line);background:#faf9f2}
.topinner,.shell{max-width:var(--max);padding-inline:32px;margin-inline:auto}
.topinner{min-height:77px;display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:24px;padding-top:max(0px,var(--tg-content-safe-area-inset-top,0px),env(safe-area-inset-top))}
.wordmark{display:inline-flex;align-items:center;gap:10px;font-size:26px;font-weight:750;letter-spacing:-1.6px;line-height:1;width:max-content;color:#263e35}
.wordmark img{image-rendering:auto}
.nav{display:flex;align-items:center;gap:4px}
.nav button,.mobile-nav button{position:relative;display:flex;align-items:center;justify-content:center;gap:8px;white-space:nowrap;font-size:14px;font-weight:600;line-height:1.2;color:#56645b}
.nav button{border-radius:11px;min-height:42px;padding:0 15px}
.nav button:hover,.nav button[aria-current=page]{background:#e5ebe0;color:#263f35}
.profile-link{display:flex;align-items:center;gap:9px;justify-self:end;font-size:14px;font-weight:600;padding:4px;border-radius:20px}
.avatar{display:grid;place-items:center;background:var(--mint);border:1px solid #c9d4c6;border-radius:50%;width:36px;height:36px;font-weight:700}
.profile-link:hover>.avatar,.profile-link[aria-current=page]>.avatar{background:#c9dac6}
.shell{padding-top:36px;padding-bottom:50px;min-height:65vh;outline:none}
.heading{display:flex;align-items:end;justify-content:space-between;gap:14px;margin-bottom:22px}
.heading .eyebrow{margin-bottom:5px}
.eyebrow,.overline{font-size:.77rem;line-height:1.4;font-weight:700;color:var(--muted);letter-spacing:.065em;text-transform:uppercase;display:flex;align-items:center;gap:7px}
h1{font-size:clamp(2.15rem,4vw,3.55rem);line-height:1.05;letter-spacing:-.061em;font-weight:650;color:var(--ink)}
h2{font-size:1.42rem;line-height:1.17;letter-spacing:-.045em;font-weight:650}
h3{font-size:1.02rem;line-height:1.4;letter-spacing:-.017em}
.grid{display:grid;grid-template-columns:minmax(0,1.96fr) minmax(270px,1fr);gap:18px}
.card{background:var(--paper);border:1px solid var(--line);border-radius:var(--radius);min-width:0}
.world-card{overflow:hidden;display:flex;flex-direction:column;background:#263f35;color:#fcf8df;border-color:#263e35}
.scene{position:relative;flex:1;min-height:315px;isolation:isolate;overflow:hidden;background:linear-gradient(180deg,#526b82,#345c59 62%,#435b40);border-bottom:1px solid #425846}
.world-canvas{display:block;width:100%;height:100%;position:absolute;inset:0;image-rendering:pixelated}
.scenebar{position:absolute;inset:14px 14px auto;display:flex;justify-content:space-between;align-items:start;gap:10px;pointer-events:none}
.scenebar>*{pointer-events:auto}
.scene-tag,.expand{background:#203e34e8;color:#faf8e4;border:1px solid #92a78c85;border-radius:10px;display:inline-flex;gap:7px;align-items:center;justify-content:center;backdrop-filter:blur(4px)}
.scene-tag{padding:7px 10px;font-size:13px;font-weight:600}
.expand{height:36px;width:36px}
.world-foot{display:flex;align-items:center;gap:12px;padding:14px 18px;font-size:14px;min-height:66px}
.world-foot .world-text{font-weight:550;line-height:1.4;flex:1}
.world-foot .tiny{color:#c6d6c6;margin-top:1px}
.paw-circle{border-radius:12px;padding:9px;color:#edc39a;background:#3e5345}
.world-foot .touch{border:1px solid #718376;border-radius:10px;color:#f4f3df;min-height:36px;padding:5px 12px;font-size:13px;font-weight:650}
.world-foot .touch:hover{background:#435a48}
.pet-card{padding:22px;display:flex;flex-direction:column;justify-content:space-between;gap:18px}
.section-label{display:flex;align-items:center;justify-content:space-between;gap:12px}
.subtle{color:var(--muted);font-size:.875rem}
.plainicon,.roundbtn{border-radius:10px;display:grid;place-items:center;color:var(--muted);width:38px;height:38px;flex-shrink:0}
.plainicon:hover,.roundbtn:hover{background:#e9ede3}
.section-label .plainicon{width:32px;height:32px;margin:-5px -5px -5px 0}
.identity{display:flex;align-items:center;gap:13px}
.pet-stamp{position:relative;align-self:stretch;min-height:64px;width:68px;flex-shrink:0;border-radius:16px;background:#efe8d6;display:grid;place-items:center}
.pet-stamp canvas,.pet-mini{image-rendering:pixelated;width:56px;height:56px}
.pet-title{font-size:1.9rem;letter-spacing:-.06em;line-height:1.14;overflow-wrap:anywhere}
.pet-meta{color:var(--muted);font-size:.9rem;margin-top:3px}
.meters{display:grid;gap:13px}
.meter-label{display:flex;align-items:center;gap:7px;font-size:.86rem;font-weight:600;margin-bottom:6px;color:#445449}
.meter-label strong{margin-left:auto;font-weight:600;color:#45574a;font-variant-numeric:tabular-nums}
.track{height:7px;background:#e7e9dd;border-radius:10px;overflow:hidden}
.track i{display:block;height:100%;border-radius:10px;transition:width .5s ease}
.meter-energy .track i{background:#9eaf64}.meter-energy svg{color:#607c3e}
.meter-bond .track i{background:#df997b}.meter-bond svg{color:#b86d5f}
.actions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:7px}
.actions button{border:1px solid #d5dacd;min-height:60px;border-radius:12px;display:grid;place-items:center;align-content:center;gap:4px;font-size:.79rem;line-height:1.2;font-weight:600;background:#f3f4ea;padding:5px 2px}
.actions button:first-child{background:#f8eadd;border-color:#e9cdb6;color:#815438}
.actions button:hover{filter:brightness(.97)}
.below{margin-top:19px;display:grid;grid-template-columns:1.2fr 1fr;gap:18px}
.tile{display:flex;align-items:center;gap:15px;text-align:left;width:100%;padding:21px 22px;min-height:100px;border-radius:var(--radius);border:1px solid var(--line);background:var(--paper)}
.tile:hover{border-color:#9eae9d;box-shadow:0 3px 12px #253c3010}
.tile h2{font-size:1.2rem;margin-bottom:3px}
.tile p{color:#57665b;font-size:.91rem;line-height:1.45}
.tile>:last-child{margin-left:auto;flex-shrink:0;color:#576e5e}
.tile-art{width:56px;height:56px;display:grid;place-items:center;border-radius:16px;color:#865d42;background:#f0dfc8;flex-shrink:0}
.tile.memory .tile-art{color:#586c4e;background:#e5ebd9}
.luna-symbol{position:relative;width:28px;height:28px;display:block}
.luna-symbol::before,.luna-symbol::after{content:"";position:absolute;background:currentColor;clip-path:polygon(50% 0,62% 35%,100% 50%,62% 65%,50% 100%,38% 65%,0 50%,38% 35%)}
.luna-symbol::before{inset:0 6px 6px 0}.luna-symbol::after{right:0;bottom:0;width:12px;height:12px}
.note{padding:12px 15px;display:flex;align-items:center;justify-content:space-between;gap:12px;background:#e9eee2;border:1px solid #d3ddc9;border-radius:13px;font-size:.9rem;margin-top:18px}
.note button,.inline-link{color:#374d3c;text-decoration:underline;text-underline-offset:3px;font-weight:650;padding:5px;flex-shrink:0}
.mobile-nav{display:none}
.buttons{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.primary,.secondary,.danger,.button{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:44px;border-radius:11px;font-size:.91rem;font-weight:650;line-height:1.3;padding:10px 15px}
.primary{background:var(--dark);color:#fffdf0;border:1px solid var(--dark)}
.primary:hover{background:#385244}
.secondary,.button{border:1px solid #c6d1c3;background:#f1f3e8}
.secondary:hover,.button:hover{background:#e6ecdc}
.danger{background:#f9eae2;color:#884837;border:1px solid #dfbfae}
.tiny{font-size:.8rem;color:var(--muted);line-height:1.4}
.stack{display:grid;gap:16px;align-content:start}
.pad{padding:23px}
.pad h2{margin-bottom:12px}
.two-col{display:grid;grid-template-columns:minmax(0,1.75fr) minmax(260px,1fr);gap:18px;align-items:start}
.profile-grid{display:grid;grid-template-columns:1fr 1fr;gap:18px;align-items:start}
label.field{display:grid;gap:6px;margin-block:12px;font-size:.9rem;font-weight:600}
input:not([type=checkbox]),textarea,select{width:100%;padding:10px 12px;border:1px solid #c4cfbf;border-radius:10px;background:#fffef9;min-height:44px;line-height:1.45;font-size:16px}
textarea{resize:vertical;min-height:84px}
.switchrow{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:13px 0;border-bottom:1px solid #e1e4d8}
.switchrow:last-child{border:0;padding-bottom:0}
.switchrow:first-child{padding-top:0}
.switchrow p,.help{font-size:.88rem;color:var(--muted);margin-top:3px;line-height:1.5}
.switchrow input{appearance:none;flex-shrink:0;position:relative;margin:0;width:43px;height:25px;border:1px solid #bdc5b7;border-radius:16px;background:#d7dcd1;cursor:pointer}
.switchrow input:before{content:"";width:17px;height:17px;background:#fffefa;position:absolute;left:3px;top:3px;border-radius:50%;box-shadow:0 1px 3px #0002;transition:transform .15s}
.switchrow input:checked{background:#4b6a51;border-color:#4b6a51}
.switchrow input:checked:before{transform:translateX(18px)}
.switchrow input:disabled{cursor:default;opacity:.4}
.chat-card{display:flex;flex-direction:column;min-height:470px;max-height:min(67vh,680px);overflow:hidden}
.chat-top{display:flex;gap:12px;align-items:center;border-bottom:1px solid var(--line);padding:14px 18px}
.chat-top .tile-art{width:40px;height:40px;border-radius:12px}
.chat-top h2{font-size:1.02rem;margin:0 0 2px}
.thread{overflow:auto;overscroll-behavior:contain;display:flex;flex:1;flex-direction:column;align-items:stretch;gap:12px;padding:18px;scrollbar-width:thin}
.empty-chat{margin:auto;align-self:center;text-align:center;padding:20px 10px}
.empty-chat .tile-art{margin:0 auto 13px}
.empty-chat p{max-width:36ch;margin:6px auto 0;color:var(--muted);font-size:.92rem}
.bubble{align-self:flex-start;border-radius:14px 14px 14px 3px;background:#eef0e6;max-width:88%;padding:10px 13px;white-space:pre-wrap;overflow-wrap:anywhere;font-size:.96rem}
.bubble.me{background:#2f4d3e;color:#fffdf3;align-self:flex-end;border-radius:14px 14px 3px 14px}
.speak{display:inline-flex;align-items:center;justify-content:center;gap:5px;font-size:.78rem;text-decoration:underline;padding:4px 0;color:#466044}
.composer{display:flex;align-items:end;gap:8px;padding:12px;border-top:1px solid var(--line);background:#fafaf2}
.composer textarea{min-height:44px;height:44px;max-height:120px;resize:none}
.composer button{width:44px;height:44px;padding:0;flex-shrink:0}
.factrow{display:flex;gap:8px;padding:12px 0;border-bottom:1px solid var(--line);align-items:center}.factrow:last-child{border:0}
.factrow .facttext{flex:1;min-width:0;overflow-wrap:anywhere;white-space:pre-line}
.factrow .plainicon{width:36px;height:36px}.empty{padding:30px 12px;text-align:center}.empty .tile-art{margin:0 auto 12px}.empty p{color:var(--muted);margin:7px auto 0;max-width:43ch;font-size:.92rem}
.pills{display:flex;gap:7px;flex-wrap:wrap;margin:11px 0 0}
.pills button{border:1px solid var(--line);border-radius:10px;text-align:left;padding:7px 10px;font-size:.86rem;background:#f2f4e9}
.dialog-body{padding:24px;min-width:0}
dialog{padding:0;max-width:min(440px,calc(100vw - 28px));width:100%;border:1px solid var(--line);background:var(--paper);color:var(--text);border-radius:20px;box-shadow:0 18px 70px #112c2733}
dialog::backdrop{background:#1b342a8c;backdrop-filter:blur(3px)}
.dialog-top{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:12px}.dialog-top h2{font-size:1.4rem}
.dialog-body>.buttons,.dialog-body form>.buttons{margin-top:16px}
.dialog-body p{color:var(--muted);font-size:.95rem;line-height:1.5}
dialog.wide{max-width:min(1050px,96vw)}.big-scene{height:min(68vh,620px);min-height:240px}
.toast{position:fixed;bottom:max(20px,env(safe-area-inset-bottom));left:50%;transform:translate(-50%,10px);opacity:0;pointer-events:none;color:#fffef2;background:#283f34;padding:11px 16px;border:1px solid #6f826f;border-radius:12px;box-shadow:0 4px 22px #14281e25;font-size:.9rem;z-index:10;max-width:min(550px,calc(100% - 24px));width:max-content;transition:opacity .15s,transform .15s}
.toast.show{opacity:1;transform:translate(-50%,0)}
.code-box{font-family:ui-monospace,monospace;font-size:1.65rem;overflow-wrap:anywhere;text-align:center;letter-spacing:.1em;background:var(--mint);border-radius:12px;padding:10px;margin:12px 0}
#pair-login{max-width:460px;margin:50px auto}
@media(min-width:1250px){.shell{padding-top:43px}.scene{min-height:350px}.pet-card{padding:25px}.world-foot{padding:16px 21px}.below{margin-top:21px}}
@media(max-width:850px){.topinner,.shell{padding-inline:20px}.topinner{gap:10px}.nav button{padding-inline:10px}.grid{grid-template-columns:minmax(0,1.6fr) minmax(240px,1fr);gap:13px}.pet-card{padding:17px}.scene{min-height:280px}.two-col{grid-template-columns:minmax(0,1.5fr) minmax(220px,1fr)}.tile{padding:16px}.tile p{font-size:.85rem}.below{gap:13px}}
@media(max-width:680px){
  :root{--radius:18px}.topinner,.shell{padding-inline:max(16px,env(safe-area-inset-left),var(--tg-content-safe-area-inset-left,0px));}
  .topinner{min-height:56px;display:flex;justify-content:space-between;gap:12px}.wordmark{font-size:23px;gap:8px}.wordmark img{width:31px;height:31px}.profile-link{font-size:13px}.avatar{width:31px;height:31px}.nav{display:none}
  .mobile-nav{position:fixed;inset:auto 0 0;z-index:4;display:grid;grid-template-columns:repeat(3,1fr);padding:5px max(12px,env(safe-area-inset-right)) max(5px,env(safe-area-inset-bottom),var(--tg-content-safe-area-inset-bottom,0px));border-top:1px solid var(--line);background:#fcfbf4f5;backdrop-filter:blur(10px)}
  .mobile-nav button{flex-direction:column;gap:1px;min-height:49px;font-size:12px;font-weight:650}.mobile-nav button svg{height:20px}.mobile-nav button[aria-current=page]{color:#284736}.mobile-nav button[aria-current=page]::before{content:"";width:45px;height:25px;position:absolute;top:1px;border-radius:9px;background:#e2eadb;z-index:-1}
  .shell{padding-top:22px;padding-bottom:calc(83px + env(safe-area-inset-bottom))}.heading{margin-bottom:16px}.heading .eyebrow{font-size:.72rem}.heading h1{font-size:2.33rem}.grid,.two-col,.profile-grid,.below{grid-template-columns:1fr;gap:12px}.scene{min-height:0;height:clamp(206px,60vw,312px);flex:auto}.world-foot{padding:10px 12px;gap:8px;min-height:58px}.world-foot .tiny{font-size:.74rem}.world-foot .touch{padding:5px 9px}.paw-circle{padding:7px}.world-text{font-size:13px}.scenebar{inset:10px 10px auto}.pet-card{gap:13px;padding:16px}.identity{gap:11px}.pet-stamp{width:50px;min-height:46px;border-radius:11px}.pet-stamp canvas{width:45px;height:45px}.pet-title{font-size:1.55rem}.pet-meta{font-size:.84rem;margin-top:0}.meters{grid-template-columns:1fr 1fr;gap:15px}.actions button{min-height:45px;display:flex;align-items:center;justify-content:center;gap:5px;font-size:.79rem}.actions button svg{width:17px;height:17px}.pet-card .overline{font-size:.71rem}
  .below{margin-top:12px}.tile{min-height:76px;padding:12px 15px;gap:12px}.tile h2{font-size:1.09rem}.tile-art{width:45px;height:45px;border-radius:13px}.note{font-size:.82rem;padding:10px;align-items:start}.note button{padding:0}.pad{padding:17px}.chat-card{min-height:350px;max-height:max(350px,calc(var(--tg-viewport-height,100dvh) - 234px))}.thread{padding:12px}.chat-top{padding:11px 13px}.chat-top .tile-art{height:35px;width:35px}.toast{bottom:calc(70px + env(safe-area-inset-bottom))}.dialog-body{padding:17px}.big-scene{height:min(65vh,480px)}.buttons .primary,.buttons .secondary{font-size:.86rem}.section-label{min-height:22px}.pills button{min-height:38px}
}
@media(max-width:360px){.topinner,.shell{padding-inline:11px}.actions button{font-size:.74rem}.world-foot .touch{font-size:.76rem}.actions{gap:4px}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:0s!important;transition:none!important;scroll-behavior:auto!important}}
.gap-top{margin-top:12px}.chaterror{padding:7px 14px;color:#8e493b}.pill-active{background:#dce7d7!important;border-color:#78906c!important}.new-note{font-size:.76rem;color:#78573a;background:#f6e5cb;padding:2px 6px;border-radius:6px;margin-left:4px}
.doclink{text-decoration:underline;text-underline-offset:3px}
