@import url('https://fonts.googleapis.com/css2?family=Geologica:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-base: #0d1117;
    --bg-radial: rgba(255, 255, 255, 0.05);
    --bg-grid: rgba(255, 255, 255, 0.035);
    --bg-elevated: rgba(22, 24, 30, 0.82);
    --glass-bg: rgba(30, 30, 35, 0.62);
    --glass-soft: rgba(255, 255, 255, 0.045);
    --glass-border: rgba(255, 255, 255, 0.10);
    --text-primary: #f4f4f5;
    --text-muted: #a1a1aa;
    --accent-color: #e5e7eb;
    --accent-strong: #ffffff;
    --accent-glow: #22c55e;
    --accent-soft: rgba(229, 231, 235, 0.14);
    --accent-border: rgba(229, 231, 235, 0.44);
    --success-color: #22c55e;
    --danger-color: #fb7185;
    --warning-color: #fbbf24;
    --cell-bg: rgba(8, 18, 31, 0.96);
    --shadow-lg: 0 18px 54px rgba(0, 0, 0, 0.42);
    --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.24);
    --blur-strength: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Geologica', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    min-height: 100%;
    overscroll-behavior: none;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--text-primary);
    background:
        radial-gradient(circle at 50% 0%, var(--bg-radial), transparent 38%),
        linear-gradient(135deg, color-mix(in srgb, var(--accent-color) 9%, transparent), transparent 42%),
        var(--bg-base);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.35s ease, color 0.35s ease;
    overscroll-behavior: none;
}

button,
input,
canvas {
    font: inherit;
}

button {
    user-select: none;
}

img {
    max-width: 100%;
}

/* Utility classes used by the markup */
.hidden { display: none !important; }
.relative { position: relative; }
.absolute { position: absolute; }
.top-4 { top: 1rem; }
.right-4 { right: 1rem; }
.w-full { width: 100%; }
.max-w-xs { max-width: 320px; width: 100%; }
.max-w-sm { max-width: 380px; width: 100%; }
.max-w-md { max-width: 470px; width: 100%; }
.max-w-xl { max-width: 720px; width: 100%; }
.max-w-2xl { max-width: 840px; width: 100%; }
.text-center { text-align: center; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-3xl { font-size: clamp(1.9rem, 4vw, 3rem); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-black { font-weight: 800; }
.tracking-wider { letter-spacing: 0.08em; }
.uppercase { text-transform: uppercase; }
.opacity-60 { opacity: 0.6; }
.opacity-70 { opacity: 0.7; }
.opacity-80 { opacity: 0.8; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.p-4 { padding: 1rem; }
.py-1 { padding-top: 0.35rem; padding-bottom: 0.35rem; }
.py-2 { padding-top: 0.6rem; padding-bottom: 0.6rem; }
.px-3 { padding-left: 0.85rem; padding-right: 0.85rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-2 { gap: 0.5rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }
.text-warning { color: var(--warning-color); }
.w-12 { width: 3rem; }
.w-16 { width: 4rem; }
.w-20 { width: 5rem; }

.glass-bg-blur {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.glass-bg-blur::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(var(--bg-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(circle at center, black 0%, transparent 72%);
}

.sphere {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.24;
}

.sphere-1 {
    width: 420px;
    height: 420px;
    background: var(--accent-color);
    top: -120px;
    left: -120px;
}

.sphere-2 {
    width: 520px;
    height: 520px;
    background: var(--accent-glow);
    right: -150px;
    bottom: -170px;
}

.view-panel {
    display: none;
    width: 100%;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 4.5rem 1rem 1.5rem;
}

.view-panel.active-view {
    display: flex;
    animation: fadeIn 0.36s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.glass-card {
    position: relative;
    overflow: hidden;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 28px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(var(--blur-strength)) saturate(130%);
    -webkit-backdrop-filter: blur(var(--blur-strength)) saturate(130%);
}

.glass-card::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 42%);
    opacity: 1;
}

.glass-card > * {
    position: relative;
}

.title-glow,
h1,
h2,
h3 {
    line-height: 1.1;
}

.title-glow {
    font-size: clamp(1.55rem, 4vw, 2.1rem);
    font-weight: 800;
    letter-spacing: 0;
    color: var(--text-primary);
    text-shadow: 0 0 26px rgba(56, 189, 248, 0.28);
}

.subtitle {
    margin: 0.85rem auto 1.5rem;
    max-width: 34ch;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.55;
}

.input-group {
    margin-bottom: 1rem;
}

.auth-card {
    width: 360px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.auth-card .title-glow {
    text-align: center;
    font-size: 1.55rem;
}

.auth-card .subtitle {
    margin: 8px auto 18px;
    text-align: center;
    font-size: 0.9rem;
}

.auth-avatar-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}

#scr-auth .auth-avatar-block {
    width: 100%;
    align-items: center !important;
}

.auth-card .input-group {
    margin-bottom: 10px;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.25rem;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.035);
}

.auth-tab {
    min-height: 38px;
    border: 0;
    border-radius: 11px;
    cursor: pointer;
    color: var(--text-muted);
    background: transparent;
    font-size: 0.8rem;
    font-weight: 800;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.auth-tab.active {
    color: var(--text-primary);
    background: color-mix(in srgb, var(--accent-color) 18%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-color) 26%, transparent);
}

.auth-id-row {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding: 0 14px;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.035);
}

.auth-id-row span {
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 700;
}

.auth-id-row strong {
    color: var(--text-primary);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.82rem;
}

input[type="text"],
input[type="password"],
select {
    min-height: 46px;
    width: 100%;
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    outline: none;
    padding: 0.75rem 0.95rem;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

input[type="text"]::placeholder,
input[type="password"]::placeholder {
    color: color-mix(in srgb, var(--text-muted) 82%, transparent);
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
    border-color: color-mix(in srgb, var(--accent-color) 72%, white);
    background: rgba(0, 0, 0, 0.24);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

select option {
    color: #111827;
}

.action-btn,
.icon-btn,
.sub-action-btn {
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-primary);
    outline: none;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
}

.action-btn {
    min-height: 46px;
    border-color: color-mix(in srgb, var(--accent-color) 44%, rgba(255, 255, 255, 0.18));
    background: color-mix(in srgb, var(--accent-color) 15%, rgba(255, 255, 255, 0.08));
    padding: 0.85rem 1.15rem;
    font-size: 0.94rem;
    font-weight: 700;
    text-align: center;
    box-shadow: none;
}

.action-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--accent-color) 72%, white);
    background: color-mix(in srgb, var(--accent-color) 24%, rgba(255, 255, 255, 0.10));
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.18);
}

.action-btn:active:not(:disabled) {
    transform: translateY(0);
}

.action-btn.secondary,
.sub-action-btn {
    color: var(--text-primary);
    border-color: color-mix(in srgb, var(--accent-color) 44%, rgba(255, 255, 255, 0.18));
    background: color-mix(in srgb, var(--accent-color) 15%, rgba(255, 255, 255, 0.08));
    box-shadow: none;
}

.action-btn.secondary:hover:not(:disabled) {
    color: var(--text-primary);
    border-color: color-mix(in srgb, var(--accent-color) 68%, white);
    background: color-mix(in srgb, var(--accent-color) 20%, rgba(255, 255, 255, 0.08));
}

.action-btn.danger {
    color: #fecdd3;
    border-color: color-mix(in srgb, var(--danger-color) 42%, transparent);
    background: color-mix(in srgb, var(--danger-color) 13%, transparent);
}

.action-btn.danger:hover:not(:disabled) {
    color: #fff;
    background: color-mix(in srgb, var(--danger-color) 24%, transparent);
}

.action-btn.disabled:not(.friend-remove-only),
.action-btn:disabled:not(.friend-remove-only) {
    opacity: 0.62;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.sub-action-btn {
    margin-top: 0;
    padding: 0.6rem 0.85rem;
    font-size: 0.78rem;
}

.auth-clear-btn {
    width: 150px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.sub-action-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent-color);
}

.icon-btn {
    min-width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.7rem;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-md);
}

.icon-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(125, 211, 252, 0.45);
    background: rgba(255, 255, 255, 0.11);
}

.menu-actions-stack {
    display: grid;
    gap: 12px;
    margin-top: 22px;
}

.menu-shell {
    width: 320px;
    display: grid;
    gap: 18px;
}

.site-brand-title {
    margin: 0;
    color: var(--text-primary);
    font-size: clamp(1.7rem, 5vw, 2.45rem);
    font-weight: 800;
    letter-spacing: 0;
    text-align: center;
    text-shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
}

.menu-card {
    width: 320px;
    min-height: 408px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.loading-card {
    width: min(100%, 320px);
    padding: 34px 28px;
}

.menu-card .action-btn {
    height: 46px;
}

#menu-username-lbl {
    width: 100%;
    margin-top: 8px;
    text-align: center;
    word-break: break-word;
}

.profile-card,
.edit-profile-card {
    max-width: 500px;
    padding: 18px 22px 24px;
}

.friends-card {
    max-width: 620px;
    width: min(100%, 620px);
    padding: 34px 28px 28px;
}

.settings-card {
    width: min(100%, 430px);
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding: 34px 26px 26px;
}

.password-card {
    width: min(100%, 430px);
    padding: 34px 26px 26px;
}

.settings-card .profile-title {
    padding-top: 0;
    padding-right: 58px;
    text-align: left;
}

#profile-close-btn,
#changelog-close-btn,
#edit-profile-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 3;
    min-width: 36px;
    width: 36px;
    height: 36px;
    padding: 0;
}

#friends-close-btn,
#settings-close-btn,
#password-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 3;
    min-width: 36px;
    width: 36px;
    height: 36px;
    padding: 0;
}

.profile-title {
    text-align: left;
    min-height: 36px;
    padding-right: 54px;
    margin-bottom: 18px;
}

.profile-card > .profile-title {
    padding-top: 22px;
    margin-bottom: 14px;
}

.changelog-card .profile-title {
    padding-top: 0;
    padding-right: 58px;
    margin-bottom: 20px;
}

.profile-top {
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    margin-top: -54px;
    margin-bottom: 16px;
}

.profile-banner-box {
    position: relative;
    width: 100%;
    height: 154px;
    margin: 0 0 0;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    background:
        radial-gradient(circle at 22% 18%, rgba(255, 255, 255, 0.10), transparent 34%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(120, 130, 145, 0.10) 42%, rgba(0, 0, 0, 0.18)),
        var(--surface-strong);
}

.profile-banner-box img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.profile-banner-edit {
    position: absolute;
    right: 10px;
    bottom: 10px;
    min-height: 34px;
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.46);
    backdrop-filter: blur(10px);
}

.profile-avatar-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.profile-avatar-column .avatar-circle-container {
    margin-bottom: 0;
    width: 118px;
    height: 118px;
    border: 7px solid var(--bg-base);
    background: var(--bg-base);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.36);
}

.profile-info-block {
    min-width: 0;
    padding-top: 62px;
    padding-bottom: 0;
    display: grid;
    gap: 10px;
    align-self: start;
}

.profile-nickname {
    min-height: 28px;
    max-width: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.edit-profile-card {
    width: min(100%, 500px);
}

.edit-profile-preview {
    position: relative;
    margin-top: 8px;
    margin-bottom: 18px;
}

.edit-banner-preview {
    width: 100%;
    height: 150px;
    overflow: hidden;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
    background:
        radial-gradient(circle at 22% 18%, rgba(255, 255, 255, 0.10), transparent 34%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(120, 130, 145, 0.10) 42%, rgba(0, 0, 0, 0.18)),
        var(--surface-strong);
}

.edit-banner-preview img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.avatar-circle-container.edit-avatar-preview {
    position: absolute;
    left: 18px;
    bottom: 14px;
    width: 82px;
    height: 82px;
    border: 5px solid var(--bg-base);
    background: var(--bg-base);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.36);
}

.edit-profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 18px;
}

.edit-nickname-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: stretch;
}

.edit-nickname-row .action-btn {
    min-width: 132px;
}

.profile-stats {
    margin-top: 20px;
}

.user-profile-summary {
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.avatar-circle-container {
    width: 96px;
    height: 96px;
    display: inline-block;
    position: relative;
    overflow: hidden;
    margin-bottom: 0.55rem;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.035);
    box-shadow:
        inset 0 0 0 5px rgba(255, 255, 255, 0.035),
        0 12px 28px rgba(0, 0, 0, 0.22);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.avatar-circle-container:hover {
    transform: translateY(-2px) scale(1.02);
    border-color: var(--accent-color);
}

.avatar-circle-container.mini {
    width: 34px;
    height: 34px;
    margin-bottom: 0;
    vertical-align: middle;
    transform: none !important;
    box-shadow: none;
}

.leader-avatar-fallback {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-primary);
    background: color-mix(in srgb, var(--accent-color) 20%, rgba(255, 255, 255, 0.06));
    font-size: 0.74rem;
    font-weight: 800;
}

.avatar-circle-container img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-edit-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 38%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    color: white;
    background: rgba(2, 6, 23, 0.72);
    font-size: 0.7rem;
    font-weight: 700;
    transition: opacity 0.18s ease;
}

.avatar-circle-container:hover .avatar-edit-overlay {
    opacity: 1;
}

canvas {
    display: block;
    width: 150px;
    height: 150px;
    cursor: crosshair;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.035);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
    touch-action: none;
}

#avatar-canvas {
    margin: 0 auto;
}

.draw-palette {
    width: max-content;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin: 0.75rem auto 0;
    padding: 7px 9px;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.045);
}

.draw-swatch {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.22);
    transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.draw-swatch:hover,
.draw-swatch.active {
    transform: none;
    border-color: rgba(255, 255, 255, 0.86);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-color) 34%, transparent), inset 0 0 0 1px rgba(0, 0, 0, 0.22);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(2, 6, 23, 0.62);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(86px, 1fr));
    gap: 0.75rem;
}

.stat-box {
    display: flex;
    min-height: 82px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.8rem 0.5rem;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    background: var(--glass-soft);
}

.stat-box-wide {
    grid-column: span 2;
}

.stat-box.compact {
    min-height: 68px;
}

.stat-val {
    font-size: 1.65rem;
    line-height: 1;
    font-weight: 800;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
}

.uid-tag {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0.2rem 0.6rem;
    border: 1px solid color-mix(in srgb, var(--accent-color) 28%, transparent);
    border-radius: 999px;
    color: var(--accent-color);
    background: color-mix(in srgb, var(--accent-color) 12%, transparent);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.75rem;
    max-width: 134px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avatar-editor-card {
    width: min(100%, 380px);
    padding: 28px;
}

.banner-editor-card,
.changelog-card {
    width: min(100%, 620px);
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    padding: 28px;
}

.avatar-editor-card canvas {
    width: 170px;
    height: 170px;
}

.banner-editor-card canvas {
    width: 100%;
    max-width: 560px;
    height: auto;
    aspect-ratio: 32 / 11;
    margin: 0 auto;
    border-radius: 18px;
}

.changelog-list {
    display: grid;
    gap: 0.8rem;
    max-height: min(62dvh, 560px);
    overflow-y: auto;
    padding-right: 0.2rem;
}

.changelog-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.update-type {
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    padding: 0 0.65rem;
    border: 1px solid color-mix(in srgb, var(--accent-color) 28%, transparent);
    border-radius: 999px;
    color: var(--accent-color);
    background: color-mix(in srgb, var(--accent-color) 10%, transparent);
    font-size: 0.72rem;
    font-weight: 800;
}

.update-type.major {
    color: var(--success-color);
    border-color: color-mix(in srgb, var(--success-color) 35%, transparent);
    background: color-mix(in srgb, var(--success-color) 10%, transparent);
}

.changelog-item {
    display: grid;
    gap: 0.6rem;
    padding: 1rem;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    background: var(--glass-soft);
}

.changelog-item h3 {
    font-size: 0.95rem;
}

.changelog-item p {
    color: var(--text-muted);
    font-size: 0.86rem;
    line-height: 1.45;
    white-space: pre-line;
}

.avatar-editor-actions,
.modal-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.65rem;
}

.avatar-editor-actions .action-btn,
.modal-actions .action-btn {
    min-width: 0;
    padding-left: 0.65rem;
    padding-right: 0.65rem;
    white-space: nowrap;
}

.lobby-modal-card {
    width: min(100%, 390px);
    padding: 26px;
}

.lobby-modal-card .modal-actions {
    grid-template-columns: 1fr 1fr;
}

.game-layout-container {
    width: min(1360px, 100%);
    display: grid;
    grid-template-columns: minmax(320px, 340px) max-content;
    gap: 1.25rem;
    align-items: start;
    justify-content: center;
}

.game-sidebar-left {
    display: flex;
    flex-direction: column;
}

.game-battle-grids {
    display: grid;
    grid-template-columns: repeat(2, max-content);
    gap: 1.15rem;
    align-items: start;
    justify-content: center;
}

.lobby-wait-panel {
    min-height: 560px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1.4rem;
}

.lobby-wait-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.lobby-wait-title {
    margin-top: 0.3rem;
    max-width: 540px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: clamp(1.45rem, 3vw, 2.2rem);
}

.lobby-count-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 54px;
    min-height: 34px;
    padding: 0 0.75rem;
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.055);
    font-size: 0.8rem;
    font-weight: 800;
}

.lobby-player-list {
    display: grid;
    gap: 0.85rem;
}

.lobby-player-row {
    min-height: 72px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.045);
}

.lobby-player-row.empty {
    opacity: 0.68;
    border-style: dashed;
}

.lobby-player-main {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
}

.lobby-player-main span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.muted-slot {
    color: var(--text-muted);
}

.ready-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 90px;
    min-height: 32px;
    padding: 0 0.75rem;
    border: 1px solid color-mix(in srgb, var(--danger-color) 32%, transparent);
    border-radius: 999px;
    color: var(--danger-color);
    background: color-mix(in srgb, var(--danger-color) 10%, transparent);
    font-size: 0.75rem;
    font-weight: 800;
    white-space: nowrap;
}

.ready-badge.is-ready {
    border-color: color-mix(in srgb, var(--success-color) 42%, transparent);
    color: var(--success-color);
    background: color-mix(in srgb, var(--success-color) 12%, transparent);
}

.lobby-ready-center {
    display: grid;
    justify-items: center;
    gap: 0.85rem;
    padding: 1rem 0 0.3rem;
    text-align: center;
}

.lobby-ready-btn {
    width: min(100%, 280px);
    min-height: 56px;
    font-size: 1rem;
}

.grid-wrapper {
    min-width: 0;
    width: max-content;
    max-width: 100%;
}

.player-headline {
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.65rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    background: var(--glass-soft);
}

.player-headline span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-banner {
    line-height: 1.2;
    color: var(--accent-color);
}

.battle-matrix {
    --cell-size: clamp(27px, 2.7vw, 36px);
    display: grid;
    grid-template-columns: repeat(10, var(--cell-size));
    grid-template-rows: repeat(10, var(--cell-size));
    gap: 3px;
    width: max-content;
    max-width: 100%;
    padding: 6px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025)),
        rgba(255, 255, 255, 0.045);
    box-shadow: var(--shadow-md);
    touch-action: none;
}

.cell {
    position: relative;
    min-width: 0;
    border-radius: 7px;
    cursor: pointer;
    background:
        radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.08), transparent 45%),
        var(--cell-bg);
    border: 1px solid rgba(255, 255, 255, 0.04);
    transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}

.cell:hover {
    transform: translateY(-1px);
    border-color: rgba(56, 189, 248, 0.55);
    background: color-mix(in srgb, var(--accent-color) 20%, var(--cell-bg));
}

.c-ship {
    border-color: color-mix(in srgb, var(--accent-color) 60%, white);
    background:
        linear-gradient(135deg, rgba(125, 211, 252, 0.54), rgba(14, 165, 233, 0.32)),
        var(--cell-bg);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.10);
}

.c-hit {
    border-color: var(--danger-color);
    background: color-mix(in srgb, var(--danger-color) 35%, var(--cell-bg));
    animation: hitPulse 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.c-hit::after {
    content: 'X';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 800;
}

.c-miss::after {
    content: '';
    position: absolute;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: color-mix(in srgb, var(--text-muted) 75%, transparent);
    animation: rippleMiss 0.45s ease-out;
}

.c-sunk {
    border-color: var(--danger-color) !important;
    background: color-mix(in srgb, var(--danger-color) 52%, var(--cell-bg)) !important;
}

@keyframes hitPulse {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-3px, 0, 0); }
    40%, 60% { transform: translate3d(3px, 0, 0); }
}

@keyframes rippleMiss {
    0% { width: 24px; height: 24px; opacity: 0.2; }
    100% { width: 7px; height: 7px; opacity: 1; }
}

.shake-board {
    animation: shakeGrid 0.4s ease;
}

@keyframes shakeGrid {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-4px, 2px); }
    75% { transform: translate(4px, -2px); }
}

.inactive-radar {
    pointer-events: none;
    opacity: 0.58;
    filter: saturate(0.7);
}

.table-container {
    max-height: 390px;
    overflow: auto;
    margin-top: 1rem;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
}

.leaders-card {
    width: min(100%, 720px);
}

.not-found-page {
    min-height: 100vh;
}

.not-found-wrap {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.not-found-card {
    width: min(100%, 430px);
    display: grid;
    gap: 1rem;
    text-align: center;
}

.not-found-code {
    color: var(--accent-color);
    font-size: clamp(3rem, 16vw, 5.4rem);
    font-weight: 800;
    line-height: 0.95;
}

.not-found-card h1 {
    font-size: 1.55rem;
    font-weight: 800;
}

.not-found-card p {
    color: var(--text-muted);
}

.not-found-card .action-btn {
    text-decoration: none;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.86rem;
}

th,
td {
    padding: 0.8rem 0.75rem;
    border-bottom: 1px solid var(--glass-border);
    vertical-align: middle;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: var(--text-muted);
    background: color-mix(in srgb, var(--bg-base) 78%, transparent);
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
}

tr:last-child td {
    border-bottom: 0;
}

.lobbies-grid-container {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
    max-height: 420px;
    min-height: 120px;
    overflow-y: auto;
    padding-right: 0.2rem;
}

.browser-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.lobby-card {
    min-height: 112px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.9rem;
    padding: 1rem;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    background: var(--glass-soft);
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.empty-state {
    grid-column: 1 / -1;
    min-height: 116px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border: 1px dashed var(--glass-border);
    border-radius: 16px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.028);
    text-align: center;
}

.lobby-card-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.55rem;
    align-items: center;
}

.lobby-copy-btn {
    min-width: 46px;
    padding-left: 0.7rem;
    padding-right: 0.7rem;
}

.room-panel {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.room-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.room-kicker {
    display: block;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    line-height: 1.2;
}

.room-name {
    margin-top: 0.25rem;
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1rem;
}

.room-mode-pill {
    align-self: flex-start;
    width: max-content;
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    padding: 0 0.65rem;
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.055);
    font-size: 0.75rem;
    font-weight: 800;
}

.room-settings-btn {
    min-height: 36px;
    white-space: nowrap;
}

.invite-kicker {
    margin-top: 0.1rem;
}

.invite-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.55rem;
}

.invite-row input {
    min-height: 40px;
    padding: 0.5rem 0.65rem;
    font-size: 0.76rem;
}

.lobby-card:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--accent-color) 48%, var(--glass-border));
    background: color-mix(in srgb, var(--accent-color) 8%, var(--glass-soft));
}

.shipyard-slots-box {
    display: flex;
    min-height: 78px;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem;
}

#constructor-dock .flex {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

#constructor-dock .action-btn {
    min-width: 0;
    width: 100%;
    padding-left: 0.55rem;
    padding-right: 0.55rem;
    white-space: nowrap;
}

#game-btn-ready {
    grid-column: 1 / -1;
}

#constructor-dock.fleet-complete .shipyard-slots-box {
    min-height: 34px;
    align-items: flex-start;
}

body[data-phase="placement"] #room-invite-label,
body[data-phase="placement"] #room-invite-row,
body[data-phase="placement"] #room-invite-friend,
body[data-phase="battle"] #room-invite-label,
body[data-phase="battle"] #room-invite-row,
body[data-phase="battle"] #room-invite-friend {
    display: none !important;
}

.d-ship-item {
    display: flex;
    gap: 3px;
    padding: 5px;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.18);
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
    touch-action: none;
}

.d-ship-item:hover {
    transform: translateY(-1px);
    border-color: var(--accent-color);
}

.active-d-ship {
    border-color: var(--success-color) !important;
    background: color-mix(in srgb, var(--success-color) 14%, transparent);
}

.d-deck {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-strong));
}

.friend-add-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.65rem;
}

.friends-list {
    max-height: 360px;
    overflow-y: auto;
    display: grid;
    gap: 0.65rem;
}

.friends-section-title {
    margin-top: 0.45rem;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.friend-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
}

.friend-row-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.45rem;
    min-width: 96px;
}

.friend-remove-only {
    min-width: 124px;
    min-height: 34px;
    padding: 0.46rem 0.7rem;
    font-size: 0.72rem;
}

.status-wrap {
    overflow: visible;
}

.status-dot {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 10px;
    height: 10px;
    border: 2px solid #111827;
    border-radius: 50%;
    background: #3f3f46;
}

.status-dot.online {
    background: var(--success-color);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.16);
}

.toast-root {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 160;
    width: min(360px, calc(100vw - 2rem));
    display: grid;
    gap: 0.75rem;
}

.toast-card {
    position: relative;
    overflow: hidden;
    display: grid;
    gap: 0.7rem;
    padding: 1rem;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    color: var(--text-primary);
    background: rgba(24, 24, 29, 0.88);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(14px);
}

.toast-card::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 100%;
    background: var(--danger-color);
    animation: toastTimer 15s linear forwards;
}

@keyframes toastTimer {
    from { width: 100%; }
    to { width: 0%; }
}

.toast-text strong {
    display: block;
    margin-bottom: 0.2rem;
}

.toast-text p {
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.35;
}

.toast-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.team-select-panel {
    display: grid;
    gap: 0.65rem;
    padding: 0.9rem;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
}

.team-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.active-team {
    color: var(--text-primary) !important;
    border-color: var(--accent-border) !important;
    background: var(--accent-soft) !important;
}

.public-profile-card {
    width: min(100%, 500px);
    padding: 18px 22px 24px;
}

.public-profile-banner-box {
    width: 100%;
    height: 154px;
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    background:
        radial-gradient(circle at 22% 18%, rgba(255, 255, 255, 0.10), transparent 34%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(120, 130, 145, 0.10) 42%, rgba(0, 0, 0, 0.18)),
        var(--surface-strong);
}

.public-profile-banner-box img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.public-profile-grid {
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr);
    gap: 12px;
    align-items: end;
    margin-top: -58px;
    margin-bottom: 18px;
}

.public-profile-grid .avatar-circle-container {
    width: 118px;
    height: 118px;
    border: 7px solid var(--bg-base);
    background: var(--bg-base);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.36);
}

.public-profile-info,
.public-profile-info * {
    min-width: 0;
}

.public-profile-info .profile-title {
    padding: 0;
    min-height: auto;
    line-height: 1.08;
    margin-bottom: 0.25rem;
    overflow-wrap: anywhere;
}

#public-profile-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 3;
    min-width: 36px;
    width: 36px;
    height: 36px;
    padding: 0;
}

.settings-list {
    display: grid;
    gap: 0.8rem;
}

.settings-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.9rem;
    padding: 0.9rem;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
}

.settings-row > *,
.settings-row strong,
.settings-row p,
.settings-row input,
.settings-row button {
    min-width: 0;
    max-width: 100%;
}

.settings-row p,
.settings-row strong {
    overflow-wrap: anywhere;
}

.settings-row .action-btn {
    white-space: normal;
}

.settings-row.vertical {
    grid-template-columns: 1fr;
    align-items: stretch;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.45rem;
}

.color-swatch {
    width: 100%;
    aspect-ratio: 1;
    min-height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.color-swatch:hover,
.color-swatch.active {
    transform: translateY(-1px) scale(1.04);
    border-color: rgba(255, 255, 255, 0.75);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-color) 22%, transparent);
}

.error-msg {
    color: var(--danger-color);
    font-size: 0.82rem;
    text-align: center;
    line-height: 1.4;
}

.success-msg {
    color: var(--success-color);
    font-size: 0.82rem;
    text-align: center;
    line-height: 1.4;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--accent-color) 38%, transparent);
    border: 2px solid transparent;
    border-radius: 999px;
    background-clip: content-box;
}

@media (max-width: 1120px) {
    .game-layout-container {
        grid-template-columns: 1fr;
    }

    .game-sidebar-left {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1rem;
    }

    .game-sidebar-left .glass-card {
        margin-top: 0 !important;
    }
    .room-name {
        max-width: none;
    }

    .lobby-wait-panel {
        min-height: 430px;
    }
}

@media (max-width: 820px) {
    body {
        align-items: flex-start;
    }

    button,
    input,
    select {
        font-size: 16px;
    }

    .view-panel {
        padding: 4.4rem 0.55rem 1rem;
    }

    .game-battle-grids,
    .game-sidebar-left,
    .lobbies-grid-container {
        grid-template-columns: 1fr;
    }

    .game-battle-grids {
        justify-items: center;
    }

    .battle-matrix {
        --cell-size: min(8.55vw, 36px);
        margin: 0 auto;
        gap: 2px;
        padding: 5px;
        border-radius: 13px;
    }

    .lobby-wait-title {
        max-width: 68vw;
    }

    .game-layout-container {
        gap: 0.75rem;
    }

    .game-sidebar-left {
        gap: 0.75rem;
        order: 2;
    }

    #lobby-wait-panel,
    #game-battle-grids {
        order: 1;
    }

    body[data-phase="placement"] .game-sidebar-left {
        order: 1;
    }

    body[data-phase="placement"] #game-battle-grids {
        order: 2;
    }

    body[data-phase="battle"] #game-battle-grids {
        order: 1;
    }

    body[data-phase="battle"] .game-sidebar-left {
        order: 2;
    }

    .game-sidebar-left .glass-card {
        padding: 0.85rem;
    }

    .player-headline {
        min-height: 42px;
        margin-bottom: 0.45rem;
        padding: 0.45rem 0.55rem;
    }

    .shipyard-slots-box {
        min-height: auto;
    }

    #constructor-dock .flex {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .top-settings-bar {
        display: none;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stat-box-wide {
        grid-column: 1 / -1;
    }

    .table-container {
        overflow-x: auto;
    }

    table {
        min-width: 560px;
    }
}

@media (max-width: 460px) {
    .modal-overlay {
        align-items: center;
        justify-content: center;
        padding: max(0.75rem, env(safe-area-inset-top)) 0.55rem max(0.75rem, env(safe-area-inset-bottom));
        overflow-y: auto;
    }

    .glass-card {
        border-radius: 16px;
        padding: 1.15rem;
    }

    .auth-card,
    .menu-card,
    .profile-card,
    .edit-profile-card,
    .friends-card,
    .settings-card,
    .password-card,
    .changelog-card,
    .banner-editor-card {
        width: min(100%, 350px);
        padding: 20px;
    }

    .menu-shell {
        width: min(100%, 350px);
        gap: 16px;
    }

    .friends-card,
    .settings-card,
    .password-card,
    .profile-card,
    .edit-profile-card,
    .public-profile-card,
    .changelog-card {
        max-height: calc(100dvh - 1.6rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        overflow-y: auto;
    }

    .friends-list {
        max-height: min(46dvh, 420px);
        padding-right: 0.15rem;
    }

    .leaders-card {
        width: min(100%, 350px);
        max-height: calc(100dvh - 2rem);
        padding: 20px;
        overflow: hidden;
    }

    .leaders-card .table-container {
        max-height: calc(100dvh - 11.5rem);
        margin-top: 0.75rem;
        overflow-y: auto;
        overflow-x: hidden;
        border: 0;
        border-radius: 0;
        background: transparent;
    }

    .leaders-card table,
    .leaders-card thead,
    .leaders-card tbody,
    .leaders-card tr,
    .leaders-card td {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .leaders-card thead {
        display: none;
    }

    .leaders-card tbody {
        display: grid;
        gap: 0.75rem;
    }

    .leaders-card tr {
        position: relative;
        display: grid;
        grid-template-columns: 48px 1fr 1fr;
        grid-template-areas:
            "avatar nick nick"
            "avatar wins losses"
            "rank surr surr";
        align-items: center;
        gap: 0.45rem 0.75rem;
        padding: 0.9rem;
        border: 1px solid var(--glass-border);
        border-radius: 16px;
        background: var(--glass-soft);
    }

    .leaders-card td {
        padding: 0;
        border: 0;
        text-align: left !important;
    }

    .leaders-card td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.1rem;
        color: var(--text-muted);
        font-size: 0.62rem;
        font-weight: 800;
        text-transform: uppercase;
    }

    .leaders-card td:nth-child(1) {
        grid-area: rank;
        display: inline-flex;
        width: fit-content;
        min-height: 28px;
        align-items: center;
        justify-content: center;
        padding: 0 0.7rem;
        border-radius: 999px;
        color: var(--text-primary);
        background: var(--accent-soft);
        font-weight: 800;
    }

    .leaders-card td:nth-child(1)::before,
    .leaders-card td:nth-child(2)::before,
    .leaders-card td:nth-child(3)::before {
        display: none;
    }

    .leaders-card td:nth-child(2) {
        grid-area: avatar;
    }

    .leaders-card td:nth-child(2) .avatar-circle-container {
        width: 48px;
        height: 48px;
    }

    .leaders-card td:nth-child(2) .leader-avatar-fallback {
        width: 48px;
        height: 48px;
        font-size: 0.88rem;
    }

    .leaders-card td:nth-child(3) {
        grid-area: nick;
        min-width: 0;
        font-size: 1rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .leaders-card td:nth-child(4) {
        grid-area: wins;
    }

    .leaders-card td:nth-child(5) {
        grid-area: losses;
    }

    .leaders-card td:nth-child(6) {
        grid-area: surr;
    }

    .public-profile-card {
        width: min(100%, 350px);
        padding: 18px 16px 20px;
    }

    .public-profile-banner-box {
        width: 100%;
        height: 132px;
        margin-left: 0;
        margin-right: 0;
        border-radius: 14px;
    }

    .public-profile-grid {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
        margin-top: -54px;
        gap: 10px;
    }

    .public-profile-grid .avatar-circle-container {
        width: 112px;
        height: 112px;
        border-width: 6px;
    }

    .profile-top {
        grid-template-columns: 1fr;
        justify-items: center;
        margin-top: -48px;
        gap: 8px;
    }

    .profile-banner-box {
        width: 100%;
        height: 132px;
        margin-left: 0;
        margin-right: 0;
        border-radius: 14px;
    }

    .profile-banner-edit {
        left: 10px;
        right: 10px;
        width: auto;
    }

    .profile-avatar-column .avatar-circle-container {
        width: 112px;
        height: 112px;
        border-width: 6px;
    }

    .profile-info-block {
        padding-top: 0;
        padding-bottom: 0;
        width: 100%;
        gap: 8px;
        text-align: center;
    }

    .profile-card,
    .edit-profile-card {
        max-height: none;
        margin-bottom: 1rem;
    }

    .changelog-list {
        max-height: calc(100dvh - 8.8rem);
        overflow-y: auto;
    }

    .changelog-head {
        display: grid;
        grid-template-columns: 1fr;
        justify-items: start;
    }

    .changelog-item {
        padding: 0.9rem;
    }

    .profile-title {
        text-align: center;
        padding-right: 0;
        padding-top: 22px;
    }

    .invite-row,
    .friend-add-row,
    .browser-stats {
        grid-template-columns: 1fr;
        display: grid;
    }

    .friend-row {
        grid-template-columns: minmax(0, 1fr) auto;
        display: grid;
    }

    .friend-remove-only {
        min-width: 92px;
        max-width: 118px;
        white-space: normal;
    }

    .edit-profile-grid,
    .edit-nickname-row {
        width: 100%;
        grid-template-columns: 1fr;
    }

    .edit-profile-preview {
        margin-bottom: 16px;
    }

    .edit-banner-preview {
        height: 126px;
    }

    .avatar-circle-container.edit-avatar-preview {
        left: 14px;
        bottom: 12px;
        width: 76px;
        height: 76px;
        transform: none;
        border-width: 5px;
    }

    .ready-badge {
        min-width: 78px;
        padding: 0 0.55rem;
    }

    .avatar-editor-actions {
        grid-template-columns: 1fr;
    }

    .action-btn {
        min-height: 44px;
        padding: 0.75rem 0.9rem;
    }

    .battle-matrix {
        --cell-size: calc((100vw - 1.1rem - 32px) / 10);
        gap: 2px;
        padding: 4px;
    }

    #constructor-dock .flex {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    #constructor-dock .action-btn {
        min-height: 46px;
        font-size: 0.82rem;
        padding-left: 0.35rem;
        padding-right: 0.35rem;
    }

    .cell {
        border-radius: 5px;
    }

    .game-layout-container {
        gap: 0.85rem;
    }

    .lobby-player-row {
        grid-template-columns: 1fr;
        gap: 0.55rem;
    }

    .ready-badge {
        justify-self: start;
    }

    .player-headline {
        padding: 0.5rem;
    }

    .friend-row-actions {
        width: 100%;
        grid-template-columns: 1fr 1fr;
    }

    .settings-row {
        grid-template-columns: 1fr;
    }

    .settings-card .profile-title {
        text-align: left;
        padding-top: 0;
        padding-right: 54px;
    }

    .color-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .toast-root {
        top: 0.7rem;
        right: 0.65rem;
        left: 0.65rem;
        width: auto;
    }

    .lobby-wait-panel {
        min-height: auto;
        gap: 1rem;
    }

    .lobby-wait-header {
        align-items: center;
    }

    .lobby-wait-title {
        max-width: 64vw;
        font-size: 1.25rem;
    }
}
