:root {
    --primary: #c8a415;
    --primary-hover: #b8940d;
    --primary-dark: #1a1a1a;
    --accent-gold: #d4a017;
    --accent-gold-light: #f5d76e;
    --success: #10b981;
    --danger: #ef4444;
    --gray-50: #fafafa;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
    --shadow-xl: 0 20px 25px rgba(0,0,0,.1), 0 10px 10px rgba(0,0,0,.04);
    --radius: 12px;
    --radius-lg: 16px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    min-height: 100vh;
    line-height: 1.6;
}

/* Car Carousel */
.car-carousel {
    width: 100%;
    overflow: hidden;
    background: var(--primary-dark);
    padding: 16px 0;
    border-bottom: 3px solid var(--accent-gold);
}

.car-track {
    display: flex;
    gap: 32px;
    animation: scrollCars 60s linear infinite;
    width: max-content;
}

.car-track:hover {
    animation-play-state: paused;
}

.car-slide {
    flex-shrink: 0;
}

.car-slide img {
    height: 100px;
    width: auto;
    display: block;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,.4));
    transition: transform .3s ease;
}

.car-slide img:hover {
    transform: scale(1.08);
}

@keyframes scrollCars {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.container {
    max-width: 680px;
    margin: 0 auto;
    padding: 40px 20px 60px;
}

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

.brand-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.brand-logo {
    height: 72px;
    width: auto;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,.15));
}

header h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -.5px;
    color: var(--gray-900);
}

header p {
    color: var(--gray-500);
    margin-top: 6px;
    font-size: 15px;
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all .2s ease;
    background: #fff;
    position: relative;
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent-gold);
    background: #fffdf0;
}

.upload-zone .icon {
    font-size: 40px;
    margin-bottom: 12px;
    display: block;
}

.upload-zone .label {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-700);
}

.upload-zone .sublabel {
    font-size: 13px;
    color: var(--gray-400);
    margin-top: 4px;
}

.upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* File Info */
.file-info {
    display: none;
    background: #fff;
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-top: 16px;
    box-shadow: var(--shadow-sm);
    align-items: center;
    justify-content: space-between;
}

.file-info.visible { display: flex; }

.file-info .file-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-700);
}

.file-info .file-meta {
    font-size: 13px;
    color: var(--gray-400);
}

.file-info .change-btn {
    font-size: 13px;
    color: var(--accent-gold);
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.file-info .change-btn:hover { text-decoration: underline; }

/* Controls */
.controls {
    display: none;
    margin-top: 24px;
    gap: 12px;
    flex-direction: column;
}

.controls.visible { display: flex; }

.controls-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}

.toggle-row label {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

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

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--gray-300);
    border-radius: 24px;
    transition: .2s;
    cursor: pointer;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: .2s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent-gold);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.remaining-badge {
    display: none;
    font-size: 13px;
    color: var(--accent-gold);
    font-weight: 600;
    margin-left: auto;
}

.remaining-badge.visible { display: inline; }

/* Weight Select */
.weight-select-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.weight-select-wrap label {
    font-size: 13px;
    white-space: nowrap;
}

.weight-select {
    padding: 6px 10px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-size: 13px;
    background: #fff;
    color: var(--gray-700);
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s ease;
    flex: 1;
    min-width: 160px;
}

.btn-primary {
    background: var(--primary-dark);
    color: var(--accent-gold-light);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    background: #2a2a2a;
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

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

.btn-secondary {
    background: #fff;
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
}

.btn-secondary:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
}

.btn-spinner-toggle {
    background: linear-gradient(135deg, var(--accent-gold), #e67e22);
    color: #fff;
    box-shadow: var(--shadow-md);
}

.btn-spinner-toggle:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none !important;
}

/* Loading */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,.85);
    z-index: 100;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
}

.loading-overlay.visible { display: flex; }

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--accent-gold);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
    font-size: 15px;
    color: var(--gray-500);
    font-weight: 500;
}

/* Result Card */
.result-section {
    display: none;
    margin-top: 28px;
}

.result-section.visible { display: block; }

.result-card {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: cardIn .4s ease;
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(20px) scale(.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.result-header {
    background: linear-gradient(135deg, var(--primary-dark), #333);
    color: var(--accent-gold-light);
    padding: 20px 24px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.result-body {
    padding: 8px 0;
}

.result-row {
    display: flex;
    padding: 12px 24px;
    border-bottom: 1px solid var(--gray-100);
    gap: 16px;
}

.result-row:last-child { border-bottom: none; }

.result-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--gray-400);
    font-weight: 600;
    min-width: 120px;
    flex-shrink: 0;
    padding-top: 2px;
}

.result-value {
    font-size: 15px;
    color: var(--gray-900);
    font-weight: 500;
    word-break: break-word;
}

/* Spinner Animation */
.spinner-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.92);
    z-index: 200;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.spinner-overlay.visible { display: flex; }

.spinner-display {
    color: #fff;
    font-size: 32px;
    font-weight: 700;
    text-align: center;
    padding: 24px 40px;
    min-width: 320px;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .08s ease;
}

.spinner-display.final {
    color: var(--accent-gold-light);
    font-size: 40px;
    animation: popIn .4s ease;
}

@keyframes popIn {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.spinner-label {
    color: rgba(255,255,255,.5);
    font-size: 14px;
    margin-top: 20px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.winners-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.winners-count {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
}

.btn-clear {
    background: var(--gray-200);
    color: var(--gray-700);
    font-size: 13px;
    padding: 8px 18px;
}

.btn-clear:hover {
    background: var(--gray-300);
}

.winners-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.winners-list .result-card {
    animation: slideUp .35s ease;
}

/* Footer */
.site-footer {
    text-align: center;
    padding: 20px;
    background: var(--primary-dark);
    color: var(--accent-gold);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .5px;
    border-top: 3px solid var(--accent-gold);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.footer-links {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-links a {
    color: var(--accent-gold);
    text-decoration: none;
    font-size: 13px;
    opacity: .85;
    transition: opacity .2s;
}

.footer-links a:hover {
    opacity: 1;
    text-decoration: underline;
}

.footer-logo {
    height: 36px;
    width: auto;
    filter: drop-shadow(0 1px 4px rgba(212,160,23,.3));
}

/* Error Toast */
.toast {
    position: fixed;
    top: 24px;
    right: 24px;
    background: var(--danger);
    color: #fff;
    padding: 14px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 300;
    animation: toastIn .3s ease;
    max-width: 360px;
}

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

/* Responsive */
@media (max-width: 600px) {
    .container { padding: 24px 16px 48px; }
    header h1 { font-size: 22px; }
    .upload-zone { padding: 36px 16px; }
    .btn { padding: 12px 20px; font-size: 14px; min-width: 0; }
    .controls-row { flex-direction: column; }
    .result-row { flex-direction: column; gap: 4px; }
    .result-label { min-width: 0; }
    .toggle-row { flex-direction: column; align-items: flex-start; }
    .car-slide img { height: 70px; }
    .car-track { gap: 20px; }
    .brand-header { gap: 12px; }
    .brand-logo { height: 48px; }
}
