@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@700&display=swap');

:root {
    --primary-bg: #ffe6f2;
    --secondary-bg: #e6f7ff;
    --accent: #ff6b6b;
    --accent-hover: #ff4757;
    --text-main: #2f3542;
    --text-light: #57606f;
    --egg-base: #ffffff;
    --egg-accent: #ff4757;
    
    /* Rarity Colors */
    --common: #a4b0be;
    --rare: #1e90ff;
    --epic: #9c88ff;
    --legendary: #ffa502;
    
    --shadow-soft: 0 8px 15px rgba(0,0,0,0.1);
    --shadow-hard: 0 8px 0 rgba(0,0,0,0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Nunito', sans-serif;
}

body {
    background: linear-gradient(135deg, var(--primary-bg) 0%, var(--secondary-bg) 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, .egg-label {
    font-family: 'Fredoka One', cursive;
}

/* Page Layout Wrapper */
.main-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* Mobile-like App Container (Game Dashboard) */
.app-container {
    width: 100%;
    max-width: 480px;
    height: 85vh;
    max-height: 800px;
    background: url('data:image/svg+xml;utf8,<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="40" fill="%23ffffff" fill-opacity="0.3"/></svg>') repeat;
    background-size: 50px 50px;
    background-color: #ffcccc;
    box-shadow: 0 0 30px rgba(0,0,0,0.15);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    border-radius: 20px;
}

@media (max-width: 480px) {
    .main-wrapper {
        padding: 0;
    }
    .app-container {
        border-radius: 0;
        height: 100%;
        max-height: none;
    }
}

/* Navigation Menu */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 2px solid rgba(255, 255, 255, 0.5);
    z-index: 20;
    position: sticky;
    top: 0;
}

.top-nav .logo {
    font-family: 'Fredoka One', cursive;
    color: var(--accent);
    font-size: 1.2rem;
    text-shadow: 1px 1px 0 #fff;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 15px;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-light);
    font-weight: 700;
    font-size: 0.9rem;
    padding: 5px 10px;
    border-radius: 15px;
    transition: background 0.2s, color 0.2s;
}

.nav-links a:hover, .nav-links a.active {
    background: var(--accent);
    color: white;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: rgba(255,255,255,0.7);
    z-index: 10;
}

header h1 {
    font-size: 1.5rem;
    color: var(--accent);
    text-shadow: 1px 1px 0 #fff, 2px 2px 0 rgba(0,0,0,0.1);
}

.coin-display {
    background: #fff;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 1.2rem;
    color: #f39c12;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 8px;
    border: 2px solid #ffeaa7;
}

/* Main Game Area */
.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
}

/* The Egg */
.egg-container {
    width: 200px;
    height: 260px;
    position: relative;
    perspective: 1000px;
    margin-bottom: 30px;
    cursor: pointer;
    transition: transform 0.2s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.egg-container:active {
    transform: scale(0.95);
}

.egg {
    width: 100%;
    height: 100%;
    position: relative;
    animation: float 3s ease-in-out infinite;
    transform-style: preserve-3d;
}

.egg.cracking {
    animation: shake 0.5s infinite;
}

.egg.open {
    animation: none;
}

.egg-top, .egg-bottom {
    position: absolute;
    width: 100%;
    background: linear-gradient(135deg, #ffffff 0%, #f1f2f6 100%);
    box-shadow: inset -10px -10px 20px rgba(0,0,0,0.1), 0 20px 30px rgba(0,0,0,0.2);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.egg-top {
    height: 55%;
    top: 0;
    border-radius: 100px 100px 10px 10px;
    transform-origin: bottom center;
    z-index: 2;
}

.egg-bottom {
    height: 50%;
    bottom: 0;
    border-radius: 10px 10px 100px 100px;
    background: linear-gradient(135deg, var(--egg-accent) 0%, #e84118 100%);
    z-index: 1;
}

.egg-label {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    padding: 5px 15px;
    border-radius: 15px;
    color: var(--egg-accent);
    font-size: 1.5rem;
    z-index: 3;
    pointer-events: none;
    box-shadow: 0 4px 0px rgba(0,0,0,0.1);
    transition: opacity 0.3s;
}

/* Egg states */
.egg.crack-1 .egg-top { transform: rotate(5deg) translateY(-2px); }
.egg.crack-2 .egg-top { transform: rotate(-5deg) translateY(-5px); }
.egg.crack-3 .egg-top { transform: rotate(10deg) translateY(-10px); }

.egg.open .egg-top {
    transform: rotate(45deg) translateY(-120px) translateX(60px);
    opacity: 0;
}
.egg.open .egg-label { opacity: 0; }
.egg.open .egg-bottom {
    transform: scale(0.9);
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px) rotate(-2deg); }
    75% { transform: translateX(5px) rotate(2deg); }
}

.instruction {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.8);
    padding: 10px 20px;
    border-radius: 20px;
    margin-bottom: 20px;
    text-align: center;
}

/* Buttons */
.action-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.btn {
    border: none;
    padding: 15px 30px;
    border-radius: 30px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    font-family: 'Fredoka One', cursive;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn:active {
    transform: translateY(4px);
    box-shadow: 0 4px 0 rgba(0,0,0,0.2) !important;
}

.btn:disabled {
    filter: grayscale(1);
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: #ff4757;
    color: #fff;
    box-shadow: 0 8px 0 #c23616;
}

.btn-secondary {
    background: #1e90ff;
    color: #fff;
    box-shadow: 0 8px 0 #3742fa;
}

/* Modals */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(47, 53, 66, 0.9);
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
    opacity: 1;
    transition: opacity 0.3s ease;
}

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

#confetti-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 101;
}

/* Reveal Content */
.reveal-content {
    background: #fff;
    padding: 40px;
    border-radius: 30px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    z-index: 102;
    transform: scale(1);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 90%;
    max-width: 400px;
}

.modal.hidden .reveal-content {
    transform: scale(0.5);
}

.reveal-content h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    text-transform: uppercase;
}

.glow-effect {
    width: 150px;
    height: 150px;
    margin: 0 auto 20px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    animation: pulseGlow 2s infinite alternate;
}

.toy-display {
    font-size: 5rem;
    filter: drop-shadow(0 10px 10px rgba(0,0,0,0.3));
    z-index: 2;
    animation: bounceReveal 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.reveal-content h3 {
    font-size: 1.5rem;
    color: var(--text-main);
    margin-bottom: 10px;
}

.reveal-content p {
    font-size: 1.2rem;
    font-weight: bold;
    color: #f39c12;
    margin-bottom: 25px;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Rarity Styles */
.rarity-Common { color: var(--text-light); }
.rarity-Rare { color: var(--rare); }
.rarity-Epic { color: var(--epic); }
.rarity-Legendary { 
    color: var(--legendary); 
    text-shadow: 0 0 10px #ffeaa7;
    animation: legendaryTextGlow 1.5s infinite alternate;
}

.glow-Common { background: radial-gradient(circle, #f1f2f6 0%, transparent 70%); }
.glow-Rare { background: radial-gradient(circle, rgba(30,144,255,0.5) 0%, transparent 70%); }
.glow-Epic { background: radial-gradient(circle, rgba(156,136,255,0.5) 0%, transparent 70%); }
.glow-Legendary { 
    background: radial-gradient(circle, rgba(255,165,2,0.6) 0%, transparent 70%);
    box-shadow: 0 0 40px #ffa502;
}

@keyframes pulseGlow {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.1); opacity: 1; }
}

@keyframes bounceReveal {
    0% { transform: scale(0) translateY(50px); }
    50% { transform: scale(1.2) translateY(-20px); }
    100% { transform: scale(1) translateY(0); }
}

@keyframes legendaryTextGlow {
    0% { text-shadow: 0 0 5px #ffa502, 0 0 10px #ffa502; }
    100% { text-shadow: 0 0 20px #ff7f50, 0 0 30px #ff7f50, 0 0 40px #ff7f50; }
}

/* Collection Gallery */
#collection-modal {
    background: var(--primary-bg);
    justify-content: flex-start;
    padding-top: 20px;
}

.collection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 90%;
    margin-bottom: 20px;
    background: #fff;
    padding: 15px 20px;
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
}

.collection-header h2 {
    color: var(--text-main);
    font-size: 1.5rem;
}

.btn-close {
    background: #ff4757;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 0 #c23616;
}

.btn-close:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #c23616;
}

.collection-filters {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    width: 90%;
    padding-bottom: 10px;
    margin-bottom: 10px;
    /* Hide scrollbar */
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.collection-filters::-webkit-scrollbar {
    display: none;
}

.filter-btn {
    padding: 8px 15px;
    border-radius: 20px;
    border: none;
    background: #fff;
    font-weight: bold;
    color: var(--text-light);
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.filter-btn.active {
    background: var(--text-main);
    color: #fff;
}

.collection-grid {
    width: 90%;
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 15px;
    padding-bottom: 40px;
    align-content: start;
}

.toy-card {
    background: #fff;
    border-radius: 15px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    position: relative;
    aspect-ratio: 1;
    justify-content: center;
    transition: transform 0.2s;
}

.toy-card:hover {
    transform: translateY(-5px);
}

.toy-card .emoji {
    font-size: 2.5rem;
    margin-bottom: 5px;
    filter: drop-shadow(0 4px 4px rgba(0,0,0,0.2));
}

.toy-card .name {
    font-size: 0.7rem;
    text-align: center;
    font-weight: bold;
    color: var(--text-main);
    line-height: 1.1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Rarity indicators on cards */
.toy-card.rarity-Common { border-bottom: 4px solid var(--common); }
.toy-card.rarity-Rare { border-bottom: 4px solid var(--rare); }
.toy-card.rarity-Epic { border-bottom: 4px solid var(--epic); background: linear-gradient(to bottom, #fff, #f6f4ff); }
.toy-card.rarity-Legendary { 
    border-bottom: 4px solid var(--legendary); 
    background: linear-gradient(to bottom, #fff, #fff8e6);
    box-shadow: 0 4px 15px rgba(255, 165, 2, 0.3);
}

/* Locked state */
.toy-card.locked {
    background: #f1f2f6;
    border-bottom: 4px solid #dfe4ea;
}

.toy-card.locked .emoji {
    filter: brightness(0) opacity(0.2);
}

.toy-card.locked .name {
    color: transparent;
    background: #dfe4ea;
    border-radius: 4px;
    height: 10px;
    width: 80%;
}

/* Footer */
footer {
    background: #2f3542;
    color: #f1f2f6;
    padding: 30px 20px;
    text-align: center;
    border-top: 5px solid var(--accent);
    margin-top: auto;
    font-size: 0.9rem;
}

.footer-content p {
    margin-bottom: 10px;
    color: #dfe4ea;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.footer-links a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s;
    font-weight: 700;
}

.footer-links a:hover {
    color: #ffcccc;
}
