* {
    box-sizing: border-box;
}

:root {
    color-scheme: light;
    --background: #edf3f8;
    --panel: #ffffff;
    --text: #1d2d3d;
    --muted: #526273;
    --accent: #2f67a1;
    --border: #8fa7bf;
}

body {
    min-height: 100vh;
    margin: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    color: var(--text);
    background: var(--background);
    font-family: Verdana, Arial, Helvetica, sans-serif;
}

.profile-shell {
    width: min(100%, 560px);
    padding: clamp(30px, 6vw, 56px);
    text-align: center;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 2px;
    box-shadow: 0 14px 36px rgb(53 79 104 / 15%);
}

.eyebrow {
    margin: 0 0 14px;
    color: #183d63;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.16em;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 12px;
    color: #183d63;
    font-size: clamp(2.2rem, 7vw, 4rem);
    line-height: 1;
}

.message,
.profile-card p {
    color: var(--muted);
    line-height: 1.6;
}

.users-directory {
    margin: 28px 0;
    padding: 22px;
    text-align: left;
    background: #f7fafc;
    border: 1px solid var(--border);
}

.directory-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.directory-heading .eyebrow {
    margin-bottom: 6px;
}

.directory-heading h2 {
    margin: 0;
    color: #183d63;
}

.directory-count {
    color: var(--muted);
    font-size: 0.75rem;
    white-space: nowrap;
}

.directory-table {
    overflow: hidden;
    border: 1px solid var(--border);
    background: #ffffff;
}

.directory-row {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(74px, 0.65fr);
    gap: 14px;
    align-items: center;
    min-height: 52px;
    padding: 12px 14px;
    border-bottom: 1px solid #d8e2ea;
}

.directory-row:last-child {
    border-bottom: 0;
}

.directory-header {
    min-height: 42px;
    color: #183d63;
    background: #e8f0f6;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.directory-row span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.directory-user {
    color: var(--text);
    font-weight: 700;
}

.directory-value {
    color: var(--muted);
    font-size: 0.78rem;
}

.directory-empty {
    margin: 0;
    padding: 18px 14px;
    color: var(--muted);
    font-size: 0.82rem;
}

.profile-card {
    display: flex;
    align-items: center;
    gap: 18px;
    margin: 28px 0;
    padding: 20px;
    text-align: left;
    background: #eef4f9;
    border: 1px solid var(--border);
}

.avatar {
    display: grid;
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    place-items: center;
    color: #ffffff;
    background: var(--accent);
    border-radius: 50%;
    font-size: 1.6rem;
    font-weight: 700;
}

.profile-card h2 {
    margin-bottom: 6px;
    color: #183d63;
}

.profile-card p {
    margin-bottom: 4px;
}

.profile-note {
    font-size: 0.8rem;
}

.profile-tools {
    margin-top: 24px;
    padding: 20px;
    text-align: left;
    background: #f7fafc;
    border: 1px solid var(--border);
}

.profile-tools h2,
.profile-tools h3 {
    margin: 0 0 14px;
    color: #183d63;
}

.profile-form {
    display: grid;
    gap: 8px;
}

.profile-form label,
.setting,
.agreement {
    color: var(--muted);
    font-size: 0.78rem;
}

.profile-form input,
.profile-form textarea,
.profile-form select,
.friend-search input,
.avatar-options select {
    width: 100%;
    padding: 9px;
    color: var(--text);
    background: #ffffff;
    border: 1px solid var(--border);
    font: inherit;
}

.profile-form textarea {
    min-height: 76px;
    resize: vertical;
}

.profile-form button,
.photo-tools button,
.avatar-editor button {
    justify-self: start;
    margin-top: 8px;
}

.avatar-editor,
.photo-tools {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.avatar-large {
    margin-bottom: 14px;
}

.avatar.orange { background: #d36c42; }
.avatar.sky { background: #3f9bc2; }
.avatar.wide { box-shadow: 0 0 0 5px #ffffff, 0 0 0 7px var(--accent); }
.avatar.badge::after { content: "*"; color: #ffffff; font-size: 0.8rem; }

.avatar-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.avatar-options label {
    color: var(--muted);
    font-size: 0.72rem;
}

.file-label,
.secondary-button {
    display: inline-block;
    margin-top: 8px;
    padding: 10px 14px;
    color: var(--accent);
    background: #ffffff;
    border: 1px solid var(--accent);
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
}

.agreement {
    display: block;
    margin: 14px 0 4px;
}

.agreement input {
    margin-right: 6px;
}

.photo-tools button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.friend-search {
    display: flex;
    gap: 8px;
}

.friend-search button {
    margin: 0;
    white-space: nowrap;
}

.friend-results {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.friend-result {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: #ffffff;
    border: 1px solid var(--border);
}

.friend-result span {
    color: var(--muted);
    font-size: 0.75rem;
}

.friend-result button {
    margin: 0;
    padding: 7px 10px;
    font-size: 0.72rem;
}

.profile-actions,
.profile-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
}

.profile-stats span {
    padding: 8px 10px;
    color: var(--muted);
    background: #ffffff;
    border: 1px solid var(--border);
    font-size: 0.75rem;
}

.compact-friends {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0 12px;
}

.compact-friend {
    flex: 0 0 92px;
    padding: 8px;
    color: var(--text);
    background: #ffffff;
    border: 1px solid var(--border);
    text-align: center;
    text-decoration: none;
    font-size: 0.72rem;
}

.compact-friend .avatar {
    margin: 0 auto 6px;
    width: 42px;
    height: 42px;
    font-size: 1rem;
}

.profile-actions button,
.profile-tools > .secondary-button {
    margin-top: 0;
}

.rules-dialog {
    max-width: 520px;
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: 0 18px 60px rgb(29 45 61 / 30%);
}

.rules-dialog::backdrop {
    background: rgb(29 45 61 / 45%);
}

.rules-dialog li,
.rules-dialog p {
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.55;
}

.profile-link {
    display: inline-block;
    margin: 22px 10px 0 0;
    color: var(--accent);
}

button {
    padding: 12px 24px;
    color: #ffffff;
    background: var(--accent);
    border: 1px solid #1d4772;
    border-radius: 2px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

button:hover,
button:focus-visible {
    background: #3f7fbe;
}

button:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 3px;
}

@media (max-width: 480px) {
    .directory-row {
        grid-template-columns: 1fr 1fr;
        gap: 8px 12px;
    }

    .directory-header {
        min-height: 0;
    }

    .directory-row span:nth-child(2),
    .directory-row span:nth-child(3),
    .directory-row span:nth-child(4) {
        padding-top: 4px;
    }

    .profile-card {
        align-items: flex-start;
        flex-direction: column;
    }

    .avatar-options,
    .friend-result {
        grid-template-columns: 1fr;
    }

    .friend-search {
        flex-direction: column;
    }
}
