/* ...existing styles... */
@font-face {
    font-family: "Speedee";
    src: url("/Speedee-Bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
/* Base */
:root {
    --yellow: #FFC72C;
    --red: #DA291C;
    --cream: #FFF5E1;
    --gray: #555555;
    --black: #000000;
    --white: #FFFFFF;
}
* { box-sizing: border-box; }
html, body {
    height: 100%;
    margin: 0;
    font-family: "McDonalds Sans", "Noto Sans", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    color: var(--white);
    background: transparent;
}
body { position: relative; }

/* Animated background */
.bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}
.bg-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    animation: fadeCycle 9s linear infinite;
    will-change: opacity;
}
.layer-1 { animation-delay: 0s; }
.layer-2 { animation-delay: 3s; }
.layer-3 { animation-delay: 6s; }

@keyframes fadeCycle {
    0% { opacity: 0; }
    5% { opacity: 0.7; }
    30% { opacity: 0.7; }
    35% { opacity: 0; }
    100% { opacity: 0; }
}

/* Navbar */
.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 10;
    background: transparent;
    backdrop-filter: none;
}
.nav-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
}
.brand img {
    height: 32px;
    width: auto;
    display: block;
}
.nav-links {
    display: flex;
    gap: 24px;
    justify-content: center;
}
.nav-links a {
    color: var(--white);
    text-decoration: none;
    font-weight: 500;
    padding: 6px 8px;
    border-radius: 6px;
    transition: color 160ms ease, background-color 160ms ease;
}
.nav-links a:hover {
    color: var(--red);
    background-color: rgba(255, 199, 44, 0.2);
}
.contract-btn {
    justify-self: end;
    font: 500 14px/1 "Noto Sans";
    color: var(--white);
    background: transparent;
    border: 2px solid var(--yellow);
    border-radius: 8px;
    padding: 10px 14px;
    min-height: 44px;
    cursor: pointer;
    transition: background-color 160ms ease, border-color 160ms ease;
}
.contract-btn:hover { background-color: var(--cream); }
.contract-btn:active { border-color: var(--red); }

/* Hero */
.hero {
    position: relative;
    z-index: 1;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 96px 24px 64px; /* top padding accounts for navbar */
}
.hero-title {
    font-family: "Speedee", "Noto Sans", sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin: 0 0 16px;
    color: var(--white);
    font-size: clamp(22px, 4.5vw, 44px);
}
.hero-sub {
    max-width: 900px;
    margin: 0 auto 24px;
    font-size: clamp(14px, 2.2vw, 20px);
    line-height: 1.5;
    color: var(--white);
}
.cta {
    display: inline-block;
    background: var(--yellow);
    color: var(--black);
    text-decoration: none;
    font-weight: 700;
    border-radius: 10px;
    padding: 12px 22px;
    min-height: 44px;
    line-height: 20px;
    transition: background-color 160ms ease, transform 120ms ease;
}
.cta:hover { background-color: #FFD465; }
.cta:active { background-color: var(--red); color: var(--white); }
.partner-logos {
    margin-top: 24px;
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: center;
}
.partner-logos img {
    height: 28px;
    width: auto;
    filter: none;
}

/* Footer */
.footer {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 10;
    background: transparent;
    padding: 10px 24px;
}
.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 12px;
}
.footer-links a {
    color: var(--white);
    text-decoration: none;
    margin-right: 12px;
    padding: 4px 6px;
    border-radius: 6px;
    transition: color 160ms ease, background-color 160ms ease;
}
.footer-links a:hover {
    color: var(--red);
    background-color: rgba(255, 199, 44, 0.2);
}

/* Responsive tweaks */
@media (max-width: 768px) {
    .nav-inner { grid-template-columns: auto 1fr auto; }
    .nav-links { gap: 16px; }
    .brand img { height: 28px; }
    .partner-logos img { height: 24px; }
}
@media (max-width: 520px) {
    .nav-links { display: none; }
    .hero-sub { padding: 0 8px; }
}

.identity-main {
    position: relative; z-index: 1; min-height: 100dvh;
    display: grid; place-items: center; padding: 96px 24px 64px;
}

.form-card {
    width: min(720px, 94vw);
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 16px; padding: 28px; color: var(--white);
    backdrop-filter: saturate(120%) blur(4px);
}

.form-title {
    font-family: "Speedee","Noto Sans",sans-serif; font-weight: 700;
    text-transform: uppercase; margin: 0 0 18px; font-size: clamp(20px,3.6vw,32px); color: var(--white);
}

.form-group { display: grid; gap: 8px; margin-bottom: 16px; }
.form-group label {
    font-family: "Speedee","Noto Sans",sans-serif; font-weight: 700; color: var(--white); font-size: 14px;
}

.form-card input[type="text"], .form-card select, .form-card input[type="file"] {
    font: 500 14px/1.2 "Noto Sans"; color: var(--black); background: var(--white);
    border: 2px solid transparent; border-radius: 10px; padding: 12px 12px;
}

.form-card input::placeholder { color: var(--gray); }
.form-card :is(input,select):focus { outline: none; border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(255,199,44,0.35); }

.image-preview {
    background: var(--white); border-radius: 10px; min-height: 140px; display: grid; place-items: center;
    overflow: hidden; border: 2px solid transparent;
}

.image-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

.primary-btn {
    display: block; width: 100%; min-height: 44px; border: none; border-radius: 10px;
    background: var(--yellow); color: var(--black); font-weight: 700; padding: 12px 18px;
    transition: background-color 220ms ease, box-shadow 220ms ease, transform 120ms ease;
    will-change: background-color, box-shadow;
}

.primary-btn:hover { background-color: #FFD465; box-shadow: 0 8px 18px rgba(255,199,44,0.18); }
/* focus styles for accessibility */
.primary-btn:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(255,199,44,0.22); }
.primary-btn:disabled { filter: grayscale(40%); opacity: 0.7; cursor: not-allowed; }

.form-card select#countrySelect {
    position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; /* visually hide, keep in DOM */
}

.custom-dropdown {
    position: relative; width: 100%;
}
.custom-dropdown .dropdown-toggle {
    width: 100%; background: var(--white); color: var(--black);
    border: 2px solid transparent; border-radius: 10px; padding: 12px;
    font: 500 14px/1.2 "Noto Sans"; text-align: left; cursor: pointer;
    transition: box-shadow 160ms ease, border-color 160ms ease;
}
.custom-dropdown .dropdown-toggle:focus-visible,
.custom-dropdown.open .dropdown-toggle {
    outline: none; border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(255,199,44,0.35);
}
.custom-dropdown .dropdown-list {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    background: var(--white); color: var(--black);
    border: 1px solid rgba(0,0,0,0.12); border-radius: 10px;
    max-height: 252px; /* ~7 items visible */
    overflow-y: auto; scroll-behavior: smooth; z-index: 20; padding: 6px; box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    display: none;
}
.custom-dropdown.open .dropdown-list { display: block; }
.custom-dropdown .dropdown-item {
    padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.custom-dropdown .dropdown-item:hover,
.custom-dropdown .dropdown-item[aria-selected="true"] {
    background: rgba(255,199,44,0.18);
}

@media (max-width: 520px) { .form-card { padding: 22px; } .form-group { margin-bottom: 14px; } }

#resultBundle {
    display: flex;
    flex-direction: column;
    align-items: center; /* center horizontally */
    justify-content: center; /* center vertically inside the result area */
    gap: 20px;
    width: 100%;
    padding: 12px;
    box-sizing: border-box;
    min-height: 40vh; /* reduced so letter can center more naturally on small screens */
}

.letter-card {
    max-width: 600px; /* desktop max width */
    width: min(600px, 90vw); /* scale down to 90% of viewport on mobile */
    margin: 0 auto 20px; /* bottom margin separates from ID card */
    background: rgba(0, 0, 0, 0.92);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.45);
    text-align: left;
    max-height: calc(100vh - 220px); /* keep the card visible with room for nav/footer */
    overflow-y: auto; /* scrollable on smaller viewports */
    -webkit-overflow-scrolling: touch;
}
.letter-card .letter-body {
    padding-right: 6px; /* small padding to avoid scrollbar overlap */
}

.letter-card .letter-title {
    font-family: "Speedee","Noto Sans",sans-serif;
    font-weight: 700;
    color: var(--white);
    margin: 0 0 10px;
    font-size: clamp(18px,3.2vw,24px);
}

.letter-card .letter-body p {
    font: 500 14px/1.7 "Noto Sans";
    color: var(--white);
    margin: 10px 0;
    word-wrap: break-word;
}
.letter-card .letter-body strong { color: var(--yellow); }

.id-card { 
    width: min(350px, 90vw); /* changed to scale to 90% on very small viewports */
    max-width: 350px; /* enforce desktop max */
    aspect-ratio: 1/1; /* ensure PFP-ready square proportion */
    padding: clamp(18px, 4vw, 28px); /* responsive padding 18-28px */
    margin: 0 auto;
    background: linear-gradient(135deg, rgba(0,0,0,0.08), rgba(0,0,0,0.02)); /* fallback */
    border-radius: 16px;
    position: relative;
    box-shadow: 0 8px 20px rgba(0,0,0,0.36);
    box-sizing: border-box;
    display: grid;
    grid-template-rows: auto 1fr; /* brand row + content area */
    overflow: hidden; /* keep content contained */
}
/* Accepted / Rejected gradients */
.id-card.accepted {
    background: linear-gradient(180deg, #FFE29A 0%, #FFC72C 100%);
    border: 2px solid rgba(0,0,0,0.06);
}
.id-card.rejected {
    background: linear-gradient(180deg, #E6E6E6 0%, #BDBDBD 100%);
    border: 2px solid rgba(0,0,0,0.06);
}
/* Top-centered circular photo */
.id-card .photo {
    display:flex;
    justify-content:center;
    align-items:center;
    margin-top: 0; /* remove upward pull, keep centered inside square */
    margin-bottom: 8px;
    padding-top: 6px;
}
.id-card .photo img {
    width: clamp(84px, 26%, 120px); /* responsive circular photo */
    height: clamp(84px, 26%, 120px);
    object-fit: cover;
    border-radius: 50%;
    border: 4px solid rgba(255,255,255,0.85);
    box-shadow: 0 6px 18px rgba(0,0,0,0.28);
    background: #fff;
    display: block;
}
/* Brand (logos) top-left / top-right */
.id-card .brand {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    margin-bottom: 6px;
    padding: 0 4px;
}
.id-card .brand img { height:18px; width:auto; display:block; }
.id-card .brand .right { font:700 12px/1 "Speedee","Noto Sans"; color: rgba(0,0,0,0.8); }
/* Meta / text layout */
.id-card .meta {
    text-align:center;
    padding: 10px 8px;
    color: rgba(0,0,0,0.9);
    overflow: auto;
}
.id-card .meta h3 { margin: 8px 0 6px; font-size: 16px; color: rgba(0,0,0,0.95); }
.id-card .meta p { margin: 0; font: 500 13px/1.4 "Noto Sans"; color: rgba(0,0,0,0.85); }
/* subtle decorative accent behind text */
.id-card::before {
    content: "";
    position: absolute;
    left: -20%;
    top: 40%;
    width: 180%;
    height: 60%;
    background: radial-gradient(circle at 25% 20%, rgba(255,255,255,0.12), transparent 20%);
    pointer-events: none;
    transform: rotate(-8deg);
    opacity: 0.9;
    border-radius: 50%;
}
/* Mental health stamp overlay for rejected cards */
.id-card.rejected::after {
    content: "MENTAL HEALTH";
    position: absolute;
    top: 12px;
    left: 12px;
    font:700 11px/1 "Speedee","Noto Sans";
    color:#fff;
    background: rgba(85,85,85,0.85);
    padding:6px 10px;
    border-radius:999px;
    letter-spacing: 0.06em;
}
/* ensure actions/buttons look compact and consistent */
.actions { display:flex; gap:10px; margin-top:14px; flex-wrap:wrap; justify-content:center; }

@media (max-width: 768px) {
    #resultBundle { padding: 8px; }
    .letter-card {
        max-height: 60vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .form-card { max-height: 70vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
}

@media (max-width: 420px) {
    .id-card { aspect-ratio: 1/1; padding: 16px; }
    .id-card .photo img { width: 96px; height: 96px; }
}

h1, h2, h3, h4 {
    font-family: "Speedee","Noto Sans",sans-serif;
    font-weight: 700;
    color: var(--white);
}