@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@400;600;700&display=swap');

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

:root {
    --pink: #ff758f;
    --blue: #4cc9f0;
    --yellow: #ffd166;
    --green: #06d6a0;
    --purple: #9d4edd;
    --orange: #ff9f1c;
    --magenta: #f15bb5;
    --dark: #0f0c29;
}

body {
    font-family: 'Quicksand', sans-serif;
    background-color: var(--dark);
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

/* Floating Background */
.floating-bg {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 0;
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    overflow: hidden;
}

.shape {
    position: absolute;
    filter: blur(60px);
    opacity: 0.3;
    animation: float 15s infinite ease-in-out;
}

.shape:nth-child(1) { width: 300px; height: 300px; background: var(--pink); top: -10%; left: -10%; }
.shape:nth-child(2) { width: 400px; height: 400px; background: var(--blue); bottom: -20%; right: -10%; }

@keyframes float {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-30px) scale(1.05); }
}

header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: env(safe-area-inset-top, 5px) 15px 5px 15px;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 12, 41, 0.9);
    backdrop-filter: blur(10px);
    height: 60px; /* Smaller header */
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo img {
    height: 32px; /* Smaller logo */
    width: auto;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    width: 32px;  /* Smaller buttons */
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1rem;
    color: white;
    transition: all 0.2s;
}

.icon-btn img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.icon-btn.active {
    background: var(--blue);
    border-color: #fff;
    box-shadow: 0 0 10px var(--blue);
}

.hidden { display: none !important; }

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 12, 41, 0.95);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.title-kawaii {
    font-size: 3rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 15px var(--pink);
    margin-bottom: 10px;
}

.btn-main {
    background: linear-gradient(135deg, var(--pink) 0%, #ff8b94 100%);
    color: white;
    border: none;
    padding: 12px 35px;
    font-size: 1.3rem;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(255, 139, 148, 0.4);
}

/* GAME BOARD */
.game-container {
    padding-top: calc(env(safe-area-inset-top, 0px) + 70px); /* Space for header */
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    z-index: 5;
    position: relative;
}

.game-info-bar {
    display: flex;
    justify-content: space-around;
    width: 90%;
    max-width: 400px;
    background: rgba(162, 220, 252, 0.2);
    border: 2px solid rgba(162, 220, 252, 0.4);
    padding: 10px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    box-shadow: 0 0 15px rgba(162, 220, 252, 0.2);
    margin-bottom: 5px;
}

#level-display, #score-display {
    color: var(--blue);
    margin-left: 5px;
}

.status-message {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--blue);
    text-shadow: 0 0 10px rgba(76, 201, 240, 0.5);
    height: 25px;
    margin: 5px 0;
}

.timer-bar-wrapper {
    width: 80%;
    max-width: 300px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.timer-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #b5f2b1, var(--blue), var(--pink));
    transform-origin: left;
}

.grid-container {
    display: grid;
    gap: 12px;
    width: 85vw;
    height: 85vw;
    max-width: 360px;
    max-height: 360px;
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); }

.grid-cell {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.2);
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.grid-cell::before {
    content: '( • ω • )';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.15);
    pointer-events: none;
}

/* Colors */
.color-1 { background-color: var(--pink) !important; box-shadow: 0 0 15px var(--pink); border: 2px solid #fff; }
.color-2 { background-color: var(--blue) !important; box-shadow: 0 0 15px var(--blue); border: 2px solid #fff; }
.color-3 { background-color: var(--yellow) !important; box-shadow: 0 0 15px var(--yellow); border: 2px solid #fff; }
.color-4 { background-color: var(--green) !important; box-shadow: 0 0 15px var(--green); border: 2px solid #fff; }
.color-5 { background-color: var(--purple) !important; box-shadow: 0 0 15px var(--purple); border: 2px solid #fff; }
.color-6 { background-color: var(--orange) !important; box-shadow: 0 0 15px var(--orange); border: 2px solid #fff; }
.color-7 { background-color: var(--magenta) !important; box-shadow: 0 0 15px var(--magenta); border: 2px solid #fff; }

.grid-cell.selected { border: 4px solid #fff; box-shadow: 0 0 25px #fff; transform: scale(1.05); }
.grid-cell.error { background: #ff0033 !important; animation: shake 0.3s; }

@keyframes shake {
    0%, 100% { transform: translate(0); }
    25% { transform: translate(-4px); }
    75% { transform: translate(4px); }
}

.palette-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 30px;
    width: 90%;
    margin-top: 5px;
}

.palette-color { width: 44px; height: 44px; border-radius: 50%; cursor: pointer; transition: transform 0.2s; border: 2px solid transparent;}
.palette-color.selected { border-color: #fff; transform: scale(1.2); box-shadow: 0 0 15px #fff;}

.btn-check {
    background: #fff;
    color: var(--dark);
    padding: 12px 40px;
    font-size: 1.2rem;
    font-weight: 800;
    border-radius: 50px;
    cursor: pointer;
    margin-top: 10px;
    border: none;
}

/* Floating Feedback */
.floating-feedback {
    position: fixed;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    font-weight: 800;
    pointer-events: none;
    z-index: 3000;
    animation: floatUp 1.5s forwards;
}
.floating-feedback.success { color: #b5f2b1; text-shadow: 0 0 15px #b5f2b1; }
.floating-feedback.error { color: var(--pink); text-shadow: 0 0 15px var(--pink); }

@keyframes floatUp {
    0% { transform: translate(-50%, 0%) scale(0.5); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
    100% { transform: translate(-50%, -100%) scale(1); opacity: 0; }
}

/* Leaderboard */
.rank-item { display: flex; justify-content: space-between; padding: 12px; border-bottom: 1px solid rgba(0,0,0,0.05); font-family: inherit;}
.rank-pos { color: var(--purple); font-weight: bold; width: 40px; }
.rank-name { color: #4a4e69; font-weight: bold; flex: 1; text-align: left; }
.rank-score { color: var(--pink); font-weight: bold; }

.ranking-form {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 20px;
    width: 90%;
    max-width: 350px;
}

#player-nickname {
    background: white;
    color: #4a4e69;
    font-size: 1.1rem;
    padding: 12px;
    border: none;
    border-radius: 12px;
    outline: none;
    width: 200px;
}

#btn-submit-score {
    margin-top: 10px;
}
