:root {
  --bg: #000; --ink: #f3f1ec; --muted: rgba(243, 241, 236, .52); --faint: rgba(255, 255, 255, .08);
  --glass: rgba(16, 16, 19, .78); --accent: #a472ff; --ease: cubic-bezier(.22, 1, .36, 1);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; overscroll-behavior: none; }
body { font-family: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif; font-weight: 400; -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none; }
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
svg { width: 22px; height: 22px; display: block; }
code { font-size: .86em; background: var(--faint); padding: 1px 6px; border-radius: 6px; }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; transition: filter 1.4s var(--ease); padding: 9vh 0 13vh; box-sizing: border-box; }
body.naming #stage { padding: 4vh 0 44vh; }
#stage { transition: padding .9s var(--ease), filter 1.4s var(--ease); }
#stage [data-part] { cursor: pointer; }
#sparks { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
body.sleeping #stage { filter: brightness(.55) saturate(.8); }
#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 5; transition: opacity 1.6s ease-out; }
#flash.on { opacity: 1; transition: opacity .12s ease-in; }
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 3; overflow: hidden; }

.layer, .center-layer { position: fixed; inset: 0; pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .7s var(--ease), visibility 0s .7s; z-index: 4; }
.layer.show, .center-layer.show { opacity: 1; visibility: visible; transition: opacity .9s var(--ease); }
.center-layer { display: grid; place-content: center; justify-items: center; gap: 18px; text-align: center; padding: 24px; background: var(--bg); z-index: 20; }
.center-layer.show { pointer-events: auto; }
.center-layer p { color: var(--muted); letter-spacing: .08em; font-size: 14px; }
.loader-mark { width: 44px; height: 54px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: #f3f1ec; animation: breathe 1.8s ease-in-out infinite; box-shadow: 0 0 50px rgba(255, 255, 255, .25); }
@keyframes breathe { 50% { transform: translateY(-8px) scale(1.04); opacity: .8; } }

.btn { padding: 13px 22px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .06); font-weight: 500; letter-spacing: .01em; transition: transform .2s var(--ease), background .2s, opacity .2s; pointer-events: auto; }
.btn:hover { background: rgba(255, 255, 255, .12); }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .5; }
.btn.primary { background: var(--ink); color: #0a0a0a; border-color: transparent; }
.btn.primary:hover { background: #fff; }
.btn.primary svg path { fill: #0a0a0a; }
.btn.ghost { background: transparent; }
.btn.small { padding: 9px 16px; font-size: 14px; }
.btn.with-icon { display: inline-flex; align-items: center; gap: 10px; justify-content: center; }
.link-btn { color: var(--muted); font-size: 14px; padding: 12px 16px; pointer-events: auto; transition: color .2s; }
.link-btn:hover { color: var(--ink); }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); pointer-events: auto; transition: color .2s, background .2s, transform .2s var(--ease); }
.icon-btn:hover { color: var(--ink); background: var(--faint); }
.icon-btn:active { transform: scale(.9); }

/* Nacimiento */
#egg-ui { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; padding-bottom: calc(9vh + var(--safe-b)); }
.egg-hint { color: var(--muted); letter-spacing: .32em; text-transform: uppercase; font-size: 12px; animation: hint 2.6s ease-in-out infinite; min-height: 1.2em; }
@keyframes hint { 50% { opacity: .35; } }

/* Nombre */
#naming { display: flex; align-items: flex-end; justify-content: center; padding: 20px 20px calc(5vh + var(--safe-b)); }
.naming-card { width: min(420px, 100%); text-align: center; display: grid; gap: 14px; pointer-events: auto; }
.naming-card h1 { font-weight: 300; font-size: clamp(22px, 5vw, 30px); letter-spacing: .01em; }
.eyebrow { font-size: 11px; letter-spacing: .34em; text-transform: uppercase; color: var(--accent); }
.trait-chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.trait-chips li { font-size: 13px; padding: 6px 12px; border-radius: 999px; background: var(--faint); color: var(--muted); }
.trait-chips b { color: var(--ink); font-weight: 500; }
#naming-form { display: grid; gap: 12px; margin-top: 6px; }
#naming-input, .rename input { width: 100%; text-align: center; padding: 14px 18px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .04); outline: none; font-size: 18px; user-select: text; -webkit-user-select: text; transition: border-color .2s; }
#naming-input:focus, .rename input:focus { border-color: var(--accent); }

/* HUD */
.top { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: calc(14px + var(--safe-t)) 14px 0 18px; }
.who { display: grid; gap: 3px; text-align: left; pointer-events: auto; padding: 6px 8px 8px 4px; border-radius: 14px; transition: background .2s; }
.who:hover { background: rgba(255, 255, 255, .04); }
.pet-name { font-size: 22px; font-weight: 500; letter-spacing: .01em; }
.pet-sub { font-size: 12px; color: var(--muted); letter-spacing: .06em; }
.mini-bars { display: flex; gap: 5px; margin-top: 5px; }
.mini-bars i { --v: 50%; display: block; width: 30px; height: 3px; border-radius: 3px; background: linear-gradient(90deg, rgba(255, 255, 255, .85) var(--v), rgba(255, 255, 255, .14) var(--v)); transition: opacity .3s; }
.mini-bars i.low { background: linear-gradient(90deg, #ff7a6b var(--v), rgba(255, 255, 255, .14) var(--v)); animation: hint 1.6s infinite; }
.top-right { display: flex; align-items: center; gap: 2px; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, .2); margin-right: 6px; transition: background .4s; }
.sync-dot.ok { background: #57d99a; } .sync-dot.pending { background: #f2c14e; } .sync-dot.error { background: #ff7a6b; }
.mood-line { position: absolute; left: 0; right: 0; bottom: calc(112px + var(--safe-b)); text-align: center; font-size: 13px; letter-spacing: .08em; color: var(--muted); opacity: 0; transition: opacity .8s; }
.mood-line.on { opacity: 1; }
.dock { position: absolute; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 4px; padding: 8px; border-radius: 26px; background: var(--glass); border: 1px solid var(--faint); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); pointer-events: auto; }
.dock button { width: 62px; padding: 9px 0 7px; border-radius: 18px; display: grid; justify-items: center; gap: 4px; color: var(--muted); transition: color .2s, background .2s, transform .25s var(--ease); }
.dock button:hover { color: var(--ink); background: rgba(255, 255, 255, .06); }
.dock button:active { transform: scale(.9); }
.dock em { font-style: normal; font-size: 10px; letter-spacing: .04em; }
#hud.show .top { animation: drop .9s var(--ease) both; } #hud.show .dock { animation: rise .9s .15s var(--ease) both; }
@keyframes drop { from { opacity: 0; transform: translateY(-14px); } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 20px); } }

/* Paneles */
#sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); opacity: 0; pointer-events: none; transition: opacity .4s; z-index: 9; }
#sheet-backdrop.show { opacity: 1; pointer-events: auto; }
#sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 72vh; display: flex; flex-direction: column; background: var(--glass); border: 1px solid var(--faint); border-bottom: 0; border-radius: 26px 26px 0 0; backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); transform: translateY(105%); transition: transform .55s var(--ease); z-index: 10; padding-bottom: var(--safe-b); }
#sheet.show { transform: none; }
#sheet header { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 6px 22px; }
#sheet h2 { font-size: 17px; font-weight: 500; }
#sheet-body { overflow-y: auto; padding: 8px 22px 24px; display: grid; gap: 16px; -webkit-overflow-scrolling: touch; }
@media (min-width: 820px) {
  #sheet { left: auto; right: 24px; bottom: auto; top: 50%; width: 390px; max-height: 80vh; border-radius: 26px; border-bottom: 1px solid var(--faint); transform: translate(calc(100% + 40px), -50%); }
  #sheet.show { transform: translate(0, -50%); }
  #sheet-backdrop { background: transparent; }
}
.muted { color: var(--muted); font-size: 14px; line-height: 1.5; } .center { text-align: center; }
.warn { color: #ffb4a8; font-size: 13px; line-height: 1.5; }
.stat-head { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 7px; } .stat-head span:last-child { color: var(--muted); }
.bar { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .1); overflow: hidden; } .bar.thin { height: 4px; }
.bar i { display: block; height: 100%; border-radius: 6px; background: var(--ink); transition: width .6s var(--ease); }
.level-row { display: flex; gap: 14px; align-items: center; }
.level-badge { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; font-weight: 600; border: 1.5px solid var(--accent); box-shadow: 0 0 22px -6px var(--accent); }
.level-info { flex: 1; display: grid; gap: 6px; } .level-info small { color: var(--muted); font-size: 12px; } .level-info .bar i { background: var(--accent); }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.item { display: grid; justify-items: center; gap: 6px; padding: 16px 8px 12px; border-radius: 18px; background: rgba(255, 255, 255, .04); border: 1px solid var(--faint); transition: background .2s, transform .2s var(--ease); }
.item:hover { background: rgba(255, 255, 255, .09); } .item:active { transform: scale(.94); }
.item strong { font-weight: 500; font-size: 14px; } .item small { color: var(--muted); font-size: 12px; }
.item-dot { width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, var(--c) 55%); box-shadow: 0 0 18px -4px var(--c); }
.profile-head { display: grid; gap: 8px; justify-items: start; } .profile-head p { line-height: 1.45; }
.rarity { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; padding: 5px 12px; border-radius: 999px; border: 1px solid currentColor; }
.r-comun { color: #b9b9c2; } .r-poco_comun { color: #7fe0a6; } .r-raro { color: #6fb6ff; } .r-epico { color: #c592ff; } .r-legendario { color: #ffc94a; }
.tabs, .seg { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(255, 255, 255, .05); }
.tabs button, .seg button { flex: 1; padding: 8px 10px; border-radius: 999px; font-size: 13px; color: var(--muted); transition: background .2s, color .2s; }
.tabs button.on, .seg button.on { background: rgba(255, 255, 255, .13); color: var(--ink); }
.tab { display: none; } .tab.on { display: block; }
.timeline { list-style: none; padding: 0 0 0 16px; border-left: 1px solid rgba(255, 255, 255, .12); display: grid; gap: 16px; }
.timeline li { position: relative; display: grid; gap: 2px; } .timeline li::before { content: ''; position: absolute; left: -20px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.timeline time { font-size: 11px; color: var(--muted); letter-spacing: .05em; } .timeline.small span { font-size: 14px; }
.traits { display: grid; gap: 2px; } .traits div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--faint); font-size: 14px; }
.traits dt { color: var(--muted); } .traits dd { text-align: right; } .traits em { font-style: normal; font-size: 11px; margin-left: 6px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 44px; font-size: 15px; }
.row input[type=checkbox] { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 46px; height: 28px; border-radius: 999px; background: rgba(255, 255, 255, .14); position: relative; transition: background .25s; cursor: pointer; flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .3s var(--ease); }
input:checked + .switch { background: var(--accent); } input:checked + .switch::after { transform: translateX(18px); }
.seg { width: 200px; } .rename { gap: 10px; } .rename input { font-size: 15px; padding: 10px 14px; text-align: left; }
.account { display: grid; gap: 12px; } .account .btn { width: 100%; }
.choice { display: grid; gap: 10px; } .choice button { text-align: left; padding: 16px 18px; border-radius: 18px; background: rgba(255, 255, 255, .04); border: 1px solid var(--faint); display: grid; gap: 4px; transition: background .2s, transform .2s var(--ease); }
.choice button:hover { background: rgba(255, 255, 255, .09); } .choice button:active { transform: scale(.97); } .choice strong { font-weight: 500; } .choice small { color: var(--muted); font-size: 13px; }
.result { text-align: center; display: grid; gap: 10px; } .result .big { font-size: 46px; font-weight: 300; }

/* Juegos */
#game { z-index: 6; } #game.show #game-field, #game.show .orb, #game.show .pad { pointer-events: auto; }
.game-top { position: absolute; top: calc(18px + var(--safe-t)); left: 0; right: 0; display: flex; justify-content: center; gap: 18px; align-items: baseline; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
#game-score { font-size: 30px; color: var(--ink); letter-spacing: 0; min-width: 40px; text-align: center; }
#game-field { position: absolute; inset: 90px 0 90px; }
#game-quit { position: absolute; bottom: calc(22px + var(--safe-b)); left: 50%; transform: translateX(-50%); }
.orb { position: absolute; width: 58px; height: 58px; margin: -29px; border-radius: 50%; background: radial-gradient(circle, #fff 0, #ffe9a8 22%, rgba(255, 210, 90, .35) 48%, transparent 70%); transition: left .28s var(--ease), top .28s var(--ease); animation: orb 1.2s ease-in-out infinite; }
.orb.pop { animation: pop .3s var(--ease); }
@keyframes orb { 50% { transform: scale(1.18); } } @keyframes pop { 30% { transform: scale(1.7); opacity: .4; } }
.pad { --c: #fff; position: absolute; width: 74px; height: 74px; margin: -37px; border-radius: 50%; border: 1.5px solid var(--c); opacity: .5; transition: opacity .15s, box-shadow .15s, background .15s, transform .15s; }
.pad.on { opacity: 1; background: var(--c); box-shadow: 0 0 44px var(--c); transform: scale(1.1); } .pad.wrong { border-color: #ff5a4a; background: #ff5a4a; opacity: 1; }
.pad-0 { --c: #6fb6ff; left: 16%; top: 22%; } .pad-1 { --c: #ffd23f; left: 84%; top: 22%; } .pad-2 { --c: #7fe0a6; left: 16%; top: 78%; } .pad-3 { --c: #ff7ac8; left: 84%; top: 78%; }

/* Efectos */
.fx { position: absolute; transform: translate(-50%, -50%); animation: float 1.5s ease-out forwards; }
.fx-heart { color: #ff8fb0; } .fx-heart svg { width: 22px; height: 22px; filter: drop-shadow(0 0 8px rgba(255, 143, 176, .7)); }
.fx-zzz { color: var(--muted); font-size: 22px; font-weight: 300; animation-duration: 2.6s; } .fx-star { color: var(--accent); font-size: 20px; text-shadow: 0 0 12px var(--accent); }
@keyframes float { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.5); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px)), -150px) scale(1.15); } }
#toasts { position: fixed; top: calc(84px + var(--safe-t)); left: 0; right: 0; display: grid; justify-items: center; gap: 8px; pointer-events: none; z-index: 30; padding: 0 16px; }
.toast { max-width: 440px; padding: 11px 18px; border-radius: 18px; background: var(--glass); border: 1px solid var(--faint); backdrop-filter: blur(16px); font-size: 14px; line-height: 1.4; text-align: center; opacity: 0; transform: translateY(-8px); transition: opacity .4s, transform .4s var(--ease); }
.toast.show { opacity: 1; transform: none; }
@media (max-width: 380px) { .dock button { width: 56px; } }
@media (prefers-reduced-motion: reduce) { .egg-hint, .mini-bars i.low, .loader-mark { animation: none; } }
