/* Томо: экран питомца. Все стили под префиксом tm-, внешних файлов нет. */

.tm { position: relative; padding-bottom: 12px; color: #e4e8f0; }

/* ===== Сцена ===== */
.tm-stage {
  position: relative;
  height: 330px;
  border-radius: 22px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 90%, #1e2a4a 0%, #0d1220 72%);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.tm-stars {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, #fff, transparent),
    radial-gradient(1px 1px at 60% 70%, #fff, transparent),
    radial-gradient(2px 2px at 80% 20%, #fff, transparent),
    radial-gradient(1px 1px at 40% 80%, #fff, transparent);
  background-size: 300px 300px;
  opacity: 0.7;
  animation: tm-twinkle 3s ease-in-out infinite;
}
@keyframes tm-twinkle { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.9; } }
.tm-dim {
  position: absolute; inset: 0;
  background: rgba(5, 5, 25, 0.5);
  opacity: 0; transition: opacity 0.8s;
  pointer-events: none; z-index: 1;
}
.tm-dim.show { opacity: 1; }
.tm-moon {
  position: absolute; top: 16px; right: 24px;
  font-size: 30px; opacity: 0; transition: opacity 0.8s; z-index: 1;
}
.tm-moon.show { opacity: 1; }
.tm-ground {
  position: absolute; bottom: -10px; left: 50%;
  transform: translateX(-50%);
  width: 260px; height: 70px; border-radius: 50%; z-index: 1;
}
.tm-ground.neutral { background: radial-gradient(ellipse closest-side, rgba(110, 168, 254, 0.55), transparent 75%); }
.tm-ground.angel { background: radial-gradient(ellipse closest-side, rgba(255, 215, 0, 0.6), transparent 75%); }
.tm-ground.demon { background: radial-gradient(ellipse closest-side, rgba(255, 50, 50, 0.6), transparent 75%); }

.tm-area {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center;
  padding-bottom: 18px;
}
.tm-name-row {
  display: inline-flex; align-items: center; gap: 8px;
  margin-bottom: 6px; padding: 4px 10px;
  background: transparent; border: 0; color: inherit; font: inherit; cursor: pointer;
}
.tm-name { font-size: 20px; font-weight: 800; }
.tm-edit { font-size: 13px; opacity: 0.55; }

.tm-mascot {
  position: relative;
  display: flex; align-items: flex-end; justify-content: center;
  transform-origin: bottom center;
  will-change: transform;
  min-height: 165px;
}
.tm-mascot.sleeping { animation: tm-breathe 2.5s ease-in-out infinite; }
.tm-mascot.eating { animation: tm-munch 0.45s ease-in-out 5; }
.tm-mascot.playing { animation: tm-jump 1.25s ease-in-out 2; }
.tm-mascot.petted { animation: tm-wiggle 0.7s ease-in-out; }
.tm-mascot.egg { animation: tm-egg 1.8s ease-in-out infinite; }
@keyframes tm-breathe { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.04) rotate(-2deg); } }
@keyframes tm-munch { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06, 0.94); } }
@keyframes tm-jump {
  0%, 55%, 100% { transform: translateY(0) rotate(0); }
  20% { transform: translateY(-30px) rotate(-6deg); }
  35% { transform: translateY(0) scale(1.05, 0.9); }
  70% { transform: translateY(-22px) rotate(6deg); }
  85% { transform: translateY(0) scale(1.05, 0.9); }
}
@keyframes tm-wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
@keyframes tm-egg { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }

.tm-shadow {
  position: absolute; bottom: -10px; left: 50%;
  transform: translateX(-50%);
  width: 150px; height: 48px;
  background: radial-gradient(ellipse closest-side, rgba(0, 0, 0, 0.6), transparent 75%);
  border-radius: 50%;
}
.tm-aura {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 300px; height: 300px;
  border-radius: 50%; pointer-events: none; opacity: 0.6;
}
.tm-aura.neutral { background: radial-gradient(circle, rgba(110, 168, 254, 0.4) 0%, transparent 70%); }
.tm-aura.angel { background: radial-gradient(circle, rgba(255, 215, 0, 0.5) 0%, transparent 70%); }
.tm-aura.demon { background: radial-gradient(circle, rgba(255, 50, 50, 0.5) 0%, transparent 70%); }
.tm-mascot svg { position: relative; z-index: 1; display: block; }

/* Анимации внутри SVG */
.tm-svg-anim { transform-box: fill-box; transform-origin: center; }
.tm-chew { animation: tm-chew 0.45s ease-in-out infinite; }
@keyframes tm-chew { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(0.35); } }
.tm-pizza { animation: tm-pizza 2.4s ease-in forwards; }
@keyframes tm-pizza {
  0% { transform: scale(1); opacity: 1; }
  60% { transform: scale(0.45) rotate(6deg); }
  100% { transform: scale(0); opacity: 0; }
}
.tm-crumb { animation: tm-crumb 0.8s ease-in forwards; opacity: 0; animation-delay: 0.5s; }
.tm-crumb.tm-d2 { animation-delay: 1.1s; }
.tm-crumb.tm-d3 { animation-delay: 1.7s; }
@keyframes tm-crumb {
  0% { transform: translate(0, 0); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(-6px, 30px); opacity: 0; }
}
.tm-zzz { animation: tm-zzz 2.2s ease-out infinite; opacity: 0; }
.tm-zzz.tm-d1 { animation-delay: 0.6s; }
.tm-zzz.tm-d2 { animation-delay: 1.2s; }
@keyframes tm-zzz {
  0% { transform: translate(0, 0) scale(0.6); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: translate(18px, -45px) scale(1.2); opacity: 0; }
}
.tm-ball { animation: tm-ball 0.6s cubic-bezier(0.5, 0, 0.5, 1) infinite alternate; }
@keyframes tm-ball {
  0% { transform: translateY(0) scale(1.1, 0.9); }
  100% { transform: translateY(-55px) scale(0.95, 1.05); }
}
.tm-heart { animation: tm-heart 1.1s ease-out forwards; opacity: 0; }
.tm-heart.tm-d1 { animation-delay: 0.4s; }
.tm-heart.tm-d2 { animation-delay: 0.8s; }
@keyframes tm-heart {
  0% { transform: translate(0, 0) scale(0.4); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translate(8px, -55px) scale(1.2); opacity: 0; }
}
.tm-hand { animation: tm-hand 0.7s ease-in-out 2; }
@keyframes tm-hand {
  0%, 100% { transform: translate(-14px, 2px) rotate(-12deg); }
  50% { transform: translate(14px, -2px) rotate(12deg); }
}
.tm-sparkle { animation: tm-sparkle 0.9s ease-out forwards; opacity: 0; }
.tm-sparkle.tm-d1 { animation-delay: 0.3s; }
.tm-sparkle.tm-d2 { animation-delay: 0.6s; }
.tm-sparkle.tm-d3 { animation-delay: 0.9s; }
@keyframes tm-sparkle {
  0% { transform: scale(0) rotate(0); opacity: 0; }
  40% { transform: scale(1.3) rotate(90deg); opacity: 1; }
  100% { transform: scale(0.5) rotate(180deg); opacity: 0; }
}

/* ===== Значки ===== */
.tm-badges { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; justify-content: center; padding: 0 8px; }
.tm-badge {
  padding: 5px 10px; border-radius: 14px;
  font-size: 11px; font-weight: 700;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.tm-badge.level { background: linear-gradient(135deg, #6ea8fe, #a78bfa); border: 0; }
.tm-badge.power b { color: #ffd700; font-weight: 700; }
.tm-badge.luck b { color: #4ade80; font-weight: 700; }
.tm-badge.warn { background: rgba(255, 100, 100, 0.25); border-color: rgba(255, 100, 100, 0.5); }

/* ===== Тело экрана ===== */
.tm-body { padding: 14px 2px 0; }
.tm-wallet {
  display: flex; justify-content: space-between; gap: 6px;
  padding: 10px 12px; margin-bottom: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px; font-weight: 700;
}
.tm-wallet span { white-space: nowrap; }
.tm-xp { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; margin: -4px 4px 12px; }
.tm-xp i { display: block; height: 100%; background: linear-gradient(90deg, #6ea8fe, #a78bfa); transition: width 0.5s; }

.tm-need { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.tm-need-ico {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 17px;
}
.tm-need-ico.mood { background: rgba(255, 180, 50, 0.2); }
.tm-need-ico.energy { background: rgba(100, 200, 255, 0.2); }
.tm-need-ico.hunger { background: rgba(255, 100, 100, 0.2); }
.tm-need-info { flex: 1; }
.tm-need-name {
  display: flex; justify-content: space-between;
  font-size: 11px; font-weight: 600; color: rgba(255, 255, 255, 0.8); margin-bottom: 4px;
}
.tm-bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.tm-bar i { display: block; height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.tm-bar i.mood { background: linear-gradient(90deg, #ffb432, #ffd700); }
.tm-bar i.energy { background: linear-gradient(90deg, #64c8ff, #a78bfa); }
.tm-bar i.hunger { background: linear-gradient(90deg, #ff6464, #ff9966); }

.tm-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0 18px; }
.tm-act, .tm-menu-btn {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 12px 4px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: inherit; font: inherit; cursor: pointer; user-select: none;
  transition: transform 0.15s, background 0.2s, border-color 0.2s;
}
.tm-act:active, .tm-menu-btn:active { transform: scale(0.94); }
.tm-act:disabled { opacity: 0.5; cursor: default; }
.tm-act .i, .tm-menu-btn .i { font-size: 23px; line-height: 1; }
.tm-act .l, .tm-menu-btn .l { font-size: 11px; font-weight: 600; }
.tm-menu-btn { position: relative; background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.08); }
.tm-menu-btn .l { font-size: 10px; color: rgba(255, 255, 255, 0.85); }
.tm-menu-btn .dot {
  position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: #ff6464; font-size: 9px; font-weight: 700;
  display: grid; place-items: center;
}
.tm-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.6); margin: 0 2px 10px;
}
.tm-menu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

/* ===== Яйцо ===== */
.tm-egg-wrap { text-align: center; padding: 8px 4px 0; }
.tm-egg-wrap h2 { margin: 14px 0 6px; font-size: 20px; }
.tm-egg-wrap p { margin: 0 0 14px; color: rgba(255, 255, 255, 0.7); font-size: 13px; line-height: 1.45; }
.tm-input {
  width: 100%; padding: 14px; border-radius: 12px; margin-bottom: 12px; outline: none;
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff; font: inherit; font-size: 16px; font-weight: 600; box-sizing: border-box;
}

/* ===== Кнопки ===== */
.tm-btn {
  width: 100%; padding: 13px; margin-bottom: 8px; border-radius: 12px; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 700; color: #fff; border: 0;
  background: linear-gradient(135deg, #6ea8fe, #a78bfa);
}
.tm-btn.gold { background: rgba(255, 215, 0, 0.15); border: 1px solid rgba(255, 215, 0, 0.4); color: #ffd700; }
.tm-btn.red { background: rgba(255, 100, 100, 0.15); border: 1px solid rgba(255, 100, 100, 0.3); color: #ff6464; font-weight: 600; }
.tm-btn:disabled { opacity: 0.45; cursor: default; }

/* ===== Окна ===== */
.tm-modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.tm-modal.show { opacity: 1; pointer-events: auto; }
.tm-sheet {
  width: 100%; max-width: 480px; max-height: 85vh; overflow-y: auto;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  border-radius: 24px 24px 0 0; box-sizing: border-box;
  background: #141a2e; border: 1px solid rgba(255, 255, 255, 0.1);
  transform: translateY(100%); transition: transform 0.3s;
}
.tm-modal.show .tm-sheet { transform: translateY(0); }
.tm-sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.tm-sheet-head h3 { margin: 0; font-size: 18px; }
.tm-close {
  width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, 0.1); color: #fff; font-size: 15px;
}
.tm-chips {
  padding: 10px 14px; margin-bottom: 12px; border-radius: 12px; text-align: center;
  background: rgba(255, 215, 0, 0.1); border: 1px solid rgba(255, 215, 0, 0.3);
  font-size: 13px; font-weight: 700; color: #ffd700;
}
.tm-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.tm-slot {
  position: relative; min-height: 76px; padding: 10px 4px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: rgba(255, 255, 255, 0.04); border: 2px dashed rgba(255, 255, 255, 0.15);
  color: inherit; font: inherit; cursor: pointer;
}
.tm-slot.sel { border-color: #6ea8fe; background: rgba(110, 168, 254, 0.15); }
.tm-slot.filled { border-style: solid; }
.tm-slot .i { font-size: 24px; }
.tm-slot .n { font-size: 9px; font-weight: 600; color: rgba(255, 255, 255, 0.75); }
.tm-slot .k { position: absolute; top: 3px; left: 6px; font-size: 7px; text-transform: uppercase; color: rgba(255, 255, 255, 0.4); }

.tm-list { display: grid; gap: 8px; }
.tm-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px; border-radius: 12px; border: 2px solid transparent; box-sizing: border-box;
  background: rgba(255, 255, 255, 0.06); color: inherit; font: inherit; cursor: pointer;
}
.tm-row.static { cursor: default; }
.tm-row .i { font-size: 24px; flex-shrink: 0; width: 34px; text-align: center; }
.tm-row .b { flex: 1; min-width: 0; }
.tm-row .t { font-size: 13px; font-weight: 600; }
.tm-row .t em { font-style: normal; color: #ffd700; font-size: 10px; }
.tm-row .s { font-size: 11px; color: #4ade80; margin-top: 2px; }
.tm-row .s.mut { color: rgba(255, 255, 255, 0.6); }
.tm-row .r { font-size: 11px; font-weight: 700; white-space: nowrap; color: #ffd700; }
.tm-row .r.blue { color: #6ea8fe; }
.tm-row.dim { opacity: 0.55; }
.tm-row.none { border: 2px dashed rgba(255, 255, 255, 0.15); }
.tm-r-common { border-color: #555; }
.tm-r-rare { border-color: #6ea8fe; }
.tm-r-epic { border-color: #a78bfa; }
.tm-r-legendary { border-color: #ffd700; }
.tm-slot.tm-r-common { border-color: #888; }

.tm-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
.tm-stat { display: flex; align-items: center; gap: 10px; padding: 11px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); }
.tm-stat .i { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; background: rgba(110, 168, 254, 0.15); }
.tm-stat .n { font-size: 11px; color: rgba(255, 255, 255, 0.7); }
.tm-stat .v { font-size: 15px; font-weight: 700; }
.tm-stat .v small { color: #4ade80; font-size: 10px; font-weight: 700; }
.tm-set { padding: 11px; margin-bottom: 8px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.08); display: flex; gap: 10px; align-items: center; }
.tm-set.on { border-color: #4ade80; background: rgba(74, 222, 128, 0.1); }
.tm-set .i { font-size: 24px; }
.tm-set .b { flex: 1; }
.tm-set .t { font-size: 13px; font-weight: 600; }
.tm-set .d { font-size: 11px; color: rgba(255, 255, 255, 0.6); }
.tm-set .g { font-size: 10px; font-weight: 700; color: #4ade80; }
.tm-set .st { font-size: 10px; font-weight: 700; color: rgba(255, 255, 255, 0.4); }
.tm-set.on .st { color: #4ade80; }

.tm-card { padding: 16px; margin-bottom: 14px; border-radius: 14px; text-align: center; background: rgba(255, 255, 255, 0.06); }
.tm-card .big { font-size: 48px; margin-bottom: 6px; }
.tm-card .nm { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.tm-card .nm em { font-style: normal; color: #ffd700; }
.tm-card .rr { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.tm-card .st { font-size: 13px; font-weight: 600; color: #4ade80; margin-bottom: 8px; }
.tm-card .ds { font-size: 12px; color: rgba(255, 255, 255, 0.6); font-style: italic; }
.tm-note { font-size: 11px; color: rgba(255, 255, 255, 0.55); line-height: 1.4; margin: 10px 2px 0; }

.tm-toast {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%) translateY(-20px);
  max-width: calc(100% - 32px); padding: 11px 20px; border-radius: 22px; z-index: 90;
  background: rgba(110, 168, 254, 0.95); color: #fff; font-size: 14px; font-weight: 700;
  opacity: 0; transition: all 0.3s; pointer-events: none; text-align: center;
}
.tm-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.tm-toast.lucky { background: rgba(74, 222, 128, 0.95); }
.tm-toast.bad { background: rgba(255, 100, 100, 0.95); }

@media (prefers-reduced-motion: reduce) {
  .tm *, .tm-modal * { animation: none !important; transition: none !important; }
}

/* ---- Редактор Томо в панели создателя (.ot-*) ---- */
.owner-tomo-root { display: flex; flex-direction: column; gap: 10px; padding-bottom: 24px; }
.ot-box { display: flex; flex-direction: column; gap: 10px; }
.ot-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ot-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ot-field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; opacity: 0.95; }
.ot-field span { color: var(--muted, #8b93a7); }
.ot-check { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.ot-h { margin: 6px 2px 0; font-size: 15px; }
.ot-row { width: 100%; text-align: left; }
.ot-slot h4 { margin: 10px 2px 6px; font-size: 13px; opacity: 0.8; }
.ot-item { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 10px; margin-bottom: 6px;
  border-radius: 12px; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.07); }
.ot-item.is-owned { border-color: rgba(120, 220, 160, 0.45); }
.ot-item .info { flex: 1 1 140px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ot-item .info span { font-size: 12px; opacity: 0.7; }
.ot-item .row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ot-ico { font-size: 22px; line-height: 1; }
.ot-star { width: auto; min-width: 84px; padding: 4px 6px; }
.ot-def { flex: 1 1 100%; display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.ot-resets { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }

.tm-event { margin: 8px 0; padding: 8px 12px; border-radius: 12px; font-size: 13px; text-align: center;
  background: rgba(255, 214, 90, 0.12); border: 1px solid rgba(255, 214, 90, 0.35); color: #ffe08a; }
.tm-event[hidden] { display: none; }
