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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #1a0533, #2d1b69, #1a0533);
    color: #fff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.container {
    text-align: center;
    max-width: 520px;
    width: 100%;
    padding: 1.5rem;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.app-header h1 {
    margin-bottom: 0;
}

.auth-section {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.auth-guest {
    display: flex;
    align-items: center;
}

.auth-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.sign-in-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: 2px solid #a855f7;
    border-radius: 50px;
    background: transparent;
    color: #a855f7;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.sign-in-btn:hover {
    background: rgba(168, 85, 247, 0.1);
    transform: scale(1.05);
}

.sign-in-btn svg {
    flex-shrink: 0;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #a855f7;
    background: rgba(168, 85, 247, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    color: #a855f7;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #ddd;
}

.sign-out-btn {
    padding: 0.35rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid rgba(255, 85, 85, 0.4);
    border-radius: 50px;
    background: transparent;
    color: #ff5555;
    cursor: pointer;
    transition: background 0.2s;
}

.sign-out-btn:hover {
    background: rgba(255, 85, 85, 0.1);
}

h1 {
    font-size: 2.8rem;
    background: linear-gradient(90deg, #a855f7, #ec4899, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: #aaa;
    margin-bottom: 1.2rem;
    font-size: 1rem;
}

.sparkle-row {
    display: flex;
    justify-content: center;
    gap: 0.6rem;
    margin-bottom: 1.6rem;
    flex-wrap: wrap;
}

.sparkle {
    font-size: 2rem;
    animation: bounce 2s ease-in-out infinite;
    display: inline-block;
    filter: drop-shadow(0 0 6px rgba(168, 85, 247, 0.3));
}

.sparkle:nth-child(1) { animation-delay: 0s; }
.sparkle:nth-child(2) { animation-delay: 0.15s; }
.sparkle:nth-child(3) { animation-delay: 0.3s; }
.sparkle:nth-child(4) { animation-delay: 0.45s; }
.sparkle:nth-child(5) { animation-delay: 0.6s; }
.sparkle:nth-child(6) { animation-delay: 0.75s; }
.sparkle:nth-child(7) { animation-delay: 0.9s; }
.sparkle:nth-child(8) { animation-delay: 1.05s; }
.sparkle:nth-child(9) { animation-delay: 1.2s; }
.sparkle:nth-child(10) { animation-delay: 1.35s; }

@keyframes bounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-10px) scale(1.2); }
}

.rating-gallery {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-bottom: 1.6rem;
}

.rating-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(168, 85, 247, 0.15);
    border-radius: 12px;
    padding: 1rem 0.8rem;
    text-align: center;
    transition: transform 0.3s, border-color 0.3s, background 0.3s;
    animation: fadeIn 0.6s ease both;
}

.rating-card:nth-child(1) { animation-delay: 0.1s; }
.rating-card:nth-child(2) { animation-delay: 0.25s; }
.rating-card:nth-child(3) { animation-delay: 0.4s; }
.rating-card:nth-child(4) { animation-delay: 0.55s; }

.rating-card:hover {
    transform: translateY(-4px);
    border-color: rgba(168, 85, 247, 0.5);
    background: rgba(168, 85, 247, 0.07);
}

.rating-card-score {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(90deg, #a855f7, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.rating-card-text {
    font-size: 0.82rem;
    color: #bbb;
    line-height: 1.45;
    font-style: italic;
}

.section-label {
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: #a855f7;
    margin-bottom: 1rem;
    position: relative;
}

.section-label::before,
.section-label::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40px;
    height: 1px;
    background: rgba(168, 85, 247, 0.3);
}

.section-label::before { right: calc(50% + 60px); }
.section-label::after { left: calc(50% + 60px); }

.file-warning {
    text-align: center;
    font-size: 0.85rem;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 10px;
    padding: 0.6rem 1rem;
    margin-bottom: 0.8rem;
    animation: fadeIn 0.3s ease;
}

.file-error {
    text-align: center;
    font-size: 0.85rem;
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.08);
    border: 1px solid rgba(255, 107, 107, 0.25);
    border-radius: 10px;
    padding: 0.6rem 1rem;
    margin-bottom: 0.8rem;
    animation: fadeIn 0.3s ease;
}

.upload-area {
    border: 2px dashed #555;
    border-radius: 16px;
    padding: 2.5rem 1.5rem;
    cursor: pointer;
    transition: border-color 0.3s, background 0.3s;
    background: rgba(255, 255, 255, 0.03);
    position: relative;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #a855f7;
    background: rgba(168, 85, 247, 0.05);
}

.upload-area svg {
    color: #666;
    margin-bottom: 1rem;
}

#uploadPrompt p {
    color: #888;
    font-size: 0.95rem;
}

#previewContainer {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

#preview {
    max-width: 100%;
    max-height: 280px;
    border-radius: 12px;
    object-fit: contain;
}

.change-photo-btn {
    padding: 0.4rem 1.2rem;
    font-size: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
    color: #ccc;
    cursor: pointer;
    transition: background 0.2s;
}

.change-photo-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.source-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.2rem;
}

.source-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: 2px solid #555;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    color: #ddd;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.source-btn:hover {
    border-color: #a855f7;
    background: rgba(168, 85, 247, 0.08);
}

.source-btn svg {
    flex-shrink: 0;
}

.hidden {
    display: none !important;
}

#rateBtn {
    margin-top: 1.5rem;
    padding: 0.9rem 2.5rem;
    font-size: 1.15rem;
    font-weight: 700;
    border: none;
    border-radius: 50px;
    background: linear-gradient(90deg, #a855f7, #ec4899);
    color: #fff;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

#rateBtn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.4);
}

#rateBtn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#loading {
    margin-top: 2rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.15);
    border-top-color: #a855f7;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

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

#result {
    margin-top: 1.5rem;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 1.8rem;
    border: 1px solid rgba(168, 85, 247, 0.2);
    animation: fadeIn 0.5s ease;
}

.rating-display {
    margin-bottom: 1.5rem;
}

.rating-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 4px solid #a855f7;
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.2);
    position: relative;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 30px rgba(168, 85, 247, 0.2); }
    50% { box-shadow: 0 0 50px rgba(168, 85, 247, 0.4); }
}

.rating-value {
    font-size: 3.5rem;
    font-weight: 800;
    color: #a855f7;
}

.rating-label {
    font-size: 1.2rem;
    color: #999;
    margin-left: 0.2rem;
}

.highlights {
    margin-bottom: 1.2rem;
    text-align: left;
}

.highlights h3,
.explanation h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #a855f7;
    margin-bottom: 0.6rem;
    text-align: center;
}

#highlightsList {
    list-style: none;
    padding: 0;
}

#highlightsList li {
    padding: 0.5rem 1rem;
    margin-bottom: 0.4rem;
    background: rgba(168, 85, 247, 0.08);
    border-radius: 8px;
    border-left: 3px solid #a855f7;
    font-size: 0.95rem;
    color: #ddd;
    text-align: left;
    animation: fadeIn 0.4s ease both;
}

#highlightsList li:nth-child(1) { animation-delay: 0.1s; }
#highlightsList li:nth-child(2) { animation-delay: 0.2s; }
#highlightsList li:nth-child(3) { animation-delay: 0.3s; }
#highlightsList li:nth-child(4) { animation-delay: 0.4s; }
#highlightsList li:nth-child(5) { animation-delay: 0.5s; }

.explanation {
    text-align: left;
    margin-bottom: 1.2rem;
}

#explanationText {
    font-size: 1rem;
    line-height: 1.7;
    color: #ccc;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.8rem 1rem;
    border-radius: 8px;
}

.rate-again-btn {
    padding: 0.6rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: 2px solid #a855f7;
    border-radius: 50px;
    background: transparent;
    color: #a855f7;
    cursor: pointer;
    transition: background 0.2s;
}

.rate-again-btn:hover {
    background: rgba(168, 85, 247, 0.1);
}

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

@media (max-width: 480px) {
    .app-header h1 {
        font-size: 2rem;
    }

    .sign-in-btn {
        padding: 0.4rem 0.9rem;
        font-size: 0.82rem;
    }

    .user-name {
        display: none;
    }

    h1 {
        font-size: 2.2rem;
    }

    .subtitle {
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }

    .sparkle {
        font-size: 1.5rem;
    }

    .rating-gallery {
        grid-template-columns: 1fr;
        gap: 0.6rem;
    }

    .rating-card-text {
        font-size: 0.78rem;
    }

    .upload-area {
        padding: 2rem 1rem;
        min-height: 180px;
    }

    .source-buttons {
        gap: 0.8rem;
    }

    .source-btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }

    #rateBtn {
        padding: 0.8rem 2rem;
        font-size: 1.05rem;
    }

    .rating-circle {
        width: 120px;
        height: 120px;
    }

    .rating-value {
        font-size: 2.8rem;
    }
}

/* Share Modal */
.share-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.share-modal-content {
    background: linear-gradient(135deg, #2d1b69, #1a0533);
    border-radius: 16px;
    padding: 2rem;
    max-width: 450px;
    width: 90%;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.close-modal {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.7;
}

.close-modal:hover {
    opacity: 1;
}

.share-link-box {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.share-link-box input {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 0.9rem;
}

.copy-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #50fa7b, #2d6a4f);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.copy-btn:hover {
    opacity: 0.9;
}

.share-btn {
    margin-top: 12px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #bd93f9, #6c5ce7);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.share-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(189, 147, 249, 0.4);
}

footer {
  text-align: center;
  color: #888;
  font-size: 0.7rem;
  padding-top: 1rem;
  opacity: 0.5;
}

.footer-brand {
  margin-bottom: 0.5rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.footer-links a {
  color: #888;
  text-decoration: none;
  font-size: 0.7rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: all 0.2s;
}

.footer-links a:hover {
  color: #a855f7;
  background: rgba(168, 85, 247, 0.1);
}
