/* Win95 Retro Styling */
@import url('https://fonts.googleapis.com/css2?family=MS+Sans+Serif:wght@400;700&display=swap');

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

body {
    font-family: 'MS Sans Serif', sans-serif;
    font-size: 11px;
    background: #008080;
    overflow: hidden;
    user-select: none;
}

.desktop {
    width: 100vw;
    height: 100vh;
    position: relative;
    background: linear-gradient(45deg, #008080 25%, transparent 25%),
        linear-gradient(-45deg, #008080 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #008080 75%),
        linear-gradient(-45deg, transparent 75%, #008080 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* Taskbar */
.taskbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: #c0c0c0;
    border-top: 2px solid #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    z-index: 1000;
}

.taskbar-apps {
    display: flex;
    gap: 4px;
    margin-left: 80px;
}

.taskbar-app {
    background: #c0c0c0;
    border: 2px outset #c0c0c0;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 10px;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.taskbar-app:active {
    border: 2px inset #c0c0c0;
}

.taskbar-app.minimized {
    border: 2px inset #c0c0c0;
    background: #808080;
}

.start-button {
    background: #c0c0c0;
    border: 2px outset #c0c0c0;
    padding: 2px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: bold;
}

.start-button:active {
    border: 2px inset #c0c0c0;
}

.start-icon {
    font-size: 14px;
}

.taskbar-time {
    background: #c0c0c0;
    border: 1px inset #c0c0c0;
    padding: 2px 8px;
    font-size: 10px;
}

/* Window Styling */
.window {
    position: absolute;
    top: 50px;
    left: 50px;
    width: 800px;
    height: 600px;
    background: #c0c0c0;
    border: 2px outset #c0c0c0;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, opacity 0.2s ease, width 0.3s ease, height 0.3s ease, top 0.3s ease, left 0.3s ease;
}

.window.fullscreen {
    z-index: 999;
}

.window.fullscreen .game-container {
    height: calc(100% - 60px);
}

.window.fullscreen .game-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.window.fullscreen #gameCanvas {
    max-width: 90%;
    max-height: 90%;
    width: auto !important;
    height: auto !important;
}

.title-bar {
    height: 20px;
    background: linear-gradient(90deg, #0000ff 0%, #000080 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    font-weight: bold;
    font-size: 11px;
}

.title-bar-controls {
    display: flex;
    gap: 2px;
}

.title-bar-control {
    width: 16px;
    height: 14px;
    background: #c0c0c0;
    border: 1px outset #c0c0c0;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: black;
}

.title-bar-control:active {
    border: 1px inset #c0c0c0;
}

.title-bar-control.close {
    background: #ff0000;
    color: white;
}

/* Menu Bar */
.menu-bar {
    height: 20px;
    background: #c0c0c0;
    border-bottom: 1px solid #808080;
    display: flex;
    align-items: center;
    padding: 0 4px;
}

.menu-item {
    padding: 2px 8px;
    cursor: pointer;
    border: 1px transparent solid;
}

.menu-item:hover {
    background: #0000ff;
    color: white;
}

/* Game Container */
.game-container {
    display: flex;
    height: calc(100% - 60px);
    background: #c0c0c0;
}

.game-info {
    width: 200px;
    padding: 8px;
    border-right: 2px inset #c0c0c0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.info-panel,
.ai-panel {
    background: #c0c0c0;
    border: 2px inset #c0c0c0;
    padding: 8px;
}

.info-panel h3,
.ai-panel h3 {
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 8px;
    color: #000080;
}

.score-display,
.level-display,
.ai-status,
.ai-prediction,
.ai-difficulty,
.ai-strategy {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 10px;
}

.difficulty-bar {
    width: 80px;
    height: 8px;
    background: #808080;
    border: 1px inset #c0c0c0;
    position: relative;
}

.difficulty-fill {
    height: 100%;
    background: linear-gradient(90deg, #00ff00, #ffff00, #ff0000);
    width: 30%;
    transition: width 0.3s ease;
}

/* Canvas */
#gameCanvas {
    background: #000000;
    border: 2px inset #c0c0c0;
    margin: 8px;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Game Area */
.game-area {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 8px;
}

/* Controls Panel */
.controls-panel {
    width: 150px;
    padding: 8px;
    border-left: 2px inset #c0c0c0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.retro-button {
    background: #c0c0c0;
    border: 2px outset #c0c0c0;
    padding: 4px 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 10px;
}

.retro-button:active {
    border: 2px inset #c0c0c0;
}

.retro-button:disabled {
    color: #808080;
    cursor: not-allowed;
}

.ai-controls {
    border: 2px inset #c0c0c0;
    padding: 8px;
    margin-top: 16px;
}

.ai-controls h4 {
    font-size: 10px;
    font-weight: bold;
    margin-bottom: 8px;
    color: #000080;
}

.ai-controls label {
    display: block;
    margin-bottom: 4px;
    font-size: 9px;
    cursor: pointer;
}

.ai-controls input[type="checkbox"] {
    margin-right: 4px;
}

/* Status Bar */
.status-bar {
    height: 20px;
    background: #c0c0c0;
    border-top: 1px solid #808080;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    font-size: 10px;
}

/* Game Elements */
.snake-segment {
    background: #00ff00;
    border: 1px solid #ffffff;
}

.snake-head {
    background: #00aa00;
    border: 1px solid #ffffff;
}

.food {
    background: #ff0000;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

.ai-food {
    background: #ff00ff;
    border-radius: 50%;
    animation: glow 2s infinite;
}

.prediction-hint {
    background: rgba(255, 255, 0, 0.3);
    border: 1px dashed #ffff00;
}

@keyframes pulse {

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

    50% {
        transform: scale(1.1);
    }
}

@keyframes glow {

    0%,
    100% {
        box-shadow: 0 0 5px #ff00ff;
    }

    50% {
        box-shadow: 0 0 15px #ff00ff, 0 0 25px #ff00ff;
    }
}

/* Mobile Controls */
.game-area {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 8px;
}

.mobile-mode {
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Desktop Game Layout */
@media (min-width: 901px) {
    .game-container {
        display: flex;
        height: calc(100% - 60px);
        background: #c0c0c0;
    }

    .game-area {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 16px;
    }

    #gameCanvas {
        max-width: 100%;
        max-height: 100%;
        width: auto;
        height: auto;
        margin: 0;
        background: #c0c0c0 !important;
        border: 2px inset #c0c0c0 !important;
        object-fit: contain;
    }

    /* Desktop text colors for visibility on gray background */
    .game-area #gameCanvas {
        color: #000000;
    }
}

/* Mobile Fullscreen Layout */
@media (max-width: 900px) {
    * {
        -webkit-tap-highlight-color: transparent;
    }

    body {
        margin: 0;
        padding: 0;
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
        background: #000000;
    }

    .desktop {
        background: #000000;
        width: 100%;
        height: 100%;
        position: fixed;
        top: 0;
        left: 0;
    }

    .window {
        width: 100vw !important;
        height: 100vh !important;
        top: 0 !important;
        left: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background: #000000 !important;
        position: fixed !important;
    }

    .title-bar {
        display: none !important;
    }

    .menu-bar {
        display: none !important;
    }

    .status-bar {
        display: none !important;
    }

    .game-container {
        height: 100vh !important;
        width: 100vw !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        align-items: stretch !important;
        background: #606060 !important;
        position: fixed !important;
        padding: 0 !important;
        top: 0 !important;
        left: 0 !important;
        display: flex !important;
    }

    .game-area {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        z-index: 1 !important;
    }

    /* Mobile canvas with black background */
    #gameCanvas {
        background: #1b1b1b !important;
        border: none !important;
        margin: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        object-fit: contain !important;
        display: block !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
    }

    .game-info {
        position: fixed !important;
        top: 5px !important;
        left: 5px !important;
        right: 5px !important;
        width: auto !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 8px 10px !important;
        background: rgba(0, 0, 0, 0.85) !important;
        border: 1px solid rgba(255, 255, 255, 0.3) !important;
        border-radius: 10px !important;
        z-index: 1000 !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
        display: flex !important;
        pointer-events: auto !important;
    }

    .info-panel,
    .ai-panel {
        flex: 1 !important;
        margin: 0 4px !important;
        padding: 4px !important;
        font-size: 10px !important;
        background: transparent !important;
        border: none !important;
        color: #ffffff !important;
        display: block !important;
    }

    .info-panel h3,
    .ai-panel h3 {
        font-size: 10px !important;
        margin-bottom: 4px !important;
        color: #00ffff !important;
        display: block !important;
    }

    .info-panel label,
    .ai-panel label {
        color: #aaaaaa !important;
        font-size: 9px !important;
    }

    .info-panel span,
    .ai-panel span {
        color: #ffffff !important;
        font-size: 10px !important;
        font-weight: bold !important;
    }

    .score-display,
    .level-display,
    .ai-status,
    .ai-prediction,
    .ai-difficulty,
    .ai-strategy {
        display: flex !important;
        justify-content: space-between !important;
        margin-bottom: 3px !important;
        font-size: 9px !important;
    }

    .controls-panel {
        position: fixed !important;
        bottom: 5px !important;
        left: 5px !important;
        right: 5px !important;
        width: auto !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        align-items: center !important;
        padding: 10px !important;
        background: rgba(0, 0, 0, 0.85) !important;
        border: 1px solid rgba(255, 255, 255, 0.3) !important;
        border-radius: 10px !important;
        z-index: 1000 !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
        gap: 8px !important;
        display: flex !important;
        pointer-events: auto !important;
    }

    .controls-panel .retro-button {
        background: rgba(192, 192, 192, 0.95) !important;
        border: 2px solid #ffffff !important;
        padding: 8px 16px !important;
        font-size: 11px !important;
        border-radius: 6px !important;
        color: #000000 !important;
        font-weight: bold !important;
        min-width: 70px !important;
    }

    .controls-panel .retro-button:active {
        background: rgba(150, 150, 150, 0.95) !important;
    }

    .ai-controls {
        margin: 0 !important;
        margin-top: 8px !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        align-items: center !important;
        justify-content: center !important;
        border: none !important;
        padding: 0 !important;
        background: transparent !important;
        width: 100% !important;
    }

    .ai-controls h4 {
        margin: 0 !important;
        margin-right: 8px !important;
        color: #00ffff !important;
        font-size: 10px !important;
        width: 100% !important;
        text-align: center !important;
        margin-bottom: 4px !important;
    }

    .ai-controls label {
        margin: 0 6px !important;
        font-size: 9px !important;
        color: #ffffff !important;
        white-space: nowrap !important;
        display: inline-flex !important;
        align-items: center !important;
    }

    .ai-controls input[type="checkbox"] {
        margin-right: 4px !important;
    }

    /* Hide desktop taskbar on mobile */
    .taskbar {
        display: none !important;
    }

    /* Difficulty bar styling for mobile */
    .difficulty-bar {
        background: rgba(128, 128, 128, 0.5) !important;
        border: 1px solid rgba(255, 255, 255, 0.3) !important;
        width: 60px !important;
        height: 6px !important;
    }

    .difficulty-fill {
        height: 100% !important;
    }
}

@media (max-width: 600px) {
    .game-info {
        flex-direction: row !important;
        gap: 4px !important;
        padding: 6px 8px !important;
        max-height: 25vh !important;
        overflow-y: auto !important;
    }

    .info-panel,
    .ai-panel {
        font-size: 8px !important;
        padding: 3px !important;
    }

    .info-panel h3,
    .ai-panel h3 {
        font-size: 9px !important;
        margin-bottom: 2px !important;
    }

    .score-display,
    .level-display,
    .ai-status,
    .ai-prediction,
    .ai-difficulty,
    .ai-strategy {
        font-size: 8px !important;
        margin-bottom: 2px !important;
    }

    .controls-panel {
        padding: 8px !important;
        flex-wrap: wrap !important;
    }

    .controls-panel .retro-button {
        font-size: 10px !important;
        padding: 6px 12px !important;
        min-width: 60px !important;
    }

    .ai-controls {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        align-items: center !important;
        width: 100% !important;
    }

    .ai-controls h4 {
        font-size: 9px !important;
        margin-bottom: 3px !important;
    }

    .ai-controls label {
        font-size: 8px !important;
        margin: 0 4px !important;
    }

    .difficulty-bar {
        width: 50px !important;
        height: 5px !important;
    }
}