@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@600;800&family=M+PLUS+Rounded+1c:wght@700&display=swap');

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

body {
    font-family: 'Nunito', 'M PLUS Rounded 1c', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    touch-action: manipulation;
}

#game-container {
    margin-top: 60px;
    width: 100%;
    max-width: 500px;
    height: 85vh;
    max-height: 850px;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    position: relative;
    overflow: hidden;
    border-radius: 24px;
}

#header {
    padding: 25px 20px 20px;
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    z-index: 2;
}

#level-display {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#lives-display {
    font-size: 1.5rem; 
    margin-bottom: 8px; 
    text-align: center;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2));
}

#timer-bar-container {
    width: 100%;
    max-width: 300px;
    height: 12px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    margin: 10px auto 15px auto;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

#timer-bar {
    width: 100%;
    height: 100%;
    background-color: #00e676;
    border-radius: 10px;
    transition: width 0.05s linear, background-color 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#message {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
}

#board {
    flex-grow: 1;
    display: grid;
    padding: 15px;
    gap: 3px;
    background-color: transparent;
    align-content: center;
    justify-content: center;
    align-items: center;
    margin: auto;
    width: 100%;
    max-width: 400px;
    /* max-height: 350px; */
}

.cell {
    border-radius: 5px;
    cursor: pointer;
    transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s;
    /* aspect-ratio: 1 / 1; */
    width: 100%;
    height: 100%;
    /* max-width: 120px; */
    max-height: 350px;
}

.cell:active {
    transform: scale(0.9) translateY(4px);
}

#result-screen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgb(255 255 255 / 90%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    padding: 20px;
    text-align: center;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.hidden {
    display: none !important;
}

#result-title {
    font-size: 2.5rem;
    margin-bottom: 15px;
    font-weight: 800;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#result-message {
    font-size: 1.3rem;
    margin-bottom: 40px;
    color: #333;
    line-height: 1.6;
    font-weight: 700;
}

#mypage-btn {
    padding: 18px 20px;
    font-size: 1.1rem;
    font-weight: 800;
    background: linear-gradient(135deg, #f6d365 0%, #ff6d43 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 15px rgba(253, 160, 133, 0.4);
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#mypage-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 20px rgba(253, 160, 133, 0.5);
}

#mypage-btn:active {
    transform: translateY(2px);
    box-shadow: 0 4px 8px rgba(253, 160, 133, 0.3);
}

#restart-btn {
    padding: 18px 45px;
    font-size: 1.3rem;
    font-weight: 800;
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);
    color: #d13076;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 15px rgba(209, 48, 118, 0.2);
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 20px rgba(209, 48, 118, 0.3);
}

#restart-btn:active {
    transform: translateY(2px);
    box-shadow: 0 4px 8px rgba(209, 48, 118, 0.2);
}

#restart-btn.secondary {
    background: transparent;
    color: #888;
    box-shadow: none;
    border: 2px solid #ccc;
    padding: 16px 45px; /* offset border */
    font-size: 1rem;
}

#restart-btn.secondary:hover {
    background: rgba(0,0,0,0.05);
    transform: none;
    box-shadow: none;
}

@media (max-width: 500px) {
    #game-container {
        border-radius: 0;
        height: 80vh;
        max-height: none;
        margin-top: 0;
    }
    #header {
        border-bottom-left-radius: 20px;
        border-bottom-right-radius: 20px;
    }
}

#start-screen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    padding: 20px;
    text-align: center;
}

#age-select {
    padding: 15px;
    font-size: 1.2rem;
    border: 2px solid #ccc;
    border-radius: 10px;
    width: 250px;
    margin-bottom: 20px;
    text-align: center;
    background-color: white;
    cursor: pointer;
}

#age-select:focus {
    outline: none;
    border-color: #667eea;
}

#start-btn {
    padding: 18px 45px;
    font-size: 1.3rem;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 15px rgba(118, 75, 162, 0.3);
    transition: all 0.2s ease;
    letter-spacing: 1px;
}

#start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 20px rgba(118, 75, 162, 0.4);
}

#start-btn:active {
    transform: translateY(2px);
    box-shadow: 0 4px 8px rgba(118, 75, 162, 0.2);
}
