:root {
    --fern-green: #228B22;
    --fern-light: #90EE90;
    --fern-dark: #006400;
    --bg-dark: #0f2027;
    --bg-mid: #203a43;
    --bg-light: #2c5364;
    --primary-blue: #1e40af;
    --white: #ffffff;
    --gray-dark: #374151;
    --gray-light: #e5e7eb;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-dark), var(--bg-mid), var(--bg-light));
    color: var(--white);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

header {
    text-align: center;
    padding: 1rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

header h1 {
    font-size: 1.8rem;
    font-weight: 300;
    margin-bottom: 0.3rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

header p {
    font-size: 0.9rem;
    opacity: 0.9;
    color: var(--gray-light);
}

main {
    padding: 1rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.canvas-container {
    position: relative;
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

#fernCanvas {
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    background: #000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

#fernCanvas:hover {
    transform: scale(1.01);
}

.info-panel {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: bold;
    color: var(--fern-light);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.control-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    padding: 1.2rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

button {
    background: linear-gradient(145deg, var(--primary-blue), #1d4ed8);
    color: var(--white);
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 12px rgba(30, 64, 175, 0.3);
    min-height: 36px;
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(30, 64, 175, 0.4);
    background: linear-gradient(145deg, #1d4ed8, var(--primary-blue));
}

button:active:not(:disabled) {
    transform: translateY(0);
}

button:disabled {
    background: var(--gray-dark);
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

button:focus {
    outline: 2px solid var(--fern-light);
    outline-offset: 2px;
}

.speed-control, .theme-control {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.speed-control label, .theme-control label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--gray-light);
}

#speedSlider {
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

#speedSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--fern-green);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(34, 139, 34, 0.4);
    transition: transform 0.3s ease;
}

#speedSlider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

#speedSlider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--fern-green);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(34, 139, 34, 0.4);
}

#speedValue {
    font-weight: bold;
    color: var(--fern-light);
    font-family: 'Courier New', monospace;
}

#themeSelect {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 0.5rem;
    font-size: 1rem;
    cursor: pointer;
    min-height: 44px;
}

#themeSelect:focus {
    outline: 2px solid var(--fern-light);
    outline-offset: 2px;
}

#themeSelect option {
    background: var(--gray-dark);
    color: var(--white);
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    #fernCanvas {
        width: 100%;
        max-width: calc(100vw - 20px);
        touch-action: pan-y pinch-zoom;
    }

    .control-panel {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1.5rem;
    }

    button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    main {
        padding: 1rem 0.5rem;
    }

    header {
        padding: 1.5rem 1rem;
    }

    .info-panel {
        position: static;
        text-align: center;
        margin-top: 1rem;
    }

    .canvas-container {
        flex-direction: column;
        align-items: center;
    }

    .modal-content {
        margin: 5% auto;
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
    }
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal.show {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

.modal-content {
    background: linear-gradient(135deg, var(--bg-dark), var(--bg-mid));
    margin: 3% auto;
    padding: 0;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: slideIn 0.3s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem 2rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 300;
    color: var(--fern-light);
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--gray-light);
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    transform: rotate(90deg);
}

.modal-body {
    padding: 1.5rem;
    line-height: 1.4;
}

.modal-body h3 {
    color: var(--fern-light);
    margin: 1rem 0 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-body ul {
    margin: 0.5rem 0;
    padding-left: 1.3rem;
}

.modal-body li {
    margin: 0.3rem 0;
    color: var(--gray-light);
}

.modal-body p {
    margin: 0.5rem 0;
}

.modal-body strong {
    color: var(--white);
}

.modal-footer {
    padding: 1rem 1.5rem 1.5rem;
    text-align: center;
    background: linear-gradient(135deg, var(--bg-dark), var(--bg-mid));
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0 0 16px 16px;
    position: sticky;
    bottom: 0;
}

.btn-primary {
    background: linear-gradient(145deg, var(--fern-green), var(--fern-dark));
    color: var(--white);
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(34, 139, 34, 0.3);
    min-width: 120px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(34, 139, 34, 0.4);
    background: linear-gradient(145deg, var(--fern-dark), var(--fern-green));
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}