:root {
    --primary-color: #0d4726;
    /* Deep Islamic Green */
    --secondary-color: #1a5e3a;
    --accent-gold: #d4af37;
    /* Metallic Gold */
    --accent-gold-light: #f3e5ab;
    --text-dark: #1a1a1a;
    --text-light: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

* {
    margin: 0;
    padding: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    /* Remove blue highlight on tap */
}

html,
body {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    /* Prevent horizontal scroll only */
    background-color: var(--primary-color);
}

/* Nuclear Background Fix: Infinite Green Canvas */
body::before {
    content: "";
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background-color: var(--primary-color);
    z-index: -100;
}

body {
    font-family: 'Outfit', sans-serif;
    color: var(--text-light);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    min-height: 100dvh;
    /* Allow growing */
    padding: 20px 0;
    /* Vertical breathing room */
}

/* Background Effects */
.background-pattern {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(212, 175, 55, 0.1) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(212, 175, 55, 0.1) 0%, transparent 20%);
    z-index: -2;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, transparent 0%, rgba(0, 0, 0, 0.6) 100%);
    z-index: -1;
}

.container {
    width: 100%;
    max-width: 600px;
    z-index: 10;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* Typography */
.header {
    margin-bottom: 30px;
}

.header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2.8rem;
    /* Slightly larger */
    background: linear-gradient(45deg, #FFD700, #FDB931, #FFD700);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    /* Gradient Text */
    text-shadow: 0px 0px 20px rgba(255, 215, 0, 0.3);
    margin-bottom: 5px;
    animation: titleEntrance 2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    /* Animate on load */
    opacity: 0;
    /* Start hidden */
}

/* Premium Entrance Animation */
@keyframes titleEntrance {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
        filter: blur(10px);
    }

    50% {
        opacity: 1;
        text-shadow: 0 0 30px rgba(255, 215, 0, 0.8), 0 0 10px rgba(255, 215, 0, 0.5);
        /* Strong Glow */
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
        text-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
        /* Elegant Setup */
    }
}

.header h2 {
    font-family: 'Outfit', sans-serif;
    font-weight: 300;
    font-size: 1.2rem;
    color: var(--text-light);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.subtitle {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 10px;
}

/* Card Style */
.twibbon-card {
    background: rgba(20, 20, 20, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* Canvas Area */
.canvas-container {
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: #e0e0e0;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.2);
    border: 2px dashed var(--accent-gold);
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
}

canvas:active {
    cursor: grabbing;
}

.loading-overlay,
.instruction-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 1.2rem;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.loading-overlay i,
.instruction-overlay i {
    font-size: 2rem;
    margin-bottom: 10px;
    color: var(--accent-gold);
}

.instruction-overlay {
    background: transparent;
    color: #666;
}

.instruction-overlay span {
    font-weight: 500;
}

/* Controls */
.controls {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.input-group {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.zoom-control {
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--accent-gold);
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

input[type="range"] {
    flex-grow: 1;
    accent-color: var(--accent-gold);
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 50px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-gold) 0%, #b8860b 100%);
    color: var(--primary-color);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-success {
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    color: white;
    width: 100%;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.3);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.5);
}

.hidden {
    display: none !important;
}

/* Footer */
.footer {
    margin-top: 40px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
}

.footer i {
    color: var(--accent-gold);
}

/* Responsive */
/* Responsive & Compact Mode */
@media (max-width: 480px) {
    body {
        justify-content: flex-start;
        /* Start from top on small screens to avoid cut-off */
        padding-top: 20px;
    }

    .container {
        padding: 10px;
        justify-content: flex-start;
    }

    .header {
        margin-bottom: 20px;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .twibbon-card {
        padding: 20px;
        gap: 15px;
        width: 100%;
    }

    /* Ensure canvas doesn't take too much height */
    .canvas-container {
        width: 100%;
        max-width: 100%;
        margin-bottom: 10px;
    }

    .btn {
        padding: 12px;
        /* Touch friendly */
    }
}

/* Landscape / Short Screen Fix */
@media (max-height: 700px) {
    .header {
        display: none;
    }

    /* Hide header on very short screens/landscape to focus on app */
    .footer {
        display: none;
    }

    .twibbon-card {
        flex-direction: row;
        /* Side by side on landscape? Or just compact */
        padding: 10px;
    }

    .canvas-container {
        height: 80vh;
        width: auto;
    }
}