/* Back to games link */
.back-to-games {
    position: fixed;
    top: calc(10px + env(safe-area-inset-top, 0px));
    right: calc(10px + env(safe-area-inset-right, 0px));
    z-index: 200;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 7px 13px;
    font: bold 13px Arial, sans-serif;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}
.back-to-games:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: translateY(-1px);
}

/* Основні стилі */
* {
    margin: 0;
    padding: 0;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent; /* remove blue tap flash on Android */
    box-sizing: border-box;
}

html, body {
    background: #87CEEB;
    font-family: Arial, sans-serif;
    overflow: hidden;
    position: fixed;
    inset: 0;
    width: 100%;
    /* Dynamic viewport units account for the mobile URL bar; fall back to vh. */
    height: 100vh;
    height: 100dvh;
    overscroll-behavior: none; /* stop pull-to-refresh / rubber-banding on Android */
}

canvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    /* width/height are set in JS (CSS px) for DPI-aware rendering */
    touch-action: none; /* the game handles all gestures on the canvas itself */
}

/* Honor users who prefer reduced motion: drop non-essential UI transitions. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* UI елементи */
.ui {
    position: absolute;
    top: calc(10px + env(safe-area-inset-top, 0px));
    left: calc(10px + env(safe-area-inset-left, 0px));
    color: white;
    background: rgba(0,0,0,0.8);
    padding: 10px;
    border-radius: 5px;
    font-size: 12px;
    z-index: 100;
    transition: all 0.3s ease;
    min-width: 200px;
    cursor: pointer;
}

/* Desktop: collapsed state by default */
@media (min-width: 769px) {
    .ui .game-timer,
    .ui .game-controls,
    .ui .language-selector {
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: all 0.3s ease;
    }

    .ui:hover .game-timer,
    .ui:hover .game-controls,
    .ui:hover .language-selector {
        max-height: 500px;
        opacity: 1;
    }
}

/* Mobile UI adjustments */
@media (max-width: 768px) {
    .ui {
        font-size: 10px;
        padding: 6px;
        top: 5px;
        left: 5px;
        transform: translateY(-100%);
        opacity: 0;
        pointer-events: none;
        cursor: default;
    }

    .ui.visible {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }
}

/* Landscape mode: always show UI panel */
@media (orientation: landscape) {
    .ui {
        transform: translateY(0) !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    /* Mobile: always show all elements */
    .ui .game-timer,
    .ui .game-controls,
    .ui .language-selector {
        max-height: none;
        opacity: 1;
    }
}

.game-version {
    font-size: 10px;
    color: #FFD700;
    opacity: 0.8;
    margin-top: 2px;
    font-weight: bold;
}

.game-timer {
    font-size: 14px;
    color: #00FF00;
    font-weight: bold;
    margin-top: 8px;
    padding: 5px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    text-align: center;
}

.save-status {
    margin-top: 8px;
    padding: 5px;
    background: rgba(0,0,0,0.3);
    border-radius: 3px;
    border-left: 3px solid #FFD700;
}

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

.save-help {
    margin-top: 8px;
    font-size: 10px;
}

.save-help details {
    padding: 5px;
    background: rgba(0,0,0,0.2);
    border-radius: 3px;
}

.save-help details[open] {
    background: rgba(0,0,0,0.4);
}

.save-btn {
    background: rgba(255,215,0,0.2);
    border: 1px solid #FFD700;
    border-radius: 4px;
    color: white;
    padding: 6px 10px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: Arial, sans-serif;
}

.save-btn:hover {
    background: rgba(255,215,0,0.4);
    box-shadow: 0 0 8px rgba(255,215,0,0.5);
    transform: scale(1.02);
}

.save-btn:active {
    transform: scale(0.98);
}

.save-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: rgba(128,128,128,0.2);
    border-color: #666;
}

.save-btn:disabled:hover {
    background: rgba(128,128,128,0.2);
    box-shadow: none;
    transform: none;
}

.current-block-display {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 10px;
    border-radius: 8px;
    border: 2px solid #FFD700;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Mobile adjustments for current block display */
@media (max-width: 768px) {
    .current-block-display {
        top: 5px;
        left: 50%;
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
        pointer-events: none;
        padding: 6px;
        font-size: 12px;
    }

    .current-block-display.visible {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .current-block-display .current-block-icon {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
}

/* Landscape mode: always show current block display */
@media (orientation: landscape) {
    .current-block-display {
        transform: translateX(-50%) translateY(0) !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}

.current-block-icon {
    width: 40px;
    height: 40px;
    border: 2px solid #FFD700;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: rgba(255,215,0,0.2);
}

/* Керування */
.controls {
    position: absolute;
    bottom: 60px;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 10px);
}

/* Mobile controls toggle bar */
.mobile-toggle-bar {
    position: absolute;
    bottom: 70px;
    left: 10px;
    display: flex;
    gap: 8px;
    z-index: 101;
    padding: 6px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Landscape mode: always show toggle bar */
@media (orientation: landscape) {
    .mobile-toggle-bar {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Portrait mode: more spacing */
@media (orientation: portrait) {
    .mobile-toggle-bar {
        gap: 15px;
        padding: 10px;
    }
}

.mobile-toggle-btn {
    width: 48px;
    height: 48px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

/* Hover effects only on devices with a real pointer (avoids stuck hover on touch). */
@media (hover: hover) {
    .mobile-toggle-btn:hover {
        background: rgba(255, 255, 255, 0.3);
        transform: scale(1.1);
    }
}

.mobile-toggle-btn:active {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0.95);
}

.mobile-toggle-btn.active {
    background: rgba(255, 215, 0, 0.5);
    border-color: #FFD700;
}

/* Block selector dropdown */
.block-selector {
    display: flex;
    justify-content: center;
    background: rgba(0,0,0,0.9);
    padding: 10px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    border-radius: 10px 10px 0 0;
}

.block-selector.visible {
    transform: translateY(0);
}

/* Mobile: always show block selector next to toggle bar */
@media (max-width: 768px) {
    .block-selector {
        position: absolute;
        bottom: 70px;
        right: 10px;
        transform: translateY(0);
        background: rgba(0, 0, 0, 0.8);
        padding: 6px;
        border-radius: 15px;
        border: 1px solid rgba(255, 255, 255, 0.3);
        z-index: 101;
    }

    .block-selector.visible {
        transform: translateY(0);
    }
}

/* Landscape mode: always show block selector */
@media (orientation: landscape) {
    .block-selector {
        opacity: 1;
        pointer-events: auto;
    }
}

.block-dropdown {
    background: rgba(0,0,0,0.9);
    color: white;
    border: 2px solid #FFD700;
    border-radius: 6px;
    padding: 8px 15px;
    font-size: 14px;
    font-family: Arial, sans-serif;
    min-width: 180px;
    max-width: 250px;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

/* Mobile: compact dropdown */
@media (max-width: 768px) {
    .block-dropdown {
        padding: 6px 10px;
        font-size: 12px;
        min-width: 140px;
        max-width: 180px;
        border: 1px solid rgba(255, 255, 255, 0.5);
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.2);
    }
}

.block-dropdown:hover {
    background: rgba(255,215,0,0.1);
    box-shadow: 0 0 15px rgba(255,215,0,0.5);
}

.block-dropdown:focus {
    box-shadow: 0 0 20px rgba(255,215,0,0.8);
    transform: scale(1.02);
}

.block-dropdown option {
    background: rgba(0,0,0,0.95);
    color: white;
    padding: 6px;
    font-size: 14px;
}

/* Legacy hotbar styles - hidden as replaced by dropdown */
.hotbar {
    display: none;
}

.hotbar-slot {
    width: 45px;
    height: 45px;
    border: 3px solid #666;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: rgba(255,255,255,0.1);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.hotbar-slot.selected {
    border-color: #FFD700;
    background: rgba(255,215,0,0.4);
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(255,215,0,0.8);
}

.hotbar-slot:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.05);
}

.block-name {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
}

.hotbar-slot.selected .block-name {
    opacity: 1;
}

/* Мобільне керування */
.mobile-controls {
    display: flex;
    height: 70px;
    background: rgba(0,0,0,0.8);
    margin-bottom: 5px;
    border-radius: 8px 8px 0 0;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.mobile-controls.visible {
    transform: translateY(0);
}

/* Landscape mode: always show controls */
@media (orientation: landscape) {
    .mobile-controls {
        transform: translateY(0);
    }
}

.left-controls {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 15px;
}

.right-controls {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 15px;
    gap: 8px;
}

.joystick {
    width: 72px;
    height: 72px;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: 50%;
    position: relative;
    touch-action: none;
}

.joystick-knob {
    width: 30px;
    height: 30px;
    background: rgba(255,255,255,0.8);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.action-btn {
    width: 56px;
    height: 56px;
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.1s ease, background 0.1s ease;
    text-align: center;
    touch-action: none;
}

.action-btn:active {
    background: rgba(255,255,255,0.4);
    transform: scale(0.95);
}

/* Десктопний UI */
.desktop-ui {
    position: absolute;
    top: 10px;
    right: 10px;
    color: white;
    background: rgba(0,0,0,0.8);
    padding: 10px;
    border-radius: 5px;
    font-size: 12px;
    z-index: 100;
    display: none;
    min-width: 200px;
}

.inventory-btn {
    background: rgba(255,215,0,0.2);
    border: 1px solid #FFD700;
    border-radius: 4px;
    color: white;
    padding: 6px 10px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: Arial, sans-serif;
    margin-top: 8px;
    width: 100%;
}

.inventory-btn:hover {
    background: rgba(255,215,0,0.4);
    box-shadow: 0 0 8px rgba(255,215,0,0.5);
    transform: scale(1.02);
}

.inventory-btn:active {
    transform: scale(0.98);
}

.controls.desktop-mode .mobile-controls {
    display: none;
}

.controls.desktop-mode .block-selector {
    display: flex;
}

.controls.desktop-mode .mobile-toggle-bar {
    display: none;
}

/* Модальне вікно вибору скіна */
.skin-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.skin-modal.visible {
    display: flex;
}

.skin-modal-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 3px solid #FFD700;
    border-radius: 15px;
    padding: 25px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
}

.skin-modal-content h2 {
    color: #FFD700;
    margin-bottom: 20px;
    font-size: 22px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.skin-options {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 25px;
}

.skin-option {
    background: rgba(255, 255, 255, 0.1);
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 140px;
}

.skin-option:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
}

.skin-option.selected {
    border-color: #FFD700;
    background: rgba(255, 215, 0, 0.2);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
}

.skin-option canvas {
    background: linear-gradient(180deg, #87CEEB 0%, #87CEEB 60%, #7CCD7C 60%, #7CCD7C 100%);
    border-radius: 8px;
    margin-bottom: 10px;
}

.skin-name {
    color: white;
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 5px;
}

.skin-desc {
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
}

.skin-modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.skin-btn {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.skin-btn-cancel {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.skin-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.3);
}

.skin-btn-confirm {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #1a1a2e;
}

.skin-btn-confirm:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

@media (max-width: 400px) {
    .skin-options {
        flex-direction: column;
        align-items: center;
    }

    .skin-option {
        width: 100%;
        max-width: 180px;
    }
}

/* Language selector */
.language-selector {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.language-selector .lang-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #a0a0a0;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
    transition: all 0.2s ease;
}

.language-selector .lang-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.language-selector .lang-btn.active {
    background: rgba(255, 215, 0, 0.3);
    border-color: #FFD700;
    color: #FFD700;
}

/* Inventory modal */
.inventory-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.inventory-modal.visible {
    display: flex;
}

.inventory-modal-content {
    background: linear-gradient(135deg, #2a1a0e 0%, #3e2723 100%);
    border: 3px solid #8B4513;
    border-radius: 15px;
    padding: 25px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 0 30px rgba(139, 69, 19, 0.5);
}

.inventory-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.inventory-header h2 {
    color: #FFD700;
    font-size: 22px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    margin: 0;
}

.inventory-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.inventory-close-btn:hover {
    background: rgba(255, 0, 0, 0.3);
    border-color: #ff4444;
    transform: scale(1.1);
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    max-height: 380px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 5px;
}

/* Scrollbar styling for inventory */
.inventory-grid::-webkit-scrollbar {
    width: 8px;
}

.inventory-grid::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.inventory-grid::-webkit-scrollbar-thumb {
    background: rgba(139, 69, 19, 0.6);
    border-radius: 4px;
}

.inventory-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 69, 19, 0.8);
}

.inventory-slot {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(139, 69, 19, 0.5);
    border-radius: 8px;
    height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s ease;
}

.inventory-slot:hover {
    background: rgba(139, 69, 19, 0.2);
    border-color: #8B4513;
}

.inventory-slot.empty {
    opacity: 0.5;
}

.inventory-slot-image {
    width: 50%;
    height: 50%;
    object-fit: contain;
    image-rendering: pixelated;
}

.inventory-slot-count {
    position: absolute;
    bottom: 5px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-weight: bold;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

@media (max-width: 400px) {
    .inventory-modal-content {
        padding: 15px;
        width: 95%;
    }

    .inventory-header h2 {
        font-size: 18px;
    }

    .inventory-grid {
        gap: 6px;
    }

    .inventory-slot {
        min-height: 60px;
    }

    .inventory-slot-count {
        font-size: 11px;
        padding: 1px 4px;
    }
}

/* Game Over modal */
.game-over-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.game-over-modal.visible {
    display: flex;
}

.game-over-modal-content {
    width: min(92vw, 420px);
    max-height: 85vh;
    max-height: 85dvh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #1a0000 0%, #3d0000 100%);
    border: 4px solid #8B0000;
    border-radius: 15px;
    box-shadow: 0 0 50px rgba(139, 0, 0, 0.8);
    animation: scaleIn 0.3s ease;
    overflow: hidden;
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.game-over-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid rgba(139, 0, 0, 0.3);
}

.game-over-title {
    color: #FF0000;
    font-size: 28px;
    font-weight: bold;
    text-shadow: 0 0 20px rgba(255, 0, 0, 0.8);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.game-over-close {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.8);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    line-height: 1;
}

.game-over-close:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.6);
    color: white;
    transform: rotate(90deg);
}

.game-over-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    text-align: center;
}

.game-over-body::-webkit-scrollbar {
    width: 8px;
}

.game-over-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.game-over-body::-webkit-scrollbar-thumb {
    background: rgba(139, 0, 0, 0.5);
    border-radius: 4px;
}

.game-over-body::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 0, 0, 0.8);
}

.game-over-message {
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    margin-bottom: 20px;
    font-style: italic;
    line-height: 1.5;
}

.game-over-stats {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(139, 0, 0, 0.5);
    border-radius: 8px;
    padding: 15px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    line-height: 1.8;
}

.game-over-footer {
    flex-shrink: 0;
    padding: 20px;
    border-top: 2px solid rgba(139, 0, 0, 0.3);
    text-align: center;
}

.game-over-btn {
    background: linear-gradient(135deg, #8B0000 0%, #DC143C 100%);
    border: 3px solid #FF4444;
    color: white;
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.game-over-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(220, 20, 60, 0.6);
}

@media (max-width: 480px) {
    .game-over-header {
        padding: 15px;
    }

    .game-over-title {
        font-size: 24px;
    }

    .game-over-body {
        padding: 15px;
    }

    .game-over-message {
        font-size: 14px;
    }

    .game-over-stats {
        font-size: 13px;
        padding: 12px;
    }

    .game-over-footer {
        padding: 15px;
    }

    .game-over-btn {
        font-size: 14px;
        padding: 10px 20px;
    }
}

@media (max-height: 600px) {
    .game-over-header {
        padding: 15px;
    }

    .game-over-title {
        font-size: 22px;
    }

    .game-over-body {
        padding: 15px;
    }

    .game-over-footer {
        padding: 15px;
    }
}

/* Victory modal */
.victory-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.victory-modal.visible {
    display: flex;
}

.victory-modal-content {
    width: min(92vw, 420px);
    max-height: 85vh;
    max-height: 85dvh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #0a2e0a 0%, #1a4d1a 100%);
    border: 4px solid #FFD700;
    border-radius: 15px;
    box-shadow: 0 0 50px rgba(255, 215, 0, 0.8);
    animation: scaleIn 0.3s ease;
    overflow: hidden;
}

.victory-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid rgba(255, 215, 0, 0.3);
}

.victory-title {
    color: #FFD700;
    font-size: 28px;
    font-weight: bold;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    animation: pulse 2s ease-in-out infinite;
}

.victory-close {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.8);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    line-height: 1;
}

.victory-close:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.6);
    color: white;
    transform: rotate(90deg);
}

.victory-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    text-align: center;
}

.victory-body::-webkit-scrollbar {
    width: 8px;
}

.victory-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.victory-body::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.5);
    border-radius: 4px;
}

.victory-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.8);
}

.victory-message {
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    margin-bottom: 20px;
    font-style: italic;
    line-height: 1.5;
}

.victory-stats {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 215, 0, 0.5);
    border-radius: 8px;
    padding: 15px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    line-height: 1.8;
}

.victory-footer {
    flex-shrink: 0;
    padding: 20px;
    border-top: 2px solid rgba(255, 215, 0, 0.3);
    text-align: center;
}

.victory-btn {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    border: 3px solid #FFED4E;
    color: #1a4d1a;
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.victory-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}

@media (max-width: 480px) {
    .victory-header {
        padding: 15px;
    }

    .victory-title {
        font-size: 24px;
    }

    .victory-body {
        padding: 15px;
    }

    .victory-message {
        font-size: 14px;
    }

    .victory-stats {
        font-size: 13px;
        padding: 12px;
    }

    .victory-footer {
        padding: 15px;
    }

    .victory-btn {
        font-size: 14px;
        padding: 10px 20px;
    }
}

@media (max-height: 600px) {
    .victory-header {
        padding: 15px;
    }

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

    .victory-body {
        padding: 15px;
    }

    .victory-footer {
        padding: 15px;
    }
}

/* Game Selection Menu */
.game-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.game-menu.hidden {
    display: none;
}

.game-menu-content {
    text-align: center;
    max-width: 800px;
    width: 90%;
}

.game-menu-title {
    color: white;
    font-size: 48px;
    margin-bottom: 40px;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.3);
}

.game-list {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

.game-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    width: 200px;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 12px rgba(0,0,0,0.3);
}

.game-logo {
    width: 100px;
    height: 100px;
    margin: 0 auto 15px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    image-rendering: pixelated;
}

.game-name {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}

.game-description {
    font-size: 14px;
    color: #666;
    line-height: 1.4;
}

@media (max-width: 768px) {
    .game-menu-title {
        font-size: 32px;
        margin-bottom: 30px;
    }

    .game-card {
        width: 150px;
        padding: 15px;
    }

    .game-logo {
        width: 80px;
        height: 80px;
    }

    .game-name {
        font-size: 18px;
    }

    .game-description {
        font-size: 12px;
    }
}

/* Game Controls */
.game-controls {
    margin-top: 8px;
}

.game-btn {
    background: rgba(255, 0, 0, 0.8);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: background 0.3s;
    width: 100%;
    margin-bottom: 5px;
}

.game-btn:hover {
    background: rgba(255, 0, 0, 1);
}

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

/* Confirmation Modal */
.confirm-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10001;
    justify-content: center;
    align-items: center;
}

.confirm-modal.active {
    display: flex;
}

.confirm-modal-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.confirm-title {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin-bottom: 15px;
}

.confirm-message {
    font-size: 16px;
    color: #666;
    margin-bottom: 25px;
    line-height: 1.5;
}

.confirm-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.confirm-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.confirm-btn-cancel {
    background: #ccc;
    color: #333;
}

.confirm-btn-cancel:hover {
    background: #bbb;
}

.confirm-btn-confirm {
    background: #f44336;
    color: white;
}

.confirm-btn-confirm:hover {
    background: #d32f2f;
}

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

@media (max-width: 768px) {
    .confirm-modal-content {
        padding: 20px;
    }

    .confirm-title {
        font-size: 20px;
    }

    .confirm-message {
        font-size: 14px;
    }

    .confirm-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
}