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

body {
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow-x: hidden;
}

.mr-page {
    --mr-gutter: 16px;
    --mr-pad: 15px;
    --mr-vh: 100vh;
    width: min(1080px, calc(100% - 2 * var(--mr-gutter)));
    margin: 0 auto;
    padding-bottom: 24px;
    text-align: center;
}

@supports (height: 100svh) {
    .mr-page {
        --mr-vh: 100svh;
    }
}

html body .mr-page a.back-home.back-home {
    display: flex;
    width: fit-content;
    margin: 8px auto 16px 0;
}

html[dir="rtl"] body .mr-page a.back-home.back-home {
    margin: 8px 0 16px auto;
}

.mr-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

#gameContainer {
    display: inline-block;
    vertical-align: top;
    text-align: center;
    background: white;
    padding: var(--mr-pad);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    max-width: 100%;
}

#lives {
    font-size: 24px;
    line-height: 1.3;
    min-height: 1.3em;
    margin-bottom: 5px;
}

.mr-stage {
    position: relative;
}

#gameCanvas {
    --mr-canvas-w: min(calc(100vw - 2 * var(--mr-gutter) - 2 * var(--mr-pad)), calc((var(--mr-vh) - 180px) * 2 / 3), 640px);
    width: max(260px, var(--mr-canvas-w));
    max-width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
    border: 3px solid #333;
    border-radius: 10px;
    background: #228B22;
    display: block;
    margin: 0 auto;
    touch-action: none;
}

#question {
    font-size: clamp(24px, 6vw, 32px);
    font-weight: bold;
    color: #2c3e50;
    margin: 10px 0;
    padding: 12px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-radius: 15px;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.pre-start #question {
    visibility: hidden;
}

.overlay {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.97);
    padding: 30px 40px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 100;
    min-width: 280px;
    max-width: calc(100% - 24px);
}

.overlay h2 {
    color: #e74c3c;
    font-size: clamp(28px, 7vw, 36px);
    margin-bottom: 15px;
}

#startScreen h2 {
    color: #667eea;
}

#gameOver.win h2 {
    color: #27ae60;
}

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: clamp(16px, 4vw, 18px);
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 10px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    min-height: 44px;
}

button:active {
    transform: scale(0.95);
}

@media (max-width: 480px) {
    .mr-page {
        --mr-gutter: 10px;
        --mr-pad: 8px;
    }

    #gameContainer {
        border-radius: 15px;
    }

    .overlay {
        padding: 24px 28px;
        min-width: 0;
        width: calc(100% - 32px);
    }
}

@media (min-width: 1000px) and (min-aspect-ratio: 1/1) {
    .mr-page {
        --mr-pad: 20px;
        width: min(1240px, calc(100% - 48px));
    }

    #gameContainer {
        display: inline-flex;
        align-items: center;
        gap: 32px;
        padding: var(--mr-pad) 32px;
    }

    .mr-side {
        width: clamp(240px, 24vw, 360px);
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 20px;
    }

    #lives {
        font-size: 36px;
        margin-bottom: 0;
    }

    #question {
        font-size: clamp(34px, 3.4vw, 52px);
        padding: 28px 16px;
        margin: 0;
        border-radius: 20px;
    }

    #gameCanvas {
        --mr-canvas-w: min(calc((var(--mr-vh) - 2 * var(--mr-pad) - 12px) * 2 / 3), 680px);
    }

    .overlay h2 {
        font-size: 40px;
    }

    button {
        font-size: 20px;
        padding: 14px 36px;
    }
}
