* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg: #0f0f1a;
    --surface: #1a1a2e;
    --surface2: #22223a;
    --accent: #7c6aff;
    --accent2: #ff6ab0;
    --hunger: #ff7043;
    --mood: #f9ca24;
    --energy: #6bcb77;
    --text: #e0e0ff;
    --text-dim: #8888aa;
    --radius: 16px;
}

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    color: var(--text);
    user-select: none;
    -webkit-user-select: none;
}

#app {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    height: 100vh;
    height: 100dvh;
    position: relative;
}

/* ── Screens ── */

.screen {
    display: none;
    flex-direction: column;
    height: 100%;
    padding: 16px 16px 24px;
}

.screen.active {
    display: flex;
}

/* ── Create screen ── */

.create-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    text-align: center;
    padding: 24px;
}

.create-egg {
    font-size: 88px;
    animation: pulse 2s ease-in-out infinite;
    line-height: 1;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

.create-area h2 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.create-area p {
    color: var(--text-dim);
    font-size: 15px;
}

#pet-name-input {
    width: 100%;
    max-width: 260px;
    padding: 14px 18px;
    background: var(--surface);
    border: 2px solid rgba(124, 106, 255, 0.25);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 17px;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
    caret-color: var(--accent);
}

#pet-name-input::placeholder {
    color: var(--text-dim);
}

#pet-name-input:focus {
    border-color: var(--accent);
}

.create-btn {
    padding: 15px 40px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
}

.create-btn:active {
    opacity: 0.85;
    transform: scale(0.97);
}

/* ── Top bar ── */

.top-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.coin-badge {
    background: var(--surface);
    color: #f9ca24;
    font-size: 13px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 20px;
}

.streak-badge {
    background: var(--surface);
    font-size: 13px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 20px;
}

/* ── Pet screen ── */

.pet-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.days-badge {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-dim);
    background: var(--surface);
    padding: 5px 10px;
    border-radius: 20px;
}

.pet-bubble {
    width: 148px;
    height: 148px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 68px;
    box-shadow: 0 0 48px rgba(124, 106, 255, 0.35);
    animation: float 3.2s ease-in-out infinite;
    cursor: pointer;
    transition: transform 0.1s;
    flex-shrink: 0;
}

.pet-bubble:active {
    transform: scale(0.93) !important;
    animation: none;
}

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

@keyframes bounce {
    0% { transform: scale(1); }
    30% { transform: scale(1.12); }
    60% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.pet-bubble.react {
    animation: bounce 0.4s ease forwards;
}

.pet-name {
    font-size: 21px;
    font-weight: 700;
    letter-spacing: 0.3px;
    margin-top: 4px;
}

.pet-phrase {
    font-size: 14px;
    color: var(--text-dim);
    text-align: center;
    min-height: 20px;
    padding: 0 24px;
    line-height: 1.4;
    transition: opacity 0.3s;
}

/* ── Stats ── */

.stats {
    display: flex;
    flex-direction: column;
    gap: 11px;
    padding: 16px;
    background: var(--surface);
    border-radius: var(--radius);
}

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

.stat-icon {
    font-size: 17px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.stat-bar-wrap {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 4px;
    overflow: hidden;
}

.stat-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 4px;
}

.hunger-bar { background: var(--hunger); }
.mood-bar   { background: var(--mood); }
.energy-bar { background: var(--energy); }

.stat-value {
    font-size: 12px;
    color: var(--text-dim);
    width: 34px;
    text-align: right;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

/* ── Actions ── */

.actions {
    display: flex;
    gap: 10px;
    margin: 14px 0 8px;
}

.action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 13px 6px;
    background: var(--surface);
    border: none;
    border-radius: var(--radius);
    color: var(--text);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, opacity 0.2s;
    line-height: 1.2;
}

.action-btn:active:not(:disabled) {
    transform: scale(0.94);
    background: var(--surface2);
}

.action-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.btn-icon {
    font-size: 26px;
}

.btn-label {
    text-align: center;
    word-break: break-word;
}

/* ── Footer ── */

.footer {
    text-align: center;
    padding-top: 4px;
}

.full-game-link {
    color: var(--accent);
    font-size: 13px;
    text-decoration: none;
    opacity: 0.8;
}

.full-game-link:active {
    opacity: 0.5;
}

/* ── Popup ── */

.popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface2);
    border: 1px solid rgba(124, 106, 255, 0.2);
    border-radius: 20px;
    padding: 22px 36px;
    text-align: center;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
    z-index: 200;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
}

.popup.hidden {
    opacity: 0;
    transform: translate(-50%, -46%);
}

#popup-emoji {
    font-size: 46px;
    display: block;
    margin-bottom: 8px;
}

#popup-text {
    font-size: 15px;
    color: var(--text);
    line-height: 1.4;
}

/* ── Games screen ── */

.games-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.games-header h2 {
    flex: 1;
    font-size: 20px;
    font-weight: 700;
}

.back-btn {
    background: var(--surface);
    border: none;
    color: var(--text);
    font-size: 18px;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.games-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.game-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    border: 1px solid transparent;
}

.game-card:active { transform: scale(0.98); background: var(--surface2); }

.game-card.special {
    border-color: rgba(124, 106, 255, 0.3);
    background: linear-gradient(135deg, #1a1a2e, #1f1535);
}

.game-card-icon { font-size: 36px; flex-shrink: 0; }

.game-card-info { flex: 1; }

.game-card-name { font-size: 15px; font-weight: 700; margin-bottom: 3px; }

.game-card-desc { font-size: 12px; color: var(--text-dim); }

.game-card-reward {
    font-size: 14px;
    font-weight: 700;
    color: #f9ca24;
    flex-shrink: 0;
}

.game-card.special .game-card-reward { color: var(--accent); font-size: 18px; }

/* ── Play screen ── */

.play-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.play-title { flex: 1; font-size: 16px; font-weight: 700; }

.play-timer {
    font-size: 22px;
    font-weight: 900;
    color: var(--accent);
    min-width: 32px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.play-timer.urgent { color: #ff4444; animation: blink 0.5s ease-in-out infinite; }

.play-score { font-size: 15px; font-weight: 700; color: #f9ca24; }

.game-area {
    flex: 1;
    position: relative;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    touch-action: none;
}

/* Game 1: Stars */
.star-item {
    position: absolute;
    font-size: 32px;
    cursor: pointer;
    transition: opacity 0.15s;
    user-select: none;
    animation: star-fade var(--life) linear forwards;
    transform: translate(-50%, -50%);
}

@keyframes star-fade {
    0%   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    80%  { opacity: 0.8; transform: translate(-50%, -50%) scale(1.1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
}

/* Game 2: Food catch */
.game-pet-strip {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.game-pet-strip.hidden { display: none; }

.game-pet {
    font-size: 44px;
    position: absolute;
    transition: left 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(-50%);
}

.food-item {
    position: absolute;
    font-size: 28px;
    transform: translateX(-50%);
    animation: food-fall var(--speed) linear forwards;
    pointer-events: none;
}

@keyframes food-fall {
    from { top: -40px; }
    to   { top: 100%; }
}

/* Game 3: Rhythm */
.rhythm-lane {
    position: absolute;
    top: 0; bottom: 60px;
    width: 23%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.rhythm-zone {
    position: absolute;
    bottom: -60px;
    left: 0; right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    background: rgba(124, 106, 255, 0.1);
    border-top: 2px solid rgba(124, 106, 255, 0.3);
    cursor: pointer;
    transition: background 0.1s;
    user-select: none;
}

.rhythm-zone:active, .rhythm-zone.hit { background: rgba(124, 106, 255, 0.4); }

.rhythm-note {
    position: absolute;
    width: 80%;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    box-shadow: 0 0 12px rgba(124, 106, 255, 0.5);
    animation: note-fall var(--speed) linear forwards;
    pointer-events: none;
}

@keyframes note-fall {
    from { top: -40px; }
    to   { top: calc(100% + 20px); }
}

/* ── Result screen ── */

.result-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 24px;
    text-align: center;
}

.result-emoji { font-size: 72px; animation: pulse 1.5s ease-in-out infinite; }
.result-title { font-size: 24px; font-weight: 700; }
.result-coins { font-size: 32px; font-weight: 900; color: #f9ca24; }
.result-phrase { font-size: 15px; color: var(--text-dim); line-height: 1.5; }

/* ── Overlay base ── */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 300;
    transition: opacity 0.3s;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ── Package (день 5) ── */

.package-card {
    background: var(--surface);
    border-radius: 28px 28px 0 0;
    padding: 28px 24px 36px;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    border-top: 1px solid rgba(124, 106, 255, 0.2);
}

.package-label {
    font-size: 13px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.part-reveal {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.part-glow {
    width: 110px;
    height: 110px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 52px;
    position: relative;
}

.part-glow.rare {
    background: linear-gradient(135deg, #1a2a6c, #2563eb22);
    border: 2px solid #3b82f6;
    box-shadow: 0 0 32px rgba(59, 130, 246, 0.4), inset 0 0 20px rgba(59, 130, 246, 0.1);
    animation: glow-pulse 2s ease-in-out infinite;
}

.part-glow.epic {
    background: linear-gradient(135deg, #2d1b69, #7c3aed22);
    border: 2px solid #8b5cf6;
    box-shadow: 0 0 32px rgba(139, 92, 246, 0.4);
    animation: glow-pulse 2s ease-in-out infinite;
}

.part-glow.legendary {
    background: linear-gradient(135deg, #3d2000, #f59e0b22);
    border: 2px solid #f59e0b;
    box-shadow: 0 0 40px rgba(245, 158, 11, 0.5);
    animation: glow-pulse 1.5s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% { box-shadow: 0 0 24px rgba(59, 130, 246, 0.3); }
    50%       { box-shadow: 0 0 48px rgba(59, 130, 246, 0.6); }
}

.part-icon {
    font-size: 48px;
    filter: drop-shadow(0 0 12px rgba(255,255,255,0.4));
}

.rarity-badge {
    font-size: 13px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
}

.rarity-badge.rare       { color: #60a5fa; background: rgba(59,130,246,0.12); }
.rarity-badge.epic       { color: #a78bfa; background: rgba(139,92,246,0.12); }
.rarity-badge.legendary  { color: #fbbf24; background: rgba(245,158,11,0.12); }

.package-pet-text {
    font-size: 15px;
    color: var(--text);
    text-align: center;
    font-style: italic;
    line-height: 1.5;
    padding: 0 8px;
}

.package-note {
    font-size: 13px;
    color: var(--text-dim);
    text-align: center;
    line-height: 1.5;
}

.package-close-btn {
    width: 100%;
    padding: 14px;
    background: var(--surface2);
    border: none;
    border-radius: var(--radius);
    color: var(--text);
    font-size: 15px;
    cursor: pointer;
    transition: opacity 0.15s;
}

.package-close-btn:active { opacity: 0.7; }

/* ── Conversion screen (день 7) ── */

.screen.conversion {
    background: radial-gradient(ellipse at center top, #1a0f3a 0%, var(--bg) 70%);
    align-items: center;
    justify-content: center;
    text-align: center;
}

.conversion-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 24px;
    max-width: 340px;
}

.conversion-pet {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    box-shadow: 0 0 60px rgba(124, 106, 255, 0.5);
    animation: float 3s ease-in-out infinite;
}

.conversion-speech {
    font-size: 17px;
    line-height: 1.6;
    color: var(--text);
    font-style: italic;
}

.conversion-stats {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 14px 20px;
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.8;
    width: 100%;
}

.conversion-btn {
    display: block;
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
}

.conversion-btn:active {
    opacity: 0.85;
    transform: scale(0.98);
}

.conversion-skip {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 13px;
    cursor: pointer;
    padding: 4px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ── Low stat warning ── */

.stat-bar.danger {
    animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
