:root {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
    color: #191f28;
    background: #fff;
    --blue: #3182f6;
    --muted: #6b7684;
    font-synthesis: none;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

button, input {
    font: inherit;
}

button {
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;
}

button:disabled {
    opacity: .45;
    cursor: default;
}

[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 3px solid #90bfff;
    outline-offset: 5px;
}

h1, h2, p {
    margin: 0;
}

h1 {
    font-size: 36px;
    line-height: 1.35;
    letter-spacing: -1.3px;
}

h2 {
    font-size: 19px;
    letter-spacing: -.5px;
}

.header {
    border-bottom: 1px solid #e5e8eb;
}

.header-inner {
    max-width: 1040px;
    margin: auto;
    padding: 22px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-logo {
    display: block;
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.brand-title {
    font-size: 18px;
    font-weight: 750;
    white-space: nowrap;
}

.header nav {
    display: flex;
    align-items: center;
    gap: 24px;
    color: var(--muted);
    font-size: 14px;
}

.header nav button {
    padding: 0;
}

.header [aria-current] {
    color: var(--blue);
    font-weight: 700;
}

.page {
    max-width: 800px;
    margin: auto;
    padding: 48px 32px 64px;
    min-height: calc(100vh - 175px);
}

.page-heading {
    padding-bottom: 28px;
    border-bottom: 1px solid #e5e8eb;
}

.page-heading p {
    margin-top: 12px;
    font-size: 15px;
    color: var(--muted);
    line-height: 1.7;
}

.click-area {
    text-align: center;
    padding: 16px 0 8px;
    margin-top: 28px;
}

.click-area h2 {
    color: #191f28;
    font-size: 19px;
    text-align: left;
    padding-left: 12px;
    border-left: 3px solid var(--blue);
}

.big-number {
    font-size: clamp(48px, 8vw, 68px);
    font-weight: 750;
    letter-spacing: -2px;
    font-variant-numeric: tabular-nums;
    margin: 12px 0 24px;
    overflow-wrap: anywhere;
}

.unit {
    font-size: 20px;
    margin-left: 8px;
    color: #8b95a1;
    letter-spacing: 0;
}

.primary {
    background: var(--blue);
    color: white;
    border-radius: 12px;
    padding: 17px 24px;
    font-size: 16px;
    font-weight: 650;
}

.save-warning {
    margin-top: 8px;
    color: #d92d20;
    font-size: 14px;
}

.ranking td.rank-loading {
    text-align: center;
    padding: 32px 12px;
    color: var(--muted);
}

.click-button {
    position: relative;
    width: 100%;
    min-height: 180px;
    max-width: 640px;
    font-size: clamp(28px, 5vw, 36px);
    touch-action: manipulation;
    user-select: none;
}

.click-feedback {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.click-plus {
    position: absolute;
    top: 45%;
    font-size: 20px;
    font-weight: 700;
    animation: click-plus 650ms ease-out forwards;
}

@keyframes click-plus {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-45px);
    }
}

.rank-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.rank-heading-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    padding-top: 8px;
    flex-shrink: 0;
    text-align: right;
}

.rank-loading .spinner {
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
    border-color: #3182f633;
    border-top-color: var(--blue);
}

.muted {
    font-size: 14px;
    color: var(--muted);
}

#save-status {
    margin-top: 16px;
    line-height: 1.7;
}

.text-link {
    color: var(--blue);
    font-weight: 600;
    font-size: 14px;
}

.click-area .text-link {
    display: inline-block;
    margin-top: 12px;
}

.stats-section {
    margin-top: 36px;
    padding-top: 28px;
    border-top: 1px solid #e5e8eb;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.refresh-note {
    font-size: 12px;
    color: #8b95a1;
    line-height: 1.7;
}

.global-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 24px;
}

.global-stats > div + div {
    border-left: 1px solid #e5e8eb;
    padding-left: 28px;
}

.global-stats strong {
    display: block;
    font-size: 28px;
    letter-spacing: -.8px;
    font-variant-numeric: tabular-nums;
    margin-top: 10px;
    overflow-wrap: anywhere;
}

.small-unit {
    font-size: 16px;
    color: #8b95a1;
    margin-left: 5px;
}

.footer {
    border-top: 1px solid #e5e8eb;
    text-align: center;
    padding: 26px 20px;
    color: #8b95a1;
    font-size: 12px;
}

.footer a {
    color: #4e5968;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 14px;
}

.auth-section {
    max-width: 440px;
    margin: 32px auto 64px;
}

.auth-section .primary {
    width: 100%;
    margin-top: 32px;
}

.auth-note {
    padding-top: 24px;
    margin-top: 32px;
    border-top: 1px solid #e5e8eb;
    color: #8b95a1;
    font-size: 13px;
    line-height: 1.8;
}

.auth-section #email-login-btn {
    margin-top: 12px;
}

.auth-section .google-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: #131314;
    color: #e3e3e3;
    border: 1px solid #8e918f;
    font-weight: 500;
}

.google-mark {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.email-recipient {
    padding: 16px;
    background: #f7f8fa;
    border-radius: 12px;
}

.email-recipient strong {
    display: block;
    margin-top: 5px;
    font-size: 15px;
    font-weight: 600;
    overflow-wrap: anywhere;
    min-width: 0;
}

.email-recipient-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

#email-change-btn {
    flex-shrink: 0;
    padding: 4px 0;
}

.email-resend {
    display: block;
    width: 100%;
    margin: 12px auto 0;
    padding: 14px 16px;
    border: 1px solid #d1d6db;
    border-radius: 12px;
    background: #f2f4f6;
    color: #4e5968;
}

.email-resend:disabled {
    opacity: 1;
    color: #8b95a1;
}

.email-resend:not(:disabled):hover {
    background: #e5e8eb;
}

.email-auth-form .primary,
.email-auth-form .email-resend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 56px;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 650;
    line-height: 22px;
}

.email-button-loading::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    vertical-align: -3px;
    margin-right: 8px;
    flex-shrink: 0;
    animation: spin .8s linear infinite;
}

.email-auth-form .email-button-loading::before {
    margin-right: 0;
}

.email-auth-form .email-button-success:disabled {
    opacity: 1;
    background: #e8f3ff;
    color: #2272eb;
}

.email-button-success::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 14px;
    border: solid #2272eb;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
    margin: -4px 4px 0 0;
    flex-shrink: 0;
}

.auth-section .email-login {
    background: var(--blue);
    color: #fff;
}

#email-recaptcha {
    margin-top: 20px;
    width: 100%;
    min-width: 0;
}

.email-auth-popup #email-recaptcha-status {
    margin: 8px 0 0;
    font-size: 13px;
}

.popup.email-auth-popup {
    position: relative;
    margin: 0;
    width: min(420px, 100%);
    min-width: 0;
    max-width: 100%;
    padding: clamp(16px, 4vw, 24px);
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
}

.email-auth-layer {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: clamp(12px, 3vw, 20px);
    background: #191f2866;
}

.email-auth-popup .email-auth-form input {
    min-width: 0;
    max-width: 100%;
    padding: 14px;
    margin: 8px 0 0;
    border: 1px solid #d1d6db;
}

.email-auth-popup .email-auth-form .primary {
    margin-top: 14px;
}

.email-auth-form label {
    display: block;
    margin-top: 20px;
    font-size: 14px;
}

.email-auth-form input {
    width: 100%;
    padding: 14px;
    margin-top: 8px;
    border: 1px solid #d1d6db;
    border-radius: 10px;
}

.email-auth-form .primary {
    margin-top: 14px;
}

#email-auth-status, #email-auth-error {
    margin-top: 12px;
    font-size: 13px;
    line-height: 1.7;
    overflow-wrap: anywhere;
}

#email-auth-status:empty,
#email-auth-error:empty {
    display: none;
}

.email-auth-popup #email-auth-status,
.email-auth-popup #email-auth-error {
    margin-bottom: 0;
    white-space: pre-line;
}

.email-auth-popup #email-auth-description {
    white-space: pre-line;
}

.email-auth-form {
    min-width: 0;
}

#email-auth-error {
    color: #d92d20;
}

.auth-note a {
    margin-left: 8px;
    color: var(--muted);
}

.secondary-link {
    display: block;
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--muted);
}

.ranking {
    margin-top: 24px;
}

.search-form {
    display: flex;
    align-items: center;
    gap: 20px;
    border-bottom: 2px solid #d1d6db;
}

.search-form input {
    width: 100%;
    min-width: 0;
    border: 0;
    padding: 16px 0;
    color: #191f28;
    background: transparent;
}

.search-form input::placeholder {
    color: #8b95a1;
}

.search-form button {
    padding: 16px 0;
    white-space: nowrap;
}

.rank-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 28px 0 20px;
}

.rank-meta h2 {
    font-size: 16px;
}

.rank-meta label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--muted);
}

.rank-meta input {
    accent-color: var(--blue);
}

table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    text-align: left;
}

th {
    background: #f7f8fa;
    color: var(--muted);
    padding: 15px 12px;
    font-size: 12px;
    font-weight: 500;
}

th:first-child {
    width: 65px;
}

th:last-child {
    width: 130px;
    text-align: right;
}

td {
    padding: 20px 12px;
    border-bottom: 1px solid #eef0f3;
    font-size: 15px;
    overflow-wrap: anywhere;
}

td:first-child {
    color: #8b95a1;
}

td:last-child {
    text-align: right;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.rank-top td:first-child {
    color: var(--blue);
    font-weight: 750;
}

.blocked-label {
    display: inline-block;
    margin-left: 8px;
    color: #f04452;
    font-size: 11px;
}

.popup {
    width: min(420px, calc(100% - 40px));
    border: 0;
    border-radius: 24px;
    padding: 30px;
    color: #191f28;
    box-shadow: 0 24px 80px #0002;
}

.popup::backdrop {
    background: #191f2866;
}

.popup h2 {
    font-size: 23px;
}

.popup p {
    margin: 16px 0 24px;
    font-size: 15px;
    line-height: 1.7;
    color: var(--muted);
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.popup .primary {
    width: 100%;
}

.popup-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.popup-heading button {
    padding: 0 4px;
    font-size: 28px;
    color: #8b95a1;
}

.popup label {
    font-size: 13px;
    color: var(--muted);
}

.popup input {
    display: block;
    width: 100%;
    padding: 15px 0;
    margin: 8px 0 12px;
    border: 0;
    border-bottom: 2px solid #e5e8eb;
}

.popup small {
    font-size: 12px;
    color: #8b95a1;
}

.popup p.error {
    min-height: 20px;
    margin: 12px 0;
    color: #f04452;
    font-size: 13px;
}

.busy {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    background: #191f28;
    color: #fff;
    padding: 16px 22px;
    border-radius: 16px;
    font-size: 14px;
    max-width: calc(100% - 40px);
    z-index: 10;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff55;
    border-top-color: white;
    border-radius: 50%;
    animation: spin .8s linear infinite;
    flex-shrink: 0;
}

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

}

.sr-only, .skip-link:not(:focus) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}

.skip-link:focus {
    position: fixed;
    top: 8px;
    left: 8px;
    padding: 12px;
    background: white;
    z-index: 20;
}

@media (max-width: 600px) {
    .header-inner {
        padding: 18px 20px;
        gap: 18px;
        flex-wrap: wrap;
    }

    .brand-logo {
        width: 30px;
        height: 30px;
    }

    .brand-title {
        font-size: 16px;
    }

    .header nav {
        font-size: 13px;
        gap: 18px;
        flex-wrap: wrap;
    }

    .page {
        padding: 32px 24px 48px;
    }

    h1 {
        font-size: 30px;
    }

    .click-area {
        padding: 16px 0 8px;
    }

    .global-stats strong {
        font-size: 24px;
    }

    .global-stats > div + div {
        padding-left: 20px;
    }

    .rank-meta label {
        font-size: 11px;
    }

    th:first-child {
        width: 55px;
    }

    th:last-child {
        width: 105px;
    }

    td {
        font-size: 14px;
        padding: 18px 8px;
    }

    .footer {
        font-size: 11px;
    }

}

@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation: none;
    }

    .click-plus {
        animation-duration: 1ms;
    }

}

.account-info {
    margin-top: 28px;
    padding: 24px;
    border: 1px solid #e5e8eb;
    border-radius: 20px;
    background: #f9fafb;
}

.account-info h2 {
    margin: 0 0 16px;
    font-size: 18px;
}

.account-info dl {
    margin: 0;
}

.account-info dl > div {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 12px;
    margin-top: 16px;
}

.account-info dt {
    color: var(--muted);
    font-size: 14px;
}

.account-info dd {
    margin: 0;
    overflow-wrap: anywhere;
    font-weight: 600;
}

.account-help {
    font-size: 13px;
    line-height: 1.6;
    color: var(--muted);
}

.account-delete-help {
    margin-top: 20px;
}

.danger-button {
    padding: 14px 18px;
    border: 1px solid #ffc9cf;
    border-radius: 12px;
    color: #b42332;
    background: #fff1f3;
    font-weight: 650;
}

.account-section > .danger-button {
    width: 100%;
    margin-top: 24px;
}

.account-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 20px;
    align-items: center;
}

.my-rank-button {
    display: inline-block;
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    background: #e8f1ff;
    color: #185abc;
    font-size: 14px;
    text-align: left;
}

.my-rank-button:disabled {
    background: transparent;
    padding-left: 0;
    color: var(--muted);
    opacity: 1;
}

.my-rank-button:focus-visible,
.danger-button:focus-visible {
    outline: 3px solid #3182f6;
    outline-offset: 3px;
}

.ranking .rank-me td {
    background: #e8f1ff;
    border-bottom-color: #bed8ff;
    color: #185abc;
    font-weight: 650;
}

.ranking .rank-me td:first-child {
    box-shadow: inset 4px 0 #3182f6;
    color: #185abc;
}

.mail-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.auth-section .email-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.rank-me-icon {
    display: inline-flex;
    margin-left: 8px;
    vertical-align: middle;
    color: #185abc;
}

.rank-me-icon svg {
    width: 22px;
    height: 22px;
}
