:root {
    --primary-color: #ff6b6b;
    --secondary-color: #4ecdc4;
    --bg-color: #f7f9fc;
    --text-color: #2c3e50;
    --card-bg: #ffffff;
    --border-radius: 12px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

@font-face {
    font-family: 'CustomFont';
    src: url('../fonts/text.woff2') format('woff2');
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    padding: 20px;
}

.github-link {
    position: absolute;
    top: 20px;
    right: 20px;
    color: var(--text-color);
    transition: color 0.2s, transform 0.2s;
    z-index: 100;
}

.github-link:hover {
    color: var(--primary-color);
    transform: scale(1.1);
}

.github-link svg {
    fill: currentColor;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    /* For absolute positioning context if needed, though fixed/absolute to body is better usually, but here inside container is fine if container is relative */
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-family: 'CustomFont';
}

main {
    display: flex;
    flex-direction: column;
    gap: 30px;
    background: var(--card-bg);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

@media (min-width: 900px) {
    main {
        flex-direction: row;
        align-items: flex-start;
    }
}

.controls {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 300px;
}

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

label {
    font-weight: 600;
    color: var(--text-color);
}

select,
textarea {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
}

textarea {
    min-height: 150px;
    resize: vertical;
}

.expression-controls {
    display: flex;
    gap: 10px;
}

.expression-controls select {
    flex: 1;
}

button {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
}

button:active {
    transform: scale(0.98);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
}

.secondary-btn {
    background-color: var(--secondary-color);
    color: white;
}

#random-expression-btn {
    background-color: #eee;
    color: #333;
    padding: 0 15px;
    font-size: 20px;
}

#random-background-btn {
    background-color: #eee;
    color: #333;
    padding: 0 15px;
    font-size: 20px;
}

.actions {
    display: flex;
    gap: 10px;
}

.preview {
    flex: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #eee;
    border-radius: var(--border-radius);
    padding: 20px;
    position: relative;
    min-height: 455px;
    overflow: hidden;
}

canvas {
    max-width: 100%;
    height: auto;
    box-shadow: var(--shadow);
    background: white;
}

.hidden {
    display: none;
}

#loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2em;
    color: #666;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
    width: 100%;
    flex-wrap: wrap;
}

.tab-btn {
    background: none;
    border: none;
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-color);
    border-radius: 8px;
    transition: background-color 0.2s;
}

.tab-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.tab-btn.active {
    background-color: var(--primary-color);
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Trial Options */
.option-item {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.option-item select {
    width: 120px;
}

.option-item input {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.remove-option-btn {
    background: none;
    border: none;
    color: #ff4444;
    cursor: pointer;
    font-size: 18px;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 30px;
    font-size: 0.9em;
    color: #888;
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    main {
        padding: 15px;
    }

    h1 {
        font-size: 24px;
        max-width: 80%;
    }

    .text-muted {
        font-size: 14px;
        max-width: 80%;
    }

    .controls {
        min-width: auto;
        /* Allow shrinking below 300px */
    }

    .tabs {
        gap: 5px;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 14px;
        flex: 1 1 auto;
        /* Allow growing and shrinking */
        text-align: center;
    }

    .option-item {
        flex-wrap: wrap;
    }

    .option-item select {
        width: 100%;
        /* Full width on mobile */
        flex: 1 1 100%;
    }

    .option-item input {
        width: calc(100% - 40px);
        /* Leave space for remove button */
        flex: 1 1 auto;
    }

    .remove-option-btn {
        padding: 10px;
        /* Larger touch target */
    }

    .expression-controls {
        flex-wrap: wrap;
    }

    .preview {
        min-height: 100px;
        order: 2;
    }

    /* Reorder layout: Controls -> Preview -> Actions */
    .controls {
        display: contents;
        /* Remove controls wrapper from layout flow */
    }

    .actions {
        order: 3;
        width: 100%;
        margin-top: 10px;
    }

    /* Ensure tab content appears first */
    .tab-content {
        order: 1;
    }
}