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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #fff;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

header h1 {
    font-size: 2em;
    margin-bottom: 15px;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.header-info {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 15px;
}

.info-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 1.1em;
}

.info-item .label {
    font-weight: bold;
    margin-right: 8px;
}

.main-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.panel {
    background: rgba(0, 0, 0, 0.4);
    padding: 20px;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.panel h2 {
    margin-bottom: 15px;
    font-size: 1.3em;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    padding-bottom: 10px;
}

.gauge-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.gauge {
    position: relative;
    height: 200px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.gauge-fill {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: linear-gradient(to top, #2196F3, #64B5F6);
    transition: height 0.5s ease;
}

.gauge-fill.tower {
    background: linear-gradient(to top, #4CAF50, #81C784);
    transition: background 0.5s ease;
}

.gauge-fill.tower.warning {
    background: linear-gradient(to top, #FF9800, #FFB74D);
}

.gauge-fill.tower.danger {
    background: linear-gradient(to top, #f44336, #e57373);
}

.gauge-fill.tower.critical {
    background: linear-gradient(to top, #b71c1c, #f44336);
    animation: pulse 1s infinite;
}

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

.gauge-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5em;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    z-index: 10;
}

.gauge-info {
    display: flex;
    justify-content: space-around;
    font-size: 1em;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 5px;
}

.alarm-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    font-weight: bold;
}

.alarm-indicator.hidden {
    display: none;
}

.alarm-indicator.pre-warning {
    background: #FF9800;
    animation: blink 2s infinite;
}

.alarm-indicator.pre-warning::after {
    content: '⚠️';
}

.alarm-indicator.warning {
    background: #f44336;
    animation: blink 1s infinite;
}

.alarm-indicator.warning::after {
    content: '🚨';
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.tower-status {
    margin-top: 10px;
    padding: 8px;
    border-radius: 5px;
    font-size: 0.9em;
    font-weight: bold;
    text-align: center;
}

.tower-status.ok {
    background: rgba(76, 175, 80, 0.3);
    color: #4CAF50;
}

.tower-status.pre-warning {
    background: rgba(255, 152, 0, 0.3);
    color: #FF9800;
}

.tower-status.warning {
    background: rgba(244, 67, 54, 0.3);
    color: #f44336;
}

.active-penalties {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.penalty-item {
    background: rgba(244, 67, 54, 0.2);
    border: 1px solid #f44336;
    padding: 8px 12px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9em;
}

.penalty-reason {
    font-weight: bold;
    color: #f44336;
}

.penalty-rate {
    color: #ff5252;
    font-weight: bold;
}

.financial-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.financial-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 12px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.financial-item .label {
    font-weight: bold;
}

.value.positive {
    color: #4CAF50;
    font-weight: bold;
}

.value.negative {
    color: #f44336;
    font-weight: bold;
}

.control-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.mode-selector {
    display: flex;
    gap: 10px;
}

.mode-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: all 0.3s;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.mode-btn.active {
    background: #2196F3;
    border-color: #2196F3;
}

.schedule-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.schedule-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: bold;
    transition: all 0.3s;
}

.schedule-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.schedule-btn.active {
    background: #4CAF50;
    border-color: #4CAF50;
}

.target-section {
    margin-bottom: 10px;
}

.target-section.hidden {
    display: none;
}

.schedule-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    border-radius: 5px;
}

.schedule-grid .input-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.schedule-grid input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
}

.schedule-grid input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
}

.schedule-grid input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    border: none;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-group.hidden {
    display: none;
}

.pump-btn {
    padding: 15px;
    font-size: 1.2em;
    font-weight: bold;
    border: 3px solid;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.pump-btn.off {
    background: #4CAF50;
    border-color: #4CAF50;
    color: white;
}

.pump-btn.on {
    background: #f44336;
    border-color: #f44336;
    color: white;
}

.pump-btn:hover {
    transform: scale(1.05);
}

.status-indicator {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
}

.status {
    font-weight: bold;
    padding: 3px 10px;
    border-radius: 3px;
}

.status.off {
    background: #666;
}

.status.on {
    background: #4CAF50;
}

.flow-info {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.input-group label {
    font-weight: bold;
    font-size: 0.9em;
}

.input-group input {
    padding: 8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 5px;
    font-size: 1em;
}

.pid-controls {
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    border-radius: 5px;
}

.pid-controls h3 {
    font-size: 1em;
    margin-bottom: 10px;
}

.time-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.speed-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.speed-btn {
    padding: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: all 0.3s;
}

.speed-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.speed-btn.active {
    background: #FF9800;
    border-color: #FF9800;
}

#time-speed {
    font-weight: bold;
    color: #FF9800;
}

.time-info {
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 5px;
}

.restriction-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.restriction-status {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
}

.restriction-info {
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 5px;
}

.restriction-btn {
    padding: 12px;
    font-size: 1em;
    font-weight: bold;
    border: 2px solid #FF9800;
    background: #FF9800;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.restriction-btn:hover {
    background: #F57C00;
    border-color: #F57C00;
}

.restriction-btn.active {
    background: #f44336;
    border-color: #f44336;
}

.game-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.game-btn {
    padding: 15px 30px;
    font-size: 1.1em;
    font-weight: bold;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.game-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

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

.game-over-content {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    padding: 40px;
    border-radius: 15px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    max-width: 600px;
    text-align: center;
}

.game-over-content h2 {
    font-size: 2em;
    margin-bottom: 30px;
}

.final-stats {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 30px;
}

.stat-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    font-size: 1.2em;
}

.stat-item .label {
    font-weight: bold;
}

@media (max-width: 768px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
    
    .financial-grid {
        grid-template-columns: 1fr;
    }
    
    .speed-selector {
        grid-template-columns: repeat(2, 1fr);
    }
}
