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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

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

header {
    text-align: center;
    margin-bottom: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px 30px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.3);
    border: none;
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
    pointer-events: none;
}

header h1 {
    font-size: 2.5em;
    color: white;
    margin-bottom: 12px;
    font-weight: 600;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 1;
}

header p {
    font-size: 1.1em;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
    position: relative;
    z-index: 1;
    text-shadow: 0 1px 5px rgba(0, 0, 0, 0.1);
}

.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.controls-panel {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid #e0e0e0;
    margin-bottom: 20px;
}

.control-group {
    margin-bottom: 32px;
}

.control-group h3 {
    color: #333;
    font-size: 1.1em;
    margin-bottom: 15px;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.shape-buttons, .transform-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.shape-btn, .transform-btn, .reset-btn, .initial-position-btn {
    padding: 16px 20px;
    border: none;
    border-radius: 50px;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.shape-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.shape-btn:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.shape-btn.active {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 6px 25px rgba(79, 172, 254, 0.5);
}

.transform-btn {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    color: #2d3748;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.transform-btn:hover {
    background: linear-gradient(135deg, #96e6e1 0%, #fcc8d8 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(168, 237, 234, 0.4);
}

.transform-btn.active {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    color: #2d3748;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 6px 25px rgba(252, 182, 159, 0.5);
}

.rotation-direction {
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.rotation-direction label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #495057;
    font-size: 0.9em;
}

.rotation-direction select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    background: white;
    font-size: 0.9em;
    color: #495057;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.rotation-direction select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}



.reset-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
    width: 100%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 10px;
}

.reset-btn:hover {
    background: linear-gradient(135deg, #ff5252 0%, #e53e3e 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

.initial-position-btn {
    background: linear-gradient(135deg, #4ecdc4 0%, #44a08d 100%);
    color: white;
    width: 100%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 15px;
}

.initial-position-btn:hover {
    background: linear-gradient(135deg, #3bb8b0 0%, #3a8f7a 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(78, 205, 196, 0.4);
}

.info-panel {
    background: #f8f8f8;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
}

.movement-info, .position-info {
    margin-bottom: 10px;
    font-size: 0.95em;
}

.movement-info strong, .position-info strong {
    color: #1e293b;
}

#last-transform, #current-position {
    color: #475569;
    font-weight: 600;
}

.grid-container {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid #e0e0e0;
    position: relative;
    align-self: start;
}

.grid-header {
    text-align: center;
    margin-bottom: 20px;
}

.grid-header h3 {
    color: #333;
    font-size: 1.3em;
    margin-bottom: 8px;
    font-weight: 500;
}

.grid-info {
    color: #666;
    font-size: 0.9em;
    font-weight: 400;
}

#grid-canvas {
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: crosshair;
    display: block;
    margin: 0 auto;
    background: #ffffff;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    max-width: 100%;
}

.axis-labels {
    position: relative;
    margin-top: 30px;
    margin-bottom: 20px;
    height: 40px;
    width: 100%;
}

.x-axis-label {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    color: #718096;
    font-weight: 600;
    font-size: 0.9em;
    white-space: nowrap;
}

.y-axis-label {
    position: absolute;
    left: -25px;
    top: -190px;
    transform: rotate(-90deg);
    transform-origin: center;
    color: #718096;
    font-weight: 600;
    font-size: 0.9em;
    white-space: nowrap;
}



/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .controls-panel {
        order: 2;
    }
    
    .grid-container {
        order: 1;
    }
    
    #grid-canvas {
        width: 100%;
        max-width: 500px;
        height: auto;
    }
}

/* Footer styles */
footer {
    color: #666;
    text-align: center;
    padding: 20px;
    margin-top: 30px;
    clear: both;
}

footer p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

footer a {
    color: #2563eb;
    text-decoration: none;
    font-weight: bold;
}

footer a:hover {
    text-decoration: underline;
    color: #1d4ed8;
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    header p {
        font-size: 1em;
    }
    
    .shape-buttons, .transform-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    #grid-canvas {
        max-width: 400px;
    }
    
    footer {
        margin-top: 20px;
        padding: 15px;
    }

    footer p {
        font-size: 12px;
    }
}

/* Animation for shape movements */
.shape-moving {
    transition: all 0.3s ease-in-out;
}

/* Hover effects for canvas */
#grid-canvas:hover {
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1), 0 0 20px rgba(66, 153, 225, 0.3);
}