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

body {
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
    touch-action: none;
}

#game-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

#gameCanvas {
    border: 4px solid #3E2723;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background: #7CB342;
}

@keyframes shake {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-10px, 0); }
    75% { transform: translate(10px, 0); }
}

#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 10;
}

#top-left, #top-right {
    background: rgba(255, 248, 225, 0.95);
    border: 3px solid #3E2723;
    border-radius: 8px;
    padding: 10px;
    font-size: 14px;
    color: #3E2723;
    font-weight: bold;
}

#welli-portrait {
    width: 40px;
    height: 40px;
    background: #E91E63;
    border: 2px solid #3E2723;
    border-radius: 4px;
    margin-bottom: 5px;
}

#xp-bar-container {
    margin-top: 5px;
    position: relative;
}

#xp-bar {
    height: 10px;
    background: #4CAF50;
    border: 2px solid #3E2723;
    border-radius: 4px;
    transition: width 0.3s;
    width: 0%;
}

#level {
    font-size: 12px;
    margin-top: 2px;
}

#mobile-controls {
    position: absolute;
    bottom: 20px;
    width: 100%;
    display: none;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none;
    z-index: 10;
}

#dpad {
    position: relative;
    width: 120px;
    height: 120px;
    pointer-events: all;
}

.dpad-btn {
    position: absolute;
    width: 40px;
    height: 40px;
    background: rgba(255, 248, 225, 0.95);
    border: 3px solid #3E2723;
    border-radius: 4px;
    font-size: 20px;
    color: #3E2723;
    cursor: pointer;
    user-select: none;
}

.dpad-btn:active {
    background: #E91E63;
    color: white;
}

.dpad-btn[data-dir="up"] { top: 0; left: 40px; }
.dpad-btn[data-dir="down"] { bottom: 0; left: 40px; }
.dpad-btn[data-dir="left"] { top: 40px; left: 0; }
.dpad-btn[data-dir="right"] { top: 40px; right: 0; }

#action-buttons {
    display: flex;
    gap: 10px;
    pointer-events: all;
}

#throw-btn, #scan-btn {
    width: 80px;
    height: 80px;
    background: rgba(255, 248, 225, 0.95);
    border: 3px solid #3E2723;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    color: #3E2723;
    cursor: pointer;
}

#throw-btn:active {
    background: #F44336;
    color: white;
}

#scan-btn:active {
    background: #2196F3;
    color: white;
}

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

.modal-content {
    background: #FFF8E1;
    border: 4px solid #3E2723;
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.modal-content h2 {
    color: #3E2723;
    margin-bottom: 20px;
    text-align: center;
    font-size: 24px;
}

.help-list {
    list-style: none;
    padding: 0;
}

.help-list li {
    padding: 8px;
    margin: 5px 0;
    background: white;
    border: 2px solid #3E2723;
    border-radius: 4px;
}

.pixel-btn {
    background: #E91E63;
    color: white;
    border: 3px solid #3E2723;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 8px;
    margin: 5px;
    transition: all 0.2s;
    font-family: 'Courier New', monospace;
}

.pixel-btn:hover {
    background: #C2185B;
    transform: scale(1.05);
}

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

#start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.pixel-title {
    font-size: 48px;
    color: white;
    text-shadow: 4px 4px 0 #3E2723;
    margin-bottom: 30px;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

#high-score {
    margin-top: 20px;
    color: white;
    font-size: 18px;
}

.footer {
    position: absolute;
    bottom: 20px;
    color: white;
    font-size: 12px;
}

.footer a {
    color: #FFD700;
    text-decoration: none;
}

#encounter-panel .modal-content {
    text-align: center;
}

#server-sprite {
    width: 100px;
    height: 100px;
    margin: 20px auto;
    background: #546E7A;
    border: 3px solid #3E2723;
    border-radius: 8px;
}

.difficulty {
    color: #FFD700;
    font-size: 24px;
    margin: 10px 0;
}

.health-bar {
    width: 100%;
    height: 20px;
    background: #333;
    border: 2px solid #3E2723;
    border-radius: 4px;
    overflow: hidden;
    margin: 10px 0;
}

.health-fill {
    height: 100%;
    background: #4CAF50;
    width: 100%;
    transition: width 0.3s;
}

#catch-meter {
    width: 100%;
    height: 30px;
    background: #333;
    border: 3px solid #3E2723;
    border-radius: 4px;
    position: relative;
    margin: 20px 0;
}

#catch-zone {
    position: absolute;
    left: 40%;
    width: 20%;
    height: 100%;
    background: rgba(76, 175, 80, 0.5);
}

#catch-indicator {
    position: absolute;
    width: 4px;
    height: 100%;
    background: #F44336;
    left: 0;
    transition: left 0.05s linear;
}

.tip {
    font-style: italic;
    color: #666;
}

#final-stats {
    margin: 20px 0;
    text-align: left;
}

#final-stats p {
    padding: 8px;
    margin: 5px 0;
    background: white;
    border: 2px solid #3E2723;
    border-radius: 4px;
}

@media (max-width: 768px) {
    #mobile-controls {
        display: flex;
    }
    
    .pixel-title {
        font-size: 32px;
    }
    
    #hud {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .pixel-title {
        font-size: 24px;
    }
    
    .modal-content {
        padding: 20px;
    }
}