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

:root {
    --primary-pink: #D14F8A;
    --light-pink: #FFF0F5;
    --cream: #FFF9E6;
    --brown: #5D4037;
    --dark-brown: #6D4C41;
}

body {
    font-family: 'Nunito', sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 80px 20px 20px; /* เพิ่ม padding-top เพื่อเว้นที่สำหรับ title */
    color: var(--brown);
    overflow-x: hidden;
    /* Animated Gradient Background */
    background: linear-gradient(-45deg, #ffb6c1, #ffd1dc, #fff0f5, #fff9e6, #e0f7fa, #e1f5fe);
    background-size: 400% 400%;
    animation: gradientAnimation 15s ease infinite;
}

@keyframes gradientAnimation {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Title Styles */
.page-title {
    position: fixed;
    top: 20px;
    left: 20px;
    font-family: 'Nunito', sans-serif;
    font-size: 1.2rem;
    color: var(--dark-brown);
    z-index: 100;
    line-height: 1.3;
}

.brand {
    font-weight: 900;
}

.subtitle {
    font-weight: 200;
}

.container {
    text-align: center;
    z-index: 10;
    position: relative;
    width: 100%;
    max-width: 900px;
}

.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1.5rem;
    justify-items: center;
    align-items: center;
    width: 100%;
}

.link-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    outline: none;
    width: 100%;
    aspect-ratio: 1 / 1; /* ทำให้เป็นสี่เหลี่ยมจัตุรัส */
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 1.5rem 1rem;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* ตัวอักษรเล็กๆ จางๆ ที่มุมบนขวา (เหมือนตารางธาตุ) */
.element-symbol {
    position: absolute;
    top: 10px;
    right: 12px;
    font-size: 0.8rem;
    font-weight: 900;
    color: rgba(209, 79, 138, 0.3);
    text-transform: uppercase;
}

.link {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.2rem;
    text-decoration: none;
    color: var(--primary-pink);
    background: var(--light-pink);
    width: 70px;
    height: 70px;
    border-radius: 50%;
    margin-bottom: 0.8rem;
    transition: all 0.3s ease;
}

.link-description {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--dark-brown);
    text-align: center;
    line-height: 1.3;
    transition: all 0.3s ease;
}

.link-item:hover, .link-item.highlight {
    transform: scale(1.05) translateY(-5px);
    background: rgba(255, 255, 255, 0.95);
}

.link-item:hover .link, .link-item.highlight .link {
    background: var(--primary-pink);
    color: #FFFFFF;
    transform: rotate(-10deg) scale(1.1);
}

.link-item:hover .link-description, .link-item.highlight .link-description {
    color: var(--primary-pink);
}

/* Digital Clock Styles */
.clock-display {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--dark-brown);
    text-align: center;
    line-height: 1.3;
    transition: all 0.3s ease;
}

/* Ripple Effect Animation */
@keyframes ripple {
    to {
        width: 400px;
        height: 400px;
        opacity: 0;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 70px 15px 15px; /* ปรับ padding-top สำหรับมือถือ */
    }
    
    .links-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
    
    .link-item {
        padding: 1rem 0.5rem;
    }
    
    .link {
        width: 55px;
        height: 55px;
        font-size: 1.8rem;
    }
    
    .link-description, .clock-display {
        font-size: 0.85rem;
    }
    
    .page-title {
        font-size: 1rem;
        top: 15px;
        left: 15px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 65px 10px 10px; /* ปรับ padding-top สำหรับมือถือขนาดเล็ก */
    }
    
    .links-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.8rem;
    }
    
    .link-item {
        padding: 1rem 0.5rem;
    }
    
    .link {
        width: 50px;
        height: 50px;
        font-size: 1.6rem;
        margin-bottom: 0.5rem;
    }
    
    .link-description, .clock-display {
        font-size: 0.8rem;
    }
    
    .element-symbol {
        font-size: 0.7rem;
        top: 8px;
        right: 10px;
    }
    
    .page-title {
        font-size: 0.9rem;
        top: 12px;
        left: 12px;
    }
}

@media (max-width: 360px) {
    body {
        padding: 60px 8px 8px; /* ปรับ padding-top สำหรับมือถือขนาดเล็กมาก */
    }
    
    .links-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.7rem;
    }
    
    .link-item {
        padding: 0.8rem 0.3rem;
    }
    
    .link {
        width: 45px;
        height: 45px;
        font-size: 1.4rem;
    }
    
    .link-description, .clock-display {
        font-size: 0.75rem;
    }
}

/* PWA Fullscreen Styles */
@media all and (display-mode: fullscreen) {
    body {
        padding-top: 20px;
    }
    
    .page-title {
        top: 10px;
        left: 10px;
    }
}

@media all and (display-mode: standalone) {
    body {
        padding-top: 70px;
    }
    
    .page-title {
        top: 20px;
        left: 20px;
    }
}