/* ============================================
   PON - Tu Mascota Virtual | Mylinkgames
   ============================================ */

:root {
    --pon-primary: #8B4513;
    --pon-secondary: #A0522D;
    --pon-accent: #D2691E;
    --pon-light: #DEB887;
    --pon-dark: #654321;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-sky: linear-gradient(180deg, #87CEEB 0%, #98D8E8 50%, #B0E0E6 100%);
    --success: #4CAF50;
    --warning: #FF9800;
    --danger: #f44336;
    --happy: #FFD700;
    --energy: #FF6B35;
    --clean: #00BCD4;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

#app {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

/* ============================================
   PANTALLAS
   ============================================ */

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
}

.screen.active {
    display: flex;
}

/* ============================================
   PANTALLA DE CARGA
   ============================================ */

#loading-screen {
    background: var(--bg-gradient);
    justify-content: center;
    align-items: center;
}

.loading-content {
    text-align: center;
    color: white;
}

.pon-logo {
    margin-bottom: 40px;
}

.pon-emoji {
    font-size: 80px;
    animation: bounce 2s infinite;
}

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

.pon-logo h1 {
    font-size: 48px;
    font-weight: 900;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.3);
    letter-spacing: 8px;
}

.pon-logo .subtitle {
    font-size: 18px;
    opacity: 0.9;
    margin-top: 8px;
}

.loading-bar {
    width: 200px;
    height: 8px;
    background: rgba(255,255,255,0.3);
    border-radius: 4px;
    margin: 0 auto;
    overflow: hidden;
}

.loading-fill {
    height: 100%;
    background: white;
    border-radius: 4px;
    width: 0%;
    animation: load 2s ease-in-out forwards;
}

@keyframes load {
    0% { width: 0%; }
    100% { width: 100%; }
}

.loading-text {
    margin-top: 16px;
    font-size: 14px;
    opacity: 0.8;
}

/* ============================================
   PANTALLA DEL JUEGO
   ============================================ */

#game-screen {
    background: var(--bg-sky);
    padding: 10px;
    padding-bottom: 70px;
}

/* Header */
.game-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.9);
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.level-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 14px;
    color: #654321;
}

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

.coins-display {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: bold;
    font-size: 16px;
    color: #8B6914;
}

.coin-icon {
    font-size: 18px;
}

.xp-bar {
    flex: 1;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.xp-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    border-radius: 4px;
    width: 0%;
    transition: width 0.5s ease;
}

/* Stats */
.stats-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 10px 0;
}

.stat {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.9);
    padding: 8px 12px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.stat-icon {
    font-size: 20px;
}

.stat-bar {
    flex: 1;
    height: 10px;
    background: #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
}

.stat-fill {
    height: 100%;
    background: var(--success);
    border-radius: 5px;
    transition: width 0.5s ease;
}

.stat-fill.happy { background: var(--happy); }
.stat-fill.energy { background: var(--energy); }
.stat-fill.clean { background: var(--clean); }

.stat-value {
    font-size: 12px;
    font-weight: bold;
    color: #666;
    min-width: 24px;
    text-align: right;
}

/* ============================================
   PON (LA MASCOTA)
   ============================================ */

.pon-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    margin: 10px 0;
}

.pon-background {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.cloud {
    position: absolute;
    font-size: 40px;
    opacity: 0.6;
    animation: float 8s ease-in-out infinite;
}

.cloud-1 { top: 10%; left: 10%; }
.cloud-2 { top: 20%; right: 15%; animation-delay: -4s; }

@keyframes float {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(20px); }
}

.star {
    position: absolute;
    font-size: 20px;
    animation: twinkle 2s ease-in-out infinite;
}

.star-1 { top: 30%; right: 20%; }
.star-2 { top: 15%; left: 25%; animation-delay: -1s; }

@keyframes twinkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.pon {
    cursor: pointer;
    position: relative;
    z-index: 10;
    transition: transform 0.2s ease;
}

.pon:hover {
    transform: scale(1.05);
}

.pon:active {
    transform: scale(0.95);
}

.pon-body {
    width: 140px;
    height: 140px;
    background: radial-gradient(circle at 40% 40%, var(--pon-light), var(--pon-primary));
    border-radius: 50% 50% 45% 45%;
    position: relative;
    box-shadow: 
        0 8px 20px rgba(0,0,0,0.2),
        inset 0 -5px 15px rgba(0,0,0,0.1),
        inset 0 5px 15px rgba(255,255,255,0.2);
    animation: ponBounce 3s ease-in-out infinite;
}

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

.pon-eye {
    position: absolute;
    width: 30px;
    height: 35px;
    background: white;
    border-radius: 50%;
    top: 35%;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.pon-eye-left { left: 25%; }
.pon-eye-right { right: 25%; }

.pon-pupil {
    width: 16px;
    height: 18px;
    background: #333;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
}

.pon-pupil::after {
    content: '';
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 3px;
    right: 3px;
}

.pon-mouth {
    position: absolute;
    bottom: 25%;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 15px;
    border-bottom: 3px solid #8B4513;
    border-radius: 0 0 50% 50%;
    transition: all 0.3s ease;
}

.pon-mouth.happy {
    height: 20px;
    border-bottom-width: 4px;
}

.pon-mouth.sad {
    height: 10px;
    border-bottom: none;
    border-top: 3px solid #8B4513;
    border-radius: 50% 50% 0 0;
}

.pon-mouth.eating {
    width: 20px;
    height: 20px;
    border: 3px solid #8B4513;
    border-radius: 50%;
    animation: eat 0.5s ease;
}

@keyframes eat {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(0.8); }
}

.pon-mouth.sleeping {
    width: 25px;
    height: 0;
    border-bottom: none;
    border-top: 2px solid #8B4513;
}

.pon-blush {
    position: absolute;
    width: 20px;
    height: 12px;
    background: rgba(255, 150, 150, 0.6);
    border-radius: 50%;
    top: 55%;
}

.pon-blush-left { left: 15%; }
.pon-blush-right { right: 15%; }

.pon-feet {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: -5px;
}

.pon-foot {
    width: 35px;
    height: 20px;
    background: var(--pon-dark);
    border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%;
    box-shadow: 0 3px 6px rgba(0,0,0,0.2);
}

.pon-shadow {
    width: 120px;
    height: 20px;
    background: radial-gradient(ellipse, rgba(0,0,0,0.2), transparent);
    border-radius: 50%;
    margin-top: 10px;
    animation: shadowPulse 3s ease-in-out infinite;
}

@keyframes shadowPulse {
    0%, 100% { transform: scaleX(1); }
    50% { transform: scaleX(0.8); }
}

/* Speech Bubble */
.speech-bubble {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 10px 16px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    white-space: nowrap;
    z-index: 20;
    animation: popIn 0.3s ease;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid white;
}

.speech-bubble.hidden {
    display: none;
}

@keyframes popIn {
    0% { transform: translateX(-50%) scale(0); }
    100% { transform: translateX(-50%) scale(1); }
}

/* ============================================
   ACCIONES RÁPIDAS
   ============================================ */

.quick-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 10px 0;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

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

.action-btn span {
    font-size: 28px;
}

.action-btn small {
    font-size: 11px;
    font-weight: 600;
}

.action-btn.food {
    background: linear-gradient(135deg, #FF6B6B, #ee5a24);
    color: white;
}

.action-btn.play {
    background: linear-gradient(135deg, #4834d4, #686de0);
    color: white;
}

.action-btn.sleep {
    background: linear-gradient(135deg, #686de0, #4834d4);
    color: white;
}

.action-btn.clean {
    background: linear-gradient(135deg, #22a6b3, #7ed6df);
    color: white;
}

.action-btn.dance {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
}

.action-btn.trick {
    background: linear-gradient(135deg, #f9ca24, #f0932b);
    color: white;
}

/* ============================================
   NAVEGACIÓN INFERIOR
   ============================================ */

.bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    background: rgba(255,255,255,0.95);
    padding: 8px 0;
    border-top: 1px solid rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 12px;
    transition: all 0.2s ease;
    color: #666;
}

.nav-btn.active {
    color: #764ba2;
    background: rgba(118, 75, 162, 0.1);
}

.nav-btn:hover {
    background: rgba(0,0,0,0.05);
}

.nav-btn span {
    font-size: 24px;
}

.nav-btn small {
    font-size: 10px;
    font-weight: 600;
}

/* ============================================
   PANELES
   ============================================ */

.panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f5f5f5;
    z-index: 100;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.panel.hidden {
    display: none;
}

@keyframes slideUp {
    0% { transform: translateY(100%); }
    100% { transform: translateY(0); }
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 10;
}

.panel-header h2 {
    font-size: 20px;
    color: #333;
}

.close-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #e0e0e0;
}

/* ============================================
   JUEGOS
   ============================================ */

.games-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 16px;
}

.game-card {
    background: white;
    border-radius: 16px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.game-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.game-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.game-card h3 {
    font-size: 14px;
    margin-bottom: 4px;
    color: #333;
}

.game-card p {
    font-size: 11px;
    color: #666;
    margin-bottom: 8px;
}

.game-reward {
    font-size: 12px;
    font-weight: bold;
    color: #4CAF50;
}

/* Game Screens */
.game-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1a1a2e;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-screen.hidden {
    display: none;
}

.game-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 12px 16px;
    background: rgba(0,0,0,0.5);
    color: white;
}

.game-instructions {
    color: white;
    font-size: 14px;
    margin-top: 16px;
    opacity: 0.8;
}

canvas {
    background: white;
    border-radius: 12px;
    margin-top: 16px;
}

/* Memory Game */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 16px;
    max-width: 320px;
}

.memory-card {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #764ba2, #667eea);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.memory-card.flipped {
    background: white;
    transform: rotateY(180deg);
}

.memory-card.matched {
    background: #4CAF50;
    opacity: 0.7;
}

/* Math Game */
.math-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.math-question {
    font-size: 48px;
    font-weight: bold;
    color: white;
    margin-bottom: 32px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.math-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    max-width: 300px;
}

.math-option {
    padding: 16px;
    font-size: 24px;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background: white;
    color: #333;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.math-option:hover {
    transform: scale(1.05);
}

.math-option.correct {
    background: #4CAF50;
    color: white;
}

.math-option.wrong {
    background: #f44336;
    color: white;
}

/* ============================================
   HISTORIA
   ============================================ */

.story-content {
    padding: 16px;
}

.story-chapter {
    display: none;
    background: white;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    animation: fadeIn 0.5s ease;
}

.story-chapter.active {
    display: block;
}

@keyframes fadeIn {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

.story-image {
    font-size: 64px;
    text-align: center;
    margin-bottom: 16px;
}

.story-chapter h3 {
    font-size: 20px;
    color: #764ba2;
    margin-bottom: 12px;
}

.story-chapter p {
    font-size: 15px;
    line-height: 1.6;
    color: #555;
    margin-bottom: 16px;
}

.story-next {
    display: block;
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #764ba2, #667eea);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.story-next:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(118, 75, 162, 0.4);
}

.family-preview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 16px 0;
}

.family-member {
    padding: 12px;
    background: #f5f5f5;
    border-radius: 12px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
}

/* ============================================
   TIENDA
   ============================================ */

.shop-categories {
    display: flex;
    gap: 8px;
    padding: 16px;
    overflow-x: auto;
}

.shop-cat {
    padding: 8px 16px;
    border: none;
    background: white;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.shop-cat.active {
    background: linear-gradient(135deg, #764ba2, #667eea);
    color: white;
}

.shop-items {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 0 16px 16px;
}

.shop-item {
    background: white;
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.shop-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.shop-item-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.shop-item-name {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.shop-item-price {
    font-size: 12px;
    color: #8B6914;
    font-weight: bold;
}

/* ============================================
   VESTUARIO
   ============================================ */

.wardrobe-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 16px;
}

.wardrobe-item {
    background: white;
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.wardrobe-item.owned {
    border: 2px solid #4CAF50;
}

.wardrobe-item.equipped {
    background: linear-gradient(135deg, #FFD700, #FFA500);
}

.wardrobe-item:hover {
    transform: translateY(-2px);
}

.wardrobe-item-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.wardrobe-item-name {
    font-size: 11px;
    font-weight: 600;
    color: #333;
}

/* ============================================
   NOTIFICACIONES
   ============================================ */

.notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    animation: slideDown 0.3s ease, slideUp 0.3s ease 2s forwards;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.notification.hidden {
    display: none;
}

@keyframes slideDown {
    0% { transform: translateX(-50%) translateY(-100%); }
    100% { transform: translateX(-50%) translateY(0); }
}

/* ============================================
   ANIMACIONES ESPECIALES
   ============================================ */

@keyframes dance {
    0% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-20px) rotate(10deg); }
    50% { transform: translateY(0) rotate(0deg); }
    75% { transform: translateY(-20px) rotate(-10deg); }
    100% { transform: translateY(0) rotate(0deg); }
}

@keyframes trick {
    0% { transform: translateY(0) scale(1); }
    25% { transform: translateY(-30px) scale(1.1); }
    50% { transform: translateY(0) scale(1); }
    75% { transform: translateY(-15px) scale(1.05); }
    100% { transform: translateY(0) scale(1); }
}

@keyframes wiggle {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(5deg); }
    50% { transform: rotate(0deg); }
    75% { transform: rotate(-5deg); }
    100% { transform: rotate(0deg); }
}

/* ============================================
   EFECTOS ESPECIALES
   ============================================ */

.particle {
    position: absolute;
    pointer-events: none;
    animation: particleFade 1s ease forwards;
}

@keyframes particleFade {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-50px) scale(0); }
}

/* Hearts animation */
.heart-particle {
    color: #ff6b6b;
    font-size: 24px;
}

/* Coin animation */
.coin-particle {
    color: #FFD700;
    font-size: 20px;
}

/* Star animation */
.star-particle {
    color: #FFD700;
    font-size: 16px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 360px) {
    .pon-body {
        width: 120px;
        height: 120px;
    }
    
    .action-btn {
        padding: 10px 12px;
    }
    
    .action-btn span {
        font-size: 24px;
    }
}

@media (min-width: 481px) {
    #app {
        border-radius: 20px;
        margin-top: 20px;
        height: calc(100vh - 40px);
        box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    }
}
