:root {
    --bg: #ffffff;
    --card-bg: #f8f8f8;
    --text: #000000;
    --sub-text: #666666;
    --accent: #000000;
    --btn-text: #ffffff;
    --neon: #99FF00;
    --yellow: #ffea00;
    --border: #efefef;
    --chip-bg: #f0f0f0;
    --legal-text: #8E8E8E;
}

body.dark-mode {
    --bg: #000000;
    --card-bg: #121212;
    --text: #EAEAEA;
    --sub-text: #A8A8A8;
    --accent: #99FF00;
    --btn-text: #000000;
    --neon: #99FF00;
    --border: #262626;
    --chip-bg: #1A1A1A;
    --legal-text: #8E8E8E;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    transition: background-color 0.4s ease;
    height: 100dvh;
    display: flex;
    justify-content: center;
    overflow: hidden;
}

.app-container {
    width: 100%;
    max-width: 420px;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 0 20px;
    position: relative;
    z-index: 1;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    flex-shrink: 0;
}

.logo {
    font-size: 20px;
    font-weight: 900;
    letter-spacing: -1px;
    cursor: pointer;
    color: var(--text);
}

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

.icon-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    font-weight: 800;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
}

/* Genre Nav */
.genre-nav {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 0 12px 0;
    margin-bottom: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    cursor: grab;
}

.genre-nav:active {
    cursor: grabbing;
}

.genre-nav::-webkit-scrollbar { 
    height: 3px;
}

.genre-nav::-webkit-scrollbar-track {
    background: transparent;
}

.genre-nav::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.genre-nav::-webkit-scrollbar-thumb:hover {
    background: var(--sub-text);
}

.genre-chip {
    padding: 8px 16px;
    background: var(--chip-bg);
    border-radius: 100px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--sub-text);
}

.genre-chip.active {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
    transform: scale(1.05);
}

/* Main Card Area */
.main-card {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    min-height: 0;
    margin-bottom: 140px;
}

.film-strip-bg {
    position: absolute;
    inset: 0;
    opacity: 0.03;
    pointer-events: none;
    background-image: repeating-linear-gradient(
        transparent,
        transparent 100px,
        rgba(255,255,255,0.1) 100px,
        rgba(255,255,255,0.1) 102px
    );
    animation: slideUp 15s linear infinite;
    z-index: -1;
}

@keyframes slideUp {
    from { transform: translateY(0); }
    to { transform: translateY(-102px); }
}

/* Slot View */
.slot-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.slot-window {
    width: 280px;
    height: 400px;
    border-radius: 48px;
    overflow: hidden;
    background: #000;
    border: 1px solid var(--border);
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}

.slot-track { 
    display: flex; 
    flex-direction: column; 
    width: 100%; 
    will-change: transform; 
    transform: translate3d(0, 0, 0); 
    backface-visibility: hidden;
}
.slot-track.spinning {
    filter: blur(4px);
}
.slot-item { width: 100%; height: 400px; flex-shrink: 0; display: flex; justify-content: center; align-items: center; }
.slot-item img { width: 100%; height: 100%; object-fit: cover; }
.slot-item.placeholder { background: #000; }

.ticket-icon {
    font-size: 100px;
    filter: drop-shadow(0 0 30px rgba(255, 0, 255, 0.4)) drop-shadow(0 0 10px rgba(138, 43, 226, 0.6));
    animation: ticketPulse 4s infinite ease-in-out;
    will-change: transform, opacity;
}

@keyframes ticketPulse {
    0%, 100% { transform: scale(1) translate3d(0,0,0); opacity: 0.8; }
    50% { transform: scale(1.1) translate3d(0,0,0); opacity: 1; }
}

.hero-text-area { text-align: center; }
.mystery-phrase { font-size: 16px; font-weight: 700; margin-bottom: 8px; color: var(--text); opacity: 0.9; }
.trust-badge { font-size: 11px; font-weight: 800; color: var(--neon); letter-spacing: 0.5px; }

/* Result View */
.result-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    animation: feedReveal 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    will-change: transform, opacity;
}

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

.poster-display {
    width: 100%;
    height: 65%;
    border-radius: 32px;
    overflow: hidden;
    flex-shrink: 0;
    background: #1a1a1a;
    position: relative;
    cursor: pointer;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5), 0 15px 30px rgba(0,0,0,0.3);
}

.poster-display.loading::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
    animation: skeleton 1.5s infinite;
}

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

.poster-display img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    transition: opacity 0.3s ease;
    opacity: 0;
}
.poster-display img.loaded {
    opacity: 1;
}
.trailer-container { 
    position: absolute; 
    inset: -1px; /* Slightly larger to hide parent edge artifacts */
    z-index: 5; 
    display: none; 
    background: #000; 
    overflow: hidden;
    border-radius: 32px;
}
.trailer-container iframe { 
    width: 100%; 
    height: 100%; 
    border: 0 !important; 
    outline: none !important;
    box-shadow: none !important;
    display: block;
    background: #000;
    transform: scale(1.01); /* Micro-scale to eliminate edge lines */
}
.play-overlay { position: absolute; inset: 0; display: flex; justify-content: center; align-items: center; z-index: 10; pointer-events: none; }
.play-icon { font-size: 60px; color: #fff; opacity: 0.7; filter: drop-shadow(0 0 10px rgba(0,0,0,0.5)); }

/* INFO CARD */
.movie-info-box {
    margin-top: 10px;
    background: var(--yellow);
    border-radius: 28px;
    padding: 14px 18px 18px 18px;
    color: #000;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.rating-row { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.rating-badge { background: #000; color: #fff; padding: 2px 7px; border-radius: 5px; font-size: 10px; font-weight: 900; }

.movie-title { font-size: 20px; font-weight: 900; margin-bottom: 2px; line-height: 1.2; display: flex; align-items: center; gap: 8px; }
.movie-title a { text-decoration: none; color: inherit; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.movie-title a:hover { text-decoration: underline; }

.new-badge {
    background: #ff3b30;
    color: #fff;
    font-size: 10px;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.release-date {
    font-size: 0.7em;
    opacity: 0.6;
    margin-left: 4px;
    font-weight: 600;
    white-space: nowrap;
}

.credits-info { margin-bottom: 6px; font-size: 11px; font-weight: 700; opacity: 0.8; }
.credit-link { text-decoration: none; color: inherit; }
.credit-link:hover { text-decoration: underline; }

.movie-overview {
    font-size: 12.5px;
    line-height: 1.35;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    opacity: 0.85;
}

.ott-section { margin-top: auto; padding-top: 4px; }
.ott-list { display: flex; gap: 8px; flex-wrap: wrap; }
.ott-item { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.ott-link { width: 30px; height: 30px; border-radius: 7px; overflow: hidden; display: block; border: 1px solid rgba(0,0,0,0.08); }
.ott-link img { width: 100%; height: 100%; object-fit: cover; }

.ott-name {
    font-size: 8px;
    font-weight: 900;
    text-align: center;
    max-width: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: -0.2px;
    color: #000;
    opacity: 0.7;
}

/* FOOTER */
.footer {
    position: absolute;
    bottom: 16px;
    left: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-color: var(--bg);
}

.draw-btn {
    width: 100%;
    padding: 18px;
    border: none;
    border-radius: 100px;
    background-color: var(--accent);
    color: var(--btn-text);
    font-size: 17px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(153, 255, 0, 0.2);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.draw-btn:active { transform: scale(0.94); }

.draw-btn.drawing {
    animation: glowPulse 1.5s infinite ease-in-out;
    cursor: wait;
}

@keyframes glowPulse {
    0% { box-shadow: 0 0 5px var(--accent), 0 0 10px var(--accent); opacity: 0.9; }
    50% { box-shadow: 0 0 20px var(--accent), 0 0 40px var(--accent); opacity: 1; }
    100% { box-shadow: 0 0 5px var(--accent), 0 0 10px var(--accent); opacity: 0.9; }
}

.legal-footer {
    text-align: center;
    padding-bottom: 4px;
}

.legal-links {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 6px;
}

.legal-links a {
    color: var(--legal-text);
    text-decoration: none;
    font-weight: 600;
    font-size: 11px;
    transition: color 0.2s;
}

.legal-links a:hover {
    color: var(--text);
}

.copyright {
    font-size: 9px;
    color: var(--legal-text);
    opacity: 0.5;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* PC OPTIMIZATION */
@media (min-width: 1024px) {
    .main-card {
        margin-bottom: 160px;
        gap: 15px;
    }
    .poster-display {
        height: 60%;
    }
}

/* MOBILE OPTIMIZATION */
@media (max-width: 768px) {
    .app-container { padding: 0 16px; }
    
    .poster-display {
        width: 75%; /* Slightly narrower to fit better */
        height: auto;
        max-height: 42dvh; /* Limit height to 40-45% of screen */
        aspect-ratio: 2 / 3;
        margin: 0 auto;
        box-shadow: 0 12px 30px rgba(0,0,0,0.6);
    }

    .movie-info-box {
        margin-top: 8px; /* Tighter gap */
        padding: 12px 16px 14px 16px; /* Reduced padding */
        border-radius: 20px;
        box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    }

    .movie-title { font-size: 17px; margin-bottom: 1px; } /* Smaller title */
    .credits-info { font-size: 10px; margin-bottom: 4px; } /* Smaller text */
    
    .movie-overview {
        font-size: 11.5px;
        -webkit-line-clamp: 3; /* Keep 3 lines */
        line-height: 1.3;
        margin-bottom: 6px;
    }

    .ott-link { width: 26px; height: 26px; }
    .ott-name { font-size: 7.5px; }

    .main-card { margin-bottom: 115px; } /* Adjust for footer */
    .footer { bottom: 18px; gap: 10px; } /* More bottom padding for button */
    .draw-btn { padding: 14px; font-size: 15.5px; }
}

/* ULTRA SMALL SCREENS */
@media (max-height: 700px) {
    .slot-window { height: 280px; width: 220px; }
    .slot-item { height: 280px; }
    .poster-display { width: 75%; aspect-ratio: 2 / 3; }
    .movie-title { font-size: 17px; }
    .movie-overview { -webkit-line-clamp: 2; }
    .main-card { margin-bottom: 110px; }
    .footer { bottom: 8px; gap: 8px; }
}
