/* Mobile-Optimized Spice Tactics Styles */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #8B4513 0%, #D2691E 100%);
    font-family: 'Orbitron', monospace;
    color: #D4AF37;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

#header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(90deg, #8B4513, #CD853F, #8B4513);
    border: 3px solid #D4AF37;
    border-bottom: none;
    padding: 8px 15px;
    box-shadow: inset 0 0 20px rgba(212, 175, 55, 0.3);
    height: 50px;
    position: relative;
    z-index: 100;
}

.header-btn {
    background: linear-gradient(145deg, #DAA520, #B8860B);
    border: 2px solid #D4AF37;
    color: #000;
    padding: 8px 12px;
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    font-size: 11px;
    cursor: pointer;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    transition: all 0.2s ease;
    min-height: 44px;
    min-width: 60px;
    border-radius: 4px;
}

.header-btn:hover,
.header-btn:active {
    background: linear-gradient(145deg, #FFD700, #DAA520);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.8);
    transform: scale(1.05);
}

#credits {
    font-weight: 900;
    font-size: 16px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    letter-spacing: 1px;
}

#house-banner {
    font-weight: 900;
    font-size: 12px;
    color: #4169E1;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    background: rgba(65, 105, 225, 0.2);
    padding: 6px 10px;
    border: 2px solid #4169E1;
    border-radius: 4px;
}

#game-container {
    position: relative;
    display: flex;
    background: #2F2F2F;
    border: 3px solid #D4AF37;
    border-top: none;
    height: calc(100vh - 50px);
    overflow: hidden;
}

#canvas {
    border: none;
    cursor: crosshair;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    touch-action: none;
    flex: 1;
}

#command-panel {
    width: 300px;
    background: linear-gradient(180deg, #8B4513, #654321);
    border-left: 3px solid #D4AF37;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
    transition: transform 0.3s ease;
    position: relative;
    z-index: 50;
}

#command-panel.collapsed {
    transform: translateX(100%);
}

#command-panel.portrait {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 250px;
    border-left: none;
    border-top: 3px solid #D4AF37;
    transform: translateY(100%);
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: flex-start;
}

#command-panel.portrait.collapsed {
    transform: translateY(100%);
}

#command-panel.portrait:not(.collapsed) {
    transform: translateY(0);
}

#panel-handle {
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 80px;
    background: linear-gradient(90deg, #8B4513, #CD853F);
    border: 2px solid #D4AF37;
    border-right: none;
    border-radius: 10px 0 0 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

#command-panel.portrait #panel-handle {
    left: 50%;
    top: -20px;
    transform: translateX(-50%);
    width: 80px;
    height: 20px;
    border-radius: 10px 10px 0 0;
    border-right: 2px solid #D4AF37;
    border-bottom: none;
}

.handle-bar {
    width: 4px;
    height: 40px;
    background: #D4AF37;
    border-radius: 2px;
}

#command-panel.portrait .handle-bar {
    width: 40px;
    height: 4px;
}

#panel-handle:hover,
#panel-handle:active {
    background: linear-gradient(90deg, #CD853F, #DAA520);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.6);
    transform: translateY(-50%) scale(1.1);
}

#command-panel.portrait #panel-handle:hover {
    transform: translateX(-50%) scale(1.1);
}

#unit-portrait {
    width: 64px;
    height: 64px;
    border: 2px solid #D4AF37;
    background: #1a1a1a;
    align-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    position: relative;
}

#unit-portrait img {
    width: 60px;
    height: 60px;
    image-rendering: pixelated;
}

#portrait-placeholder {
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

#unit-info {
    text-align: center;
    min-width: 150px;
}

#unit-name {
    font-weight: 900;
    font-size: 14px;
    margin-bottom: 8px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

#health-bar {
    width: 100%;
    height: 12px;
    background: #333;
    border: 2px solid #666;
    margin-bottom: 8px;
    position: relative;
    overflow: hidden;
    border-radius: 6px;
}

#health-fill {
    height: 100%;
    background: #00FF00;
    width: 100%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

#unit-stats {
    font-size: 11px;
    color: #AAA;
    font-weight: 400;
}

#command-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

#command-panel.portrait #command-buttons {
    grid-template-columns: repeat(4, 1fr);
}

.cmd-btn {
    padding: 15px 10px;
    border: 3px solid #666;
    background: linear-gradient(145deg, #333, #555);
    color: #D4AF37;
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 60px;
    min-width: 60px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    touch-action: manipulation;
}

.btn-icon {
    font-size: 20px;
    display: block;
}

.cmd-btn:hover,
.cmd-btn:active {
    border-color: #D4AF37;
    background: linear-gradient(145deg, #555, #777);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
    transform: scale(1.05);
}

.cmd-btn.active {
    border-color: #FFD700;
    background: linear-gradient(145deg, #DAA520, #B8860B);
    color: #000;
    box-shadow: inset 0 0 10px rgba(255, 215, 0, 0.3);
    transform: scale(1.1);
}

.attack-btn:hover { border-color: #FF6B6B; }
.move-btn:hover { border-color: #4ECDC4; }
.guard-btn:hover { border-color: #FFE66D; }
.retreat-btn:hover { border-color: #A8A8A8; }

#status-display {
    background: rgba(0,0,0,0.8);
    border: 2px solid #666;
    padding: 10px;
    font-size: 11px;
    text-align: center;
    color: #D4AF37;
    border-radius: 6px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

#mini-map {
    position: absolute;
    bottom: 15px;
    right: 15px;
    border: 3px solid #D4AF37;
    background: #000;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

#mini-map.portrait {
    bottom: 270px;
    right: 15px;
}

#mini-map.expanded {
    transform: scale(1.5);
    z-index: 200;
}

#mini-canvas {
    cursor: pointer;
    image-rendering: pixelated;
    display: block;
}

#mini-map-toggle {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: #8B4513;
    color: #D4AF37;
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 700;
    border: 2px solid #D4AF37;
    border-top: none;
    border-radius: 0 0 6px 6px;
    cursor: pointer;
    min-height: 30px;
    display: flex;
    align-items: center;
}

#mini-map-toggle:hover,
#mini-map-toggle:active {
    background: #CD853F;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

#touch-feedback {
    position: absolute;
    background: rgba(255, 215, 0, 0.9);
    color: #000;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 6px;
    pointer-events: none;
    z-index: 1000;
    display: none;
    transition: opacity 0.3s ease;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.7);
}

#touch-feedback.show {
    opacity: 1;
    animation: feedbackPulse 1s ease-out;
}

@keyframes feedbackPulse {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

#controls {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0,0,0,0.8);
    padding: 8px 12px;
    border: 2px solid #666;
    border-radius: 6px;
    font-size: 10px;
    color: #AAA;
    z-index: 100;
}

#gesture-help {
    margin-top: 4px;
    font-size: 9px;
    color: #888;
}

/* Responsive Design */
@media (max-width: 768px) {
    #header {
        padding: 5px 10px;
        height: 45px;
    }
    
    .header-btn {
        padding: 6px 8px;
        font-size: 10px;
        min-width: 50px;
    }
    
    #credits {
        font-size: 14px;
    }
    
    #house-banner {
        font-size: 10px;
        padding: 4px 8px;
    }
    
    #command-panel {
        width: 250px;
        padding: 10px;
    }
    
    .cmd-btn {
        padding: 12px 8px;
        min-height: 50px;
        font-size: 9px;
    }
    
    .btn-icon {
        font-size: 16px;
    }
    
    #mini-canvas {
        width: 100px;
        height: 75px;
    }
}

@media (max-height: 600px) {
    #command-panel:not(.portrait) {
        padding: 8px;
        gap: 8px;
    }
    
    #unit-portrait {
        width: 48px;
        height: 48px;
    }
    
    #unit-portrait img,
    #portrait-placeholder {
        width: 44px;
        height: 44px;
        font-size: 24px;
    }
    
    .cmd-btn {
        padding: 8px 6px;
        min-height: 40px;
        font-size: 8px;
    }
}

/* Portrait orientation specific styles */
@media (orientation: portrait) {
    #game-container {
        flex-direction: column;
    }
    
    #command-panel:not(.portrait) {
        display: none;
    }
    
    #mini-map:not(.portrait) {
        bottom: 15px;
        right: 15px;
    }
}

/* Landscape orientation specific styles */
@media (orientation: landscape) {
    #command-panel.portrait {
        display: none;
    }
    
    #mini-map.portrait {
        display: none;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    body {
        background: #000;
    }
    
    #header {
        background: #333;
        border-color: #FFF;
    }
    
    .header-btn {
        background: #FFF;
        color: #000;
        border-color: #FFF;
    }
    
    #command-panel {
        background: #222;
        border-color: #FFF;
    }
    
    .cmd-btn {
        background: #444;
        border-color: #FFF;
        color: #FFF;
    }
}

/* Scrollbar styling for any overflow areas */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: #333;
    border-radius: 6px;
}

::-webkit-scrollbar-thumb {
    background: #D4AF37;
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: #FFD700;
}

/* Focus styles for keyboard navigation */
button:focus,
canvas:focus {
    outline: 3px solid #FFD700;
    outline-offset: 2px;
}