:root {
    --bg-dark: #0f111a;
    --panel-bg: rgba(25, 28, 41, 0.65);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --accent-primary: #6366f1;
    --accent-hover: #4f46e5;
    --accent-glow: rgba(99, 102, 241, 0.5);
    --success: #10b981;
    --error: #ef4444;
    --blob-1: #4f46e5;
    --blob-2: #ec4899;
    --blob-3: #8b5cf6;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
    padding: 2rem 1rem;
}

/* Background Blobs (Premium Design) */
.blob {
    position: absolute;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.6;
    animation: float 20s infinite alternate;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: var(--blob-1);
    border-radius: 50%;
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: var(--blob-2);
    border-radius: 50%;
    animation-delay: -5s;
}

.blob-3 {
    top: 40%;
    left: 60%;
    width: 400px;
    height: 400px;
    background: var(--blob-3);
    border-radius: 50%;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, -50px) scale(1.1); }
}

/* Container & Glassmorphism */
.app-container {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    z-index: 1;
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Typography & Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.highlight {
    color: var(--accent-primary);
    text-shadow: 0 0 20px var(--accent-glow);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

/* Tabs */
.tabs {
    display: flex;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem;
    border-radius: 100px;
    gap: 0.5rem;
    margin: 0 auto;
    max-width: fit-content;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.75rem 1.5rem;
    border-radius: 100px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}

/* Content Sections */
.tab-content {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-header {
    margin-bottom: 2rem;
    text-align: center;
}

.section-header h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.section-header p {
    color: var(--text-secondary);
}

/* Inputs & Buttons */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.input-group label {
    font-weight: 600;
    color: var(--text-secondary);
}

textarea, input[type="text"] {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.2rem;
    padding: 1.2rem;
    border-radius: 12px;
    resize: none;
    transition: all 0.3s ease;
}

textarea:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

textarea {
    height: 120px;
}

.primary-btn, .secondary-btn {
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

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

.primary-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 8px 25px var(--accent-glow);
    transform: translateY(-2px);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Peg Sequence Output */
.peg-sequence {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.peg-card {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: transform 0.2s ease;
}

.peg-card:hover {
    transform: scale(1.05);
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--accent-primary);
}

.peg-number {
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-primary);
    font-weight: 700;
    font-size: 1.2rem;
}

.peg-word {
    font-weight: 600;
    font-size: 1.1rem;
}

/* Dictionary Grid */
.search-bar {
    margin-bottom: 2rem;
}

.dictionary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 10px;
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
    max-height: 600px;
    overflow-y: auto;
    padding: 1rem;
}

.gallery-card {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 1rem;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow: hidden;
}

.gallery-card:hover {
    transform: translateY(-5px) scale(1.02);
    border-color: var(--accent-primary);
    box-shadow: 0 10px 30px -10px var(--accent-glow);
}

.gallery-image-wrapper {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.gallery-card:hover .gallery-image-wrapper img {
    transform: scale(1.1);
}

.gallery-info {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0 0.25rem;
}

.gallery-num {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: var(--accent-primary);
}

.gallery-word {
    font-weight: 600;
    text-transform: capitalize;
}

/* Preview Overlay */
.preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

.preview-content {
    max-width: 600px;
    width: 100%;
    position: relative;
    padding: 3rem;
    text-align: center;
}

.close-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--text-primary);
}

.preview-header {
    margin-bottom: 2rem;
}

.preview-number {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    color: var(--accent-primary);
    display: block;
    margin-bottom: 0.5rem;
}

.preview-word {
    font-size: 2.5rem;
    text-transform: capitalize;
}

.preview-image-container {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--panel-border);
    background: rgba(0,0,0,0.2);
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.5);
}

.preview-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Scrollbar styling */
.dictionary-grid::-webkit-scrollbar {
    width: 8px;
}
.dictionary-grid::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
    border-radius: 4px;
}
.dictionary-grid::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 4px;
}

/* Drill Specific Styles */
.drill-card {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    text-align: center;
}

.slider-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 24px;
    width: 24px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    margin-top: -8px;
    box-shadow: 0 0 10px var(--accent-glow);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    cursor: pointer;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

#drill-length-val {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.large-sequence .peg-card {
    font-size: 1.2rem;
    padding: 1.5rem 1rem;
}

.large-sequence .peg-number {
    font-size: 1.5rem;
}

.large-sequence .peg-word {
    font-size: 1.4rem;
}

.timer-container {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin: 1rem 0;
}

.instruction {
    color: var(--accent-primary);
    font-style: italic;
    background: rgba(99, 102, 241, 0.1);
    padding: 1rem;
    border-radius: 8px;
}

/* Results */
.result-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.result-comparison {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background: rgba(0,0,0,0.2);
    padding: 1.5rem;
    border-radius: 12px;
    text-align: left;
}

.comparison-block span {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.number-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    letter-spacing: 2px;
    margin-top: 0.5rem;
    word-break: break-all;
}

.correct-text { color: var(--success); }
.error-text { color: var(--error); }

/* Story Sentence */
.story-sentence-container {
    margin-top: 2rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(139, 92, 246, 0.12));
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 16px;
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.story-sentence-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-primary), var(--blob-2), var(--blob-3));
}

.story-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.story-icon {
    font-size: 1.5rem;
}

.story-header h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin: 0;
}

.story-text {
    font-size: 1.2rem;
    line-height: 2;
    color: var(--text-primary);
    font-weight: 400;
    letter-spacing: 0.02em;
}

.story-text .story-word {
    color: #a78bfa;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 1.05em;
    padding: 0.15em 0.4em;
    background: rgba(167, 139, 250, 0.12);
    border-radius: 6px;
    transition: all 0.2s ease;
    cursor: default;
}

.story-text .story-word:hover {
    background: rgba(167, 139, 250, 0.25);
    box-shadow: 0 0 12px rgba(167, 139, 250, 0.3);
}

.regenerate-btn {
    margin-top: 1.25rem;
    width: auto !important;
    align-self: flex-start;
    padding: 0.6rem 1.5rem !important;
    font-size: 0.95rem !important;
    border-radius: 100px !important;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .glass-panel {
        padding: 1.5rem;
    }
    
    .tabs {
        flex-direction: column;
        width: 100%;
        border-radius: 12px;
    }
    
    .tab-btn {
        width: 100%;
        border-radius: 8px;
    }
}
