*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Modern forest purple + gold on cream */
    --bg: #f8f4ed;
    --bg-mid: #f3ece3;
    --bg-warm: #ebe3d6;
    --bg-soft: #faf7f2;
    --surface: #ffffff;
    --surface-elevated: #ffffff;
    --surface-muted: #faf7f2;
    --border: #e5ddd0;
    --border-soft: rgba(92, 74, 138, 0.12);
    --text: #1c1528;
    --text-muted: #6b6378;
    --nav-text: #3d3558;
    --brand: #5c4a8a;
    --brand-dark: #3f2f66;
    --brand-light: #7a68b0;
    --brand-soft: #ede8f8;
    --brand-glow: rgba(92, 74, 138, 0.18);
    --gold: #e5b82a;
    --gold-dark: #b8921a;
    --gold-light: #f5d060;
    --gold-soft: rgba(229, 184, 42, 0.14);
    --navy: #1a1428;
    --navy-mid: #2d2444;

    /* Play section aliases */
    --bg-deep: var(--bg);
    --bg-card: var(--surface);
    --bg-card-border: var(--border);
    --text-primary: var(--text);
    --accent-gold: var(--gold);
    --accent-purple: var(--brand);
    --accent-pink: #d45d8a;
    --accent-blue: #5a8fc4;
    --fire: #d45a3a;
    --earth: #5a9a4a;
    --air: #4a9ab4;
    --water: #4a72c4;
    --ring-size: 230px;
    --font-display: 'Outfit', system-ui, sans-serif;
    --font-body: 'Outfit', system-ui, sans-serif;
    --radius: 20px;
    --radius-sm: 12px;
    --shadow: 0 4px 24px rgba(28, 21, 40, 0.06), 0 1px 3px rgba(28, 21, 40, 0.04);
    --shadow-soft: 0 8px 30px rgba(92, 74, 138, 0.08);
    --shadow-lg: 0 24px 56px rgba(28, 21, 40, 0.1);
}

html {
    scroll-behavior: smooth;
    font-size: 21px;
    font-family: var(--font-body);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: clip;
}

body {
    min-height: 100vh;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-primary);
    background:
        radial-gradient(ellipse 70% 50% at 0% 0%, rgba(92, 74, 138, 0.07), transparent 55%),
        radial-gradient(ellipse 55% 40% at 100% 5%, rgba(229, 184, 42, 0.09), transparent 50%),
        radial-gradient(ellipse 80% 45% at 50% 100%, rgba(92, 74, 138, 0.05), transparent 55%),
        linear-gradient(180deg, #faf7f2 0%, var(--bg) 45%, var(--bg-mid) 100%);
    background-attachment: fixed;
    line-height: 1.6;
    overflow-x: hidden;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

img,
svg,
video {
    max-width: 100%;
    height: auto;
}

a,
button {
    -webkit-tap-highlight-color: rgba(92, 74, 138, 0.15);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Subtle ambient texture */
.stars {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.35;
    background-image:
        radial-gradient(1px 1px at 10% 20%, rgba(92, 74, 138, 0.25), transparent),
        radial-gradient(1px 1px at 30% 65%, rgba(229, 184, 42, 0.2), transparent),
        radial-gradient(1.5px 1.5px at 55% 30%, rgba(92, 74, 138, 0.15), transparent),
        radial-gradient(1px 1px at 75% 75%, rgba(229, 184, 42, 0.15), transparent),
        radial-gradient(1px 1px at 90% 15%, rgba(92, 74, 138, 0.2), transparent);
    background-size: 100% 100%;
}

/* Header */
.site-header {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 2.5rem 1.5rem 1rem;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.logo-symbol {
    color: var(--accent-gold);
    font-size: 1.5rem;
    animation: spin-slow 20s linear infinite;
}

@keyframes spin-slow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.tagline {
    margin-top: 0.4rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 300;
}

.meet-banner {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.meet-banner a {
    color: var(--accent-gold);
    font-weight: 600;
    text-decoration: none;
}

.meet-banner a:hover {
    text-decoration: underline;
}

/* Layout */
.container {
    position: relative;
    z-index: 1;
    max-width: 1140px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 3.5rem;
}

/* Cards */
.match-card,
.result-card {
    background: var(--surface);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

.result-card {
    margin-top: 1.5rem;
    text-align: center;
    animation: fadeUp 0.5s ease;
}

.result-card.hidden {
    display: none;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Type toggle */
.type-toggle {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-warm);
    border-radius: var(--radius-sm);
    padding: 5px;
    margin-bottom: 1.75rem;
    border: 1px solid var(--border);
}

.type-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    min-width: 0;
    flex-wrap: nowrap;
    white-space: nowrap;
    line-height: 1.2;
}

.type-btn:hover {
    color: var(--text-primary);
}

.type-btn.active {
    background: var(--surface);
    color: var(--brand-dark);
    box-shadow: var(--shadow-soft);
}

.type-btn[data-type="friendship"].active {
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.type-icon {
    font-size: 1rem;
    flex-shrink: 0;
    line-height: 1;
}

.type-label {
    min-width: 0;
    line-height: 1.2;
}

/* Sign selectors */
.sign-selectors {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0.75rem;
    align-items: start;
    margin-bottom: 1.5rem;
}

.sign-column {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.column-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sign-select {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--bg-card-border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a89bc4' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}

.sign-select:focus {
    outline: 2px solid var(--accent-purple);
    outline-offset: 2px;
}

.sign-card {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0.5rem;
    border-radius: 12px;
    border: 1px solid var(--bg-card-border);
    background: var(--brand-soft);
    text-align: center;
}

.sign-card.selected {
    display: flex;
}

.sign-symbol {
    font-size: 2.25rem;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.sign-name {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
}

.sign-dates {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.versus {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 2.5rem;
}

.versus-ring {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    font-size: 1rem;
    color: white;
    box-shadow: 0 0 20px rgba(104, 84, 248, 0.4);
}

.birth-input-wrap {
    margin-top: 0.25rem;
}

.birth-label {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.birth-input {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--bg-card-border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.82rem;
}

.birth-input:focus {
    outline: 2px solid var(--accent-purple);
    outline-offset: 2px;
}

/* Sign grid */
.sign-grid-section {
    margin-bottom: 1.5rem;
}

.grid-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 0.75rem;
}

.sign-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.sign-grid-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.65rem 0.25rem;
    border: 1px solid var(--bg-card-border);
    border-radius: 10px;
    background: var(--brand-soft);
    color: var(--text-primary);
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.2s ease;
}

.sign-grid-btn:hover {
    border-color: var(--accent-purple);
    background: rgba(104, 84, 248, 0.15);
    transform: translateY(-2px);
}

.sign-grid-btn.active-sign1 {
    border-color: var(--accent-pink);
    background: rgba(255, 107, 157, 0.2);
    box-shadow: 0 0 12px rgba(255, 107, 157, 0.25);
}

.sign-grid-btn.active-sign2 {
    border-color: var(--accent-blue);
    background: rgba(107, 184, 255, 0.2);
    box-shadow: 0 0 12px rgba(107, 184, 255, 0.25);
}

.grid-symbol {
    font-size: 1.4rem;
    line-height: 1;
}

.grid-name {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
}

.active-target {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
}

.active-target strong {
    color: var(--accent-gold);
}

/* Match button */
.match-btn {
    position: relative;
    display: block;
    width: 100%;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
    color: #2a1f00;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 20px rgba(229, 184, 42, 0.35);
}

.match-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 32px rgba(229, 184, 42, 0.45);
    background: linear-gradient(135deg, var(--gold-dark) 0%, var(--gold) 100%);
    color: #2a1f00;
}

.match-btn:active {
    transform: translateY(0);
}

.btn-glow {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    transform: translateX(-100%);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    100% { transform: translateX(100%); }
}

/* Results */
.result-header {
    margin-bottom: 1.5rem;
}

.result-type {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent-purple);
    font-weight: 500;
}

.result-pair {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    margin-top: 0.25rem;
}

.score-ring-wrap {
    position: relative;
    width: var(--ring-size);
    height: var(--ring-size);
    margin: 0 auto 1.25rem;
}

.score-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: rgba(15, 23, 42, 0.08);
    stroke-width: 12;
}

.ring-fill {
    fill: none;
    stroke: url(#scoreGradient);
    stroke-width: 12;
    stroke-linecap: round;
    stroke-dasharray: 534;
    stroke-dashoffset: 534;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.score-center {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.score-value {
    font-family: var(--font-display);
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1;
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.score-percent {
    font-size: 1.5rem;
    color: var(--accent-gold);
    margin-top: 0.5rem;
    margin-left: 0.1rem;
}

.score-label {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--brand);
    margin-bottom: 0.75rem;
}

.score-insight {
    font-size: 0.95rem;
    color: var(--text-muted);
    max-width: 480px;
    margin: 0 auto 1.25rem;
    line-height: 1.7;
}

.element-tags {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.element-tag {
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
    border: 1px solid;
}

.element-tag.fire { color: var(--fire); border-color: var(--fire); background: rgba(255,107,74,0.1); }
.element-tag.earth { color: var(--earth); border-color: var(--earth); background: rgba(143,188,106,0.1); }
.element-tag.air { color: var(--air); border-color: var(--air); background: rgba(126,200,232,0.1); }
.element-tag.water { color: var(--water); border-color: var(--water); background: rgba(107,159,255,0.1); }

.share-btn,
.reset-btn {
    display: inline-block;
    padding: 0.7rem 1.5rem;
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0.25rem;
}

.share-btn {
    border: 1px solid var(--brand);
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.share-btn:hover {
    background: var(--brand);
    color: #fff;
}

.reset-btn {
    border: 1px solid var(--bg-card-border);
    background: transparent;
    color: var(--text-muted);
}

.reset-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

/* Footer */
.site-footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 1.35rem 1.25rem;
    font-size: 1rem;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.85);
    background: linear-gradient(165deg, var(--navy-mid) 0%, var(--navy) 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.site-footer p {
    margin: 0;
}

/* Responsive */
@media (max-width: 768px) {
    html {
        font-size: 18px;
    }

    :root {
        --ring-size: min(72vw, 200px);
    }

    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .container {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(2rem, env(safe-area-inset-bottom));
    }

    .site-header {
        padding: 1.75rem 1rem 0.75rem;
    }

    .logo {
        font-size: 1.45rem;
    }

    .birth-input {
        font-size: 1rem;
        min-height: 44px;
        padding: 0.65rem 0.75rem;
    }

    .sign-select {
        font-size: 1rem;
        min-height: 44px;
        padding: 0.65rem 0.75rem;
    }

    .sign-grid-btn {
        min-height: 44px;
        padding: 0.5rem 0.2rem;
        touch-action: manipulation;
    }

    .type-toggle {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.35rem;
        padding: 4px;
    }

    .type-btn {
        min-height: 44px;
        width: 100%;
        padding: 0.6rem 0.4rem;
        font-size: clamp(0.72rem, 2.8vw, 0.88rem);
        gap: 0.25rem;
        letter-spacing: 0;
    }

    .type-icon {
        font-size: 0.9rem;
    }

    .match-btn {
        min-height: 48px;
        font-size: 1.05rem;
        touch-action: manipulation;
    }

    .share-btn,
    .reset-btn {
        min-height: 44px;
        touch-action: manipulation;
    }

    .result-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .result-actions button {
        width: 100%;
    }

    .element-tags {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.35rem;
    }

    .score-insight {
        font-size: 0.95rem;
        padding-inline: 0.25rem;
    }
}

@media (max-width: 560px) {
    :root {
        --ring-size: min(68vw, 180px);
    }

    .sign-selectors {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .versus {
        padding-top: 0;
    }

    .versus-ring {
        margin: 0 auto;
        transform: rotate(90deg);
    }

    .sign-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.4rem;
    }

    .match-card,
    .result-card {
        padding: 1.25rem;
    }

    .score-value {
        font-size: 2.75rem;
    }

    .grid-name {
        font-size: 0.6rem;
    }
}
