:root {
    --bg-color-start: #f0f4f8;
    --bg-color-end: #d9e2ec;
    --text-color: #102a43;
    --container-bg: rgba(255, 255, 255, 0.7);
    --number-bg: #ffffff;
    --shadow-color: rgba(16, 42, 67, 0.3);
    --input-bg: #ffffff;
    --input-border: #d9e2ec;
}

body[data-theme="dark"] {
    --bg-color-start: #102a43;
    --bg-color-end: #0a1a29;
    --text-color: #f0f4f8;
    --container-bg: rgba(16, 42, 67, 0.5);
    --number-bg: #243b53;
    --shadow-color: rgba(0, 0, 0, 0.6);
    --input-bg: #102a43;
    --input-border: #334e68;
}

/* --- Header & Navigation --- */
header {
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    background: var(--container-bg);
    backdrop-filter: blur(15px);
    z-index: 1000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.lang-switcher {
    display: flex;
    gap: 5px;
}

.lang-btn {
    background: none;
    border: 1px solid var(--input-border);
    color: var(--text-color);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.lang-btn:hover, .lang-btn.active {
    background: var(--text-color);
    color: var(--bg-color-start);
}

.logo {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text-color);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 14px;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 600;
    transition: opacity 0.2s;
}

.nav-links a:hover {
    opacity: 0.7;
}

/* --- Main Layout Adjustments --- */
body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    background: linear-gradient(135deg, var(--bg-color-start), var(--bg-color-end));
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 80px; /* Space for fixed header */
    transition: background 0.4s ease, color 0.4s ease;
}

.main-wrapper {
    display: flex;
    flex-direction: column;
    gap: 30px;
    width: 100%;
    max-width: 800px; /* Increased width for better content display */
    padding: 20px;
    z-index: 1;
    flex-grow: 1;
}

/* --- Content Sections --- */
.content-section {
    text-align: left;
    line-height: 1.6;
}

.content-section h3 {
    margin-top: 25px;
    color: var(--text-color);
}

/* --- Footer --- */
footer {
    width: 100%;
    padding: 40px 20px;
    background: var(--container-bg);
    backdrop-filter: blur(10px);
    margin-top: 50px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.footer-content {
    max-width: 800px;
    margin: 0 auto;
}

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

.footer-links a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.85rem;
}

.copyright {
    font-size: 0.8rem;
    opacity: 0.6;
}

/* --- Existing Container Overrides --- */
.container {
    background: var(--container-bg);
    padding: 2.5rem;
    border-radius: 24px;
    box-shadow: 0 20px 40px var(--shadow-color);
    backdrop-filter: blur(12px);
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    box-sizing: border-box;
}

.lotto-numbers {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.lotto-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--number-bg);
    display: grid;
    place-content: center;
    font-weight: bold;
    box-shadow: 0 2px 5px var(--shadow-color);
}

#generate-btn, .submit-btn {
    padding: 12px 30px;
    border-radius: 25px;
    border: none;
    background: #486581;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, background 0.3s;
    width: 100%;
}

#generate-btn:hover, .submit-btn:hover {
    transform: translateY(-2px);
    background: #334e68;
}

.partnership-container h2 {
    margin-top: 0;
    margin-bottom: 10px;
}

.partnership-form {
    text-align: left;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
    font-weight: 600;
}

.form-group input, .form-group textarea {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-color);
    font-family: inherit;
    box-sizing: border-box;
}

.form-group textarea {
    resize: vertical;
}

/* --- New Statistics Styles -- */
.stats-box {
    margin-top: 20px;
}

.stats-list {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

/* --- Fortune Page Styles --- */
.fortune-form {
    text-align: left;
    max-width: 360px;
    margin: 20px auto 0;
}

.form-group select {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-color);
    font-family: inherit;
    box-sizing: border-box;
}

.fortune-result {
    margin-top: 30px;
    text-align: left;
}

.fortune-date {
    text-align: center;
    font-weight: 600;
    opacity: 0.7;
    margin-bottom: 20px;
}

.fortune-card {
    background: var(--number-bg);
    border-radius: 16px;
    padding: 16px 20px;
    margin-bottom: 14px;
    box-shadow: 0 4px 10px var(--shadow-color);
}

.fortune-card h3 {
    margin: 0 0 10px;
    font-size: 1rem;
}

.score-bar {
    width: 100%;
    height: 10px;
    border-radius: 6px;
    background: var(--input-border);
    overflow: hidden;
    margin-bottom: 10px;
}

.score-bar span {
    display: block;
    height: 100%;
    border-radius: 6px;
    background: linear-gradient(90deg, #486581, #829ab1);
    transition: width 0.8s ease;
}

.fortune-text {
    margin: 0;
    line-height: 1.6;
    font-size: 0.95rem;
}

.lucky-box {
    display: flex;
    justify-content: space-around;
    gap: 10px;
    flex-wrap: wrap;
    margin: 22px 0;
    padding: 18px;
    border-radius: 16px;
    background: var(--container-bg);
    border: 1px solid var(--input-border);
}

.lucky-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 90px;
}

.lucky-label {
    font-size: 0.75rem;
    opacity: 0.7;
    text-align: center;
}

.lucky-value {
    font-size: 1.3rem;
    font-weight: 700;
}

.cross-link {
    display: block;
    text-align: center;
    margin-top: 10px;
    padding: 14px;
    border-radius: 25px;
    background: #486581;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.3s, transform 0.2s;
}

.cross-link:hover {
    background: #334e68;
    transform: translateY(-2px);
}

/* --- Face Reading & Compatibility shared --- */
.upload-input {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px dashed var(--input-border);
    background: var(--input-bg);
    color: var(--text-color);
    font-family: inherit;
    box-sizing: border-box;
    cursor: pointer;
}

.privacy-note {
    font-size: 0.8rem;
    opacity: 0.75;
    margin-top: 10px;
    text-align: center;
}

.face-preview {
    display: block;
    max-width: 220px;
    width: 60%;
    margin: 0 auto 20px;
    border-radius: 16px;
    box-shadow: 0 8px 20px var(--shadow-color);
}

.overall-score {
    text-align: center;
    background: var(--container-bg);
    border: 1px solid var(--input-border);
    border-radius: 16px;
    padding: 20px;
    margin: 22px 0;
}

.overall-score .big-number {
    font-size: 2.6rem;
    font-weight: 700;
    line-height: 1;
}

.overall-score .big-number span {
    font-size: 1.1rem;
    opacity: 0.6;
}

.overall-score .overall-label {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-bottom: 8px;
}

.summary-text {
    margin-top: 14px;
    line-height: 1.6;
    font-weight: 600;
}

.section-title {
    margin: 26px 0 12px;
    font-size: 1.15rem;
}

/* ===== Premium report paywall ===== */
.premium-locked {
    position: relative;
    margin-top: 10px;
    border-radius: 16px;
    overflow: hidden;
}

.premium-locked .premium-content {
    filter: blur(9px);
    pointer-events: none;
    user-select: none;
    transition: filter 0.35s ease;
}

.premium-locked.unlocked .premium-content {
    filter: none;
    pointer-events: auto;
    user-select: auto;
}

.premium-paywall {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    padding: 24px;
    background: linear-gradient(180deg, rgba(16,42,67,0.35), rgba(16,42,67,0.75));
    backdrop-filter: blur(2px);
}

.premium-locked.unlocked .premium-paywall {
    display: none;
}

.premium-paywall h3 {
    margin: 0;
    font-size: 1.2rem;
}

.premium-paywall .price-note {
    font-size: 0.8rem;
    opacity: 0.85;
}

.premium-badge {
    display: none;
    text-align: center;
    background: rgba(72, 101, 129, 0.18);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 10px;
    margin: 6px 0 14px;
    font-weight: 600;
    font-size: 0.9rem;
}

.premium-locked.unlocked + .premium-badge,
.premium-badge.show {
    display: block;
}

/* ===== Daily dashboard ===== */
.daily-weather {
    text-align: center;
}
.daily-weather .w-emoji {
    font-size: 3.4rem;
    line-height: 1;
}
.daily-weather .w-temp {
    font-size: 2.6rem;
    font-weight: 700;
    line-height: 1.1;
}
.daily-weather .w-label {
    opacity: 0.8;
    font-size: 0.95rem;
}
.daily-weather .w-tip {
    margin-top: 10px;
    font-weight: 600;
}
.today-greeting {
    text-align: center;
    opacity: 0.75;
    margin-top: -6px;
}

/* ===== Mobile / Responsive ===== */
/* Prevent iOS from auto-resizing text on orientation change. */
html { -webkit-text-size-adjust: 100%; }

/* Tablets and phones: header becomes static so a wrapped nav can never
   overlap the page content, and spacing tightens up. */
@media (max-width: 768px) {
    header {
        position: static;
    }
    body {
        padding-top: 0;
    }
    .nav-container {
        flex-direction: column;
        gap: 12px;
        padding: 12px 16px;
    }
    .nav-links {
        justify-content: center;
        gap: 8px 14px;
    }
    .nav-links a {
        font-size: 0.85rem;
    }
    .main-wrapper {
        padding: 14px;
        gap: 20px;
    }
    .container {
        padding: 1.6rem 1.3rem;
        border-radius: 18px;
    }
    h1 {
        font-size: 1.6rem;
    }
    .subtitle {
        font-size: 0.95rem;
    }
    /* 16px inputs stop mobile Safari from zooming in on focus. */
    .form-group input,
    .form-group select,
    .form-group textarea,
    .upload-input {
        font-size: 16px;
    }
}

/* Small phones: tighten further and shrink the lotto balls / big score. */
@media (max-width: 420px) {
    .container {
        padding: 1.3rem 1rem;
    }
    .nav-links {
        gap: 6px 10px;
    }
    .nav-links a {
        font-size: 0.8rem;
    }
    .lotto-number {
        width: 34px;
        height: 34px;
        font-size: 0.9rem;
    }
    .lotto-numbers,
    .stats-list {
        gap: 7px;
    }
    .overall-score .big-number {
        font-size: 2.2rem;
    }
    .lucky-item {
        min-width: 72px;
    }
    .lucky-value {
        font-size: 1.1rem;
    }
    footer {
        padding: 30px 16px;
    }
}
