/* AI RPG Specific Styles */

/* Utility: hidden class used by UIManager.js */
.hidden {
    display: none !important;
}

/* Reduce container padding to minimize black margins */
.container-fluid.p-0 {
    padding: 0 !important;
}

/* Optimize game layout spacing */
.row.no-gutters {
    margin: 0;
}

.col-lg-9, .col-lg-3, .col-lg-2, .col-lg-7, .col-lg-6, .col-xl-2, .col-xl-8, .col-md-8, .col-md-4, .col-md-6, .col-md-3 {
    padding: 0 5px;
}

.ai-rpg-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.game-wrapper {
    background: linear-gradient(145deg, #1a1a1a, #2d2d2d);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    border: 1px solid #333;
}

.game-canvas-container {
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
}

#gameCanvas {
    display: block;
    max-width: 100%;
    height: auto;
    border: 1px solid #000; /* Match container background to hide border */
    border-radius: 4px;
}

.game-stats-bar {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    border: 1px solid #555;
}

.progress {
    background-color: #333;
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar {
    border-radius: 10px;
    transition: width 0.6s ease;
}

.menu-screen {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.menu-content {
    max-width: 400px;
    width: 90%;
    background: linear-gradient(145deg, #2c3e50, #34495e);
    border: 1px solid #555;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    border-radius: 12px;
}

.ai-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    z-index: 1000;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.modal-content {
    background: linear-gradient(145deg, #2c3e50, #34495e);
    border: 1px solid #555;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    border-radius: 12px;
}

.game-sidebar {
    background: linear-gradient(145deg, #ecf0f1, #bdc3c7);
    border-left: 4px solid #3498db;
    border-radius: 8px;
    max-height: 700px;
    overflow-y: auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.game-sidebar h5 {
    color: #2c3e50;
    font-weight: 600;
    border-bottom: 2px solid #3498db;
    padding-bottom: 8px;
    margin-bottom: 16px;
}

.ai-features-panel .btn {
    margin-bottom: 8px;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.ai-features-panel .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ai-features-panel .btn-outline-primary:hover {
    border-color: #007bff;
    background: #007bff;
    color: white;
}

.ai-features-panel .btn-outline-success:hover {
    border-color: #28a745;
    background: #28a745;
    color: white;
}

.ai-features-panel .btn-outline-warning:hover {
    border-color: #ffc107;
    background: #ffc107;
    color: #212529;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 8px;
}

.inventory-slot {
    background: linear-gradient(145deg, #ffffff, #f1f3f4);
    border: 2px solid #dee2e6;
    border-radius: 8px;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.inventory-slot:hover {
    background: linear-gradient(145deg, #e9ecef, #f8f9fa);
    border-color: #3498db;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.inventory-slot::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.inventory-slot:hover::before {
    left: 100%;
}

.inventory-slot.usable-item {
    border-color: #28a745;
    background: linear-gradient(145deg, #d4edda, #f8f9fa);
    box-shadow: 0 0 8px rgba(40, 167, 69, 0.3);
}

.inventory-slot.usable-item:hover {
    border-color: #20c997;
    background: linear-gradient(145deg, #a3d5a5, #e8f5e8);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

.quest-item {
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    border: 1px solid #dee2e6;
    border-left: 4px solid #28a745;
    border-radius: 8px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.quest-item:hover {
    transform: translateX(8px);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.2);
    border-color: #28a745;
}

.quest-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, #28a745, #20c997);
    transition: width 0.3s ease;
}

.quest-item:hover::before {
    width: 8px;
}

.quest-title {
    color: #2c3e50;
    font-size: 0.9rem;
}

.quest-description {
    color: #6c757d;
    font-size: 0.8rem;
    line-height: 1.3;
}

.quest-progress .progress {
    height: 6px;
    background-color: #e9ecef;
}

.quest-progress .progress-bar {
    background: linear-gradient(90deg, #28a745, #20c997);
}

.control-item {
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    margin-bottom: 2px;
}

.control-item:hover {
    background: linear-gradient(90deg, rgba(52, 152, 219, 0.1), rgba(52, 152, 219, 0.05));
    transform: translateX(4px);
}

.control-item .badge {
    min-width: 45px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    background: linear-gradient(135deg, #6c757d, #495057);
    border-radius: 4px;
}

.chat-message {
    margin-bottom: 12px;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    text-align: right;
}

.user-message .message-content {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    padding: 8px 12px;
    border-radius: 18px 18px 4px 18px;
    display: inline-block;
    max-width: 80%;
    word-wrap: break-word;
}

.ai-message .message-content {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    padding: 8px 12px;
    border-radius: 18px 18px 18px 4px;
    display: inline-block;
    max-width: 80%;
    word-wrap: break-word;
}

.system-message .message-content {
    background: linear-gradient(135deg, #6c757d, #495057);
    color: white;
    padding: 6px 10px;
    border-radius: 12px;
    display: inline-block;
    font-size: 0.85rem;
    font-style: italic;
}

/* Scrollbar Styling */
.game-sidebar::-webkit-scrollbar,
#aiChatHistory::-webkit-scrollbar {
    width: 6px;
}

.game-sidebar::-webkit-scrollbar-track,
#aiChatHistory::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.game-sidebar::-webkit-scrollbar-thumb,
#aiChatHistory::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #3498db, #2980b9);
    border-radius: 3px;
}

.game-sidebar::-webkit-scrollbar-thumb:hover,
#aiChatHistory::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #2980b9, #21618c);
}

/* Responsive Design */
@media (max-width: 768px) {
    .ai-rpg-header {
        padding: 1.5rem;
        margin-bottom: 1rem;
    }
    
    .game-wrapper {
        padding: 16px;
    }
    
    .game-sidebar {
        margin-top: 20px;
        border-left: none;
        border-top: 4px solid #3498db;
        border-radius: 8px 8px 0 0;
    }
    
    .ai-modal {
        width: 95%;
        top: 20px;
        transform: translate(-50%, 0);
    }
    
    .inventory-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .menu-content {
        width: 95%;
        padding: 20px;
    }
}

@media (max-width: 576px) {
    .ai-rpg-header h1 {
        font-size: 1.8rem;
    }
    
    .ai-rpg-header p {
        font-size: 0.9rem;
    }
    
    .inventory-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .game-stats-bar .row > div {
        margin-bottom: 8px;
    }
}

/* Animation for game loading */
.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Glow effects for interactive elements */
.btn-primary:focus,
.btn-success:focus,
.btn-info:focus {
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.5);
}

.form-control:focus {
    border-color: #3498db;
    box-shadow: 0 0 10px rgba(52, 152, 219, 0.3);
}

/* Custom button styles for AI features */
.ai-features-panel .btn {
    position: relative;
    overflow: hidden;
}

.ai-features-panel .btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.ai-features-panel .btn:hover::before {
    left: 100%;
}

/* Conversation Display Styles */
.conversation-display {
    max-height: 200px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.conversation-message {
    margin-bottom: 1rem;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.character-face {
    font-size: 2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    min-width: 48px;
    text-align: center;
}

.message-bubble {
    border-radius: 15px;
    padding: 12px 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    position: relative;
}

.hero-message .message-bubble {
    background: linear-gradient(135deg, #007bff, #0056b3) !important;
    margin-left: auto;
}

.npc-message .message-bubble {
    background: linear-gradient(135deg, #6c757d, #495057) !important;
    margin-right: auto;
}

.character-name {
    font-weight: bold;
    opacity: 0.9;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.75rem;
}

.message-text {
    line-height: 1.4;
    word-wrap: break-word;
}

/* Improved interaction modal */
.interaction-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 600px;
    z-index: 1000;
    animation: modalFadeIn 0.3s ease;
}

.interaction-modal .modal-content {
    background: linear-gradient(145deg, #1a1a1a, #2d2d2d);
    border: 2px solid #444;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.8);
    border-radius: 15px;
}

/* Combat modal improvements */
.combat-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    transform: none !important;
    z-index: 9999 !important;
    background: rgba(0, 0, 0, 0.8) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    animation: modalFadeIn 0.3s ease;
}

.combat-modal.d-none {
    display: none !important;
}

.combat-modal .modal-content {
    background: linear-gradient(145deg, #1a1a1a, #2d2d2d);
    border: 2px solid #dc3545;
    box-shadow: 0 25px 50px rgba(220, 53, 69, 0.3);
    border-radius: 15px;
    position: relative;
    z-index: 10000;
}

/* Scrollbar styling for conversation display */
.conversation-display::-webkit-scrollbar {
    width: 6px;
}

.conversation-display::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.conversation-display::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.conversation-display::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.combat-info {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid #444;
}

.enemy-stats {
    background: rgba(139, 69, 19, 0.15);
    border: 1px solid #8B4513;
    border-radius: 6px;
    padding: 0.75rem;
    margin-top: 0.5rem;
}

.stat-item {
    text-align: center;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-weight: bold;
    font-size: 0.9rem;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.7rem;
    line-height: 1;
    margin-top: 2px;
}

.tiny {
    font-size: 0.65rem !important;
}

#enemy-type {
    font-weight: 500;
    font-style: italic;
}

/* Magic Attack Interface */
.magic-input {
    border: 2px solid #17a2b8;
    border-radius: 8px;
    background: rgba(23, 162, 184, 0.1) !important;
    transition: all 0.3s ease;
}

.magic-input textarea {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #17a2b8;
    border-radius: 4px;
    color: #333;
    resize: vertical;
    min-height: 60px;
}

.magic-input textarea:focus {
    background: rgba(255, 255, 255, 1);
    border-color: #138496;
    box-shadow: 0 0 10px rgba(23, 162, 184, 0.3);
}

#magicCost.text-danger {
    color: #dc3545 !important;
    font-weight: bold;
}

#magicCost.text-success {
    color: #28a745 !important;
    font-weight: bold;
}

#magicCost.text-warning {
    color: #ffc107 !important;
    font-weight: bold;
}

.combat-log-entry.magic-result {
    color: #17a2b8;
    font-style: italic;
    background: rgba(23, 162, 184, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    margin: 2px 0;
}

.combat-log-entry.magic-context {
    color: #e74c3c;
    font-weight: 500;
    background: rgba(231, 76, 60, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    margin: 2px 0;
    border-left: 3px solid #e74c3c;
}

.combat-log-entry.spell-name {
    color: #f39c12;
    font-weight: bold;
    background: rgba(243, 156, 18, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    margin: 2px 0;
    border-left: 3px solid #f39c12;
    text-shadow: 0 0 5px rgba(243, 156, 18, 0.3);
}

/* Disabled attack button styling */
.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-outline-danger.disabled {
    border-color: #dc3545;
    color: #dc3545;
}

.btn-outline-danger.disabled:hover {
    background-color: transparent !important;
    border-color: #dc3545 !important;
    color: #dc3545 !important;
}

/* Mobile and Tablet Responsive Styles */
@media (max-width: 1199px) {
    .ai-rpg-header {
        padding: 1.5rem;
    }
    
    .ai-rpg-header h1 {
        font-size: 2.5rem;
    }
    
    .game-wrapper {
        padding: 8px;
    }
    
    .col-lg-9, .col-lg-3, .col-lg-2, .col-lg-7, .col-lg-6, .col-xl-2, .col-xl-8, .col-md-8, .col-md-4, .col-md-6, .col-md-3 {
        padding: 0 3px;
    }
}

@media (max-width: 991px) {
    .container-fluid {
        padding: 0 3px;
    }
    
    .col-lg-9, .col-lg-3, .col-lg-2, .col-lg-7, .col-lg-6, .col-xl-2, .col-xl-8, .col-md-8, .col-md-4, .col-md-6, .col-md-3 {
        padding: 0 2px;
    }
    
    .ai-rpg-header {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .ai-rpg-header h1 {
        font-size: 2rem;
    }
    
    .ai-rpg-header .lead {
        font-size: 1rem;
    }
    
    /* Stack layout on medium screens */
    .row.no-gutters {
        flex-direction: column;
    }
    
    .col-lg-9, .col-md-8 {
        width: 100%;
        margin-bottom: 1rem;
    }
    
    .col-lg-3, .col-md-4 {
        width: 100%;
    }
    
    .game-sidebar {
        min-height: auto;
        max-height: none;
    }
    
    /* Canvas container responsive */
    .game-canvas-container {
        width: 100%;
        height: 400px;
        overflow: hidden;
    }
    
    #gameCanvas {
        width: 100%;
        height: 100%;
        max-width: none;
        object-fit: contain;
    }
    
    /* Touch-friendly buttons */
    .btn {
        min-height: 44px;
        font-size: 16px;
        padding: 10px 16px;
    }
    
    .btn-sm {
        min-height: 38px;
        font-size: 14px;
        padding: 8px 12px;
    }
    
    /* Combat modal adjustments */
    .combat-modal .modal-content {
        max-width: 95vw;
        width: 95vw;
        max-height: 85vh;
    }
    
    /* Interaction modal adjustments */
    .interaction-modal .modal-content {
        max-width: 95vw;
        width: 95vw;
        padding: 20px;
    }
    
    /* Player stats panel mobile */
    .player-stats-panel .row {
        margin: 0;
    }
    
    .player-stats-panel .col-6 {
        padding: 2px;
    }
    
    /* Inventory grid mobile */
    .inventory-grid {
        gap: 3px;
    }
    
    .inventory-slot {
        padding: 8px 4px;
        font-size: 12px;
    }
}

@media (max-width: 767px) {
    .ai-rpg-header h1 {
        font-size: 1.75rem;
    }
    
    .game-wrapper {
        padding: 12px;
        overflow: visible; /* Allow scaled content to be visible */
        display: flex;
        justify-content: center;
    }
    
    /* Mobile canvas sizing - scale down to 70% and center on screen */
    .game-canvas-container {
        transform: scale(0.7);
        transform-origin: center;
        width: 142.86%; /* 100% / 0.7 to maintain container size */
        height: 430px; /* Scaled height for 600px canvas */
        margin: 0 auto -120px auto; /* Center horizontally and adjust for scaling */
        overflow: visible;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    #gameCanvas {
        width: 800px !important;
        height: 600px !important;
        max-width: none !important; /* Override responsive max-width */
        display: block;
        background-color: #000; /* Ensure black background is visible */
    }
    
    .game-wrapper {
        overflow: visible; /* Changed from hidden to visible for mobile scaling */
        padding: 8px;
        display: flex;
        justify-content: center;
    }
    
    /* Mobile controls removed - using gesture controls only */
    
    /* Mobile sidebar adjustments */
    .game-sidebar {
        padding: 15px;
    }
    
    .player-stats {
        padding: 15px;
    }
    
    .player-avatar {
        width: 36px !important;
        height: 36px !important;
    }
    
    .player-avatar img {
        width: 24px !important;
        height: 24px !important;
    }
    
    /* Mobile combat modal */
    .combat-modal .modal-content {
        padding: 15px;
        max-height: 90vh;
    }
    
    .combat-info .col-6 {
        padding: 0 5px;
    }
    
    .player-stats, .enemy-stats {
        padding: 8px;
        margin-top: 8px;
    }
    
    .combat-actions .btn {
        padding: 8px 4px;
        font-size: 12px;
    }
    
    /* Mobile interaction modal */
    .interaction-modal .modal-content {
        padding: 15px;
    }
    
    .conversation-display {
        max-height: 150px;
        padding: 10px;
    }
    
    /* Mobile menu adjustments - counter-scale to appear normal size on scaled canvas */
    .menu-content {
        transform: scale(1.43); /* Counter 0.7 scale = 1/0.7 ≈ 1.43 */
        transform-origin: center;
        padding: 1.5rem 1rem;
        width: 280px;
        max-width: 350px;
        margin: 0 auto;
        font-size: 1rem;
        position: relative;
        z-index: 11;
    }
    
    .menu-buttons .btn {
        font-size: 1.1rem;
        padding: 0.8rem 0.5rem;
        margin-bottom: 0.8rem;
        width: 100%;
    }
    
    /* Ensure game overlay works within scaled container */
    .game-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 10;
    }
}

@media (max-width: 575px) {
    .container-fluid {
        padding: 0 5px;
    }
    
    .ai-rpg-header {
        padding: 0.75rem;
    }
    
    .ai-rpg-header h1 {
        font-size: 1.5rem;
    }
    
    .game-wrapper {
        padding: 8px;
    }
    
    /* Extra small mobile canvas - scale to 50% and center for very small screens */
    .game-canvas-container {
        transform: scale(0.5);
        transform-origin: center;
        width: 200%; /* 100% / 0.5 to maintain container size */
        height: 300px; /* Scaled height for 600px canvas */
        margin: 0 auto -180px auto; /* Center horizontally and adjust for scaling */
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    #gameCanvas {
        width: 800px !important;
        height: 600px !important;
        max-width: none !important; /* Override responsive max-width */
        display: block;
        background-color: #000; /* Ensure black background is visible */
    }
    
    /* Mobile controls removed - using gesture controls only */
    
    /* Minimal sidebar on tiny screens */
    .game-sidebar {
        padding: 10px;
    }
    
    .instructions-panel {
        display: none; /* Hide instructions on very small screens */
    }
    
    /* Extra small mobile menu adjustments - counter-scale for 0.5 scaling */
    .menu-content {
        transform: scale(2); /* Counter 0.5 scale = 1/0.5 = 2 */
        transform-origin: center;
        padding: 1rem 0.5rem;
        width: 200px;
        max-width: 250px;
        margin: 0 auto;
        font-size: 0.9rem;
        position: relative;
        z-index: 11;
    }
    
    .menu-buttons .btn {
        font-size: 1rem;
        padding: 0.6rem 0.3rem;
        margin-bottom: 0.6rem;
        width: 100%;
    }
    
    /* Compact combat modal */
    .combat-modal .modal-content {
        padding: 10px;
    }
    
    .combat-info .enemy-avatar span,
    .combat-info .player-avatar img {
        width: 24px;
        height: 24px;
        font-size: 24px;
    }
    
    .combat-actions {
        gap: 5px;
    }
    
    .combat-actions .btn {
        padding: 6px 8px;
        font-size: 11px;
    }
    
    /* Magic input mobile */
    .magic-input {
        padding: 6px;
    }
    
    .magic-input .form-control {
        font-size: 14px;
    }
}

/* Message Container - properly sized notification */
.message-container {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 9999 !important;
    max-width: 400px !important;
    width: auto !important;
    min-width: 300px !important;
}

.message-container .alert {
    margin-bottom: 0 !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
    border-radius: 8px !important;
}

/* Mobile message container adjustments */
@media (max-width: 767px) {
    .message-container {
        max-width: 90vw !important;
        min-width: 280px !important;
        left: 50% !important;
        right: auto !important;
    }
}

/* Touch-specific enhancements */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    .btn {
        min-height: 48px;
        padding: 12px 20px;
    }
    
    .btn-sm {
        min-height: 42px;
        padding: 10px 16px;
    }
    
    /* Remove hover effects on touch devices */
    .btn:hover {
        transform: none;
    }
    
    /* Touch-friendly inventory slots */
    .inventory-slot {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Touch-friendly canvas interaction */
    #gameCanvas {
        touch-action: none; /* Prevent default touch behaviors */
    }
}

/* ============================================================
   DESKTOP SIMPLIFIED LAYOUT — hero profile only, actions on demand
   ============================================================ */

body:not(.mobile-landscape) .order-1,
body:not(.mobile-landscape) .order-3 {
    display: none !important;
}

/* Floating Menu Button */
.floating-menu-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 20;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 20px;
    cursor: pointer;
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
}
.floating-menu-btn:hover { background: rgba(0,0,0,0.8); }

/* Floating Menu Panel */
.floating-menu-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 25;
    width: 240px;
    max-height: 85%;
    background: rgba(15, 15, 25, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px;
    color: #eee;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    pointer-events: auto;
}
.floating-menu-panel.d-none { display: none !important; }

.fmp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    font-weight: bold;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.fmp-close, .fmp-close-sub {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.fmp-close:hover, .fmp-close-sub:hover { color: white; }

.fmp-body {
    overflow-y: auto;
    padding: 8px 12px;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.fmp-section {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.fmp-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

/* Floating panel progress bars */
.floating-menu-panel .progress {
    background: rgba(255,255,255,0.12);
    border-radius: 3px;
}

/* Floating panel inventory grid */
.fmp-inv-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
}
.fmp-inv-slot {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 4px;
    font-size: 1.1rem;
    color: rgba(255,255,255,0.3);
    cursor: default;
    position: relative;
}
.fmp-inv-slot.filled {
    color: white;
    cursor: pointer;
    border-color: rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.1);
}
.fmp-inv-slot.filled:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(100,180,255,0.5);
}
.fmp-inv-slot sub {
    position: absolute;
    bottom: 1px;
    right: 3px;
    font-size: .55rem;
    color: rgba(255,255,255,0.7);
}

/* Floating panel quest items */
.fmp-quest-item {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-left: 3px solid #28a745;
    padding: 6px;
    margin-bottom: 4px;
    border-radius: 4px;
}

/* Floating panel buttons */
.floating-menu-panel .btn-outline-light {
    font-size: 0.8rem;
    padding: 5px 8px;
    border-color: rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.85);
}
.floating-menu-panel .btn-outline-light:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.35);
    color: white;
}

/* Accordion sections */
.fmp-acc {
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.fmp-acc:last-child { border-bottom: none; }

.fmp-acc-btn {
    display: block;
    width: 100%;
    background: none;
    border: none;
    color: #ddd;
    text-align: left;
    padding: 8px 4px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.fmp-acc-btn:hover {
    background: rgba(255,255,255,0.07);
    color: #fff;
}

.fmp-acc-content {
    padding: 4px 0 8px;
}

/* Action row (world magic — no collapse, direct button) */
.fmp-action-row .fmp-acc-btn {
    color: #a78bfa;
}
.fmp-action-row .fmp-acc-btn:hover {
    color: #c4b5fd;
    background: rgba(167,139,250,0.12);
}

/* Save / Load row */
.fmp-save-row {
    display: flex;
    gap: 6px;
    padding: 8px 4px 4px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.fmp-save-row .btn {
    font-size: 0.78rem;
    padding: 5px 0;
    min-height: 30px;
}

/* Hide floating menu on mobile (mobile HUD takes over) */
body.mobile-landscape .floating-menu-btn,
body.mobile-landscape .floating-menu-panel {
    display: none !important;
}

/* ============================================================
   MOBILE LANDSCAPE FULLSCREEN MODE
   ============================================================ */

/* Portrait rotation hint banner (non-blocking) */
.mobile-rotate-banner {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 10000;
    background: rgba(26, 26, 46, 0.92);
    color: white;
    padding: 8px 16px;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
}
.mobile-rotate-banner button {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    padding: 0 4px;
    cursor: pointer;
    opacity: 0.7;
}
.mobile-rotate-banner button:hover { opacity: 1; }

/* Mobile HUD — hidden by default */
.mobile-hud { display: none; }
.mobile-panel { display: none; }

/* Landscape on touch device — fullscreen game */
body.mobile-landscape {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    font-family: monospace !important;
}

body.mobile-landscape .mobile-hud,
body.mobile-landscape .mobile-hud-level,
body.mobile-landscape .mobile-bar-text,
body.mobile-landscape .mobile-panel,
body.mobile-landscape .mobile-panel-title,
body.mobile-landscape .mobile-panel-body,
body.mobile-landscape .interaction-modal,
body.mobile-landscape .interaction-modal .btn,
body.mobile-landscape .combat-modal,
body.mobile-landscape .combat-modal .btn,
body.mobile-landscape .menu-content,
body.mobile-landscape .menu-buttons .btn,
body.mobile-landscape .form-control,
body.mobile-landscape .form-select {
    font-family: monospace !important;
}

body.mobile-landscape .navbar,
body.mobile-landscape nav,
body.mobile-landscape footer,
body.mobile-landscape .ai-rpg-header {
    display: none !important;
}

body.mobile-landscape .container-fluid {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    overflow: hidden !important;
}

/* Hide sidebar columns */
body.mobile-landscape .order-1,
body.mobile-landscape .order-3 {
    display: none !important;
}

body.mobile-landscape .row.no-gutters {
    margin: 0 !important;
    height: 100% !important;
    flex-wrap: nowrap !important;
}

/* Hide the header row entirely — its child .ai-rpg-header is hidden but the row
   itself was still taking 100% height, pushing the game content off-screen */
body.mobile-landscape .container-fluid > .row.no-gutters:first-child {
    display: none !important;
}

/* Canvas column fills entire viewport */
body.mobile-landscape .order-2 {
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 1 100% !important;
    padding: 0 !important;
    height: 100% !important;
}

body.mobile-landscape .game-wrapper {
    padding: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: #000 !important;
    width: 100% !important;
    height: 100% !important;
}

body.mobile-landscape .game-canvas-container {
    width: 100% !important;
    height: 100% !important;
    transform: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
}

body.mobile-landscape #gameCanvas {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    display: block !important;
    border: none !important;
    border-radius: 0 !important;
}

body.mobile-landscape .movement-hint,
body.mobile-landscape .pan-indicator {
    display: none !important;
}

/* Mobile HUD */
body.mobile-landscape .mobile-hud {
    display: flex !important;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 50;
    justify-content: space-between;
    align-items: flex-start;
    padding: env(safe-area-inset-top, 4px) env(safe-area-inset-right, 8px) 0 env(safe-area-inset-left, 8px);
    pointer-events: none;
}

.mobile-hud-top {
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
}

.mobile-hud-bars {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 120px;
}

.mobile-hp-bar, .mobile-mp-bar {
    height: 14px;
    border-radius: 7px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255,255,255,.4);
    background: rgba(0,0,0,.5);
}

.mobile-hp-fill {
    height: 100%;
    background: linear-gradient(90deg, #e74c3c, #c0392b);
    width: 100%;
    transition: width .3s;
    border-radius: 7px;
}

.mobile-mp-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2980b9);
    width: 100%;
    transition: width .3s;
    border-radius: 7px;
}

.mobile-bar-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,.8);
}

.mobile-hud-level {
    background: rgba(0,0,0,.6);
    color: #f39c12;
    font-weight: bold;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    border: 1px solid rgba(243,156,18,.5);
    pointer-events: auto;
}

.mobile-hud-buttons {
    display: flex;
    gap: 6px;
    pointer-events: auto;
}

.mobile-hud-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,.3);
    background: rgba(0,0,0,.55);
    color: white;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    backdrop-filter: blur(4px);
}

.mobile-hud-btn:active {
    background: rgba(255,255,255,.2);
    transform: scale(.9);
}

/* Mobile slide-in panel */
body.mobile-landscape .mobile-panel {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    width: 260px;
    max-width: 55vw;
    height: 100%;
    height: 100dvh;
    background: rgba(20,20,30,.95);
    backdrop-filter: blur(10px);
    z-index: 60;
    flex-direction: column;
    border-left: 1px solid rgba(255,255,255,.15);
    color: white;
    padding: env(safe-area-inset-top, 4px) 0 env(safe-area-inset-bottom, 4px) 0;
}

body.mobile-landscape .mobile-panel.open {
    display: flex !important;
}

.mobile-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,.15);
    flex-shrink: 0;
}

.mobile-panel-title { font-weight: bold; font-size: 14px; }

.mobile-panel-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,.3);
    background: rgba(255,255,255,.1);
    color: white;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.mobile-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px;
    font-size: 13px;
    -webkit-overflow-scrolling: touch;
}

.mobile-panel-body .stat-row { margin-bottom: 8px; }
.mobile-panel-body .progress { height: 6px; margin-top: 2px; }
.mobile-panel-body small { color: rgba(255,255,255,.8); }
.mobile-panel-body .stat-value { color: white; }
.mobile-panel-body .quest-item {
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.15);
    border-left: 3px solid #28a745;
    padding: 8px;
    margin-bottom: 6px;
    border-radius: 6px;
}
.mobile-panel-body .quest-title { color: white; font-size: .85rem; }
.mobile-panel-body .quest-description { color: rgba(255,255,255,.6); font-size: .75rem; }
.mobile-panel-body .inventory-slot {
    background: rgba(255,255,255,.08);
    border-color: rgba(255,255,255,.2);
    color: white;
}
.mobile-panel-body .inventory-slot small { color: rgba(255,255,255,.5); }

/* Mobile D-Pad — hidden by default, grid in mobile landscape */
.mobile-dpad { display: none; }

body.mobile-landscape .mobile-dpad {
    display: grid;
    grid-template-columns: 52px 52px 52px;
    grid-template-rows: 52px 52px 52px;
    gap: 4px;
    position: fixed;
    bottom: env(safe-area-inset-bottom, 12px);
    left: env(safe-area-inset-left, 12px);
    z-index: 55;
    pointer-events: none;
}

.dpad-btn {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,.3);
    background: rgba(0,0,0,.55);
    color: white;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    backdrop-filter: blur(4px);
    pointer-events: auto;
    user-select: none;
}

.dpad-btn:active {
    background: rgba(255,255,255,.2);
    transform: scale(.92);
}

.dpad-up    { grid-column: 2; grid-row: 1; }
.dpad-left  { grid-column: 1; grid-row: 2; }
.dpad-center { grid-column: 2; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down  { grid-column: 2; grid-row: 3; }

.dpad-interact {
    background: rgba(23,162,184,.4);
    border-color: rgba(23,162,184,.6);
    font-weight: bold;
    font-size: 16px;
}

.dpad-interact:active {
    background: rgba(23,162,184,.6);
}

/* Mobile combat modal adjustments */
body.mobile-landscape .combat-modal .modal-content {
    max-width: 90vw !important;
    max-height: 95dvh !important;
    width: auto !important;
    padding: 10px !important;
}

body.mobile-landscape .combat-info {
    padding: .5rem;
}

body.mobile-landscape .combat-info h5 { font-size: .85rem; }
body.mobile-landscape .combat-log { max-height: 60px !important; font-size: .75em; }
body.mobile-landscape .combat-actions .btn { padding: 6px 8px; font-size: 11px; min-height: 34px; }
body.mobile-landscape .player-stats, body.mobile-landscape .enemy-stats { padding: 4px; }
body.mobile-landscape .player-stats .row, body.mobile-landscape .enemy-stats .row { margin: 0; }

body.mobile-landscape .magic-input { padding: 6px; }
body.mobile-landscape .magic-input .form-control { font-size: 13px; }

/* Mobile NPC interaction modal — compact */
body.mobile-landscape .interaction-modal {
    width: 60vw !important;
    max-width: 340px !important;
}

body.mobile-landscape .interaction-modal .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    padding: 6px 8px !important;
    border-radius: 8px !important;
    border-width: 1px !important;
    box-sizing: border-box !important;
    background-color: rgba(50, 50, 65, 0.95) !important;
    --bs-bg-opacity: 1 !important;
}

/* Kill Bootstrap mb-3 / mb-2 margins inside modal */
body.mobile-landscape .interaction-modal .mb-3 {
    margin-bottom: 4px !important;
}
body.mobile-landscape .interaction-modal .mb-2 {
    margin-bottom: 2px !important;
}

body.mobile-landscape .interaction-modal .modal-header {
    margin-bottom: 2px !important;
    padding-bottom: 2px !important;
    border-bottom-width: 1px !important;
}

body.mobile-landscape .interaction-modal .modal-header h3 {
    font-size: 0.85rem !important;
}

body.mobile-landscape .interaction-modal .modal-body {
    padding: 0 !important;
}

body.mobile-landscape .conversation-display {
    max-height: 50px !important;
    padding: 4px 6px !important;
    font-size: 0.72rem !important;
    margin-bottom: 3px !important;
    background: rgba(255,255,255,0.08) !important;
}

body.mobile-landscape .conversation-display .message-bubble {
    font-size: 0.7rem;
    padding: 2px 5px;
    margin-bottom: 1px;
}

body.mobile-landscape .dialogue-options {
    margin-bottom: 3px !important;
}

body.mobile-landscape .dialogue-options h6 {
    font-size: 0.7rem !important;
    margin-bottom: 2px !important;
}

/* Mobile: hide button choices, show dropdown */
body.mobile-landscape .dialogue-choices {
    display: none !important;
}
body.mobile-landscape .dialogue-choices-mobile {
    display: block !important;
}
body.mobile-landscape .dialogue-choices-mobile .form-select {
    font-size: 0.72rem !important;
    padding: 3px 6px !important;
    height: auto !important;
}
body.mobile-landscape .dialogue-choices-mobile .btn {
    font-size: 0.7rem;
    padding: 3px 8px;
    white-space: nowrap;
}

body.mobile-landscape .interaction-modal .custom-input .form-control {
    font-size: 0.72rem !important;
    padding: 3px 6px !important;
    height: auto !important;
}

body.mobile-landscape .interaction-modal .custom-input .btn {
    font-size: 0.7rem;
    padding: 3px 8px;
}

/* Mobile: action buttons in single row */
body.mobile-landscape .interaction-actions .row {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 4px;
    --bs-gutter-x: 0;
}
body.mobile-landscape .interaction-actions .row > [class*="col"] {
    flex: 1 1 0 !important;
    width: auto !important;
    max-width: none !important;
    padding: 0 !important;
    margin-bottom: 0 !important;
}

body.mobile-landscape .interaction-actions .btn {
    font-size: 0.68rem;
    min-height: 26px;
    padding: 2px 4px;
}

/* Mobile menu screens */
body.mobile-landscape .menu-content {
    transform: none !important;
    width: auto !important;
    max-width: 320px !important;
    padding: 1.5rem !important;
}

body.mobile-landscape .menu-buttons .btn {
    font-size: 1rem;
    padding: .6rem .5rem;
}

/* Legacy landscape rule — now superseded by mobile-landscape class */
@media (max-width: 991px) and (orientation: landscape) {
    .row.no-gutters {
        flex-direction: row;
    }

    .col-lg-9, .col-md-8 {
        width: 70%;
        margin-bottom: 0;
    }

    .col-lg-3, .col-md-4 {
        width: 30%;
    }

    .game-canvas-container {
        height: 350px;
    }

    .game-sidebar {
        max-height: 350px;
        overflow-y: auto;
    }
}

/* High DPI display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    #gameCanvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
        image-rendering: pixelated;
    }
}

/* Game canvas touch controls */
.game-canvas-container {
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: manipulation;
}

/* Mobile touch controls removed - using gestures only */
.mobile-controls {
    display: none;
}

.mobile-controls.active {
    display: none;
}

.mobile-actions button {
    width: 50px;
    height: 50px;
    border: 2px solid rgba(255, 255, 255, 0.7);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border-radius: 50%;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.mobile-actions button:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.95);
}

/* Pan gesture indicator */
.pan-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 12px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.pan-indicator.visible {
    opacity: 1;
}

/* Movement instruction indicator */
.movement-hint {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(52, 152, 219, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 15;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    text-align: center;
    white-space: nowrap;
}

.movement-hint.visible {
    opacity: 1;
}

.movement-hint.fade-out {
    animation: fadeOut 2s ease-out forwards;
}

@keyframes fadeOut {
    0% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

/* Enhanced game canvas cursor feedback */
#gameCanvas {
    cursor: grab;
    transition: cursor 0.2s ease;
}

#gameCanvas:active {
    cursor: grabbing;
}

.mobile-device #gameCanvas {
    cursor: default; /* Remove cursor on mobile */
}

/* Visual feedback for interaction targets */
.interaction-target-hint {
    position: absolute;
    pointer-events: none;
    z-index: 20;
    background: rgba(40, 167, 69, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    transform: translate(-50%, -100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.interaction-target-hint.visible {
    opacity: 1;
    animation: bounce 0.5s ease-in-out;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translate(-50%, -100%) translateY(0);
    }
    40% {
        transform: translate(-50%, -100%) translateY(-10px);
    }
    60% {
        transform: translate(-50%, -100%) translateY(-5px);
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .game-canvas-container {
        -webkit-overflow-scrolling: touch;
    }
    
    #gameCanvas {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

/* Prevent pull-to-refresh on mobile */
body {
    overscroll-behavior-y: contain;
}

.game-canvas-container {
    overscroll-behavior: none;
}

/* Fix for mobile viewport issues */
@media screen and (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }
    
    .container-fluid {
        height: 100vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Hide mobile controls by default */
.mobile-controls {
    display: none;
}

/* Show controls on touch devices */
@media (hover: none) and (pointer: coarse) {
    .mobile-controls.active {
        display: flex !important;
    }
}

/* Performance optimizations for mobile */
@media (max-width: 768px) {
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
    
    .game-wrapper {
        will-change: transform;
    }
    
    #gameCanvas {
        will-change: transform;
    }
}

/* Layout Optimization: Minimize margins and ensure proper sidebar positioning */
.game-sidebar {
    margin-right: 0;
    border-right: 1px solid #ddd;
}

/* Ensure no extra spacing in layout containers */
.row.no-gutters > .col-lg-3,
.row.no-gutters > .col-lg-9,
.row.no-gutters > .col-lg-2,
.row.no-gutters > .col-lg-7,
.row.no-gutters > .col-lg-6,
.row.no-gutters > .col-xl-2,
.row.no-gutters > .col-xl-8,
.row.no-gutters > .col-md-4,
.row.no-gutters > .col-md-8,
.row.no-gutters > .col-md-6,
.row.no-gutters > .col-md-3 {
    padding-left: 3px;
    padding-right: 3px;
}

/* Make canvas container more compact */
.game-canvas-container {
    margin: 0;
}

/* Optimize inventory grid for both sidebars */
.col-lg-3 .inventory-grid,
.col-xl-2 .inventory-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

/* Smaller inventory grid for XL screens */
.col-xl-2 .inventory-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
}

/* Optimize responsive column layout */
@media (min-width: 992px) {
    .order-2 {
        flex: 1;
        max-width: 100%;
    }
}
