/* Reset und Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #FF6B35;
    --secondary-color: #F7931E;
    --accent-color: #FFB700;
    --background: #FFF8F0;
    --text-dark: #2C3E50;
    --text-light: #7F8C8D;
    --white: #FFFFFF;
    --success: #27AE60;
    --error: #E74C3C;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-strong: rgba(0, 0, 0, 0.2);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
    background: linear-gradient(135deg, var(--background) 0%, #FFE5D9 100%);
    color: var(--text-dark);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
    overflow-x: hidden;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
    animation: fadeIn 0.3s ease-in;
}

.screen.active {
    display: block;
}

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

/* Container */
.container {
    max-width: 500px;
    margin: 0 auto;
    background: var(--white);
    border-radius: 24px;
    padding: 30px;
    box-shadow: 0 10px 40px var(--shadow);
}

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

header h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
}

.tagline {
    color: var(--text-light);
    font-size: 1rem;
}

/* Product Section */
.product-section {
    margin-bottom: 30px;
}

.product-image {
    text-align: center;
    margin-bottom: 20px;
}

.product-image img {
    max-width: 100%;
    height: auto;
    max-height: 250px;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px var(--shadow));
}

.product-info h2 {
    font-size: 1.75rem;
    color: var(--text-dark);
    margin-bottom: 10px;
}

.price {
    font-size: 1.5rem;
    color: var(--secondary-color);
    font-weight: 700;
    margin-bottom: 15px;
}

.description {
    color: var(--text-light);
    line-height: 1.6;
    font-size: 0.95rem;
}

/* Scan Section */
.scan-section {
    text-align: center;
    margin: 40px 0;
}

.primary-button {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    border: none;
    padding: 18px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.primary-button:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
}

.secondary-button {
    background: var(--white);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.secondary-button:active {
    transform: scale(0.98);
    background: rgba(255, 107, 53, 0.1);
}

.scan-info {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-top: 15px;
}

/* Social Section */
.social-section {
    text-align: center;
    padding-top: 30px;
    border-top: 2px solid #F0F0F0;
}

.social-title {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 15px;
}

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

.social-link {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    text-decoration: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.social-link.facebook {
    background: #1877F2;
    color: var(--white);
}

.social-link.instagram {
    background: linear-gradient(45deg, #F58529, #DD2A7B, #8134AF);
    color: var(--white);
}

.social-link.twitter {
    background: #1DA1F2;
    color: var(--white);
}

.social-link:active {
    transform: scale(0.95);
}

/* Scanner Screen */
.scanner-container {
    max-width: 600px;
    margin: 0 auto;
}

.scanner-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    position: relative;
}

.scanner-header h2 {
    color: var(--white);
    font-size: 1.5rem;
}

.close-button {
    position: absolute;
    left: 0;
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.close-button:active {
    transform: scale(0.95);
}

.scanner-viewport {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto 20px;
    border-radius: 20px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 10px 40px var(--shadow-strong);
}

#video {
    width: 100%;
    height: auto;
    display: block;
}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.scanner-frame {
    width: 250px;
    height: 250px;
    border: 3px solid var(--accent-color);
    border-radius: 20px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        border-color: var(--accent-color);
    }
    50% {
        border-color: var(--secondary-color);
    }
}

.scanner-instructions {
    text-align: center;
    color: var(--white);
    margin-bottom: 30px;
}

.scanner-instructions p {
    font-size: 1.1rem;
}

.manual-input {
    text-align: center;
}

.manual-input p {
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 10px;
    font-size: 0.9rem;
}

/* Win Screen */
.result-container {
    text-align: center;
}

.result-animation {
    position: relative;
    margin-bottom: 30px;
}

.trophy {
    font-size: 6rem;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

.confetti {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.win-title {
    font-size: 2rem;
    color: var(--success);
    margin-bottom: 10px;
}

.win-message {
    font-size: 1.25rem;
    color: var(--text-dark);
    margin-bottom: 30px;
}

.prize-info {
    background: linear-gradient(135deg, #FFF8F0, #FFE5D9);
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 30px;
}

.prize-info h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 1.25rem;
}

.prize-info p {
    color: var(--text-dark);
}

/* Form */
.win-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.win-form label {
    text-align: left;
    font-weight: 600;
    color: var(--text-dark);
}

.win-form input[type="email"] {
    padding: 15px;
    border: 2px solid #E0E0E0;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.win-form input[type="email"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

/* Popup */
.popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease-in;
}

.popup.active {
    display: flex;
}

.popup-content {
    background: var(--white);
    padding: 40px 30px;
    border-radius: 24px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: scaleIn 0.3s ease-out;
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.popup-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.popup-content h3 {
    font-size: 1.5rem;
    color: var(--text-dark);
    margin-bottom: 15px;
}

.popup-content p {
    color: var(--text-light);
    margin-bottom: 25px;
    line-height: 1.6;
}

/* Manual Input Modal */
#manualInputModal .popup-content {
    padding: 30px;
}

#manualCodeForm {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

#manualCodeInput {
    padding: 15px;
    border: 2px solid #E0E0E0;
    border-radius: 12px;
    font-size: 1rem;
    text-transform: uppercase;
}

#manualCodeInput:focus {
    outline: none;
    border-color: var(--primary-color);
}

.modal-buttons {
    display: flex;
    gap: 10px;
}

.modal-buttons button {
    flex: 1;
}

/* Responsive Design - Portrait Mode */
@media screen and (max-width: 480px) {
    .container {
        padding: 20px;
        border-radius: 20px;
    }

    header h1 {
        font-size: 2rem;
    }

    .product-info h2 {
        font-size: 1.5rem;
    }

    .primary-button {
        padding: 16px 30px;
        font-size: 1rem;
    }

    .scanner-frame {
        width: 200px;
        height: 200px;
    }

    .trophy {
        font-size: 4rem;
    }

    .win-title {
        font-size: 1.75rem;
    }
}

/* Landscape Mode */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .screen {
        padding: 10px;
    }

    .container {
        padding: 20px;
        max-width: 90vw;
    }

    .product-section {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        align-items: center;
    }

    .product-image img {
        max-height: 180px;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .scan-section {
        margin: 20px 0;
    }

    .scanner-frame {
        width: 180px;
        height: 180px;
    }

    .trophy {
        font-size: 3rem;
    }

    .result-animation {
        margin-bottom: 15px;
    }

    .prize-info {
        padding: 15px;
    }
}

/* Tablet Optimization */
@media screen and (min-width: 768px) {
    .container {
        max-width: 600px;
        padding: 40px;
    }

    .screen {
        padding: 40px;
    }

    .scanner-viewport {
        max-width: 600px;
    }

    .scanner-frame {
        width: 300px;
        height: 300px;
    }

    .social-link {
        width: 60px;
        height: 60px;
    }

    /* Touch target size for tablets */
    .primary-button,
    .secondary-button {
        min-height: 48px;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .product-image img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #1a1a1a;
        --text-dark: #FFFFFF;
        --text-light: #B0B0B0;
    }

    body {
        background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    }

    .container {
        background: #2d2d2d;
    }

    .win-form input[type="email"],
    #manualCodeInput {
        background: #3d3d3d;
        color: var(--white);
        border-color: #4d4d4d;
    }

    .prize-info {
        background: linear-gradient(135deg, #3d3d3d, #4d4d4d);
    }
}

/* Loading State */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--white);
    animation: spin 1s linear infinite;
}

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

/* Accessibility */
.primary-button:focus-visible,
.secondary-button:focus-visible,
.social-link:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Prevent text selection on buttons */
button {
    -webkit-user-select: none;
    user-select: none;
}
