:root {
    --primary-color: #4338ca;
    /* Darker indigo for higher contrast */
    --primary-hover: #3730a3;
    --text-main: #1e293b;
    --text-muted: #475569;
    --bg-gradient-start: #f8fafc;
    --bg-gradient-end: #e2e8f0;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    --input-bg: #ffffff;
    --input-border: #e2e8f0;
    --radius-lg: 1rem;
    --radius-md: 0.75rem;
    --transition-fast: 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    min-height: 100vh;
    background: linear-gradient(135deg, #f0f4ff 0%, #e0e7ff 100%);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 24px 0;
}

/* Background Animated Blobs */
.background-blobs {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: blob-float 20s infinite alternate;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: #c7d2fe;
    animation-delay: 0s;
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: #e9d5ff;
    animation-delay: -5s;
}

.blob-3 {
    top: 40%;
    left: 40%;
    width: 400px;
    height: 400px;
    background: #fbcfe8;
    animation-delay: -10s;
}

@keyframes blob-float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(50px, 50px) scale(1.1);
    }
}

.container {
    width: 100%;
    max-width: 500px;
    padding: 24px;
}

.card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    padding: 40px;
    transform: translateY(0);
    transition: transform var(--transition-fast);
}

.card:hover {
    transform: translateY(-4px);
}

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

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
    letter-spacing: -0.025em;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 8px;
}

.input-wrapper {
    position: relative;
}

.currency-symbol {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-weight: 500;
}

input[type="number"] {
    width: 100%;
    padding: 12px 16px 12px 36px;
    font-size: 1rem;
    border: 2px solid var(--input-border);
    border-radius: var(--radius-md);
    background: var(--input-bg);
    color: var(--text-main);
    transition: all var(--transition-fast);
}

#referenceMaxWin {
    padding-left: 16px;
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

/* File Upload */
.file-upload-wrapper {
    border: 2px dashed var(--input-border);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    background: rgba(255, 255, 255, 0.4);
}

.file-upload-wrapper:hover,
.file-upload-wrapper.drag-over {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
    color: var(--primary-color);
    margin-bottom: 12px;
}

.file-upload-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 4px;
}

.file-upload-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Selected File Card */
.file-selected-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-lg);
    animation: fade-in 0.3s ease;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-icon {
    color: var(--primary-color);
}

.selected-file-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-main);
    word-break: break-all;
}

.btn-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-remove:hover {
    background-color: #fee2e2;
    color: #ef4444;
}

/* Button */
.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(99, 102, 241, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Toggle Switch Styles */
.mode-toggle-container {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 10px;
    flex-wrap: wrap;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    bottom: 0;
    background-color: #cbd5e1;
    /* Visible grey */
    transition: .4s;
    border: 1px solid #94a3b8;
    /* Visible border */
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

input:checked+.slider:before {
    transform: translateX(24px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

.mode-label {
    font-weight: 500;
    color: var(--text-main);
    font-size: 0.9rem;
    line-height: 1.3;
}

/* Status Messages */
.status-message {
    margin-top: 5px;
    padding: 12px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    text-align: center;
    display: none;
    animation: fade-in 0.3s ease;
    word-break: break-word;
}

.status-error {
    background-color: #fef2f2;
    color: #ef4444;
    border: 1px solid #fecaca;
    display: block;
}

.status-success {
    background-color: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
    display: block;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 540px) {
    body {
        padding: 16px 0;
        /* Ensure the body itself can scroll if content is taller than viewport */
        min-height: 100svh;
    }

    .container {
        padding: 12px;
    }

    .card {
        padding: 20px 16px;
    }

    .header h1 {
        font-size: 1.4rem;
    }

    .header {
        margin-bottom: 20px;
    }

    .form-group {
        margin-bottom: 16px;
    }

    .file-upload-wrapper {
        padding: 20px 16px;
    }

    .mode-label {
        font-size: 0.82rem;
    }

    /* Prevent card from lifting on mobile (no hover state needed) */
    .card:hover {
        transform: none;
    }
}

/* Mode Selector Styles */
.mode-selector-wrapper {
    margin-bottom: 24px;
    position: relative;
    width: 100%;
}

.app-mode-select {
    width: 100%;
    padding: 14px 20px;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--primary-color);
    background: rgba(255, 255, 255, 0.7);
    border: 2px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-md);
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
    font-family: 'Inter', sans-serif;
}

.app-mode-select:hover,
.app-mode-select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.mode-selector-wrapper::after {
    content: '';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234f46e5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
}

.tab-content {
    display: none;
    animation: fade-in 0.3s ease;
}

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

/* Compact Forms */
.file-upload-wrapper.compact {
    padding: 16px;
    margin-bottom: 8px;
}

.file-upload-wrapper.compact p {
    margin: 0;
}

.file-selected-card.compact {
    padding: 8px 12px;
    margin-bottom: 8px;
}

/* Select */
select.currency-select {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid var(--input-border);
    border-radius: var(--radius-md);
    background: var(--input-bg);
    color: var(--text-main);
    transition: all var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
}

select.currency-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}