/* Cancer Awareness Snake Game - Retro Handheld Style */

body {
    background: #8ca77a;
    font-family: 'VT323', monospace;
    margin: 0;
    padding: 20px;
    color: #23281e;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

/* Game Screens */
.screen {
    display: none;
    align-items: center;
    justify-content: center;
    height: 100vh;
    width: 100vw;
    position: fixed;
    top: 0; 
    left: 0;
    background: #8ca77a;
    z-index: 1000;
    opacity: 1;
    padding: 20px;
    box-sizing: border-box;
}

.screen.active {
    display: flex;
    z-index: 1000;
    opacity: 1;
}

.content-box {
    background: #b2c7a7;
    border: 4px solid #23281e;
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    min-width: 320px;
    max-width: 500px;
    box-shadow: 0 6px 15px rgba(35, 40, 30, 0.2);
}

/* Main Game Screen */
#mainGameScreen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #8ca77a;
    z-index: 1;
    align-items: center;
    justify-content: center;
    padding: 10px;
    box-sizing: border-box;
}

#mainGameScreen.active {
    display: flex;
}

.overall-game-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Handheld Device Container */
.game-container {
    width: min(380px, 98vw);
    height: min(580px, 96vh);
    max-width: 380px;
    max-height: 580px;
    background: #8ca77a;
    border: 8px solid #23281e;
    border-radius: 20px;
    /*box-sizing: border-box;*/
    display: flex;
    flex-direction: column;
    padding: 8px 6px 6px 6px;
    position: relative;
    box-shadow: 0 8px 20px rgba(35, 40, 30, 0.3);
}

/* Typography */
h1, h2, h3 {
    font-family: 'VT323', monospace;
    margin: 0 0 16px 0;
}

/* Buttons */
button {
    font-family: 'VT323', monospace;
    font-size: 1.2em;
    background: #23281e;
    color: #8ca77a;
    border: 2px solid #23281e;
    border-radius: 6px;
    padding: 8px 20px;
    margin: 8px 5px;
    cursor: pointer;
    transition: all 0.2s;
}

button:disabled {
    background: #6b7a62;
    color: #a8b5a1;
    cursor: not-allowed;
    opacity: 0.6;
    filter: grayscale(100%);
}

button:hover:not(:disabled) {
    background: #b2c7a7;
    color: #23281e;
}

/* Info Panel */
.info-panel {
    background: #b2c7a7;
    border: 3px solid #23281e;
    border-radius: 8px;
    padding: 6px;
    width: 100%;
    margin-bottom: 8px;
    box-sizing: border-box;
    flex-shrink: 0; /* Prevent shrinking */
}

.info-panel h2 {
    margin: 0 0 10px 0;
    font-size: 1.4em;
    text-align: center;
}

#score, #highScore {
    font-size: 1.1em;
    margin: 5px 0;
    text-align: center;
}

/* Stage Progress */
.stage-container {
    margin: 10px 0;
    padding: 0;
}

.stage-label {
    font-size: 1.1em;
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
    text-align: center;
}

.stage-bar {
    display: flex;
    gap: 1px;
    margin: 0;
    border: 2px solid #23281e;
    border-radius: 4px;
    background: #23281e;
    height: 24px;
    overflow: hidden;
}

.stage-segment {
    flex: 1;
    background: #8ca77a;
    color: #23281e;
    text-align: center;
    font-size: 1em;
    line-height: 20px;
    transition: background 0.3s;
    font-weight: bold;
}

.stage-segment.active {
    background: #b2c7a7;
    color: #23281e;
}

.stage-segment.completed {
    background: #23281e;
    color: #8ca77a;
}

/* Item Info Box */
.item-info-box {
    background: #b2c7a7;
    border: 2px solid #23281e;
    border-radius: 6px;
    padding: 4px;
    margin: 6px 0;
    font-size: 1em;
    width: 100%;
    min-height: 35px;
    box-sizing: border-box;
    color: #23281e;
    text-align: center;
    flex-shrink: 0; /* Prevent shrinking */
}

.item-info-box h3 {
    margin: 0 0 5px 0;
    font-size: 1.1em;
}

/* Button Container */
.button-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 5px 0;
    flex-wrap: wrap;
}

/* Game Canvas */
.canvas-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    /*justify-content: center;*/
    min-height: 0; /* Allow flex shrinking */
    padding: 8px 4px 4px 4px;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    max-width: 320px;
    max-height: 240px;
    min-width: 240px;
    min-height: 160px;
    background: #8ca77a;
    border: 3px solid #23281e;
    border-radius: 8px;
    display: block;
    box-shadow: inset 0 2px 4px rgba(35, 40, 30, 0.3);
}

.controls-info-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 5px;
}

.controls-info {
    font-size: 0.9em;
    color: #23281e;
    text-align: center;
    margin-top: 5px;
}

/* Mobile Controls */
.mobile-controls {
    position: fixed;
    bottom: 50px;
    /*left: 50%;
    transform: translateX(-50%);*/
    z-index: 100;
    display: none;
    /*width: 120px;
    height: 120px;*/
}

.mobile-dpad {
    display: grid;
    grid-template-rows: repeat(3, 1fr);
    gap: 3px;
    width: 120px;
    height: 120px;
}

.dpad-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
}

.arrow-btn {
    width: 36px;
    height: 36px;
    background: #23281e;
    color: #8ca77a;
    border: 2px solid #23281e;
    border-radius: 8px;
    font-size: 1.2em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    touch-action: manipulation;
}

.arrow-btn:active {
    background: #b2c7a7;
    color: #23281e;
    transform: scale(0.95);
}

/* Icons */
.pixel-icon {
    width: 24px;
    height: 24px;
    image-rendering: pixelated;
    vertical-align: middle;
}

.icon-display {
    display: inline-block;
    margin: 5px;
}

/* Message Boxes and Modals */
.message-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #b2c7a7;
    border: 4px solid #23281e;
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    z-index: 2000;
    box-shadow: 0 8px 20px rgba(35, 40, 30, 0.4);
    display: none;
}

.message-box.active {
    display: block;
}

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(35, 40, 30, 0.7);
}

.modal.active {
    display: block;
}

.modal-content {
    background-color: #b2c7a7;
    margin: 5% auto;
    padding: 30px;
    border: 4px solid #23281e;
    border-radius: 15px;
    width: 80%;
    max-width: 600px;
    position: relative;
    box-shadow: 0 8px 20px rgba(35, 40, 30, 0.4);
}

.close-button {
    color: #23281e;
    float: right;
    font-size: 2em;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    top: 10px;
    right: 20px;
}

.close-button:hover {
    color: #8ca77a;
}

/* Growth Halt Countdown */
#growthHaltCountdown {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: #23281e;
    color: #8ca77a;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 1.2em;
    font-weight: bold;
    display: none;
    z-index: 10;
}

/* Responsive Design */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    #mainGameScreen {
        padding: 20px 10px 260px 10px;
    }
    
    .game-container {
        width: min(360px, 90vw);
        height: min(500px, 70vh);
        padding: 4px 3px 4px 3px;
        border: 6px solid #23281e;
        margin: auto;
    }
    
    .canvas-panel {
        padding: 8px 2px 2px 2px;
    }
    
    #gameCanvas {
        width: 100%;
        height: 100%;
        min-width: 260px;
        min-height: 180px;
        max-width: 300px;
        max-height: 220px;
    }
    
    .mobile-controls {
        display: block;
        /*bottom: 40px;*/
    }
    
    .content-box {
        min-width: 280px;
        padding: 20px;
    }
    
    .info-panel {
        padding: 8px;
        margin-bottom: 6px;
    }
    
    .stage-bar {
        height: 20px;
    }
    
    .stage-segment {
        font-size: 0.9em;
        line-height: 16px;
    }
}

@media (max-width: 360px) {
    #mainGameScreen {
        padding: 20px 10px 150px 10px;
    }
    
    .game-container {
        width: min(320px, 88vw);
        height: min(480px, 65vh);
        padding: 6px 4px 4px 4px;
        border: 4px solid #23281e;
        margin: auto;
    }
    
    .canvas-panel {
        padding: 6px 2px 2px 2px;
    }
    
    #gameCanvas {
        width: 100%;
        height: 100%;
        min-width: 240px;
        min-height: 160px;
        max-width: 280px;
        max-height: 200px;
    }
    
    .info-panel {
        padding: 6px;
    }
    
    .mobile-controls {
        bottom: 35px;
        width: 100px;
        height: 100px;
    }
    
    .mobile-dpad {
        width: 100px;
        height: 100px;
        gap: 2px;
    }
    
    .arrow-btn {
        width: 32px;
        height: 32px;
        font-size: 1em;
    }
    
    button {
        font-size: 1em;
        padding: 6px 15px;
        margin: 5px 3px;
    }
}

@media (max-height: 650px) {
    #mainGameScreen {
        padding: 15px 10px 140px 10px;
    }
    
    .game-container {
        height: min(450px, 60vh);
        padding: 6px 4px 4px 4px;
    }
    
    .canvas-panel {
        padding: 4px 2px 2px 2px;
    }
    
    #gameCanvas {
        max-height: 200px;
    }
    
    .info-panel {
        padding: 6px;
        margin-bottom: 4px;
    }
    
    .mobile-controls {
        bottom: 30px;
    }
}

@media (max-height: 550px) {
    #mainGameScreen {
        padding: 10px 10px 130px 10px;
    }
    
    .game-container {
        height: min(380px, 55vh);
        padding: 4px 3px 3px 3px;
    }
    
    .canvas-panel {
        padding: 4px 2px 2px 2px;
    }
    
    #gameCanvas {
        max-height: 160px;
        min-height: 140px;
    }
    
    .info-panel {
        padding: 4px;
        margin-bottom: 4px;
    }
    
    .item-info-box {
        min-height: 30px;
        padding: 4px;
        margin: 4px 0;
    }
    
    .mobile-controls {
        bottom: 25px;
        width: 100px;
        height: 100px;
    }
    
    .mobile-dpad {
        width: 100px;
        height: 100px;
    }
    
    .arrow-btn {
        width: 30px;
        height: 30px;
        font-size: 0.9em;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    .mobile-controls {
        display: block;
    }
    
    .game-container {
        width: 450px;
        height: 350px;
        flex-direction: row;
        padding: 15px;
    }
    
    .info-panel {
        width: 180px;
        margin-right: 15px;
        margin-bottom: 0;
    }
    
    .canvas-panel {
        flex: 1;
    }
    
    #gameCanvas {
        width: 240px;
        height: 180px;
    }
}
