* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    background: #c8e6f0;
    font-family: 'Comic Neue', 'Segoe UI', Roboto, sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    position: relative;
}
.game-wrapper {
    max-width: 1400px; width: 100%;
    background: #fefdf6;
    border-radius: 50px;
    box-shadow: 0 20px 30px rgba(0, 30, 40, 0.2);
    padding: 25px;
    border: 4px solid white;
    transition: filter 0.3s;
}
.blurred { filter: blur(8px); pointer-events: none; }

.cheater-banner {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 0, 0, 0.9);
    display: flex; align-items: center; justify-content: center;
    z-index: 10000; font-size: 8rem; font-weight: 900;
    color: yellow; text-shadow: 10px 10px 0 black;
    transform: rotate(-5deg); border: 20px solid black;
    pointer-events: none; animation: blink 0.5s infinite alternate;
}
@keyframes blink { from { opacity: 0.9; } to { opacity: 1; background: rgba(200, 0, 0, 1); } }

.top-bar {
    display: flex; justify-content: space-between; align-items: center;
    background: #ffffffd9; border-radius: 70px; padding: 18px 35px;
    margin-bottom: 25px; box-shadow: 0 6px 0 #bbcfdd;
    font-size: 2rem; font-weight: 600; color: #1e3c5a; flex-wrap: wrap; gap: 15px;
}
.money { background: #f7d88e; padding: 10px 35px; border-radius: 50px; box-shadow: inset 0 -4px 0 #cb9f4a; }
.day { background: #b3d2e6; padding: 10px 35px; border-radius: 50px; box-shadow: inset 0 -4px 0 #6189a6; }
.rating { background: #f0b27a; padding: 10px 35px; border-radius: 50px; box-shadow: inset 0 -4px 0 #b86824; display: flex; align-items: center; gap: 8px; }
.player-info { background: #b0d0b0; padding: 10px 25px; border-radius: 50px; font-size: 1.5rem; display: flex; align-items: center; gap: 10px; }

.three-col { display: flex; gap: 20px; margin-bottom: 25px; flex-wrap: wrap; }
.col {
    flex: 1 1 300px; background: #ebf3fa; border-radius: 40px;
    padding: 20px; box-shadow: 0 8px 0 #b4c9db; display: flex; flex-direction: column; gap: 15px;
}
.col h2 { font-size: 1.8rem; color: #1f4d6e; border-left: 8px solid #ffb84d; padding-left: 15px; margin-bottom: 5px; }

.order-list { display: flex; flex-direction: column; gap: 12px; max-height: 400px; overflow-y: auto; padding-right: 5px; }
.order-card { background: white; border-radius: 30px; padding: 15px; border: 2px solid #d3e2ef; display: flex; flex-direction: column; gap: 8px; }
.order-header { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 1.3rem; }
.order-detail { display: flex; justify-content: space-between; color: #305f7a; }
.take-btn {
    background: #ffb84d; border: none; border-radius: 40px; padding: 10px 20px;
    font-weight: 700; font-size: 1.2rem; box-shadow: 0 4px 0 #b2721a; cursor: pointer; transition: 0.1s; align-self: flex-end;
}
.take-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b2721a; }
.take-btn:disabled { opacity: 0.5; pointer-events: none; }

.tab-bar { display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.tab { background: #d4e3f0; border-radius: 40px; padding: 10px 25px; font-weight: 600; font-size: 1.2rem; cursor: pointer; border: 2px solid transparent; }
.tab.active { background: #ffb84d; border-color: #b2721a; }
.tab-content { background: white; border-radius: 30px; padding: 15px; min-height: 200px; max-height: 500px; overflow-y: auto; }

.machine-summary { background: #e1f0fa; border-radius: 30px; padding: 10px 15px; margin-bottom: 15px; font-size: 1.1rem; display: flex; flex-wrap: wrap; gap: 15px; justify-content: center; }
.summary-item { display: flex; align-items: center; gap: 8px; background: white; padding: 5px 12px; border-radius: 20px; border: 1px solid #b4c9db; }

/* ВИЗУАЛИЗАЦИЯ ФАБРИКИ */
.factory-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 15px;
    background: #d3e5f2; border-radius: 20px; padding: 15px; margin-bottom: 10px;
    min-height: 220px; border: 3px solid #b4c9db; box-shadow: inset 0 5px 10px rgba(0,0,0,0.05);
    justify-items: center;
}

/* Строгий размер ячеек 128x128 */
.machine-sprite {
    background: white; border-radius: 15px; width: 128px; height: 128px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; box-shadow: 0 4px 0 #b4c9db; position: relative; 
    cursor: pointer; transition: transform 0.1s, box-shadow 0.1s;
}
.machine-sprite:hover { transform: translateY(-2px); box-shadow: 0 6px 0 #9cb5cb; }
.machine-sprite:active { transform: translateY(2px); box-shadow: 0 2px 0 #b4c9db; }
.machine-sprite.empty-slot {
    background: transparent; box-shadow: none; border: 3px dashed #b4c9db;
    color: #b4c9db; font-size: 4rem; font-weight: bold;
}
.machine-sprite.empty-slot:hover { border-color: #ffb84d; color: #ffb84d; background: rgba(255, 255, 255, 0.5); }

.machine-health-mini { position: absolute; bottom: 5px; width: 80%; left: 10%; height: 8px; background: #ddd; border-radius: 10px; overflow: hidden; border: 1px solid #ccc; }
.health-mini-fill { height: 100%; background: #6ec06e; transition: width 0.3s, background-color 0.3s; }
.health-critical { background: #e48383 !important; }

.machine-smoke {
    position: absolute; top: -15px; font-size: 1.5rem; animation: smokeRise 1s infinite alternate;
    display: none; user-select: none; pointer-events: none; z-index: 5;
}
.needs-repair .machine-smoke { display: block; }
.needs-repair { animation: shake 0.5s infinite; border: 2px solid #e48383; box-shadow: 0 4px 0 #c76a6a; }

@keyframes smokeRise {
    0% { transform: translateY(0) scale(1) translateX(0); opacity: 0.8; }
    100% { transform: translateY(-15px) scale(1.3) translateX(5px); opacity: 0; }
}
@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    25% { transform: translate(-1px, -2px) rotate(-2deg); }
    50% { transform: translate(-2px, 0px) rotate(2deg); }
    75% { transform: translate(2px, 1px) rotate(0deg); }
    100% { transform: translate(1px, -1px) rotate(1deg); }
}

/* Tooltip для станков */
.machine-sprite::after {
    content: attr(data-tooltip); position: absolute; bottom: 110%; left: 50%; transform: translateX(-50%);
    background: #1e3c5a; color: white; padding: 8px 12px; border-radius: 10px; font-size: 0.9rem;
    white-space: nowrap; opacity: 0; pointer-events: none; transition: 0.2s; z-index: 10; font-weight: 600;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.machine-sprite:hover::after { opacity: 1; bottom: 120%; }

.storage-item { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 2px solid #e7f0f8; align-items: center;}

.action-button {
    background: #c8e0f0; border: 3px solid #7fa6c2; border-radius: 60px; padding: 15px;
    font-size: 1.5rem; font-weight: 700; color: #1e3c5a; text-align: center; cursor: pointer;
    box-shadow: 0 6px 0 #7f9fb0; margin-top: 10px;
}
.action-button:active { transform: translateY(4px); box-shadow: 0 2px 0 #7f9fb0; }
.loan-item { background: #ffe5b9; border-radius: 30px; padding: 12px; display: flex; justify-content: space-between; font-weight: 600; }

.new-day-btn {
    background: #ff9f4d; border: none; border-radius: 80px; padding: 20px 50px;
    font-size: 2.8rem; font-weight: 800; color: white; text-shadow: 0 3px 0 #b25e00;
    box-shadow: 0 10px 0 #b25e00; cursor: pointer; width: fit-content; margin: 0 auto 10px; transition: 0.1s;
}
.new-day-btn:active { transform: translateY(5px); box-shadow: 0 5px 0 #b25e00; }

/* Модальные окна */
.modal {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.3); backdrop-filter: blur(4px); align-items: center; justify-content: center; z-index: 2000;
}
.modal.active { display: flex; }
.modal-content {
    background: #fffcf0; border-radius: 70px; padding: 40px; max-width: 600px; width: 90%;
    border: 6px solid #ffb84d; box-shadow: 0 20px 0 #b2721a; text-align: center;
}
.modal-content h2, .modal-content h3 { font-size: 2.5rem; color: #1e3c5a; margin-bottom: 20px; }
.modal-content select, .modal-content input { font-size: 1.5rem; padding: 15px 20px; border-radius: 50px; border: 3px solid #7fa6c2; width: 100%; margin-bottom: 20px; font-family: inherit; }
.modal-content button { background: #ffb84d; border: none; border-radius: 60px; padding: 15px 30px; font-size: 1.8rem; font-weight: 700; box-shadow: 0 8px 0 #b2721a; cursor: pointer; margin: 10px; }
.machine-shop-item, .loan-offer-item { background: white; border: 2px solid #b4c9db; border-radius: 20px; padding: 15px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; text-align: left; font-size: 1.2rem; }
.machine-shop-item button, .loan-offer-item button { font-size: 1.2rem; padding: 10px 20px; margin: 0; box-shadow: 0 4px 0 #b2721a; }

.help-icon {
    font-size: 2rem; background: #e0edf5; border-radius: 50%; width: 60px; height: 60px;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    box-shadow: 0 5px 0 #a5bacb; transition: transform 0.2s, background 0.2s;
}
.help-icon-attention { animation: attention 1.5s infinite; background: #ffd966; box-shadow: 0 5px 0 #b2721a, 0 0 20px #ffb84d; }
@keyframes attention { 0% { transform: scale(1); } 50% { transform: scale(1.2); background: #ffb84d; } 100% { transform: scale(1); } }

.daily-cost-indicator {
    margin-top: 10px; font-size: 1.5rem; text-align: center; color: #1e3c5a;
    background: #ffe5b9; border-radius: 50px; padding: 10px 25px; width: fit-content;
    margin-left: auto; margin-right: auto; box-shadow: inset 0 -3px 0 #e6c89c;
}

/* ТУР */
.tour-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 3000; }
.tour-overlay.active { display: block; }
.tour-highlight {
    display: none; position: absolute; box-shadow: 0 0 0 4px #ffb84d, 0 0 20px 10px #ffb84d;
    border-radius: 20px; animation: pulse 1.5s infinite; pointer-events: none; z-index: 3001;
}
.tour-highlight.active { display: block; }
@keyframes pulse {
    0% { box-shadow: 0 0 0 4px #ffb84d, 0 0 20px 10px #ffb84d; }
    70% { box-shadow: 0 0 0 8px #ffa01e, 0 0 30px 15px #ffa01e; }
    100% { box-shadow: 0 0 0 4px #ffb84d, 0 0 20px 10px #ffb84d; }
}
.tour-tooltip {
    display: none; position: absolute; background: #fffcf0; border: 4px solid #ffb84d;
    border-radius: 40px; padding: 20px 30px; font-size: 1.6rem; font-weight: 600; color: #1e3c5a;
    box-shadow: 0 10px 0 #b2721a; z-index: 3002; max-width: 400px; text-align: center;
}
.tour-tooltip.active { display: block; }
.tour-buttons { margin-top: 20px; display: flex; gap: 15px; justify-content: center; }
.tour-buttons button { background: #ffb84d; border: none; border-radius: 50px; padding: 10px 30px; font-size: 1.4rem; font-weight: 700; box-shadow: 0 4px 0 #b2721a; cursor: pointer; }
.tour-buttons button.skip { background: #c0d0e0; box-shadow: 0 4px 0 #7f9fb0; }
/* --- ГРАФИК НАЛОГОВ --- */
.chart-container {
    display: flex; align-items: flex-end; justify-content: flex-start; gap: 20px;
    height: 300px; background: white; border: 3px solid #b4c9db; border-radius: 30px;
    padding: 20px; margin-bottom: 20px; overflow-x: auto; box-shadow: inset 0 5px 10px rgba(0,0,0,0.05);
}
.chart-col { 
    display: flex; flex-direction: column; align-items: center; 
    width: 60px; height: 100%; justify-content: flex-end; cursor: pointer;
}
.bar-group { 
    width: 50px; display: flex; flex-direction: column; justify-content: flex-end; 
    border-radius: 8px 8px 0 0; overflow: hidden; box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}
.chart-col:hover .bar-group { transform: scale(1.05); }
.bar-tax { 
    background: #e74c3c; width: 100%; display: flex; align-items: center; 
    justify-content: center; color: white; font-size: 0.8rem; font-weight: bold;
}
.bar-income { 
    background: #2ecc71; width: 100%; display: flex; align-items: center; 
    justify-content: center; color: white; font-size: 0.8rem; font-weight: bold;
}
.chart-label { font-size: 1rem; font-weight: bold; margin-top: 10px; color: #1e3c5a; }
/* --- НОВЫЕ СТИЛИ --- */
.cancel-btn {
    background: #e74c3c; color: white; border: none; border-radius: 10px;
    padding: 5px 10px; font-weight: bold; cursor: pointer; box-shadow: 0 3px 0 #c0392b;
    margin-top: 10px; transition: transform 0.1s; align-self: flex-end;
}
.cancel-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #c0392b; }

.upgrade-item { 
    background: white; border: 2px solid #b4c9db; border-radius: 20px; 
    padding: 15px; margin-bottom: 15px; display: flex; justify-content: space-between; 
    align-items: center; text-align: left; font-size: 1.2rem; transition: 0.2s;
}
.upgrade-item.purchased {
    background: #eafaf1; border-color: #2ecc71; opacity: 0.8;
}
.upgrade-item button { font-size: 1.2rem; padding: 10px 20px; margin: 0; }