/* Google Doodle Cricket - Premium Styling */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: #2b580c;
    background: radial-gradient(circle at center, #3d7e14 0%, #1e3f08 100%);
    font-family: 'Fredoka', 'Nunito', sans-serif;
    color: #fff;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 100vw;
    max-width: 1000px;
    height: 100vh;
    max-height: 650px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45);
    border-radius: 18px;
    overflow: hidden;
    background: #0d1b2a;
}

canvas#gameCanvas {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1000 / 650;
    object-fit: contain;
    display: block;
    margin: auto;
}

/* MOVEMENT PAD */
.move-pad {
    display: flex;
    gap: 12px;
}

.move-btn {
    background: #1c3b57;
    border: 3px solid #62b2fc;
    color: #fff;
    border-radius: 16px;
    width: 72px;
    height: 72px;
    font-size: 20px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: transform 0.1s ease, background 0.15s ease;
}

.move-btn small {
    font-size: 10px;
    letter-spacing: 0.5px;
    color: #a0cbf1;
}

.move-btn:hover {
    background: #255077;
    transform: translateY(-2px);
}

.move-btn:active {
    transform: translateY(3px) scale(0.96);
}

.best-digit {
    color: #00e5ff;
}

.modal-subtitle {
    font-size: 18px;
    font-weight: 700;
    color: #ffd700;
    letter-spacing: 2px;
    margin-bottom: 12px;
}

.modal-best-box {
    background: rgba(255, 215, 0, 0.15);
    border: 2px solid #ffd700;
    border-radius: 12px;
    padding: 8px 20px;
    display: inline-block;
    margin: 10px 0 16px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}

/* TOP VINTAGE SCOREBOARD (Google Doodle Style) */
#top-hud {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 10;
    pointer-events: none;
}

.scoreboard {
    background: #1c3b57;
    border: 3px solid #ffcc00;
    border-radius: 14px;
    padding: 6px 20px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    gap: 18px;
    color: #fff;
}

.scoreboard .stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.scoreboard .stat-label {
    font-size: 11px;
    text-transform: uppercase;
    color: #a0cbf1;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.scoreboard .stat-val {
    font-size: 26px;
    font-weight: 700;
    color: #fff;
    text-shadow: 2px 2px 0 #0f2336;
}

.score-digit {
    color: #ffd700;
    font-size: 32px;
}

.top-bar-btns {
    pointer-events: auto;
    display: flex;
    gap: 8px;
}

.hud-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: transform 0.15s ease, background 0.15s ease;
    color: #fff;
    font-size: 18px;
}

.hud-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.35);
}

.hud-btn:active {
    transform: scale(0.95);
}

/* BOTTOM INTERACTIVE ACTION BAR */
#controls-hud {
    position: absolute;
    bottom: 15px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    z-index: 10;
    pointer-events: none;
}

.interactive {
    pointer-events: auto;
}

/* Left & Right Batsman Movement Pad */
.move-pad {
    display: flex;
    gap: 10px;
    background: rgba(15, 30, 15, 0.6);
    padding: 6px;
    border-radius: 35px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(6px);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.move-btn {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    background: linear-gradient(135deg, #2d3748, #1a202c);
    color: #ffd700;
    font-size: 20px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
    transition: transform 0.1s ease, background 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    line-height: 1.1;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.move-btn small {
    font-size: 10px;
    color: #cbd5e0;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.move-btn:hover {
    background: linear-gradient(135deg, #4a5568, #2d3748);
    transform: scale(1.06);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45);
}

.move-btn:active {
    transform: scale(0.94);
    background: #ffcc00;
    color: #1a202c;
}

.move-btn:active small {
    color: #1a202c;
}

/* Huge Yellow Center Swing Button (Google Doodle style) */
.swing-container {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.swing-btn {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ffe600, #f39c12);
    border: 4px solid #ffffff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.8);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.08s ease, filter 0.15s ease;
    outline: none;
}

.swing-btn:hover {
    transform: scale(1.08);
    filter: brightness(1.1);
}

.swing-btn:active {
    transform: scale(0.92);
}

.swing-btn img, .swing-btn svg {
    width: 44px;
    height: 44px;
    filter: drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.3));
}

.btn-hint {
    font-size: 11px;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    background: rgba(0,0,0,0.4);
    padding: 2px 8px;
    border-radius: 10px;
}

/* Right Running & Defense Controls */
.secondary-controls {
    display: flex;
    gap: 12px;
}

.run-btn {
    background: linear-gradient(135deg, #00b894, #00cec9);
    border: 3px solid #ffffff;
    border-radius: 28px;
    padding: 10px 22px;
    color: #fff;
    font-weight: 800;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.12s, box-shadow 0.12s;
}

.run-btn:hover {
    transform: scale(1.05);
}

.run-btn:active {
    transform: scale(0.95);
}

.run-btn.disabled {
    opacity: 0.45;
    filter: grayscale(1);
    pointer-events: none;
}

.defend-btn {
    background: linear-gradient(135deg, #e17055, #d63031);
    border: 3px solid #ffffff;
    border-radius: 28px;
    padding: 10px 18px;
    color: #fff;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    transition: transform 0.12s;
}

.defend-btn:hover {
    transform: scale(1.05);
}

.defend-btn:active {
    transform: scale(0.95);
}

/* COMIC EVENT BANNER (SIX, FOUR, OUT) */
#event-banner {
    position: absolute;
    top: 38%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    z-index: 25;
    font-size: 72px;
    font-weight: 900;
    text-transform: uppercase;
    text-align: center;
    pointer-events: none;
    letter-spacing: 2px;
    white-space: nowrap;
    text-shadow: 
        -3px -3px 0 #000,  
         3px -3px 0 #000,
        -3px  3px 0 #000,
         3px  3px 0 #000,
         0 10px 25px rgba(0,0,0,0.7);
}

#event-banner.six {
    color: #ffd700;
}

#event-banner.four {
    color: #00cec9;
}

#event-banner.out {
    color: #ff3838;
}

/* OVERLAYS & MODALS */
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 25, 10, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: #1e3f5a;
    border: 4px solid #ffcc00;
    border-radius: 24px;
    padding: 30px 40px;
    max-width: 460px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.6);
}

.modal-title {
    font-size: 34px;
    font-weight: 800;
    color: #ffd700;
    margin-bottom: 12px;
    text-shadow: 2px 2px 0 #0c1c2a;
}

.modal-desc {
    font-size: 15px;
    line-height: 1.5;
    color: #d1e8ff;
    margin-bottom: 24px;
}

.level-badge-stat {
    font-size: 16px !important;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(255, 204, 0, 0.25);
    border: 1px solid #ffcc00;
    color: #ffcc00;
    text-shadow: none !important;
}

.level-badge-stat.easy {
    background: rgba(46, 204, 113, 0.25);
    border-color: #2ecc71;
    color: #2ecc71;
}

.level-badge-stat.hard {
    background: rgba(231, 76, 60, 0.25);
    border-color: #e74c3c;
    color: #ff7675;
}

.mode-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 12px 0 16px;
}

.mode-btn {
    flex: 1;
    padding: 10px 8px;
    border-radius: 12px;
    background: #0f2436;
    border: 2px solid #3a6891;
    color: #cbd5e0;
    font-weight: 800;
    cursor: pointer;
    font-size: 13px;
    letter-spacing: 0.5px;
    transition: all 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.mode-btn:hover {
    transform: translateY(-2px);
    border-color: #ffd700;
    color: #ffffff;
}

.mode-btn.selected[data-level="EASY"] {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
    border-color: #a7f3d0;
    box-shadow: 0 0 14px rgba(16, 185, 129, 0.5);
    transform: scale(1.04);
}

.mode-btn.selected[data-level="MEDIUM"] {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #ffffff;
    border-color: #fef08a;
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.5);
    transform: scale(1.04);
}

.mode-btn.selected[data-level="HARD"] {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    color: #ffffff;
    border-color: #fecaca;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.6);
    transform: scale(1.04);
}

.primary-play-btn {
    background: linear-gradient(135deg, #00b894, #00cec9);
    border: 3px solid #fff;
    border-radius: 35px;
    padding: 14px 45px;
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
    transition: transform 0.15s ease;
}

.primary-play-btn:hover {
    transform: scale(1.07);
}

.primary-play-btn:active {
    transform: scale(0.96);
}

/* Responsive Mobile Usability & Scaling */
@media (max-width: 768px) {
    body {
        align-items: center;
        background: #0d1b2a;
    }

    #game-container {
        border-radius: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
        box-shadow: none;
    }

    /* Scoreboard fits snugly at top without obscuring play */
    #top-hud {
        top: 6px;
        gap: 6px;
    }

    .scoreboard {
        padding: 4px 10px;
        gap: 8px;
        border-radius: 10px;
    }

    .scoreboard .stat-val {
        font-size: 18px;
    }

    .score-digit {
        font-size: 22px;
    }

    .scoreboard .stat-label {
        font-size: 8px;
    }

    .hud-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    /* Bottom mobile action controls optimized for two-thumb ergonomics */
    #controls-hud {
        bottom: 8px;
        padding: 0 10px;
        padding-bottom: env(safe-area-inset-bottom, 8px);
    }

    .move-pad {
        gap: 6px;
        padding: 4px;
        border-radius: 20px;
    }

    .move-btn {
        width: 46px;
        height: 46px;
        font-size: 15px;
        border-radius: 12px;
    }

    .move-btn small {
        font-size: 8px;
    }

    .swing-container {
        position: static;
        transform: none;
        margin-left: auto;
    }

    .swing-btn {
        width: 60px;
        height: 60px;
    }

    .swing-btn svg {
        width: 32px;
        height: 32px;
    }

    .btn-hint {
        display: none;
    }

    #event-banner {
        font-size: 42px;
    }

    .modal-card {
        padding: 20px 16px;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-title {
        font-size: 26px;
    }

    .modal-subtitle {
        font-size: 14px;
    }

    .primary-play-btn {
        padding: 10px 32px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .move-btn {
        width: 42px;
        height: 42px;
        font-size: 14px;
    }

    .move-btn small {
        font-size: 7px;
    }

    .swing-btn {
        width: 54px;
        height: 54px;
    }

    .swing-btn svg {
        width: 28px;
        height: 28px;
    }

    .scoreboard {
        padding: 2px 6px;
        gap: 5px;
    }

    .scoreboard .stat-val {
        font-size: 15px;
    }

    .score-digit {
        font-size: 18px;
    }

    .modal-card {
        padding: 16px 12px;
        max-height: 92vh;
    }

    .modal-title {
        font-size: 22px;
    }

    .modal-subtitle {
        font-size: 12px;
    }

    .mode-btn {
        padding: 7px 3px;
        font-size: 10px;
    }

    .modal-desc {
        font-size: 12px;
        margin-bottom: 12px;
    }

    .primary-play-btn {
        padding: 8px 26px;
        font-size: 16px;
    }
}
