:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --accent-color: #f093fb;
    --text-color: #333;
    --bg-color: rgba(255, 255, 255, 0.95);
    --shadow: 0 8px 20px rgba(0,0,0,0.1);
    --border-radius: 15px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 50%, var(--accent-color) 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    color: var(--text-color);
    text-align: center;
    min-height: 100vh;
    overflow-x: hidden;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

header {
    background: rgba(0, 123, 255, 0.9);
    color: white;
    padding: 30px;
    border-radius: 0 0 20px 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

header nav {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

header nav a {
    color: white;
    text-decoration: none;
    font-weight: bold;
    padding: 10px 15px;
    border-radius: 5px;
    transition: background 0.3s;
}

header nav a:hover {
    background: rgba(255, 255, 255, 0.2);
}

main {
    display: flex;
    max-width: 1200px;
    margin: 20px auto;
    padding: 30px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

.main-content {
    flex: 1;
    margin-right: 20px;
}

aside#calculator {
    width: 35%;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

#controls, #predictions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#controls label, #controls input, #controls select, #predictions label, #predictions select {
    margin: 5px;
    font-weight: bold;
}

button {
    padding: 12px 25px;
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
}

button::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;
}

button:hover::before {
    left: 100%;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

#results {
    margin: 30px 0;
}

#phaseDisplay img {
    width: 300px;
    height: 200px;
    border-radius: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: opacity 0.5s ease;
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#heatChart {
    border: 2px solid #007bff;
    border-radius: 10px;
    margin: 20px auto;
    display: block;
    background: #f8f9fa;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

#qDisplay, #stateDisplay, #accuracyDisplay {
    font-size: 18px;
    font-weight: bold;
    color: #007bff;
}

footer {
    margin-top: 30px;
    padding: 15px;
    background: rgba(0, 123, 255, 0.9);
    color: white;
    border-radius: 15px 15px 0 0;
    text-align: center;
}

footer #results {
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

footer #results #phaseDisplay img {
    width: 300px;
    height: 200px;
    border-radius: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: opacity 0.5s ease;
}

footer #results canvas {
    border: 2px solid #007bff;
    border-radius: 10px;
    margin: 20px auto;
    display: block;
    background: #f8f9fa;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

footer #results p {
    font-size: 18px;
    font-weight: bold;
    color: #007bff;
    margin: 10px 0;
}

footer #results button {
    padding: 12px 25px;
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    margin: 5px;
}

footer #results button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}

#calculator {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

#calc-display {
    display: block;
    width: 80%;
    max-width: 320px;
    padding: 18px 16px;
    font-size: 22px;
    margin: 0 auto 15px;
    text-align: right;
    border: 2px solid #007bff;
    border-radius: 8px;
    background: #f8f9fa;
    overflow-x: auto;
}

.calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.calc-btn {
    padding: 15px;
    font-size: 16px;
    background: linear-gradient(45deg, #007bff, #0056b3);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
}

.calc-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;
}

.calc-btn:hover::before {
    left: 100%;
}

.calc-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.calc-btn.number {
    background: #28a745;
}

.calc-btn.number:hover {
    background: #218838;
}

.calc-btn.operation {
    background: #ffc107;
    color: #333;
}

.calc-btn.operation:hover {
    background: #e0a800;
}

.calc-btn.equals {
    background: #dc3545;
    grid-column: span 2;
}

.calc-btn.equals:hover {
    background: #c82333;
}

#clear-calc {
    background: #6c757d;
    grid-column: span 2;
}

#clear-calc:hover {
    background: #5a6268;
}

#properties {
    background: linear-gradient(135deg, #e9ecef 0%, #f8f9fa 100%);
    padding: 15px;
    border-radius: 10px;
    margin-top: 10px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

/* Responsive design for mobile screens */
@media (max-width: 768px) {
    header nav {
        flex-direction: column;
        gap: 10px;
    }

    main {
        flex-direction: column;
        padding: 15px;
    }

    .main-content {
        margin-right: 0;
        margin-bottom: 20px;
    }

    aside#calculator {
        width: 100%;
        order: 1; /* Move calculator below main content on mobile */
    }

    #calc-display {
        display: block;
        width: 90%;
        max-width: 280px;
        margin: 0 auto 12px;
        font-size: 20px;
        padding: 15px 14px;
    }

    .calc-buttons {
        grid-template-columns: repeat(4, 1fr); /* Adjust grid for smaller screens */
        gap: 8px;
    }

    .calc-btn {
        padding: 12px;
        font-size: 14px;
    }

    .calc-btn.equals, #clear-calc {
        grid-column: span 2;
    }

    footer #results {
        padding: 10px;
    }

    footer #results #phaseDisplay img {
        width: 250px;
        height: 150px;
    }

    footer #results canvas {
        width: 100%;
        max-width: 500px;
        height: 250px;
    }

    footer #results p {
        font-size: 16px;
    }

    footer #results button {
        padding: 10px 20px;
        font-size: 14px;
    }
}

/* Additional responsive breakpoints */
@media (max-width: 1200px) {
    main {
        max-width: 95%;
        padding: 20px;
    }

    .main-content {
        margin-right: 15px;
    }

    aside#calculator {
        width: 25%;
    }
}

@media (max-width: 992px) {
    header nav {
        flex-wrap: wrap;
        gap: 15px;
    }

    header nav a {
        padding: 8px 12px;
        font-size: 14px;
    }

    main {
        flex-direction: column;
        padding: 15px;
    }

    .main-content {
        margin-right: 0;
        margin-bottom: 20px;
    }

    aside#calculator {
        width: 100%;
        order: 2;
    }

    #controls, #predictions {
        grid-template-columns: 1fr;
    }

    .control-group {
        flex-direction: column;
        align-items: stretch;
    }

    .control-group label, .control-group input, .control-group select {
        margin: 5px 0;
        width: 100%;
    }

    #heatChart {
        width: 100%;
        max-width: 600px;
        height: 300px;
    }

    footer #results #phaseDisplay img {
        width: 200px;
        height: 120px;
    }

    footer #results canvas {
        width: 100%;
        max-width: 500px;
        height: 250px;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 14px;
    }

    header {
        padding: 20px;
    }

    header h1 {
        font-size: 24px;
    }

    main {
        padding: 10px;
    }

    #tutorial h2 {
        font-size: 18px;
    }

    button {
        padding: 10px 20px;
        font-size: 14px;
    }

    #calc-display {
        display: block;
        width: 90%;
        max-width: 260px;
        margin: 0 auto 10px;
        font-size: 18px;
        padding: 10px 12px;
    }

    .calc-buttons {
        grid-template-columns: repeat(4, 1fr);
        gap: 5px;
    }

    .calc-btn {
        padding: 8px;
        font-size: 11px;
    }

    .calc-btn.equals {
        grid-column: span 2;
    }

    #clear-calc {
        grid-column: span 2;
    }

    #properties {
        font-size: 12px;
    }

    #results p {
        font-size: 14px;
        margin: 8px 0;
    }

    #phaseDisplay img {
        width: 120px;
        height: 80px;
    }

    #heatChart {
        height: 200px;
    }

    footer #results canvas {
        height: 150px;
    }

    footer #results p {
        font-size: 12px;
    }
}
