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

body {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%);
    min-height: 100vh;
    padding: 20px;
}

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(45deg, #ff6b6b, #ff8e8e, #ffa8a8);
    color: white;
    text-align: center;
    padding: 20px;
}

header h1 {
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header h2 {
    font-size: 1.2em;
    margin-top: 10px;
    opacity: 0.9;
}

.game-stats {
    display: flex;
    justify-content: space-around;
    background: #f8f9fa;
    padding: 15px;
    border-bottom: 2px solid #dee2e6;
}

.stat {
    text-align: center;
    font-size: 1.2em;
    font-weight: bold;
}

.label {
    color: #666;
}

.status-indicator {
    font-weight: bold;
    color: #007bff;
}

.status-indicator.processing {
    color: #ffc107;
}


.city-area {
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    margin: 20px 0;
}

.city-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-weight: bold;
    font-size: 1em;
}

.area-label {
    color: #ff6b6b;
    font-weight: bold;
}

.city-grid {
    display: grid;
    grid-template-columns: repeat(45, 1fr);
    grid-template-rows: repeat(18, 1fr);
    gap: 1px;
    background: #dee2e6;
    border: 2px solid #adb5bd;
    border-radius: 5px;
    padding: 2px;
    height: 480px;
    width: 100%;
    overflow: hidden;
}

.grid-cell {
    background: #ffffff;
    border-radius: 1px;
    position: relative;
    transition: all 0.2s ease;
}

.grid-cell.happiness-district {
    background: #ffe6e6;
}

.grid-cell.parks {
    background: #e8f5e8;
}

.grid-cell.training-grounds {
    background: #f0e6ff;
}

.grid-cell.ocean {
    background: #4da6ff;
}

.grid-cell.friends {
    background: #ffccff;
}

.grid-cell.eating {
    background: #fff9e6;
}

/* Base district colors - no longer needed since all cells use district classes */

/* Decoration styling */
.grid-cell.decoration {
    position: relative;
    overflow: hidden;
}

.decoration-emoji {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    line-height: 1;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
    max-width: 100%;
    max-height: 100%;
}

/* Decoration cells just use district colors - no decoration-specific backgrounds */

.grid-cell.occupied-cat {
    background: #007bff;
}

.grid-cell.occupied-captured-cat {
    background: #dc3545;
}


.grid-cell.occupied-toy {
    background: #ffeb3b;
}

.grid-cell.empty {
    background: #f8f9fa;
}

.grid-unit {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    position: relative;
}


.grid-unit.cat-unit {
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* Hide text when PNG is loaded */

.grid-unit.cat-unit[style*="background-image"] {
    color: transparent;
    font-size: 0; /* Additional method to hide text */
}

.grid-unit.cat-unit {
    color: transparent; /* Just hide text for cats by default since we always want PNG */
}

.cat {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    position: relative;
    display: inline-block;
    animation: bounce 2s infinite;
}

.cat.orange { background: #ff8c00; }
.cat.black { background: #2c2c2c; }
.cat.white { background: #f5f5f5; border: 2px solid #ccc; }
.cat.gray { background: #808080; }
.cat.brown { background: #8b4513; }

.cat::before {
    content: '😺';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
}

.cat.equipped::after {
    content: '⚔️';
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 12px;
}


.explosion {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 30px;
    pointer-events: none;
    animation: explode 0.6s ease-out forwards;
    z-index: 10;
}


.action-panel {
    background: #f8f9fa;
    padding: 20px;
    border-top: 2px solid #dee2e6;
}

.action-panel h3 {
    text-align: center;
    margin-bottom: 15px;
    color: #333;
}

.action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.action-btn {
    padding: 15px 20px;
    font-size: 1.1em;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
}

#feed-cats { background: #28a745; }
#train-cats { background: #dc3545; }
#play-cats { background: #ffc107; color: #333; }
#recruit-cats { background: #007bff; }

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Tooltip styling */
.action-btn[data-tooltip] {
    position: relative;
}

.action-btn[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: normal;
    white-space: nowrap;
    z-index: 1000;
    max-width: 300px;
    white-space: normal;
    text-align: center;
    line-height: 1.3;
}

.action-btn[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid rgba(0, 0, 0, 0.9);
    z-index: 1000;
}

.game-log {
    background: #343a40;
    color: white;
    padding: 20px;
    max-height: 200px;
    overflow-y: auto;
}

.game-log h3 {
    margin-bottom: 15px;
    color: #ffc107;
}

#log-messages {
    font-family: monospace;
    line-height: 1.4;
}

.log-entry {
    margin-bottom: 5px;
    padding: 5px;
    border-radius: 3px;
}

.log-success { background: rgba(40, 167, 69, 0.2); }
.log-failure { background: rgba(220, 53, 69, 0.2); }
.log-info { background: rgba(23, 162, 184, 0.2); }

.game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 2em;
    z-index: 10000;
}

.game-over.hidden {
    display: none;
}

#restart-btn {
    padding: 15px 30px;
    font-size: 1.2em;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    margin-top: 20px;
}

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

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(2deg); }
    75% { transform: rotate(-2deg); }
}

@keyframes explode {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.3);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.5);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-2px); }
    20% { transform: translateX(2px); }
    30% { transform: translateX(-2px); }
    40% { transform: translateX(2px); }
    50% { transform: translateX(-1px); }
    60% { transform: translateX(1px); }
    70% { transform: translateX(-1px); }
    80% { transform: translateX(1px); }
    90% { transform: translateX(-1px); }
}

.instruction-text {
    text-align: center;
    font-style: italic;
    color: #666;
    margin-bottom: 15px;
}

.info-text {
    font-size: 0.9em;
    line-height: 1.4;
}

.info-text p {
    margin: 5px 0;
}

/* Hover Popup Styles */
.hover-popup {
    position: fixed;
    background: white;
    border-radius: 12px;
    padding: 15px;
    min-width: 200px;
    max-width: 300px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.25);
    border: 2px solid #dee2e6;
    z-index: 9999;
    pointer-events: auto;
    transform: translate3d(0, 0, 0); /* Force hardware acceleration */
    will-change: auto;
    contain: layout style paint; /* Isolate from document reflows */
}

.hover-popup.hidden {
    display: none;
}

.hover-popup-content h4 {
    margin: 0 0 12px 0;
    color: #ff6b6b;
    font-size: 1.2em;
    text-align: center;
}

#popup-stats {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 0.9em;
}

#popup-stats p {
    margin: 5px 0;
    line-height: 1.3;
}

#popup-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.popup-action-btn {
    padding: 8px 6px;
    font-size: 0.8em;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    background: #007bff;
}

.popup-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.popup-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.popup-action-btn.rest { background: #28a745; }
.popup-action-btn.play { background: #ffc107; color: #333; }
.popup-action-btn.recruit { background: #ff6b6b; }
.popup-action-btn.train { background: #dc3545; }
.popup-action-btn.travel { background: #17a2b8; }

/* Grid cell hover interaction */
.grid-cell {
    cursor: pointer;
}

/* Travel mode styles */
.travel-mode {
    cursor: crosshair !important;
}

.travel-mode .grid-cell {
    cursor: crosshair !important;
}

.travel-mode .grid-cell:hover {
    background-color: rgba(23, 162, 184, 0.3) !important;
    border: 2px solid #17a2b8 !important;
    box-sizing: border-box;
}

.travel-mode .grid-cell.blocked {
    cursor: not-allowed !important;
}

.travel-mode .grid-cell.blocked:hover {
    background-color: rgba(220, 53, 69, 0.3) !important;
    border: 2px solid #dc3545 !important;
}

/* Traveling cat styles */
.grid-cell.traveling {
    animation: pulse 1s infinite;
}

/* Reserved destination cell */
.grid-cell.reserved-destination {
    border: 3px solid #ffc107;
    box-shadow: inset 0 0 10px rgba(255, 193, 7, 0.3);
    animation: reservedPulse 2s infinite;
    box-sizing: border-box;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes reservedPulse {
    0%, 100% { 
        border-color: #ffc107;
        box-shadow: inset 0 0 10px rgba(255, 193, 7, 0.3);
    }
    50% { 
        border-color: #ff8c00;
        box-shadow: inset 0 0 15px rgba(255, 140, 0, 0.5);
    }
}

/* Version footer */
.version-footer {
    position: fixed;
    bottom: 5px;
    right: 10px;
    color: #666;
    font-size: 10px;
    font-family: monospace;
    background: none;
    z-index: 100;
    pointer-events: none;
}

#commit-hash {
    opacity: 0.6;
}

@media (max-width: 768px) {
    .city-area {
        grid-template-columns: 1fr;
    }
    
    .game-stats {
        flex-direction: column;
        gap: 10px;
    }
    
    .cat-menu-content {
        width: 95%;
        padding: 20px;
    }
    
    .cat-menu-actions {
        grid-template-columns: 1fr;
    }
}