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

body {
    background: #f3d191;
    background-image: radial-gradient(#fae9c3 20%, transparent 20%), radial-gradient(#fae9c3 20%, transparent 20%);
    background-size: 30px 30px;
    background-position: 0 0, 15px 15px;
    font-family: 'Arial Rounded MT Bold', 'Helvetica Rounded', Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

/* --- PRELOADER UI --- */
#preloader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #2d1b33;
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease;
}

.loader-title {
    color: #f1c40f;
    font-size: 32px;
    margin-bottom: 20px;
    text-shadow: 0 4px 0 #d35400;
}

.loader-bar-container {
    width: 240px;
    height: 16px;
    background: #402849;
    border-radius: 8px;
    border: 3px solid #b57a42;
    overflow: hidden;
    margin-bottom: 20px;
}

.loader-bar {
    width: 0%;
    height: 100%;
    background: #2ecc71;
    transition: width 0.1s linear;
}

.start-btn {
    background: #2ecc71;
    border: none;
    padding: 14px 40px;
    font-size: 22px;
    color: white;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 6px 0 #27ae60;
    font-weight: bold;
    display: none;
    animation: pulse 1.5s infinite;
}

/* --- HOW TO PLAY MODAL --- */
#instructions-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(45, 27, 51, 0.98);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    z-index: 50;
    padding: 20px;
    transition: opacity 0.4s ease;
}

.modal-card {
    background: #402849;
    border: 5px solid #b57a42;
    border-radius: 28px;
    padding: 30px 24px;
    width: 90%;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
}

.modal-card h3 {
    color: #f1c40f;
    font-size: 28px;
    margin-bottom: 24px;
    text-shadow: 0 3px 0 #d35400;
    letter-spacing: 1px;
}

.rule-box {
    text-align: left;
    margin-bottom: 28px;
}

.rule-step {
    font-size: 14px;
    margin-bottom: 18px;
    line-height: 1.5;
    display: flex;
    align-items: center;
    gap: 14px;
    color: #f5f5f5;
}

.rule-icon {
    font-size: 22px;
    background: #1e1124;
    border: 2px solid #e67e22;
    border-radius: 50%;
    min-width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.rule-step strong {
    color: #f1c40f;
}

.modal-play-btn {
    background: #2ecc71;
    color: white;
    border: none;
    padding: 14px 40px;
    font-size: 22px;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 6px 0 #27ae60;
    transition: transform 0.1s, box-shadow 0.1s;
}

.modal-play-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #27ae60;
}

/* --- MAIN GAME CONTAINER --- */
#game-container {
    position: relative;
    width: 448px;
    height: 728px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    border-radius: 32px;
    border: 14px solid #b57a42;
    background-color: #2d1b33;
    overflow: hidden;
    flex-shrink: 0;
    transform-origin: center center;
}

canvas {
    display: block;
    cursor: crosshair;
}

/* --- HIGH-FIDELITY TOP UI HEADER --- */
#ui-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    background: #402849;
    border-bottom: 4px solid #1e1124;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 14px 10px 14px;
    z-index: 5;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    margin-top: 15px;
    border-radius: 0px 0px 40px 40px;
}

.level-row {
    display: flex;
    align-items: center;
    background: #1e1124;
    padding: 4px 16px;
    border-radius: 20px;
    border: 2px solid #b57a42;
    margin-bottom: 10px;
}

.level-label {
    color: #f1c40f;
    font-size: 14px;
    font-weight: bold;
    margin: 0 8px;
}

.level-progress-bg {
    width: 110px;
    height: 10px;
    background: #000;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
}

.level-progress-fill {
    width: 55%;
    height: 100%;
    background: linear-gradient(90deg, #e67e22, #f1c40f);
    border-radius: 5px;
}

.score-row {
    display: flex;
    width: 100%;
    justify-content: center;
    gap: 16px;
    margin-bottom: 2px;
}

.score-card {
    background: #e67e22;
    border-radius: 10px;
    padding: 4px 0;
    width: 110px;
    text-align: center;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2), 0 4px 6px rgba(0, 0, 0, 0.15);
}

.score-card.best-card {
    background: #f1c40f;
}

.score-card .title {
    font-size: 11px;
    color: #fff;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.score-card .value {
    font-size: 18px;
    color: #fff;
    font-weight: bold;
}

.target-badge-panel {
    background: #ffffff;
    border: 5px solid #b57a42;
    border-top: none;
    border-radius: 0 0 20px 20px;
    width: 160px;
    height: 48px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    bottom: -48px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.target-badge-value {
    font-size: 30px;
    color: #2d1b33;
    font-weight: 900;
    text-align: center;
    line-height: 1;
}

/* --- GAME OVER SCREEN --- */
#game-over-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(45, 27, 51, 0.95);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    z-index: 10;
}

#game-over-screen h2 {
    font-size: 46px;
    color: #e74c3c;
    margin-bottom: 15px;
    text-shadow: 3px 3px 0px #000;
}

#game-over-screen p {
    font-size: 24px;
    margin-bottom: 30px;
    color: #f1c40f;
}

#game-over-screen button {
    background: #e67e22;
    border: none;
    padding: 14px 35px;
    font-size: 22px;
    color: white;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 5px 0 #d35400;
    font-weight: bold;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}