/* TAMA RETRO — оформление. Мобильный экран — основной, ПК — тот же макет по центру. */
:root {
  --bg1: #ffe3ee; --bg2: #e3e1ff; --card: #ffffff; --ink: #3b2d40; --soft: #8c7a92;
  --pink: #ff6fa8; --pink2: #ffb3cf; --yellow: #ffd43b; --green: #5fd38d; --blue: #6cb8ff;
  --red: #ff5c6c; --shadow: 0 6px 0 rgba(59, 45, 64, .12), 0 10px 24px rgba(120, 60, 120, .12);
  --r: 22px;
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  color: var(--ink); background: linear-gradient(160deg, var(--bg1), var(--bg2)) fixed;
  overscroll-behavior: none; user-select: none; -webkit-user-select: none;
}
/* мягкие пузырьки на фоне */
body::before, body::after { content: ""; position: fixed; z-index: -1; border-radius: 50%; filter: blur(2px); pointer-events: none; }
body::before { width: 260px; height: 260px; left: -80px; top: 12%; background: radial-gradient(circle at 35% 35%, #fff8, #ffb3cf55 60%, transparent 70%); animation: floaty 14s ease-in-out infinite; }
body::after { width: 320px; height: 320px; right: -110px; bottom: 6%; background: radial-gradient(circle at 35% 35%, #fff8, #b7a8ff55 60%, transparent 70%); animation: floaty 18s ease-in-out infinite reverse; }
@keyframes floaty { 50% { transform: translate(30px, -40px) scale(1.08); } }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#app { max-width: 480px; margin: 0 auto; min-height: 100%; padding: max(10px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); position: relative; }
.screen { display: flex; flex-direction: column; gap: 10px; }
#main { min-height: calc(100dvh - max(10px, env(safe-area-inset-top)) - max(12px, env(safe-area-inset-bottom))); }

/* ---------- старт ---------- */
.start-head { text-align: center; margin-top: 6px; }
.logo { margin: 0; font-size: 44px; animation: logoBob 3s ease-in-out infinite; letter-spacing: 2px; color: var(--pink); text-shadow: 0 3px 0 #fff, 0 6px 0 rgba(59,45,64,.15); }
.logo span { color: #8b7cff; font-size: 22px; margin-left: 6px; vertical-align: middle; }
.sub { margin: 2px 0 0; color: var(--soft); font-weight: 700; }
.animal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.animal-card { background: linear-gradient(180deg, #fff, #fff6fb); border: 3px solid transparent; border-radius: 18px; padding: 4px 4px 6px; box-shadow: var(--shadow); text-align: center; font-weight: 800; font-size: 13px; transition: transform .15s; }
.animal-card canvas { width: 100%; aspect-ratio: 1; display: block; }
.animal-card[aria-selected="true"] { border-color: var(--pink); transform: translateY(-3px); background: #fff4f9; }
.name-field { display: flex; flex-direction: column; gap: 6px; font-weight: 800; }
.name-field input { font: inherit; font-size: 18px; padding: 12px 14px; border-radius: 16px; border: 3px solid #fff; background: #fff; box-shadow: var(--shadow); user-select: text; -webkit-user-select: text; }
.big-btn { position: relative; overflow: hidden; border: 0; border-radius: 20px; padding: 14px 18px; font-size: 19px; font-weight: 900; background: linear-gradient(180deg, #ff8fbd, var(--pink)); color: #fff; box-shadow: 0 6px 0 #d94f8a, 0 10px 20px rgba(255,111,168,.35); }
.big-btn::after { content: ""; position: absolute; top: 0; left: -60%; width: 40%; height: 100%; background: linear-gradient(100deg, transparent, rgba(255,255,255,.45), transparent); animation: shine 3.2s infinite; }
@keyframes shine { 0%, 60% { left: -60%; } 100% { left: 130%; } }
.big-btn:disabled { background: #cfc4d4; box-shadow: 0 6px 0 #a99fb0; }
.big-btn:disabled::after { display: none; }
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #d94f8a; }
.small-btn { border: 0; border-radius: 14px; padding: 8px 14px; font-weight: 800; background: var(--pink); color: #fff; box-shadow: 0 4px 0 #d94f8a; }
.small-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #d94f8a; }
.small-btn:disabled { background: #cfc4d4; box-shadow: 0 4px 0 #a99fb0; cursor: default; }
.link-btn { border: 0; background: none; color: var(--soft); text-decoration: underline; font-weight: 700; }
.hint { text-align: center; color: var(--soft); font-size: 13px; margin: 0; }

/* ---------- верхняя панель ---------- */
.topbar { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 42px; height: 42px; flex: none; border: 0; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); font-size: 20px; font-weight: 900; }
.icon-btn:active { transform: translateY(3px); }
.pet-title { flex: 1; min-width: 0; }
.pet-name { font-size: 20px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pet-meta { font-size: 12px; color: var(--soft); font-weight: 700; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; background: #8b7cff; color: #fff; font-weight: 800; }
.coins { border: 0; border-radius: 99px; padding: 8px 12px; background: #fff7d1; box-shadow: var(--shadow); font-weight: 900; font-size: 16px; }
.coins.bump { animation: bump .5s; }
@keyframes bump { 40% { transform: scale(1.25); } }

/* ---------- шкалы ---------- */
.bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 10px; background: var(--card); border-radius: var(--r); padding: 10px 12px; box-shadow: var(--shadow); }
.bar { display: flex; align-items: center; gap: 5px; font-size: 15px; }
.bar-track { flex: 1; height: 10px; border-radius: 99px; background: #f0e8f2; overflow: hidden; }
.bar-fill { position: relative; height: 100%; border-radius: 99px; transition: width .6s, background-color .6s; box-shadow: inset 0 -3px 0 rgba(0,0,0,.08); }
.bar-fill::after { content: ""; position: absolute; left: 4px; right: 4px; top: 2px; height: 3px; border-radius: 99px; background: rgba(255,255,255,.55); }
.bar.low span { display: inline-block; animation: wiggle 1.2s infinite; }
.bar.low .bar-fill { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* ---------- сцена ---------- */
.stage-wrap { position: relative; flex: 1 1 auto; min-height: 270px; max-height: 520px; border-radius: 28px; overflow: hidden; background: #ffe9d6; border: 5px solid #fff; box-shadow: 0 0 0 3px #ffc6dc, var(--shadow); }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: manipulation; }
.bubble { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); max-width: 80%; background: #fff; padding: 8px 14px; border-radius: 18px; font-weight: 800; font-size: 15px; box-shadow: 0 4px 0 rgba(59,45,64,.15); text-align: center; animation: pop .25s; pointer-events: none; }
.bubble::after { content: ""; position: absolute; bottom: -8px; left: 50%; margin-left: -8px; border: 8px solid transparent; border-top-color: #fff; border-bottom: 0; }
@keyframes pop { from { transform: translateX(-50%) scale(.6); opacity: 0; } }
.gift { position: absolute; right: 10px; top: 10px; border: 0; background: #fff; width: 48px; height: 48px; border-radius: 16px; font-size: 28px; box-shadow: var(--shadow); animation: wiggle 1.4s infinite; }
@keyframes wiggle { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(-12deg); } 80% { transform: rotate(12deg); } 90% { transform: rotate(-6deg); } }
.away, .dead { position: absolute; inset: auto 12px 12px 12px; background: rgba(255,255,255,.92); border-radius: 20px; padding: 12px; text-align: center; font-weight: 800; box-shadow: var(--shadow); }
.away-icon { font-size: 30px; }
.away-timer { font-size: 28px; font-variant-numeric: tabular-nums; color: #8b7cff; margin: 2px 0 8px; }
.dead { inset: auto 12px 12px 12px; }
.dead-title { font-size: 18px; }
.dead-reason { color: var(--soft); margin: 6px 0 2px; }
.dead-age { color: var(--soft); font-size: 13px; margin-bottom: 10px; }

/* ---------- кнопки действий ---------- */
.actions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.act { position: relative; border: 0; border-radius: 16px; background: linear-gradient(180deg, #fff 0%, #fff6fb 100%); padding: 7px 1px 6px; box-shadow: 0 5px 0 rgba(59,45,64,.12); display: flex; flex-direction: column; align-items: center; gap: 1px; font-weight: 800; font-size: 11px; min-height: 60px; transition: transform .1s; }
.act .ico { font-size: 25px; line-height: 1.15; filter: drop-shadow(0 2px 0 rgba(59,45,64,.15)); transition: transform .2s; }
.act:hover .ico { transform: translateY(-2px) rotate(-6deg); }
.act:active .ico { transform: scale(.88); }
.act:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(59,45,64,.12); }
.act.dim { opacity: .45; }
.act.need::after { content: "!"; position: absolute; top: -5px; right: -3px; width: 22px; height: 22px; border-radius: 50%; background: var(--red); color: #fff; font-size: 14px; line-height: 22px; animation: bump 1s infinite; }

/* ---------- панель ---------- */
.sheet-back { position: fixed; inset: 0; background: rgba(40, 20, 50, .35); z-index: 20; }
.sheet { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(480px, 100%); max-height: 82vh; background: #fff; border-radius: 26px 26px 0 0; z-index: 21; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); animation: slideUp .22s ease-out; }
@keyframes slideUp { from { transform: translate(-50%, 40%); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.sheet-head h2 { margin: 0; font-size: 21px; }
.sheet-head .icon-btn { box-shadow: none; background: #f4eef6; }
.sheet-body { overflow-y: auto; padding: 6px 16px 18px; }
.list { display: grid; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px; background: #faf6fb; border: 0; width: 100%; text-align: left; }
button.row:active { transform: scale(.98); }
.row .ico { font-size: 30px; width: 40px; text-align: center; flex: none; }
.row .txt { flex: 1; min-width: 0; }
.row .ttl { font-weight: 900; display: block; }
.row .dsc { font-size: 13px; color: var(--soft); display: block; }
.row .price { font-weight: 900; white-space: nowrap; }
.row.off { opacity: .5; }
.row.on { background: #eafaf0; outline: 2px solid var(--green); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { border: 0; border-radius: 16px; background: #faf6fb; padding: 10px 6px; text-align: center; font-weight: 800; font-size: 13px; }
.tile .ico { font-size: 30px; display: block; }
.tile.on { background: #eafaf0; outline: 2px solid var(--green); }
.tile.locked { opacity: .45; }
.section-title { font-weight: 900; margin: 14px 0 6px; color: var(--soft); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
.help p { margin: 6px 0; line-height: 1.45; }
.help b { color: var(--pink); }
.stat-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.stat-table td { padding: 5px 2px; border-bottom: 1px solid #f0e8f2; }
.stat-table td:last-child { text-align: right; font-weight: 800; }

/* ---------- мини-игра ---------- */
.game-view { position: fixed; inset: 0; z-index: 30; background: linear-gradient(160deg, #fff1e0, #ffe0ef); display: flex; flex-direction: column; max-width: 480px; margin: 0 auto; padding: max(10px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); }
.game-head { display: flex; align-items: center; gap: 10px; }
.game-title { flex: 1; font-weight: 900; font-size: 19px; }
.game-hud { font-weight: 900; font-size: 16px; background: #fff; border-radius: 99px; padding: 6px 12px; box-shadow: var(--shadow); }
.game-area { flex: 1; position: relative; margin: 10px 0; border-radius: 24px; overflow: hidden; background: #fff; box-shadow: var(--shadow); touch-action: none; }
.game-area canvas { width: 100%; height: 100%; display: block; }
.game-controls { display: flex; gap: 10px; }
.game-controls button { flex: 1; border: 0; border-radius: 18px; padding: 16px 0; font-size: 22px; font-weight: 900; background: #fff; box-shadow: 0 5px 0 rgba(59,45,64,.15); }
.game-controls button:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(59,45,64,.15); }
.overlay-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 20px; background: rgba(255,255,255,.88); font-weight: 800; }
.overlay-msg .big { font-size: 26px; font-weight: 900; }
.memory { position: absolute; inset: 0; background: #fff0f6; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 12px; align-content: center; }
.card { aspect-ratio: 3 / 4; border: 0; border-radius: 14px; font-size: 34px; perspective: 400px; background: transparent; padding: 0; }
.card-in { position: relative; width: 100%; height: 100%; transition: transform .35s; transform-style: preserve-3d; }
.card.open .card-in { transform: rotateY(180deg); }
.card-face { position: absolute; inset: 0; border-radius: 14px; display: flex; align-items: center; justify-content: center; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 4px 0 rgba(59,45,64,.15); }
.card-back { background: repeating-linear-gradient(45deg, #ff8fbd 0 10px, #ff6fa8 10px 20px); }
.card-front { background: #fff; transform: rotateY(180deg); }
.card.done .card-front { background: #eafaf0; }

/* ---------- обучение ---------- */
.tour { position: fixed; inset: 0; z-index: 40; }
.tour-hole { position: fixed; border-radius: 20px; box-shadow: 0 0 0 9999px rgba(40, 20, 50, .62); transition: all .3s; pointer-events: none; border: 3px solid var(--yellow); }
.tour-card { position: fixed; left: 50%; transform: translateX(-50%); width: min(440px, calc(100% - 24px)); background: #fff; border-radius: 20px; padding: 14px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-weight: 700; line-height: 1.45; transition: top .3s; }
.tour-card b { color: var(--pink); }
.tour-nav { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 8px; }
#tourStep { color: var(--soft); font-size: 13px; }

/* ---------- уведомления ---------- */
.toasts { position: fixed; left: 50%; top: 10px; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 6px; width: min(440px, calc(100% - 24px)); pointer-events: none; }
.toast { background: #3b2d40; color: #fff; padding: 10px 14px; border-radius: 16px; font-weight: 800; box-shadow: 0 6px 18px rgba(0,0,0,.2); animation: toastIn .25s ease-out; }
.toast.good { background: #2f9e62; }
.toast.bad { background: #d6455a; }
.toast.gold { background: linear-gradient(90deg, #f59f00, #fcc419); color: #3b2d40; }
@keyframes toastIn { from { transform: translateY(-20px); opacity: 0; } }

@media (min-width: 520px) { #app { padding-top: 24px; } }
@media (max-height: 700px) { .act { min-height: 56px; } .act .ico { font-size: 22px; } .bars { padding: 8px 10px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@keyframes logoBob { 50% { transform: translateY(-4px) rotate(-1deg); } }

/* ---------- комнаты, вкладки, задания, наклейки ---------- */
.rooms { display: flex; gap: 6px; }
.room-tab { flex: 1; border: 0; border-radius: 14px; padding: 7px 4px; background: rgba(255,255,255,.65); font-weight: 800; font-size: 13px; box-shadow: 0 3px 0 rgba(59,45,64,.1); }
.room-tab.on { background: #fff; box-shadow: 0 3px 0 rgba(59,45,64,.15), inset 0 -3px 0 var(--pink); }
.tabs { display: flex; gap: 6px; margin-bottom: 6px; }
.tab { flex: 1; border: 0; border-radius: 12px; padding: 9px; background: #f4eef6; font-weight: 800; }
.tab.on { background: var(--pink); color: #fff; }
.qbar { display: block; height: 8px; border-radius: 99px; background: #f0e8f2; margin: 5px 0 2px; overflow: hidden; }
.qbar span { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.row .small-btn { flex: none; }
.stickers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sticker { background: #f4eef6; border-radius: 14px; padding: 8px 2px; text-align: center; filter: grayscale(1); opacity: .5; }
.sticker span { font-size: 30px; display: block; }
.sticker small { font-size: 10px; font-weight: 700; }
.sticker.got { filter: none; opacity: 1; background: #fff4d6; box-shadow: 0 3px 0 rgba(59,45,64,.1); }
@media (max-width: 360px) { .act { font-size: 10px; } .act .ico { font-size: 22px; } .room-tab { font-size: 12px; } }
