:root {
    --ink: #263246;
    --muted: #667085;
    --cream: #fffaf4;
    --paper: rgba(255, 255, 255, 0.88);
    --blue: #3178c6;
    --blue-soft: #e5f3fc;
    --blue-line: #b8dff5;
    --pink: #cc4f87;
    --pink-soft: #fce8f0;
    --pink-line: #f4bad2;
    --focus: #7b5ce1;
    --shadow: 0 24px 70px rgba(49, 56, 82, 0.12);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
    min-height: 100%;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 50% -10%, rgba(255, 255, 255, 0.95) 0 20%, transparent 48%),
        linear-gradient(145deg, #fff9f2 0%, #fffdf9 48%, #f8fbff 100%);
    font-family: Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.5;
    overflow-x: hidden;
}

button, input { font: inherit; }
button { color: inherit; }

button:focus-visible,
input:focus-visible,
label:has(input:focus-visible) {
    outline: 3px solid color-mix(in srgb, var(--focus) 55%, white);
    outline-offset: 3px;
}

.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;
}

.ambient {
    position: fixed;
    width: min(78vw, 540px);
    aspect-ratio: 1;
    border-radius: 999px;
    filter: blur(8px);
    opacity: 0.58;
    pointer-events: none;
    z-index: -1;
}

.ambient--blue {
    top: -25vw;
    left: -38vw;
    background: radial-gradient(circle, rgba(158, 214, 247, 0.6), rgba(158, 214, 247, 0));
}

.ambient--pink {
    right: -40vw;
    top: 28vh;
    background: radial-gradient(circle, rgba(248, 177, 205, 0.55), rgba(248, 177, 205, 0));
}

.vote-shell {
    width: min(100% - 28px, 660px);
    margin: 0 auto;
    padding: max(32px, env(safe-area-inset-top)) 0 max(34px, env(safe-area-inset-bottom));
}

.hero { text-align: center; padding: 6px 8px 25px; }

.hero__mark {
    width: 54px;
    height: 54px;
    margin: 0 auto 14px;
    position: relative;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--blue-soft) 0 49%, var(--pink-soft) 51% 100%);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8), 0 10px 30px rgba(87, 93, 123, 0.12);
    transform: rotate(6deg);
}

.hero__mark::before,
.hero__mark::after,
.hero__mark span {
    content: "";
    position: absolute;
    border-radius: 999px;
    background: white;
}

.hero__mark::before { width: 9px; height: 9px; left: 13px; top: 13px; }
.hero__mark::after { width: 7px; height: 7px; right: 12px; bottom: 12px; }
.hero__mark span { width: 14px; height: 14px; left: 22px; top: 21px; }

.eyebrow {
    margin: 0 0 7px;
    color: #846d65;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.17em;
    text-transform: uppercase;
}

.hero h1 {
    margin: 0;
    font-size: clamp(2.45rem, 11.5vw, 4.7rem);
    line-height: 0.98;
    letter-spacing: -0.055em;
    text-wrap: balance;
}

.hero__intro { margin: 16px 0 10px; color: var(--muted); font-size: 1.05rem; }

.deadline-note {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 7px 13px;
    border: 1px solid rgba(113, 103, 98, 0.12);
    border-radius: 999px;
    color: #75655d;
    background: rgba(255, 255, 255, 0.62);
    font-size: 0.78rem;
    font-weight: 700;
}

.card {
    border: 1px solid rgba(255, 255, 255, 0.92);
    border-radius: 30px;
    background: var(--paper);
    box-shadow: var(--shadow);
    backdrop-filter: blur(20px);
}

.vote-card { padding: clamp(21px, 6vw, 38px); }
.form-heading { margin-bottom: 17px; }
.form-heading h2, .section-heading h2, .success-panel h2 { margin: 0; font-size: clamp(1.55rem, 7vw, 2.1rem); letter-spacing: -0.035em; }

.name-input {
    width: 100%;
    min-height: 60px;
    padding: 0 18px;
    border: 1.5px solid #dce1e8;
    border-radius: 17px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.92);
    font-size: 1.05rem;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.name-input::placeholder { color: #9ba4b0; }
.name-input:focus { border-color: #8d80c9; box-shadow: 0 0 0 5px rgba(123, 92, 225, 0.08); outline: 0; }

.choice-fieldset { margin: 25px 0 0; padding: 0; border: 0; }
.choice-fieldset legend { margin-bottom: 11px; font-size: 0.82rem; font-weight: 800; letter-spacing: 0.04em; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }

.choice {
    min-width: 0;
    min-height: 146px;
    padding: 17px 10px;
    border: 2px solid transparent;
    border-radius: 22px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 170ms ease, border-color 170ms ease, box-shadow 170ms ease;
}

.choice:hover { transform: translateY(-2px); }
.choice--boy { background: linear-gradient(145deg, #eff9ff, var(--blue-soft)); border-color: var(--blue-line); color: #235e99; }
.choice--girl { background: linear-gradient(145deg, #fff4f8, var(--pink-soft)); border-color: var(--pink-line); color: #a83c6c; }
.choice--boy.choice--selected { border-color: var(--blue); box-shadow: 0 13px 28px rgba(49, 120, 198, 0.18), inset 0 0 0 2px white; transform: translateY(-3px); }
.choice--girl.choice--selected { border-color: var(--pink); box-shadow: 0 13px 28px rgba(204, 79, 135, 0.18), inset 0 0 0 2px white; transform: translateY(-3px); }
.choice__symbol { font-size: 1.65rem; line-height: 1; }
.choice__label { margin-top: 7px; font-size: 1.25rem; font-weight: 900; letter-spacing: 0.05em; text-transform: uppercase; }
.choice__hint { margin-top: 3px; color: color-mix(in srgb, currentColor 70%, white); font-size: 0.72rem; font-weight: 650; }

.primary-button,
.secondary-button {
    width: 100%;
    min-height: 58px;
    padding: 0 20px;
    border: 0;
    border-radius: 17px;
    cursor: pointer;
    font-weight: 850;
    transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.primary-button {
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
    background: linear-gradient(105deg, #4f79ba 0%, #8a6dbe 50%, #c65f8e 100%);
    box-shadow: 0 14px 28px rgba(94, 80, 154, 0.22);
}

.primary-button:not(:disabled):hover, .secondary-button:hover { transform: translateY(-2px); }
.primary-button:disabled { cursor: not-allowed; opacity: 0.42; box-shadow: none; }
.primary-button.is-loading { color: transparent; position: relative; }
.primary-button.is-loading::after { content: ""; position: absolute; inset: 0; margin: auto; width: 22px; height: 22px; border: 3px solid rgba(255,255,255,.35); border-top-color: white; border-radius: 50%; animation: spin 700ms linear infinite; }
.secondary-button { color: #624f8f; background: #f1ecfb; }

.form-error { margin: 13px 0 -5px; padding: 10px 12px; border-radius: 12px; color: #9f2843; background: #fff0f3; font-size: 0.86rem; font-weight: 700; }

.success-panel { text-align: center; padding: 7px 0 1px; }
.success-panel__icon {
    display: grid;
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    place-items: center;
    border-radius: 50%;
    color: white;
    background: linear-gradient(135deg, #62a3dc, #cd658f);
    box-shadow: 0 10px 24px rgba(100, 88, 151, 0.22);
    font-size: 1.5rem;
    font-weight: 900;
}
.success-panel > p:not(.eyebrow) { color: var(--muted); font-size: 1.03rem; }
.success-panel hr { width: 46px; margin: 25px auto 21px; border: 0; border-top: 2px solid #ede9e5; }
.success-panel h3 { margin: 0 0 5px; }
.success-panel h3 + p { margin: 0 0 15px; color: var(--muted); font-size: 0.9rem; }

.notice { display: flex; gap: 13px; align-items: center; padding: 16px; border-radius: 18px; }
.notice--closed { color: #635243; background: #f5eee4; }
.notice__icon { display: grid; width: 38px; height: 38px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: white; background: #978271; font-weight: 900; }

.own-votes { margin-top: 17px; padding: clamp(20px, 5.5vw, 32px); }
.section-heading { margin-bottom: 14px; }
.own-votes__list { display: grid; gap: 9px; }
.own-vote { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 13px; padding: 13px 14px 13px 17px; border-radius: 16px; }
.own-vote--boy { background: var(--blue-soft); color: #2c6195; }
.own-vote--girl { background: var(--pink-soft); color: #9d4169; }
.own-vote h3, .own-vote p { margin: 0; }
.own-vote h3 { max-width: 34ch; overflow: hidden; text-overflow: ellipsis; font-size: 1rem; white-space: nowrap; }
.own-vote p { margin-top: 2px; font-size: 0.79rem; font-weight: 750; }
.text-button { padding: 8px 10px; border: 0; border-radius: 10px; color: inherit; background: rgba(255,255,255,.62); cursor: pointer; font-size: 0.76rem; font-weight: 800; white-space: nowrap; }
.limit-note { margin: 14px 0 0; color: var(--muted); font-size: 0.81rem; text-align: center; }
.privacy-note { max-width: 390px; margin: 20px auto 0; color: #8b8e96; font-size: 0.72rem; text-align: center; }

.edit-dialog { width: min(100% - 24px, 480px); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: 27px; background: white; color: var(--ink); box-shadow: 0 25px 90px rgba(33, 37, 52, 0.28); }
.edit-dialog::backdrop { background: rgba(38, 50, 70, 0.45); backdrop-filter: blur(6px); }
.edit-dialog__surface { position: relative; padding: 29px 24px 25px; }
.edit-dialog h2 { margin: 0 35px 20px 0; font-size: 1.5rem; letter-spacing: -.03em; }
.dialog-close { position: absolute; top: 14px; right: 14px; width: 38px; height: 38px; border: 0; border-radius: 50%; cursor: pointer; color: #6d7380; background: #f3f4f7; font-size: 1.5rem; line-height: 1; }
.edit-options { display: grid; gap: 9px; }
.edit-option { display: block; border: 2px solid transparent; border-radius: 16px; cursor: pointer; }
.edit-option input { position: absolute; opacity: 0; pointer-events: none; }
.edit-option span { display: flex; min-height: 66px; padding: 12px 15px; border-radius: 14px; flex-direction: column; justify-content: center; }
.edit-option--boy span { color: #2c6195; background: var(--blue-soft); }
.edit-option--girl span { color: #9d4169; background: var(--pink-soft); }
.edit-option:has(input:checked) { border-color: currentColor; }
.edit-option b { font-size: 1rem; }
.edit-option small { opacity: .76; }

.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 20; width: max-content; max-width: calc(100% - 30px); padding: 12px 18px; border-radius: 999px; color: white; background: #2d3545; box-shadow: 0 10px 30px rgba(22, 28, 40, .25); font-size: .86rem; font-weight: 750; opacity: 0; transform: translate(-50%, 12px); transition: opacity 200ms ease, transform 200ms ease; }
.toast--visible { opacity: 1; transform: translate(-50%, 0); }

.confetti-canvas { position: fixed; inset: 0; z-index: 50; width: 100%; height: 100%; pointer-events: none; opacity: 0; }
.confetti-canvas--active { opacity: 1; }
.confetti-canvas--flash { opacity: .18; animation: flash 420ms ease both; }
.confetti-canvas--boy { background: var(--blue); }
.confetti-canvas--girl { background: var(--pink); }

[hidden] { display: none !important; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes flash { 50% { opacity: .2; } }

@media (min-width: 620px) {
    .vote-shell { padding-top: 48px; padding-bottom: 56px; }
    .hero { padding-bottom: 30px; }
    .choice { min-height: 158px; }
}

@media (max-width: 370px) {
    .vote-shell { width: min(100% - 18px, 660px); }
    .vote-card, .own-votes { border-radius: 24px; }
    .choice { min-height: 130px; padding-inline: 5px; }
    .choice__label { font-size: 1.05rem; }
    .choice__hint { font-size: .65rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
