:root {
    --wine: #722f37;
    --wine-deep: #4a1c22;
    --wine-soft: rgba(114, 47, 55, 0.12);
    --camel: #c19a6b;
    --camel-soft: #f3e6d4;
    --cream: #faf6f1;
    --ink: #1c1412;
    --muted: #6b5e57;
    --line: rgba(114, 47, 55, 0.16);
    --ok: #15803d;
    --err: #b91c1c;
    --radius: 22px;
    --shadow: 0 24px 60px rgba(74, 28, 34, 0.18);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Segoe UI", ui-sans-serif, -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(193, 154, 107, 0.35), transparent 55%),
        radial-gradient(900px 500px at 100% 0%, rgba(114, 47, 55, 0.22), transparent 50%),
        linear-gradient(165deg, #f7efe6 0%, var(--cream) 45%, #efe4d8 100%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    padding: calc(20px + var(--safe-top)) 16px calc(28px + var(--safe-bottom));
}

.bg-orb {
    position: fixed;
    inset: auto;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    filter: blur(40px);
    opacity: 0.35;
    pointer-events: none;
    z-index: 0;
    animation: drift 14s ease-in-out infinite alternate;
}
.bg-orb.a {
    top: 8%;
    left: -80px;
    background: #c19a6b;
}
.bg-orb.b {
    bottom: 10%;
    right: -90px;
    background: #722f37;
    animation-delay: -4s;
}

@keyframes drift {
    from { transform: translateY(0) scale(1); }
    to { transform: translateY(-24px) scale(1.08); }
}

.shell {
    position: relative;
    z-index: 1;
    width: min(100%, 440px);
    margin: 0 auto;
}

.brand {
    text-align: center;
    margin-bottom: 18px;
}

.brand h1 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 600;
    font-size: clamp(1.35rem, 4.5vw, 1.7rem);
    letter-spacing: 0.02em;
    color: var(--wine-deep);
    opacity: 0;
    animation: rise 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.85s forwards;
}

.brand p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
    opacity: 0;
    animation: rise 0.8s cubic-bezier(0.22, 1, 0.36, 1) 1s forwards;
}

.logo-wrap {
    position: relative;
    width: min(72vw, 240px);
    margin: 0 auto 14px;
    /* Soft brand shadow — no box/border */
    filter: drop-shadow(0 14px 28px rgba(74, 28, 34, 0.16));
}

.logo-wrap::after {
    content: "";
    position: absolute;
    inset: -8% -4%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(254, 175, 15, 0.22), transparent 68%);
    opacity: 0;
    pointer-events: none;
    z-index: 0;
    animation: logoGlow 1.4s ease 0.35s forwards;
}

.logo-wrap img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: auto;
    display: block;
    background: transparent;
    border: 0;
    outline: none;
    box-shadow: none;
    transform-origin: 50% 40%;
    /* Clean reveal: fade + soft rise + slight unblur */
    animation: logoReveal 1.25s cubic-bezier(0.22, 1, 0.36, 1) 0.15s both;
}

@keyframes logoReveal {
    0% {
        opacity: 0;
        transform: translateY(18px) scale(0.9);
        filter: blur(8px);
    }
    55% {
        opacity: 1;
        transform: translateY(-3px) scale(1.03);
        filter: blur(0);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

@keyframes logoGlow {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1); }
}

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

.card {
    background: rgba(255, 252, 248, 0.92);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    opacity: 0;
    animation: rise 0.85s cubic-bezier(0.22, 1, 0.36, 1) 0.25s forwards;
}

.tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 10px;
    background: linear-gradient(180deg, rgba(114, 47, 55, 0.06), transparent);
    border-bottom: 1px solid var(--line);
}

.tab-btn {
    appearance: none;
    border: 0;
    background: transparent;
    border-radius: 14px;
    padding: 12px 10px;
    font: inherit;
    font-weight: 700;
    font-size: 0.86rem;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.2s, color 0.2s, opacity 0.2s, box-shadow 0.2s;
}

.tab-btn.active {
    background: #fff;
    color: var(--wine);
    box-shadow: 0 6px 16px rgba(114, 47, 55, 0.1);
}

.tab-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.tab-btn:disabled .lock {
    display: inline;
}

.tab-btn .lock {
    display: none;
    margin-left: 4px;
    font-size: 0.75rem;
}

.panel {
    display: none;
    padding: 18px 18px 20px;
}

.panel.active {
    display: block;
    animation: fadePanel 0.35s ease;
}

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

.panel h2 {
    margin: 0 0 8px;
    font-size: 1.05rem;
    color: var(--wine-deep);
}

.panel .lead {
    margin: 0 0 14px;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.45;
}

.terms-box {
    height: min(42vh, 320px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #fff, #fbf7f2);
    font-size: 0.82rem;
    line-height: 1.55;
    color: #3b2f2a;
    scroll-behavior: smooth;
}

.terms-box h3 {
    margin: 14px 0 6px;
    font-size: 0.88rem;
    color: var(--wine);
}

.terms-box h3:first-child {
    margin-top: 0;
}

.terms-box p {
    margin: 0 0 8px;
}

.terms-hint {
    margin: 10px 0 0;
    font-size: 0.75rem;
    color: var(--muted);
    text-align: center;
}

.terms-end {
    height: 1px;
    width: 100%;
    margin-top: 8px;
}

.btn-agree {
    appearance: none;
    display: block;
    width: 100%;
    margin-top: 14px;
    padding: 16px 18px;
    min-height: 52px;
    border: 2px solid var(--wine);
    border-radius: 14px;
    background: #fff;
    color: var(--wine);
    font: inherit;
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: 0.01em;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(114, 47, 55, 0.2);
    touch-action: manipulation;
    position: relative;
    z-index: 5;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.btn-agree:active {
    transform: scale(0.98);
}

.btn-agree.ready,
.btn-agree:hover {
    background: rgba(114, 47, 55, 0.06);
}

.btn-agree.accepted {
    background: linear-gradient(135deg, var(--wine) 0%, var(--wine-deep) 100%);
    color: #fff;
    border-color: var(--wine-deep);
    box-shadow: 0 12px 28px rgba(114, 47, 55, 0.28);
}

#statusTerms {
    margin-top: 10px;
}

.btn {
    appearance: none;
    width: 100%;
    border: 0;
    border-radius: 14px;
    padding: 14px 16px;
    min-height: 48px;
    margin-top: 14px;
    font: inherit;
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: 0.02em;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(114, 47, 55, 0.15);
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.2s, background 0.2s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--wine) 0%, var(--wine-deep) 100%);
    box-shadow: 0 12px 28px rgba(114, 47, 55, 0.28);
}

.btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
    pointer-events: none;
}

.btn-primary.pulse {
    animation: pulseBtn 1.6s ease-in-out infinite;
}

@keyframes pulseBtn {
    0%, 100% { box-shadow: 0 12px 28px rgba(114, 47, 55, 0.28); }
    50% { box-shadow: 0 12px 34px rgba(114, 47, 55, 0.45); }
}

.field {
    margin-top: 12px;
}

.field label {
    display: block;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
}

.field input {
    width: 100%;
    border: 1.5px solid var(--line);
    border-radius: 14px;
    padding: 14px 16px;
    font-size: 1.15rem;
    letter-spacing: 0.18em;
    text-align: center;
    font-weight: 700;
    color: var(--wine-deep);
    background: #fff;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus {
    border-color: var(--wine);
    box-shadow: 0 0 0 4px var(--wine-soft);
}

.field input:disabled {
    background: #f3eee8;
    color: #9a8d85;
}

.meta {
    margin-top: 12px;
    font-size: 0.75rem;
    color: var(--muted);
    text-align: center;
    line-height: 1.4;
}

.status {
    display: none;
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 0.84rem;
    text-align: center;
}

.status.show {
    display: block;
}

.status.err {
    background: #fef2f2;
    color: var(--err);
}

.status.ok {
    background: #f0fdf4;
    color: var(--ok);
}

.footer-note {
    margin-top: 16px;
    text-align: center;
    font-size: 0.72rem;
    color: var(--muted);
    opacity: 0;
    animation: rise 0.8s ease 0.5s forwards;
}

@media (min-width: 768px) {
    body {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
        padding: 40px 24px;
    }

    .shell {
        width: min(100%, 480px);
    }

    .terms-box {
        height: 280px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}
