* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-color: #1a1a2e;
    --bg-gradient: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f0f23 100%);
    --card-bg: rgba(22, 33, 62, 0.8);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-color: #eaeaea;
    --text-muted: #a0a0a0;
    --accent-color: #e94560;
    --success-color: #4ecca3;
    --warning-color: #ffc107;
    --hunger-color: #ff6b6b;
    --mood-color: #ffd93d;
    --energy-color: #6bcb77;
    --glow-color: rgba(233, 69, 96, 0.3);
    --tg-viewport-height: 100vh;
    --tg-header-height: 0px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 420px;
    margin: 0 auto;
    padding: 16px;
    padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
    min-height: var(--tg-viewport-height, 100vh);
}

/* Динамическая высота viewport для мобильных */
@supports (height: 100dvh) {
    .container {
        min-height: 100dvh;
    }
}

/* Telegram Mini App полноэкранный режим */
body.tg-fullscreen .container {
    padding-top: calc(env(safe-area-inset-top, 20px) + 30px);
}

/* Обычный режим Mini App (с заголовком Telegram) */
body:not(.tg-fullscreen) .container {
    padding-top: 16px;
}

.hidden {
    display: none !important;
}

/* ==================== Кнопка меню ==================== */
.app {
    position: relative;
}

.menu-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 20;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    transition: background 0.2s;
}

.menu-btn:hover,
.menu-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

.menu-btn-bar {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-color);
    border-radius: 1px;
}

/* ==================== Полноэкранное меню ==================== */
.menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: var(--bg-gradient);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    padding-top: calc(env(safe-area-inset-top, 0px) + 24px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.menu-overlay.open {
    opacity: 1;
    visibility: visible;
}

.menu-overlay.hidden {
    display: none !important;
}

.menu-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 280px;
}

.menu-item {
    width: 100%;
    padding: 16px 24px;
    font-size: 18px;
    font-weight: 500;
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.14);
}

.menu-item:active {
    transform: scale(0.98);
}

/* ==================== Экран сложности ==================== */
.difficulty-screen {
    position: fixed;
    inset: 0;
    z-index: 101;
    background: var(--bg-gradient);
    padding: 24px;
    padding-top: calc(env(safe-area-inset-top, 0px) + 24px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
    overflow-y: auto;
}

.difficulty-screen.hidden {
    display: none !important;
}

.difficulty-back {
    margin-bottom: 20px;
    padding: 10px 0;
    font-size: 16px;
    color: var(--accent-color);
    background: none;
    border: none;
    cursor: pointer;
}

.difficulty-title {
    font-size: 22px;
    margin-bottom: 8px;
}

.difficulty-hint {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
    line-height: 1.4;
}

.difficulty-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.difficulty-option {
    padding: 14px 16px;
    text-align: left;
    font-size: 15px;
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.difficulty-option:hover {
    background: rgba(255, 255, 255, 0.14);
}

.difficulty-option.current {
    border-color: var(--accent-color);
    background: rgba(233, 69, 96, 0.15);
}

.difficulty-option .name {
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

.difficulty-option .desc {
    font-size: 12px;
    color: var(--text-muted);
}

.difficulty-cooldown {
    margin-top: 16px;
    font-size: 13px;
    color: var(--warning-color);
}

/* Модальное окно: два кнопки в ряд */
.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.modal-buttons .save-name-btn {
    flex: 1;
}

.save-name-btn.secondary {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-color);
}

.save-name-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* TODO: временно - выбор рарности при создании персонажа */
.rarity-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 12px;
    margin-bottom: 6px;
}

.rarity-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.rarity-btn {
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.rarity-btn:hover {
    background: rgba(255, 255, 255, 0.14);
}

.rarity-btn.active {
    border-color: var(--accent-color);
    background: rgba(233, 69, 96, 0.2);
}

/* ==================== Загрузка ==================== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--card-bg);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== Модальное окно имени ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--bg-gradient);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 32px 24px;
    text-align: center;
    max-width: 320px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-pet-preview {
    margin-bottom: 20px;
}

.modal-pet-image {
    width: 120px;
    height: 120px;
    object-fit: contain;
    animation: float 3s ease-in-out infinite;
    filter: drop-shadow(0 10px 30px var(--glow-color));
}

.modal-content h2 {
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--text-color);
}

.modal-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 20px;
}

.name-input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--card-border);
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 16px;
    text-align: center;
    outline: none;
    transition: all 0.3s ease;
    margin-bottom: 16px;
}

.name-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 20px var(--glow-color);
}

.name-input::placeholder {
    color: var(--text-muted);
}

.save-name-btn {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--accent-color), #d63d56);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.save-name-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px var(--glow-color);
}

.save-name-btn:active {
    transform: translateY(0);
}

/* ==================== Основное приложение ==================== */
.app {
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: fadeIn 0.5s ease;
    padding-bottom: 20px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==================== Зона питомца ==================== */
.pet-zone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px 60px; /* Увеличиваем боковые отступы для кнопок */
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    backdrop-filter: blur(10px);
    min-height: 320px;
}

.pet-container {
    position: relative;
    display: inline-block;
    margin-bottom: 16px;
}

/* Свечение вокруг персонажа (по рарности) */
.pet-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 220px;
    height: 220px;
    border-radius: 50%;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(
        circle,
        var(--rarity-glow-color, transparent) 0%,
        transparent 50%,
        transparent 70%
    );
    opacity: var(--rarity-glow-intensity, 0);
    animation: var(--rarity-glow-animation, none);
}

@keyframes rarity-glow-constant {
    0%, 100% { opacity: var(--rarity-glow-intensity, 0.2); }
}

@keyframes rarity-glow-pulsing {
    0%, 100% { opacity: calc(var(--rarity-glow-intensity, 0.4) * 0.7); transform: translate(-50%, -50%) scale(1); }
    50% { opacity: var(--rarity-glow-intensity, 0.4); transform: translate(-50%, -50%) scale(1.08); }
}

@keyframes rarity-glow-pulsing-aura {
    0%, 100% { opacity: calc(var(--rarity-glow-intensity, 1) * 0.6); transform: translate(-50%, -50%) scale(1); }
    50% { opacity: var(--rarity-glow-intensity, 1); transform: translate(-50%, -50%) scale(1.15); }
}

/* Контейнер частиц вокруг персонажа */
.pet-particles {
    position: absolute;
    inset: -40px;
    pointer-events: none;
    z-index: 0;
    overflow: visible;
}

.pet-particles .particle {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--rarity-particle-color, transparent);
    opacity: var(--rarity-particle-opacity, 0);
    animation: var(--rarity-particle-animation, none);
}

.pet-particles .particle.sparkle {
    width: 6px;
    height: 6px;
    box-shadow: 0 0 6px 2px var(--rarity-particle-color, transparent);
}

@keyframes particle-float-soft {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0; }
    10% { opacity: var(--rarity-particle-opacity, 0.3); }
    90% { opacity: var(--rarity-particle-opacity, 0.2); }
    100% { transform: translate(var(--particle-dx), var(--particle-dy)) scale(0.5); opacity: 0; }
}

@keyframes particle-float-slow {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0; }
    15% { opacity: var(--rarity-particle-opacity, 0.5); }
    85% { opacity: var(--rarity-particle-opacity, 0.4); }
    100% { transform: translate(var(--particle-dx), var(--particle-dy)) scale(0.6); opacity: 0; }
}

@keyframes particle-float-bright {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0; }
    20% { opacity: var(--rarity-particle-opacity, 0.8); }
    80% { opacity: var(--rarity-particle-opacity, 0.6); }
    100% { transform: translate(var(--particle-dx), var(--particle-dy)) scale(0.8); opacity: 0; }
}

.pet-image {
    position: relative;
    width: 160px;
    height: 160px;
    object-fit: contain;
    animation: float 3s ease-in-out infinite;
    z-index: 1;
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.3));
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.pet-shadow {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 20px;
    background: radial-gradient(ellipse, rgba(0, 0, 0, 0.4) 0%, transparent 70%);
    border-radius: 50%;
    animation: shadow-pulse 3s ease-in-out infinite;
    z-index: 0;
}

@keyframes shadow-pulse {
    0%, 100% { transform: translateX(-50%) scaleX(1); opacity: 0.4; }
    50% { transform: translateX(-50%) scaleX(0.8); opacity: 0.6; }
}

.pet-image.grayscale {
    filter: grayscale(100%) drop-shadow(0 5px 15px rgba(0, 0, 0, 0.3));
    animation: none;
}

/* Имя питомца: цвет и свечение по рарности (задаются из JS) */
.pet-name {
    font-size: 28px;
    font-weight: 700;
    color: var(--rarity-name-color, var(--text-color));
    margin-bottom: 6px;
    text-shadow: var(--rarity-name-shadow, 0 2px 10px rgba(0, 0, 0, 0.3));
}

.pet-status {
    color: var(--text-muted);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Слот фиксированной высоты — питомец не смещается при появлении/скрытии пузыря */
.thought-bubble-slot {
    position: relative;
    height: 72px;
    width: 100%;
    margin-bottom: 4px;
}

/* Пузырь скрыт, но место под него зарезервировано */
.thought-bubble.thought-bubble-empty {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

/* ==================== Пузырь мыслей питомца (над питомцем) ==================== */
.thought-bubble {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 20px;
    padding: 12px 20px;
    max-width: min(340px, 85vw);
    width: max-content;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    animation: thoughtAppear 0.4s ease;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 10;
}

/* Кружочки как в комиксах (мысли) */
.thought-bubble::before {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 14px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 50%;
}

.thought-bubble::after {
    content: '';
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 50%;
}

.thought-text {
    color: var(--text-color);
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
    margin: 0;
    font-style: normal;
    word-break: break-word;
}

.thought-text::before {
    content: '« ';
    color: var(--accent-color);
    font-style: normal;
}

.thought-text::after {
    content: '\00a0»';
    color: var(--accent-color);
    font-style: normal;
}

.thought-bubble.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

.reaction-feedback {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 6px;
}

.reaction-feedback.hidden {
    display: none;
}

.feedback-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 16px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.15s, transform 0.15s;
    line-height: 1.4;
}

.feedback-btn:hover:not(:disabled) {
    opacity: 1;
    transform: scale(1.15);
}

.feedback-btn:disabled {
    cursor: default;
    opacity: 0.9;
}

@keyframes thoughtAppear {
    from {
        opacity: 0;
        transform: translateX(-50%) scale(0.8) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) scale(1) translateY(0);
    }
}

/* ==================== Текст рассказчика (под ником питомца) ==================== */
.narrator-text {
    margin-top: 8px;
    padding: 5px 12px;
    background: rgba(107, 114, 128, 0.1);
    border-left: 3px solid var(--accent-color);
    border-radius: 0 8px 8px 0;
    max-width: 300px;
    animation: narratorAppear 0.4s ease;
}

.narrator-text.narrator-below-name {
    margin-top: 6px;
    width: 100%;
    max-width: 320px;
    box-sizing: border-box;
}

.narrator-text p {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.35;
    text-align: left;
    margin: 0;
    font-style: normal;
}

.narrator-text.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes narratorAppear {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* ==================== Статистика ==================== */
.stats-container {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 6px 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
    backdrop-filter: blur(10px);
    width: 100%;
    box-sizing: border-box;
}

.stat {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-icon {
    font-size: 12px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.stat-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}

.stat-label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stat-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.stat-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.stat-fill.hunger {
    background: linear-gradient(90deg, var(--hunger-color), #ff8787);
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.4);
}

.stat-fill.mood {
    background: linear-gradient(90deg, var(--mood-color), #ffe066);
    box-shadow: 0 0 10px rgba(255, 217, 61, 0.4);
}

.stat-fill.energy {
    background: linear-gradient(90deg, var(--energy-color), #95d5b2);
    box-shadow: 0 0 10px rgba(107, 203, 119, 0.4);
}

.stat-value {
    font-size: 10px;
    font-weight: 600;
    min-width: 45px;
    text-align: right;
    color: var(--text-color);
}

/* ==================== Возраст (внутри stats-container) ==================== */
.stats-container .age-container {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px 0 0;
    margin-top: 2px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: none;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    color: var(--text-muted);
    font-size: 10px;
}

.stats-container .age-container .age-icon {
    font-size: 12px;
}

.age-icon {
    font-size: 16px;
}

/* ==================== Боковые кнопки действий ==================== */
.side-buttons {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 10px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
}

.left-buttons {
    left: 8px;
}

.right-buttons {
    right: 8px;
    max-height: calc(100% - 16px);
}

.icon-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    position: relative;
}

.icon-btn:hover:not(:disabled):not(.on-cooldown) {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.35);
}

.icon-btn:active:not(:disabled):not(.on-cooldown) {
    transform: scale(0.88);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    transition-duration: 0.05s;
}

.icon-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* Кулдаун: круговой индикатор (часы/радар) */
.icon-btn.on-cooldown {
    pointer-events: none;
    cursor: not-allowed;
}

.icon-btn .cooldown-overlay {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    /* Оставшееся время — затемнённая дуга, которая уменьшается по кругу */
    background: conic-gradient(
        from 0deg,
        rgba(0, 0, 0, 0.55) 0deg,
        rgba(0, 0, 0, 0.55) var(--cooldown-angle, 360deg),
        transparent var(--cooldown-angle, 360deg)
    );
    pointer-events: none;
    transition: none;
}

/* Цвета кнопок */
.icon-btn.feed-btn {
    background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
    border-color: #ff5252;
}

.icon-btn.drink-btn {
    background: linear-gradient(135deg, #4fc3f7, #29b6f6);
    border-color: #03a9f4;
}

.icon-btn.sleep-btn {
    background: linear-gradient(135deg, #667eea, #5a67d8);
    border-color: #5c6bc0;
}

.icon-btn.play-btn {
    background: linear-gradient(135deg, #ffd54f, #ffca28);
    border-color: #ffc107;
}

.icon-btn.heal-btn {
    background: linear-gradient(135deg, #81c784, #66bb6a);
    border-color: #4caf50;
}

.icon-btn.stroke-btn {
    background: linear-gradient(135deg, #f48fb1, #e91e63);
    border-color: #c2185b;
}

.icon-btn.groom-btn {
    background: linear-gradient(135deg, #ce93d8, #ab47bc);
    border-color: #8e24aa;
}


/* ==================== Сообщение ==================== */
.message {
    text-align: center;
    padding: 14px 18px;
    border-radius: 12px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    animation: slideUp 0.3s ease;
    font-size: 14px;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.success {
    border-left: 4px solid var(--success-color);
    color: var(--success-color);
}

.message.error {
    border-left: 4px solid var(--accent-color);
    color: var(--accent-color);
}

.message.info {
    border-left: 4px solid #7f8c8d;
    color: #7f8c8d;
}

/* ==================== Экран ошибки (отдельный экран) ==================== */
#error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 16px;
    text-align: center;
}

#error .error-icon {
    font-size: 64px;
    margin-bottom: 8px;
}

#error p {
    color: var(--text-muted);
    font-size: 16px;
}

.retry-btn {
    padding: 14px 28px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--glow-color);
}

/* ==================== Экран смерти ==================== */
.dead-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 16px;
    text-align: center;
}

.dead-pet-container {
    position: relative;
    margin-bottom: 16px;
}

.dead-screen h2 {
    color: var(--text-muted);
    font-size: 22px;
}

.dead-screen p {
    color: var(--text-muted);
    font-size: 14px;
}

.dead-message {
    margin-top: 8px;
    font-style: italic;
    opacity: 0.7;
}

/* Форма создания нового питомца */
.new-pet-form {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 280px;
}

.new-pet-prompt {
    color: var(--text-color);
    font-size: 15px;
    margin-bottom: 4px;
}

.new-pet-form .name-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text-color);
    text-align: center;
    transition: border-color 0.2s ease;
}

.new-pet-form .name-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.create-pet-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.create-pet-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(34, 197, 94, 0.4);
}

.create-pet-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.create-pet-btn .btn-icon {
    font-size: 20px;
}

.create-pet-btn .btn-text {
    font-size: 15px;
}

/* ==================== Адаптация под Telegram тему ==================== */
@media (prefers-color-scheme: light) {
    :root {
        --bg-color: #f0f2f5;
        --bg-gradient: linear-gradient(180deg, #f0f2f5 0%, #e8eaed 50%, #dfe1e5 100%);
        --card-bg: rgba(255, 255, 255, 0.9);
        --card-border: rgba(0, 0, 0, 0.1);
        --text-color: #1a1a2e;
        --text-muted: #666666;
        --glow-color: rgba(233, 69, 96, 0.2);
    }
}

/* ==================== Дополнительные статы ==================== */
.stat-fill.thirst {
    background: linear-gradient(90deg, #4fc3f7, #81d4fa);
    box-shadow: 0 0 10px rgba(79, 195, 247, 0.4);
}

.stat-fill.health {
    background: linear-gradient(90deg, #e91e63, #f48fb1);
    box-shadow: 0 0 10px rgba(233, 30, 99, 0.4);
}

/* ==================== Новые кнопки ==================== */
.drink-btn {
    background: linear-gradient(135deg, #4fc3f7, #29b6f6);
    color: white;
}

.drink-btn:hover {
    box-shadow: 0 8px 25px rgba(79, 195, 247, 0.4);
}

.play-btn {
    background: linear-gradient(135deg, #ffd93d, #ffca28);
    color: #333;
}

.play-btn:hover {
    box-shadow: 0 8px 25px rgba(255, 217, 61, 0.4);
}

.heal-btn {
    background: linear-gradient(135deg, #e91e63, #d81b60);
    color: white;
}

.heal-btn:hover {
    box-shadow: 0 8px 25px rgba(233, 30, 99, 0.4);
}

.clean-room-btn {
    background: linear-gradient(135deg, #a5d6a7, #66bb6a);
    color: #1b5e20;
}

.clean-room-btn:hover {
    box-shadow: 0 8px 25px rgba(102, 187, 106, 0.4);
}

.wash-pet-btn {
    background: linear-gradient(135deg, #80deea, #26c6da);
    color: #006064;
}

.wash-pet-btn:hover {
    box-shadow: 0 8px 25px rgba(38, 198, 218, 0.4);
}

.stat-fill.room-cleanliness {
    background: linear-gradient(90deg, #66bb6a, #a5d6a7);
    box-shadow: 0 0 10px rgba(102, 187, 106, 0.4);
}

.stat-fill.body-cleanliness {
    background: linear-gradient(90deg, #26c6da, #80deea);
    box-shadow: 0 0 10px rgba(38, 198, 218, 0.4);
}

.stat-fill.grooming {
    background: linear-gradient(90deg, #ce93d8, #ab47bc);
    box-shadow: 0 0 10px rgba(171, 71, 188, 0.4);
}

/* Предупреждение на кнопке при высокой загрязнённости */
.icon-btn.stat-warning {
    animation: warning-pulse 1.8s ease-in-out infinite;
}

@keyframes warning-pulse {
    0%, 100% { box-shadow: 0 4px 15px rgba(255, 152, 0, 0); }
    50% { box-shadow: 0 4px 20px rgba(255, 152, 0, 0.6); }
}

/* ==================== Анимация загрязнённости комнаты ==================== */

.room-dirt-overlay {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    overflow: hidden;
    z-index: 4;
    transition: background 2s ease;
}

/* Фоновая дымка по стадиям */
.room-dirt-overlay.room-stage-dust {
    background: radial-gradient(ellipse at 50% 110%, rgba(160, 155, 145, 0.08) 0%, transparent 55%);
}
.room-dirt-overlay.room-stage-messy {
    background:
        radial-gradient(ellipse at 50% 110%, rgba(140, 130, 110, 0.18) 0%, transparent 50%),
        radial-gradient(ellipse at 10% 100%, rgba(120, 110, 90, 0.10) 0%, transparent 35%),
        radial-gradient(ellipse at 90% 100%, rgba(120, 110, 90, 0.10) 0%, transparent 35%);
}
.room-dirt-overlay.room-stage-dirty {
    background:
        radial-gradient(ellipse at 50% 110%, rgba(110, 95, 70, 0.28) 0%, transparent 50%),
        radial-gradient(ellipse at 5%  100%, rgba(90, 78, 55, 0.18) 0%, transparent 40%),
        radial-gradient(ellipse at 95% 100%, rgba(90, 78, 55, 0.18) 0%, transparent 40%),
        linear-gradient(to top, rgba(80, 70, 50, 0.10) 0%, transparent 40%);
}
.room-dirt-overlay.room-stage-filthy {
    background:
        radial-gradient(ellipse at 50% 110%, rgba(80, 65, 35, 0.55) 0%, transparent 55%),
        radial-gradient(ellipse at 0%  100%, rgba(65, 50, 25, 0.40) 0%, transparent 45%),
        radial-gradient(ellipse at 100% 100%, rgba(65, 50, 25, 0.40) 0%, transparent 45%),
        linear-gradient(to top, rgba(55, 45, 20, 0.25) 0%, transparent 55%),
        radial-gradient(ellipse at 50% 0%, rgba(45, 75, 25, 0.22) 0%, transparent 45%);
}

/* Частица пыли */
.room-dirt-overlay .dust-p {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
    will-change: transform, opacity;
    animation: dust-drift var(--d-dur) var(--d-delay) ease-in-out infinite;
}

@keyframes dust-drift {
    0% {
        opacity: 0;
        transform: translate(0, 0) scale(var(--d-scale, 1));
    }
    15% {
        opacity: var(--d-opacity);
    }
    85% {
        opacity: var(--d-opacity);
    }
    100% {
        opacity: 0;
        transform: translate(var(--d-dx), var(--d-dy)) scale(calc(var(--d-scale, 1) * 0.6));
    }
}

/* ==================== Индикаторы ==================== */
.sleep-indicator {
    position: absolute;
    top: -15px;
    right: -15px;
    font-size: 28px;
    color: #667eea;
    text-shadow: 0 0 10px rgba(102, 126, 234, 0.6);
    animation: zzz 2s ease-in-out infinite;
    z-index: 10;
}

@keyframes zzz {
    0%, 100% { 
        opacity: 0.5;
        transform: translateY(0) scale(0.9);
    }
    50% { 
        opacity: 1;
        transform: translateY(-10px) scale(1);
    }
}

.sick-indicator {
    position: absolute;
    top: 10px;
    left: -10px;
    width: 28px;
    height: 28px;
    background: #ff6b6b;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    animation: sick-pulse 1.5s ease-in-out infinite;
    z-index: 10;
}

@keyframes sick-pulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.7);
    }
    50% { 
        transform: scale(1.1);
        box-shadow: 0 0 0 10px rgba(255, 107, 107, 0);
    }
}

/* ==================== Debug панель (тестирование) ==================== */
.debug-panel {
    padding: 12px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    font-size: 10px;
    font-family: 'Courier New', monospace;
}

.debug-title {
    text-align: center;
    color: var(--text-muted);
    font-size: 11px;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 6px;
}

.debug-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.debug-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.debug-section-title {
    color: var(--accent-color);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    font-weight: bold;
}

.debug-item {
    color: var(--text-muted);
    font-size: 9px;
    line-height: 1.4;
    padding: 2px 4px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.03);
}

.debug-item.critical {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.15);
}

/* Характер + темперамент + отношения — один блок, 2 колонки */
.debug-character-block {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
}

.debug-character-col {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.debug-character-col .debug-section-title {
    margin-bottom: 2px;
    margin-top: 4px;
}

.debug-character-col .debug-section-title:first-child {
    margin-top: 0;
}

.debug-item.debug-rarity {
    font-weight: bold;
    margin-top: 4px;
}

/* Рарность имени/персонажа задаётся через CSS-переменные из JS */

/* ==================== Кнопка скрытия дебаг-панелей ==================== */
.toggle-debug-btn {
    position: absolute;
    bottom: 6px;
    right: 6px;
    z-index: 15;
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 13px;
    line-height: 28px;
    text-align: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: var(--text-color);
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.2s;
}

.toggle-debug-btn:hover,
.toggle-debug-btn:active {
    opacity: 1;
}

.toggle-debug-btn.panels-hidden {
    opacity: 0.3;
}

.debug-panels-wrapper {
    transition: max-height 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
}

.debug-panels-wrapper.collapsed {
    max-height: 0 !important;
    opacity: 0;
    pointer-events: none;
}

/* ==================== Tooltip при зажатии кнопки ==================== */
.longpress-tooltip {
    position: fixed;
    z-index: 100;
    padding: 4px 10px;
    font-size: 12px;
    color: #fff;
    background: rgba(30, 30, 40, 0.9);
    border-radius: 8px;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 0) scale(0.9);
    transition: opacity 0.15s ease, transform 0.15s ease;
    white-space: nowrap;
}

.longpress-tooltip.visible {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
}

/* ==================== Мобильная адаптация ==================== */
@media (max-width: 380px) {
    .container {
        padding: 12px;
    }
    
    .pet-image {
        width: 140px;
        height: 140px;
    }
    
    .pet-name {
        font-size: 24px;
    }
    
    .action-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .btn-icon {
        font-size: 14px;
    }
    
    .btn-text {
        font-size: 11px;
    }
    
    .debug-panel {
        font-size: 9px;
    }
    
    .debug-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .debug-character-block {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .icon-btn {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }

    .side-buttons {
        gap: 7px;
    }

    .pet-zone {
        padding: 20px 50px;
    }
}

@media (max-height: 700px) {
    .side-buttons {
        gap: 6px;
    }

    .icon-btn {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }
}
