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

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    min-height: 100vh;
    color: #2c3e50;
    overflow-x: hidden;
}

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

/* Header Styles */
.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2.8rem;
    color: #e91e63;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    background: linear-gradient(45deg, #e91e63, #ff6b9d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

@keyframes titleBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.header p {
    font-size: 1.2rem;
    color: #6c757d;
    max-width: 700px;
    margin: 0 auto 20px;
    line-height: 1.5;
}

/* Explanation Cards */
.explanation-cards {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 20px 0;
    flex-wrap: wrap;
}

.explanation-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    max-width: 300px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
}

.explanation-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0,0,0,0.15);
}

.random-card {
    border-left: 4px solid #2196f3;
}

.poisson-card {
    border-left: 4px solid #e91e63;
}

.explanation-card h3 {
    margin-bottom: 10px;
    font-size: 1.3rem;
}

.explanation-card p {
    color: #666;
    font-size: 0.95rem;
    line-height: 1.4;
}

.tooltip {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 10;
}

.explanation-card:hover .tooltip {
    opacity: 1;
    bottom: -50px;
}

/* Share Button */
.share-btn {
    background: linear-gradient(135deg, #17a2b8, #138496);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 12px 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 15px;
    box-shadow: 0 4px 15px rgba(23, 162, 184, 0.3);
}

.share-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(23, 162, 184, 0.4);
}

/* Main Content Layout */
.main-content {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* Controls Panel */
.controls-panel {
    flex: 0 0 350px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    overflow: hidden;
    transition: all 0.3s ease;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.controls-panel.collapsed {
    flex: 0 0 60px;
}

.controls-panel.collapsed .control-section,
.controls-panel.collapsed .preset-gallery,
.controls-panel.collapsed .generate-btn,
.controls-panel.collapsed .stats {
    display: none;
}

.panel-header {
    background: linear-gradient(135deg, #e91e63, #c2185b);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3 {
    font-size: 1.3rem;
    margin: 0;
}

.toggle-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 1.2rem;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* Control Sections */
.control-section {
    padding: 25px;
    border-bottom: 1px solid #f0f0f0;
}

.control-section:last-child {
    border-bottom: none;
}

.control-section h4 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.1rem;
    border-bottom: 2px solid #e91e63;
    padding-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-item {
    margin-bottom: 20px;
}

.control-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
    font-size: 0.95rem;
}

/* Enhanced Form Controls */
input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #e91e63 0%, #e9ecef 0%);
    outline: none;
    -webkit-appearance: none;
    transition: all 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e91e63, #c2185b);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(233, 30, 99, 0.4);
    transition: all 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 6px 16px rgba(233, 30, 99, 0.6);
}

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e91e63, #c2185b);
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 12px rgba(233, 30, 99, 0.4);
}

input[type="text"], input[type="color"], select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

input[type="text"]:focus, input[type="color"]:focus, select:focus {
    outline: none;
    border-color: #e91e63;
    box-shadow: 0 0 0 3px rgba(233, 30, 99, 0.1);
}

/* Emoji Collections */
.emoji-collections {
    margin-bottom: 20px;
}

.collection-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 5px;
}

.collection-tab {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #6c757d;
}

.collection-tab.active, .collection-tab:hover {
    background: #e91e63;
    color: white;
}

.emoji-picker {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.emoji-btn {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 12px;
    font-size: 1.6rem;
    cursor: pointer;
    transition: all 0.3s ease;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-btn:hover {
    background: #e9ecef;
    transform: scale(1.1);
    border-color: #e91e63;
}

.emoji-btn.active {
    background: linear-gradient(135deg, #e91e63, #c2185b);
    border-color: #c2185b;
    color: white;
    transform: scale(1.05);
}

/* Size Controls */
.size-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.size-controls .control-item {
    margin-bottom: 0;
}

/* Color Pickers */
.color-pickers {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.color-pickers input[type="color"] {
    width: 60px;
    height: 40px;
    border-radius: 10px;
    border: 2px solid #e9ecef;
    cursor: pointer;
}

/* Visual Effects */
.visual-effects {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
}

.visual-effects label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #e91e63;
    cursor: pointer;
}

/* Preset Gallery */
.preset-gallery {
    padding: 25px;
    background: #f8f9fa;
}

.preset-gallery h4 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.preset-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.preset-btn {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 12px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #495057;
}

.preset-btn:hover {
    border-color: #e91e63;
    color: #e91e63;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(233, 30, 99, 0.2);
}

/* Generate Button */
.generate-btn {
    width: 100%;
    background: linear-gradient(135deg, #e91e63, #c2185b);
    color: white;
    border: none;
    border-radius: 15px;
    padding: 18px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(233, 30, 99, 0.3);
    margin: 25px;
    position: relative;
    overflow: hidden;
}

.generate-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(233, 30, 99, 0.4);
}

.generate-btn:active {
    transform: translateY(-1px);
}

.btn-animation {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

@keyframes buttonRipple {
    0% {
        width: 0;
        height: 0;
    }
    100% {
        width: 300px;
        height: 300px;
        opacity: 0;
    }
}

/* Stats */
.stats {
    display: flex;
    justify-content: space-around;
    padding: 20px 25px;
    background: #f8f9fa;
    gap: 15px;
}

.stat-item {
    text-align: center;
    flex: 1;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #e91e63;
    display: block;
    line-height: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 5px;
}

/* Canvas Area */
.canvas-area {
    flex: 1;
    min-width: 0;
}

.canvas-area.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: white;
    z-index: 1000;
    padding: 20px;
}

.canvas-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    justify-content: center;
}

.canvas-control-btn {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 10px 15px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #495057;
}

.canvas-control-btn:hover {
    border-color: #e91e63;
    color: #e91e63;
    transform: translateY(-2px);
}

.canvas-container {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.canvas-wrapper {
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    flex: 1;
    max-width: 600px;
}

.canvas-wrapper:hover {
    transform: translateY(-5px);
    box-shadow: 0 25px 45px rgba(0,0,0,0.15);
}

.canvas-wrapper h3 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.random-side h3 {
    color: #2196f3;
}

.poisson-side h3 {
    color: #e91e63;
}

.loading-message {
    font-size: 0.8rem;
    font-style: italic;
    color: #6c757d;
    font-weight: normal;
}

canvas {
    border: 3px solid #e9ecef;
    border-radius: 15px;
    width: 100%;
    display: block;
    cursor: crosshair;
    transition: all 0.3s ease;
    background: white;
}

canvas:hover {
    border-color: #e91e63;
}

/* Tutorial Overlay */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.8);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tutorial-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 600px;
    margin: 20px;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0,0,0,0.3);
}

.tutorial-content h3 {
    color: #e91e63;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.tutorial-content p {
    color: #495057;
    line-height: 1.6;
    margin-bottom: 30px;
}

.tutorial-progress {
    color: #6c757d;
    font-size: 0.9rem;
    margin-top: 20px;
}

.tutorial-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.tutorial-controls button {
    background: #e91e63;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tutorial-controls button:hover {
    background: #c2185b;
    transform: translateY(-2px);
}

.tutorial-controls button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Challenge Section */
.challenge-section {
    background: white;
    border-radius: 20px;
    padding: 30px;
    margin-top: 30px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    text-align: center;
}

.challenge-section h3 {
    color: #e91e63;
    margin-bottom: 25px;
    font-size: 1.4rem;
}

.challenge-canvases {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 25px;
}

.challenge-canvases canvas {
    border: 2px solid #e9ecef;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.challenge-canvases canvas:hover {
    border-color: #e91e63;
    transform: scale(1.05);
}

.challenge-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
}

.challenge-controls button {
    background: #e91e63;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.challenge-controls button:hover {
    background: #c2185b;
    transform: translateY(-2px);
}

.challenge-controls button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

#challengeResult {
    font-weight: bold;
    padding: 10px;
    border-radius: 10px;
    margin-left: 15px;
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 50px;
    padding: 30px;
    color: #6c757d;
    background: white;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
}

.footer a {
    color: #e91e63;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.footer a:hover {
    color: #c2185b;
    text-decoration: underline;
}

.link-btn {
    background: none;
    border: none;
    color: #e91e63;
    cursor: pointer;
    font-size: inherit;
    text-decoration: underline;
    transition: all 0.3s ease;
}

.link-btn:hover {
    color: #c2185b;
}

/* Floating Message */
.floating-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #e91e63;
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(233, 30, 99, 0.3);
    z-index: 1500;
    font-weight: 500;
    animation: slideInRight 0.3s ease-out;
    transition: opacity 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-content {
        flex-direction: column;
    }
    
    .controls-panel {
        flex: none;
        order: 2;
        max-height: none;
    }
    
    .canvas-area {
        order: 1;
    }
    
    .canvas-container {
        flex-direction: column;
        align-items: center;
    }
    
    .canvas-wrapper {
        max-width: 500px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 2.2rem;
    }
    
    .explanation-cards {
        flex-direction: column;
        align-items: center;
    }
    
    .controls-panel {
        flex: none;
    }
    
    .size-controls {
        grid-template-columns: 1fr;
    }
    
    .preset-buttons {
        grid-template-columns: 1fr;
    }
    
    .canvas-controls {
        flex-wrap: wrap;
    }
    
    .challenge-canvases {
        flex-direction: column;
        align-items: center;
    }
    
    .challenge-controls {
        flex-direction: column;
    }
    
    .tutorial-content {
        padding: 30px 20px;
    }
    
    .stats {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.8rem;
    }
    
    .emoji-picker {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .collection-tabs {
        flex-wrap: wrap;
    }
    
    .canvas-controls {
        gap: 5px;
    }
    
    .canvas-control-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
        color: #e0e0e0;
    }
    
    .controls-panel,
    .canvas-wrapper,
    .footer,
    .challenge-section {
        background: #2d2d2d;
        color: #e0e0e0;
    }
    
    .explanation-card,
    .preset-btn,
    .canvas-control-btn {
        background: #3d3d3d;
        color: #e0e0e0;
        border-color: #555;
    }
    
    input[type="text"],
    input[type="color"],
    select {
        background: #3d3d3d;
        color: #e0e0e0;
        border-color: #555;
    }
    
    canvas {
        background: #2d2d2d;
        border-color: #555;
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid #e91e63;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .canvas-wrapper,
    .controls-panel {
        border: 2px solid #000;
    }
    
    button,
    input,
    select {
        border: 2px solid #000;
    }
}