:root {
    --bg-dark: #121212;
    --text-light: #f5f5f5;
    --accent-blue: #00d2ff;
    --accent-red: #ff3333;
    --dk-bg: #000000;
    --font-primary: 'Outfit', sans-serif;
    --font-retro: 'Press Start 2P', cursive;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-family: var(--font-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    touch-action: none;
    /* Prevent browser handling of touch gestures */
}

/* Quit Button */
.quit-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    font-family: var(--font-retro);
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    padding: 10px 15px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    transition: all 0.2s;
}

.quit-btn:hover {
    color: white;
    border-color: white;
    background: rgba(255, 255, 255, 0.1);
}

.app-container {
    display: flex;
    gap: 20px;
    max-width: 1000px;
    width: 100%;
    padding: 20px;
    flex-direction: row;
    /* Desktop layout */
    margin-top: 40px;
    align-items: stretch;
}

/* Game Area */
.game-wrapper {
    position: relative;
    border: 4px solid #333;
    border-radius: 8px;
    background-color: var(--dk-bg);
    overflow: hidden;
    box-shadow: 0 0 30px rgba(255, 51, 51, 0.15);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 80vh;
    /* Make it tall for DK's verticality */
    max-width: 60vh;
    /* maintain aspect ratio approx 3:4 */
    width: 100%;
}

canvas {
    display: block;
    background: transparent;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

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

/* Typography styles matching menu */
h1.logo,
h2.glow {
    font-family: var(--font-retro);
    text-align: center;
    margin-bottom: 2rem;
    line-height: 1.4;
}

h1.dk-title {
    font-size: 1.8rem;
    color: var(--accent-red);
    text-shadow: 2px 2px 0px #aa0000;
}

h2.glow {
    font-size: 1.5rem;
    color: white;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

h2.text-danger {
    color: #ff3333;
    text-shadow: 0 0 10px rgba(255, 51, 51, 0.8);
}

.instruction-text {
    margin-top: 1rem;
    color: #ccc;
    font-size: 1rem;
    text-align: center;
    font-family: var(--font-retro);
}

.high-score-display {
    font-family: var(--font-retro);
    font-size: 1rem;
    margin-bottom: 2rem;
    color: #00d2ff;
}

.score-summary {
    font-family: var(--font-retro);
    font-size: 1.2rem;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
}

/* Buttons */
.btn {
    font-family: var(--font-retro);
    padding: 15px 30px;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-transform: uppercase;
    transition: transform 0.1s, filter 0.2s;
    margin: 10px 0;
}

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

.btn:hover {
    filter: brightness(1.2);
}

.btn-primary {
    background: var(--accent-red);
    color: white;
    box-shadow: 0 4px 0 #aa0000;
}

.btn-secondary {
    background: #333;
    color: white;
    box-shadow: 0 4px 0 #111;
}

/* Right Panels (Score, Level) */
.panels-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 250px;
}

.panel-box {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
}

.panel-box .label {
    font-family: var(--font-retro);
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 10px;
}

.panel-box .value {
    font-family: var(--font-retro);
    font-size: 1.2rem;
    color: white;
}

.bonus-panel .value {
    color: #ffaa00;
}

.lives-container {
    display: flex;
    justify-content: center;
    gap: 5px;
}

.mario-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    background-color: red;
    /* Placeholder for Mario face */
    clip-path: polygon(0 40%, 40% 40%, 50% 0, 60% 40%, 100% 40%, 100% 100%, 0 100%);
}

/* Mobile Controls - default hidden */
.mobile-controls {
    display: none;
    width: 100%;
}

/* Media Queries for Mobile/Tablet */
@media (max-width: 800px) {
    .app-container {
        flex-direction: column;
        align-items: center;
        margin-top: 50px;
        padding: 5px;
        gap: 10px;
    }

    .game-wrapper {
        height: 55vh;
        max-width: 100%;
    }

    .panels-container {
        flex-direction: row;
        justify-content: center;
        width: 100%;
        flex-wrap: wrap;
        gap: 10px;
    }

    .panel-box {
        flex: 1 1 40%;
        padding: 8px;
    }

    .panel-box .value {
        font-size: 1rem;
    }

    .mobile-controls {
        display: flex;
        flex-direction: column;
        gap: 5px;
        margin-top: 5px;
        flex: 1;
    }

    .control-row {
        display: none;
        /* Hide top controls to save space */
    }

    .control-grid {
        display: flex;
        justify-content: space-between;
        padding: 0 10px;
        align-items: flex-end;
        height: 100%;
    }

    .dpad-cross {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 5px;
    }

    .dpad-horizontal {
        display: flex;
        gap: 40px;
    }

    .control-btn {
        background: rgba(255, 255, 255, 0.1);
        border: 2px solid rgba(255, 255, 255, 0.2);
        color: white;
        border-radius: 50%;
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
        display: flex;
        justify-content: center;
        align-items: center;
        /* Disable touch callout on long press */
        -webkit-touch-callout: none;
    }

    .control-btn:active,
    .control-btn.pressed {
        background: rgba(255, 255, 255, 0.3);
        transform: scale(0.95);
    }

    .action-btn.jump-btn {
        background: rgba(255, 51, 51, 0.2);
        border-color: rgba(255, 51, 51, 0.5);
        color: var(--accent-red);
        width: 70px;
        height: 70px;
        font-size: 0.8rem;
        font-weight: bold;
        font-family: var(--font-retro);
        border-radius: 50%;
        margin-bottom: 20px;
        margin-right: 10px;
    }
}