
/* ========================================
   БАЗОВЫЕ СТИЛИ
   ======================================== */

/* Предотвращаем bounce эффект в Telegram */
html, body {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a2e;
    color: #e6e6e6;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow-x: auto;
    /* Долгое нажатие на телефоне не выделяет текст и не открывает меню (требование CrazyGames) */
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

input, textarea, [contenteditable="true"] {
    -webkit-user-select: text;
    user-select: text;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 10px;
}

header {
    text-align: center;
    margin-bottom: 15px;
}

header h1 {
    color: #7289da;
    margin-bottom: 5px;
    font-size: 24px;
}

/* Горизонтальная сетка 3x3 */
.grid {
    display: grid;
    gap: 8px;
}

.grid-3x3 {
    grid-template-columns: repeat(3, 80px);
    grid-template-rows: repeat(3, 80px);
    justify-content: center;
}

.cell {
    background: #2c2c3d;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.cell:hover {
    background: #3d3d5c;
    transform: scale(1.05);
}

.cell.empty {
    background: #3d3d5c;
    color: #aaa;
}

.cell.built {
    background: #444466;
}

.cell.under-construction {
    background: #555577;
}

.cell.pulse {
    animation: pulse 1s infinite;
}

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

/* Горизонтальная компоновка */
.game-container {
    display: flex;
    gap: 15px;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: wrap;
}

.wizards-panel {
    background: #2c2c3d;
    padding: 10px;
    border-radius: 10px;
    min-width: 100px;
    order: 1;
}

.wizards-panel h3 {
    margin-top: 0;
    color: #7289da;
    font-size: 16px;
    text-align: center;
}

.wizard-portrait {
    width: 40px;
    height: 40px;
    background: #444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    cursor: pointer;
    transition: transform 0.2s;
    font-size: 20px;
}

.wizard-portrait:hover {
    transform: scale(1.1);
}

/* МОБИЛЬНЫЕ - только по размеру экрана */
@media (max-width: 768px) {
    body {
        padding: 5px;
    }
    
    .container {
        padding: 5px;
    }
    
    header {
        margin-bottom: 10px;
    }
    
    header h1 {
        font-size: 20px;
        margin-bottom: 3px;
    }
    
    .game-container {
        flex-direction: row;
        gap: 10px;
        height: calc(100vh - 80px);
        align-items: center;
    }
    
    .wizards-panel {
        order: 0;
        display: flex;
        flex-direction: column;
        height: fit-content;
        max-height: 70vh;
        overflow-y: auto;
        padding: 8px;
        min-width: 80px;
    }
    
    .wizards-panel h3 {
        font-size: 14px;
        margin-bottom: 8px;
    }
    
    .wizard-portrait {
        width: 35px;
        height: 35px;
        font-size: 18px;
        margin-bottom: 6px;
    }
    
    .grid-3x3 {
        grid-template-columns: repeat(3, 70px);
        grid-template-rows: repeat(3, 70px);
        gap: 6px;
    }
    
    .cell {
        font-size: 24px;
    }
}

/* Очень маленькие экраны */
@media (max-width: 480px) {
    .grid-3x3 {
        grid-template-columns: repeat(3, 60px);
        grid-template-rows: repeat(3, 60px);
    }
    
    .cell {
        font-size: 20px;
    }
    
    .wizards-panel {
        min-width: 70px;
    }
    
    .wizard-portrait {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }
}

/* Фракционные кнопки */
.faction-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    max-width: 400px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .faction-buttons {
        grid-template-columns: repeat(4, 1fr);
        max-width: 600px;
        gap: 8px;
    }
    
    .faction-btn {
        padding: 15px 10px !important;
        font-size: 14px !important;
    }
}

/* Анимация для улучшающихся зданий */
@keyframes pulse-building {
    0% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Стили для улучшающихся зданий */
.cell.upgrading {
    position: relative;
    overflow: hidden;
}

.cell.upgrading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        45deg, 
        transparent 30%, 
        rgba(255, 165, 0, 0.2) 50%, 
        transparent 70%
    );
    animation: shimmer 2s infinite;
    pointer-events: none;
}

/* Таймер строительства */
.construction-timer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: #ffa500;
    font-size: 10px;
    padding: 2px;
    text-align: center;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

/* Индикатор улучшения */
.upgrade-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    animation: pulse-building 1.5s infinite;
    z-index: 2;
}

/* Адаптация под маленькие экраны */
@media (max-width: 480px) {
    .construction-timer {
        font-size: 9px;
        padding: 1px;
    }
    
    .upgrade-indicator {
        font-size: 20px;
    }
}

@media (max-width: 768px) {
    .construction-timer {
        font-size: 9px;
    }
    
    .upgrade-indicator {
        font-size: 24px;
    }
}