:root {
    color-scheme: light;
    --background: #f4f6f8;
    --surface: #ffffff;
    --text: #1f2933;
    --muted: #637083;
    --border: #d9e0e7;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --focus: rgba(37, 99, 235, 0.2);
    --notice-bg: #f8fafc;
    --success: #16803c;
    --danger: #c93434;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--background);
    color: var(--text);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

body.lightbox-open {
    overflow: hidden;
}

.logo-rain {
    position: fixed;
    z-index: 2;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.logo-rain img {
    position: absolute;
    top: 0;
    left: var(--x);
    width: var(--size);
    height: var(--size);
    object-fit: contain;
    opacity: var(--opacity);
    will-change: transform;
    animation: logo-fall var(--duration) linear var(--delay) both;
}

button,
input,
select {
    font: inherit;
}

.site-shell {
    position: relative;
    z-index: 1;
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 32px 16px;
}

.card {
    width: min(100%, 680px);
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 12px 32px rgba(30, 41, 59, 0.08);
}

.card-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.card-header.is-hidden {
    display: none;
}

.logo {
    display: block;
    width: 88px;
    aspect-ratio: 1;
    object-fit: contain;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: 1.6rem;
    line-height: 1.25;
}

h2 {
    margin-bottom: 8px;
    font-size: 1.35rem;
}

.page {
    display: none;
    max-width: 560px;
    margin-inline: auto;
    padding: 28px;
}

.page.is-active {
    display: block;
}

.intro {
    margin-bottom: 22px;
    color: var(--muted);
}

.notice {
    margin-bottom: 24px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-left: 4px solid #64748b;
    border-radius: 8px;
    background: var(--notice-bg);
    color: #4b5868;
    font-size: 0.88rem;
}

.field {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 7px;
    font-size: 0.92rem;
    font-weight: 650;
}

input,
select {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid #b8c2cc;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

input:hover,
select:hover {
    border-color: #8693a1;
}

input:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--focus);
}

input::placeholder {
    color: #929dab;
}

small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.8rem;
}

button {
    width: 100%;
    min-height: 46px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
    transition: background 150ms ease, transform 100ms ease;
}

button:hover:not(:disabled) {
    background: var(--primary-hover);
}

button:active:not(:disabled) {
    transform: translateY(1px);
}

button:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

button:disabled,
input:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.status {
    min-height: 24px;
    margin: 14px 0 0;
    color: var(--danger);
    font-size: 0.9rem;
}

.status.muted {
    color: var(--muted);
}

.result-page {
    padding-block: 52px;
    text-align: center;
}

.result-page p {
    max-width: 360px;
    margin: 0 auto;
    color: var(--muted);
}

.pending-page {
    padding-block: 76px;
    text-align: center;
}

.pending-logo {
    width: 180px;
    height: 180px;
    margin: 0 auto 24px;
    animation: spin 1.1s linear infinite;
}

.pending-text {
    margin: 0;
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 650;
}

.code-input {
    height: 58px;
    text-align: center;
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: 0.5em;
    padding-left: calc(12px + 0.5em);
}

#code-page {
    max-width: 620px;
}

.device-tutorial {
    margin-top: 32px;
    padding-top: 28px;
    border-top: 1px solid var(--border);
}

.tutorial-heading {
    margin-bottom: 18px;
}

.tutorial-kicker {
    margin-bottom: 3px;
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 750;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.device-tutorial h3 {
    margin: 0;
    font-size: 1.15rem;
}

.tutorial-steps {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tutorial-step {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

.tutorial-image-button {
    display: block;
    width: 100%;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: inherit;
}

.tutorial-image-button:hover:not(:disabled) {
    background: transparent;
}

.tutorial-image-button:focus-visible {
    position: relative;
    z-index: 1;
    outline: 3px solid var(--primary);
    outline-offset: -3px;
}

.tutorial-image-button img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 2;
    border-bottom: 1px solid var(--border);
    background: #eef3f8;
    object-fit: cover;
    cursor: zoom-in;
    transition: transform 180ms ease, filter 180ms ease;
}

.tutorial-image-button:hover img {
    transform: scale(1.02);
    filter: brightness(0.96);
}

.step-copy {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px;
}

.step-copy span {
    display: grid;
    flex: 0 0 26px;
    height: 26px;
    place-items: center;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 750;
}

.step-copy p {
    margin: 1px 0 0;
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.4;
}

.tutorial-fallback {
    color: var(--muted);
}

.tutorial-fallback p {
    margin: 7px 0 0;
}

.lightbox[hidden] {
    display: none;
}

.lightbox {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(10, 15, 24, 0.88);
    backdrop-filter: blur(5px);
}

.lightbox-dialog {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    width: min(100%, 1100px);
}

.lightbox-figure {
    min-width: 0;
    margin: 0;
    text-align: center;
}

.lightbox-figure img {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: min(76vh, 820px);
    margin: 0 auto;
    border-radius: 12px;
    background: #fff;
    object-fit: contain;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.lightbox-figure figcaption {
    margin-top: 15px;
    color: #fff;
    font-size: 1rem;
    font-weight: 650;
}

.lightbox-position {
    margin: 4px 0 0;
    color: #cbd5e1;
    font-size: 0.875rem;
}

.lightbox-control {
    display: grid;
    width: 48px;
    min-height: 48px;
    padding: 0;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 1.65rem;
    line-height: 1;
}

.lightbox-control:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.25);
}

.lightbox-close {
    position: absolute;
    z-index: 1;
    top: 18px;
    right: 18px;
}

.result-icon {
    display: grid;
    width: 54px;
    height: 54px;
    margin: 0 auto 18px;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    font-size: 1.5rem;
    font-weight: 800;
}

.result-icon.success {
    background: var(--success);
}

.result-icon.error {
    background: var(--danger);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes logo-fall {
    0% {
        transform: translate3d(0, -15vh, 0) rotate(-18deg);
    }

    50% {
        transform: translate3d(var(--sway), 52vh, 0) rotate(12deg);
    }

    100% {
        transform: translate3d(var(--drift), 115vh, 0) rotate(38deg);
    }
}

@media (max-width: 520px) {
    .site-shell {
        align-items: start;
        padding: 16px 12px;
    }

    .card-header,
    .page {
        padding: 22px 20px;
    }

    .pending-page,
    .result-page {
        padding-block: 42px;
    }

    .tutorial-steps {
        grid-template-columns: 1fr;
    }

    .lightbox {
        padding: 58px 12px 20px;
    }

    .lightbox-dialog {
        position: relative;
        display: block;
    }

    .lightbox-arrow {
        position: absolute;
        z-index: 2;
        top: 50%;
        width: 44px;
        min-height: 44px;
        transform: translateY(-50%);
        background: rgba(10, 15, 24, 0.68);
    }

    #lightbox-previous {
        left: 8px;
    }

    #lightbox-next {
        right: 8px;
    }

    .lightbox-figure img {
        max-height: 70vh;
    }
}

@media (prefers-reduced-motion: reduce) {
    .logo-rain {
        display: none;
    }

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
