/* =========================================================
   KHIM - dark glass theme
   Class names are unchanged; only the presentation layer.
   ========================================================= */

:root {
    color-scheme: dark;

    /* Base surfaces */
    --bg: #06070a;
    --bg-soft: #0b0d13;
    --fg: #eef1f7;
    --muted: #949cb0;
    --muted-soft: #6b7385;

    /* Glass system */
    --panel: rgba(255, 255, 255, 0.045);
    --panel-alt: rgba(255, 255, 255, 0.025);
    --panel-hover: rgba(255, 255, 255, 0.07);
    --line: rgba(255, 255, 255, 0.10);
    --soft-line: rgba(255, 255, 255, 0.06);
    --line-strong: rgba(255, 255, 255, 0.18);
    --sheen: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    --blur: saturate(160%) blur(20px);

    /* Accent */
    --accent: #ff4655;
    --accent-2: #ff8a3d;
    --accent-grad: linear-gradient(135deg, #ff4655 0%, #ff8a3d 100%);
    --accent-soft: rgba(255, 70, 85, 0.14);
    --accent-line: rgba(255, 70, 85, 0.45);
    --accent-glow: 0 10px 34px -10px rgba(255, 70, 85, 0.65);

    /* Semantic */
    --danger: #ff5f6d;
    --success: #34d399;
    --info: #57a6ff;

    /* Depth */
    --shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.95);
    --shadow-lg: 0 40px 90px -40px rgba(0, 0, 0, 1);

    /* Shape */
    --radius: 18px;
    --radius-sm: 12px;
    --radius-pill: 999px;

    /* Motion */
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --fast: 160ms var(--ease);
    --med: 280ms var(--ease);

    --space-1: 0.5rem;
    --space-2: 0.75rem;
    --space-3: 1rem;
    --space-4: 1.5rem;
    --space-5: 2rem;
    --space-6: 3rem;
}

* {
    box-sizing: border-box;
}

/* Any class that sets `display` (e.g. .button's inline-flex) outranks the
   browser's own [hidden] rule, so hidden elements kept showing. Make the
   attribute authoritative everywhere instead of patching each component. */
[hidden] {
    display: none !important;
}

html {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--fg);
    -webkit-font-smoothing: antialiased;
    scroll-behavior: smooth;
}

body {
    position: relative;
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    overflow-x: hidden;
}

/* Ambient light: two slow-drifting accent orbs + a faint grid. */
body::before {
    content: "";
    position: fixed;
    inset: -30vh -20vw;
    z-index: -2;
    pointer-events: none;
    background:
        radial-gradient(38vw 38vw at 18% 8%, rgba(255, 70, 85, 0.16), transparent 62%),
        radial-gradient(34vw 34vw at 84% 78%, rgba(87, 120, 255, 0.14), transparent 64%),
        radial-gradient(28vw 28vw at 62% 18%, rgba(255, 138, 61, 0.08), transparent 66%);
    animation: drift 26s var(--ease) infinite alternate;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px),
        linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(120vw 90vh at 50% 0%, #000 20%, transparent 78%);
}

@keyframes drift {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to   { transform: translate3d(2.5%, 3%, 0) scale(1.08); }
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
}

::selection {
    background: var(--accent-soft);
    color: #fff;
}

/* Scrollbar */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.10);
    border: 3px solid transparent;
    background-clip: content-box;
    border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.20); background-clip: content-box; }

.skip-link {
    position: absolute;
    left: var(--space-3);
    top: var(--space-3);
    transform: translateY(-200%);
    background: var(--accent-grad);
    color: #fff;
    font-weight: 700;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    z-index: 100;
    transition: transform var(--fast);
}

.skip-link:focus {
    transform: translateY(0);
}

.page {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: var(--space-4) 0 var(--space-6);
}

/* ---------------------------------------------------------
   Top bar
   --------------------------------------------------------- */

.topbar {
    position: sticky;
    top: var(--space-3);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-5);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: rgba(10, 12, 18, 0.66);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    box-shadow: var(--shadow), var(--sheen);
    animation: fade-down 600ms var(--ease) both;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding-left: var(--space-2);
    font-family: "Plus Jakarta Sans", Inter, sans-serif;
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    text-decoration: none;
    transition: opacity var(--fast);
}

.brand::before {
    content: "";
    width: 22px;
    height: 22px;
    border-radius: 7px;
    background: var(--accent-grad);
    box-shadow: var(--accent-glow);
    transform: rotate(12deg);
    transition: transform var(--med);
}

.brand:hover::before {
    transform: rotate(-20deg) scale(1.12);
}

.nav {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    flex-wrap: wrap;
}

.nav a {
    position: relative;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    padding: 0 var(--space-3);
    border-radius: var(--radius-pill);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.94rem;
    text-decoration: none;
    transition: color var(--fast), background var(--fast);
}

.nav a:hover,
.nav a:focus-visible {
    color: var(--fg);
    background: var(--panel);
    outline: none;
}

.nav a::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 6px;
    width: 0;
    height: 2px;
    border-radius: 2px;
    background: var(--accent-grad);
    transform: translateX(-50%);
    transition: width var(--med);
}

.nav a:hover::after,
.nav a:focus-visible::after {
    width: 18px;
}

/* ---------------------------------------------------------
   Buttons
   --------------------------------------------------------- */

.button {
    position: relative;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    padding: 0.7rem 1.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    background: var(--accent-grad);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    overflow: hidden;
    box-shadow: var(--accent-glow), var(--sheen);
    transition: transform var(--fast), box-shadow var(--med), filter var(--fast), background var(--fast);
}

/* Sweep of light on hover */
.button::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 20%, rgba(255, 255, 255, 0.35) 50%, transparent 80%);
    transform: translateX(-120%);
    transition: transform 700ms var(--ease);
}

.button:hover::after,
.button:focus-visible::after {
    transform: translateX(120%);
}

.button:hover,
.button:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 18px 44px -12px rgba(255, 70, 85, 0.75), var(--sheen);
    outline: none;
}

.button:active {
    transform: translateY(0) scale(0.98);
}

.button.secondary {
    background: var(--panel);
    border-color: var(--line);
    color: var(--fg);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    box-shadow: var(--sheen);
}

.button.secondary:hover,
.button.secondary:focus-visible {
    background: var(--panel-hover);
    border-color: var(--line-strong);
    box-shadow: 0 14px 34px -16px rgba(0, 0, 0, 0.9), var(--sheen);
}

.button.danger {
    background: rgba(255, 95, 109, 0.12);
    border-color: rgba(255, 95, 109, 0.4);
    color: var(--danger);
    box-shadow: none;
}

.button.danger:hover,
.button.danger:focus-visible {
    background: rgba(255, 95, 109, 0.2);
    border-color: var(--danger);
    color: #fff;
    box-shadow: 0 14px 34px -16px rgba(255, 95, 109, 0.8);
}

.button.full {
    width: 100%;
}

.button.small,
.nav .button.small {
    min-height: 38px;
    padding: 0.4rem 0.9rem;
    font-size: 0.88rem;
}

.button:disabled {
    cursor: progress;
    opacity: 0.5;
    transform: none;
    filter: grayscale(0.4);
}

.button:disabled::after {
    animation: sweep 1.2s linear infinite;
}

@keyframes sweep {
    from { transform: translateX(-120%); }
    to   { transform: translateX(120%); }
}

/* ---------------------------------------------------------
   Glass panels
   --------------------------------------------------------- */

.hero,
.panel {
    position: relative;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    box-shadow: var(--shadow), var(--sheen);
}

.panel {
    padding: var(--space-4);
    transition: border-color var(--med), background var(--med), transform var(--med);
    animation: fade-up 620ms var(--ease) both;
}

.panel:hover {
    border-color: var(--line-strong);
    background: var(--panel-hover);
}

.panel h2,
.panel h3 {
    margin: 0 0 var(--space-3);
    font-family: "Plus Jakarta Sans", Inter, sans-serif;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.panel p,
.panel li {
    color: var(--muted);
    line-height: 1.65;
}

/* Staggered entrance inside grids */
.grid > *,
.game-grid > *,
.user-grid > *,
.stack-list > * {
    animation: fade-up 620ms var(--ease) both;
}

.grid > *:nth-child(1),  .game-grid > *:nth-child(1),  .user-grid > *:nth-child(1)  { animation-delay: 40ms; }
.grid > *:nth-child(2),  .game-grid > *:nth-child(2),  .user-grid > *:nth-child(2)  { animation-delay: 90ms; }
.grid > *:nth-child(3),  .game-grid > *:nth-child(3),  .user-grid > *:nth-child(3)  { animation-delay: 140ms; }
.grid > *:nth-child(4),  .game-grid > *:nth-child(4),  .user-grid > *:nth-child(4)  { animation-delay: 190ms; }
.grid > *:nth-child(5),  .game-grid > *:nth-child(5),  .user-grid > *:nth-child(5)  { animation-delay: 240ms; }
.grid > *:nth-child(6),  .game-grid > *:nth-child(6),  .user-grid > *:nth-child(6)  { animation-delay: 290ms; }
.grid > *:nth-child(n + 7),
.game-grid > *:nth-child(n + 7),
.user-grid > *:nth-child(n + 7) { animation-delay: 330ms; }

@keyframes fade-up {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-down {
    from { opacity: 0; transform: translateY(-14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------------------------------
   Hero
   --------------------------------------------------------- */

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
    gap: var(--space-5);
    padding: clamp(1.75rem, 4vw, 3.5rem);
    min-height: 520px;
    align-items: stretch;
    overflow: hidden;
    animation: fade-up 720ms var(--ease) both;
}

/* Accent bloom behind the headline */
.hero::before {
    content: "";
    position: absolute;
    top: -40%;
    left: -10%;
    width: 60%;
    height: 140%;
    pointer-events: none;
    background: radial-gradient(closest-side, rgba(255, 70, 85, 0.20), transparent 70%);
    animation: pulse-glow 7s var(--ease) infinite alternate;
}

@keyframes pulse-glow {
    from { opacity: 0.55; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1.12); }
}

.hero > * {
    position: relative;
    z-index: 1;
}

.hero h1,
.page-title {
    margin: 0;
    font-family: "Plus Jakarta Sans", Inter, sans-serif;
    font-size: clamp(2.6rem, 8vw, 6rem);
    font-weight: 800;
    line-height: 1.02;
    letter-spacing: -0.045em;
    /* Descenders (g, j, y) are clipped by background-clip: text at tight
       line-heights, so leave a little room below the last baseline. */
    padding-bottom: 0.08em;
    background: linear-gradient(180deg, #ffffff 30%, rgba(255, 255, 255, 0.62) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.lede {
    max-width: 56ch;
    margin: var(--space-4) 0 0;
    color: var(--muted);
    font-size: 1.06rem;
    line-height: 1.7;
}

.hero-actions,
.actions {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-top: var(--space-5);
}

.info-stack {
    display: grid;
    align-content: end;
    gap: var(--space-2);
    padding-left: var(--space-4);
    border-left: 1px solid var(--line);
}

.info-row {
    padding: var(--space-3);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    transition: background var(--med), border-color var(--med), transform var(--med);
}

.info-row:hover {
    background: var(--panel-alt);
    border-color: var(--line);
    transform: translateX(4px);
}

.label {
    color: var(--muted-soft);
    text-transform: uppercase;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
}

.value {
    margin-top: var(--space-1);
    font-weight: 600;
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-3);
    margin-top: var(--space-4);
}

/* Numbered step panels on the landing page */
.grid > .panel {
    overflow: hidden;
}

.grid > .panel::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 2px;
    background: var(--accent-grad);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--med);
}

.grid > .panel:hover::before {
    transform: scaleX(1);
}

/* ---------------------------------------------------------
   Forms
   --------------------------------------------------------- */

.auth-layout {
    min-height: calc(100vh - 160px);
    display: grid;
    place-items: center;
}

.auth-panel {
    width: min(440px, 100%);
    padding: var(--space-5);
}

.form {
    display: grid;
    gap: var(--space-3);
}

.field {
    display: grid;
    gap: var(--space-1);
}

.field label {
    font-weight: 600;
    font-size: 0.92rem;
}

.field small {
    color: var(--muted-soft);
    font-size: 0.82rem;
}

.input {
    width: 100%;
    min-height: 48px;
    padding: 0.75rem 0.95rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    color: var(--fg);
    transition: border-color var(--fast), box-shadow var(--fast), background var(--fast);
}

.input::placeholder {
    color: var(--muted-soft);
}

.input:hover {
    border-color: var(--line-strong);
}

.input:focus {
    outline: none;
    border-color: var(--accent-line);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.textarea {
    min-height: 150px;
    resize: vertical;
    line-height: 1.6;
}

.file-input {
    padding: 0.6rem;
    cursor: pointer;
}

.file-input::file-selector-button {
    margin-right: var(--space-2);
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--panel);
    color: var(--fg);
    font-weight: 600;
    cursor: pointer;
    transition: background var(--fast);
}

.file-input::file-selector-button:hover {
    background: var(--panel-hover);
}

.check-row {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 44px;
    font-weight: 600;
}

.check-row input {
    width: 1.15rem;
    height: 1.15rem;
    accent-color: var(--accent);
    cursor: pointer;
}

.status {
    min-height: 1.5rem;
    font-weight: 600;
    font-size: 0.94rem;
    transition: color var(--fast);
}

.status.error,
.status.success {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0.45rem 0.85rem;
    border: 1px solid;
    border-radius: var(--radius-pill);
    animation: fade-up 320ms var(--ease) both;
}

.status.error {
    color: var(--danger);
    border-color: rgba(255, 95, 109, 0.35);
    background: rgba(255, 95, 109, 0.1);
}

.status.success {
    color: var(--success);
    border-color: rgba(52, 211, 153, 0.35);
    background: rgba(52, 211, 153, 0.1);
}

/* ---------------------------------------------------------
   Dashboard chrome
   --------------------------------------------------------- */

.dashboard-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
    animation: fade-up 600ms var(--ease) both;
}

.dashboard-grid,
.search-layout,
.profile-layout {
    display: grid;
    gap: var(--space-3);
    align-items: start;
}

.social-dashboard {
    grid-template-columns: minmax(240px, 0.55fr) minmax(420px, 1.45fr);
}

.profile-overview,
.social-tabs-panel {
    align-self: start;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.panel-heading h2,
.panel-heading p {
    margin: 0;
}

.dashboard-tabs {
    display: inline-flex;
    gap: 4px;
    flex-wrap: wrap;
    padding: 5px;
    margin-bottom: var(--space-4);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--panel-alt);
}

.dashboard-tab {
    min-height: 40px;
    padding: 0.5rem 1rem;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--muted);
    font-weight: 600;
    cursor: pointer;
    transition: background var(--fast), color var(--fast);
}

.dashboard-tab:hover,
.dashboard-tab:focus-visible {
    color: var(--fg);
    background: var(--panel);
    outline: none;
}

.dashboard-tab.active {
    background: var(--accent-grad);
    color: #fff;
    box-shadow: var(--accent-glow);
}

.dashboard-tab span {
    display: inline-grid;
    place-items: center;
    min-width: 1.4rem;
    min-height: 1.4rem;
    margin-left: var(--space-1);
    padding: 0 0.3rem;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.12);
    font-size: 0.74rem;
    font-weight: 700;
}

.dashboard-panel {
    display: grid;
    gap: var(--space-3);
    animation: fade-up 420ms var(--ease) both;
}

.dashboard-panel[hidden] {
    display: none;
}

.dashboard-search {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: var(--space-3);
    align-items: end;
}

/* ---------------------------------------------------------
   People
   --------------------------------------------------------- */

.profile-summary {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: var(--space-4);
    align-items: center;
}

.profile-summary h2 {
    margin: 0 0 var(--space-1);
    font-family: "Plus Jakarta Sans", Inter, sans-serif;
    letter-spacing: -0.02em;
}

.profile-summary p {
    margin: 0 0 var(--space-3);
}

.user-grid,
.stack-list {
    display: grid;
    gap: var(--space-3);
}

.user-grid {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.user-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-alt);
    transition: transform var(--med), border-color var(--med), background var(--med), box-shadow var(--med);
}

.user-card:hover {
    transform: translateY(-3px);
    border-color: var(--line-strong);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.user-card-content {
    min-width: 0;
}

.user-name {
    display: inline-block;
    color: var(--fg);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    text-decoration: none;
    overflow-wrap: anywhere;
    transition: color var(--fast);
}

.user-name:hover,
.user-name:focus-visible {
    color: var(--accent);
    outline: none;
}

.user-meta,
.relationship-label,
.empty-state {
    margin: 0.3rem 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.relationship-label {
    display: inline-block;
    margin-top: var(--space-2);
    padding: 0.25rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--panel-alt);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.empty-state {
    padding: var(--space-5) var(--space-3);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    color: var(--muted-soft);
    text-align: center;
}

.user-actions {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-top: var(--space-3);
}

.user-avatar-link {
    display: inline-flex;
    color: inherit;
    text-decoration: none;
}

/* ---------------------------------------------------------
   Blocky mini avatar
   --------------------------------------------------------- */

.mini-avatar {
    position: relative;
    width: 92px;
    height: 132px;
    flex: 0 0 auto;
    border-radius: var(--radius-sm);
    background:
        radial-gradient(60% 45% at 50% 96%, rgba(0, 0, 0, 0.55), transparent 70%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01));
    transition: transform var(--med);
}

.user-card:hover .mini-avatar,
.user-avatar-link:hover .mini-avatar {
    transform: translateY(-2px) scale(1.04);
}

.mini-avatar span {
    position: absolute;
    border: 1px solid rgba(0, 0, 0, 0.45);
    border-radius: 3px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.28),
        inset 0 -2px 4px rgba(0, 0, 0, 0.3);
}

.mini-head {
    left: 29px;
    top: 4px;
    width: 34px;
    height: 34px;
    overflow: hidden;
}

.mini-head img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.mini-torso {
    left: 24px;
    top: 38px;
    width: 44px;
    height: 48px;
}

.mini-left-arm,
.mini-right-arm {
    top: 38px;
    width: 18px;
    height: 48px;
}

.mini-left-arm { left: 6px; }
.mini-right-arm { right: 6px; }

.mini-left-leg,
.mini-right-leg {
    top: calc(var(--appbar-h) + var(--space-4));
    width: 22px;
    height: 38px;
}

.mini-left-leg { left: 24px; }
.mini-right-leg { left: 46px; }

/* ---------------------------------------------------------
   Avatar editor
   --------------------------------------------------------- */

.avatar-layout {
    display: grid;
    grid-template-columns: minmax(260px, 0.9fr) minmax(280px, 1.1fr);
    gap: var(--space-3);
}

.avatar-stage,
.profile-stage {
    min-height: 520px;
    display: grid;
    place-items: center;
    padding: var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        radial-gradient(70% 55% at 50% 30%, rgba(255, 70, 85, 0.10), transparent 70%),
        rgba(255, 255, 255, 0.02);
}

.profile-stage {
    min-height: 440px;
}

.avatar-figure {
    width: min(440px, 100%);
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg-soft);
    box-shadow: var(--shadow);
}

.avatar-preview-panel,
.profile-avatar-panel {
    box-shadow: none;
}

.avatar-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
    touch-action: none;
}

.avatar-canvas:active {
    cursor: grabbing;
}

.part-tabs {
    display: flex;
    gap: var(--space-1);
    flex-wrap: wrap;
}

.part-tab {
    min-height: 40px;
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--panel-alt);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--fast);
}

.part-tab:hover {
    color: var(--fg);
    border-color: var(--line-strong);
    background: var(--panel);
}

.part-tab.active {
    border-color: transparent;
    background: var(--accent-grad);
    color: #fff;
    box-shadow: var(--accent-glow);
}

.color-picker-panel {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) auto;
    gap: var(--space-3);
    align-items: end;
    margin: var(--space-4) 0;
}

.color-picker-field {
    display: grid;
    gap: var(--space-1);
    font-weight: 600;
    font-size: 0.9rem;
}

.color-picker-field input[type="color"] {
    width: 100%;
    height: 88px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    transition: border-color var(--fast), transform var(--fast);
}

.color-picker-field input[type="color"]:hover {
    border-color: var(--line-strong);
    transform: translateY(-2px);
}

.color-picker-field input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 4px;
}

.color-picker-field input[type="color"]::-webkit-color-swatch {
    border: 0;
    border-radius: 8px;
}

.color-code {
    min-height: 44px;
    display: inline-grid;
    place-items: center;
    padding: 0.55rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel-alt);
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.face-picker-panel {
    display: grid;
    gap: var(--space-2);
    margin: var(--space-4) 0;
}

.face-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    gap: var(--space-2);
}

.face-option {
    display: grid;
    gap: var(--space-1);
    justify-items: center;
    min-height: 108px;
    padding: var(--space-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel-alt);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.84rem;
    cursor: pointer;
    transition: all var(--fast);
}

.face-option:hover,
.face-option:focus-visible {
    color: var(--fg);
    border-color: var(--line-strong);
    background: var(--panel);
    transform: translateY(-3px);
    outline: none;
}

.face-option.active {
    color: #fff;
    border-color: var(--accent-line);
    background: var(--accent-soft);
    box-shadow: 0 10px 30px -14px rgba(255, 70, 85, 0.8);
}

.face-option img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: 10px;
    background: #f4f6fa;
}

/* ---------------------------------------------------------
   Stats
   --------------------------------------------------------- */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
}

.stat-tile {
    position: relative;
    padding: var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel-alt);
    overflow: hidden;
    transition: border-color var(--med), background var(--med), transform var(--med);
}

.stat-tile:hover {
    border-color: var(--line-strong);
    background: var(--panel);
    transform: translateY(-2px);
}

.stat-tile span {
    display: block;
    color: var(--muted-soft);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.stat-tile strong {
    display: block;
    margin-top: var(--space-1);
    font-family: "Plus Jakarta Sans", Inter, sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    overflow-wrap: anywhere;
}

/* ---------------------------------------------------------
   Game cards
   --------------------------------------------------------- */

.game-grid {
    display: grid;
    /* auto-fill, not auto-fit: empty tracks are kept so a short catalog shows
       normal-sized tiles instead of two cards stretched across the row. */
    grid-template-columns: repeat(auto-fill, minmax(162px, 1fr));
    gap: var(--space-2);
}

.game-card {
    position: relative;
    display: block;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel);
    color: inherit;
    text-decoration: none;
    box-shadow: var(--sheen);
    transition: transform var(--med), border-color var(--med), box-shadow var(--med);
}

.game-card:hover,
.game-card:focus-visible {
    transform: translateY(-4px);
    border-color: var(--accent-line);
    box-shadow: var(--shadow), 0 0 0 1px rgba(255, 70, 85, 0.12), var(--sheen);
    outline: none;
}

.game-card-media {
    display: block;
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-bottom: 1px solid var(--soft-line);
    background: linear-gradient(135deg, #131722, #1c2333);
}

.game-card-media::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, rgba(6, 7, 10, 0.55), transparent 55%);
    opacity: 0.8;
    transition: opacity var(--med);
}

.game-card:hover .game-card-media::after {
    opacity: 0.35;
}

.game-card-media img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.game-card-media img {
    transition: transform 620ms var(--ease);
}

.game-card:hover .game-card-media img {
    transform: scale(1.07);
}

.game-card-body {
    display: block;
    padding: 0.6rem 0.7rem 0.7rem;
}

.game-icon {
    width: 84px;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #131722, #1c2333);
}

.small-icon {
    width: 64px;
}

.game-title-link {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--fg);
    font-family: "Plus Jakarta Sans", Inter, sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.01em;
    text-decoration: none;
    overflow-wrap: anywhere;
    transition: color var(--fast);
}

.game-card:hover .game-title-link,
.game-card:focus-visible .game-title-link {
    color: var(--accent);
}

.game-meta {
    display: block;
    margin: 0.25rem 0 0;
    overflow: hidden;
    color: var(--muted-soft);
    font-size: 0.76rem;
    line-height: 1.4;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Experience page (Roblox-style game detail) */

.experience-head {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(240px, 0.85fr);
    gap: var(--space-5);
    align-items: start;
    margin-bottom: var(--space-4);
}

.experience-media {
    min-width: 0;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 8px;
    background: linear-gradient(135deg, #131722, #1c2333);
}

.experience-thumb {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.experience-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding-top: 0.2rem;
}

.experience-title {
    margin: 0;
    font-family: "Plus Jakarta Sans", Inter, sans-serif;
    font-size: clamp(1.6rem, 3vw, 2.15rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.experience-creator,
.experience-maturity {
    margin: 0.45rem 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.experience-creator a {
    color: var(--fg);
    font-weight: 600;
    text-decoration: none;
}

.experience-creator a:hover {
    text-decoration: underline;
}

.play-cta {
    width: 100%;
    max-width: 260px;
    height: 56px;
    margin-top: 1.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 10px;
    background: var(--accent-grad);
    color: #fff;
    cursor: pointer;
    box-shadow: var(--accent-glow);
    transition: filter var(--fast);
}

.play-cta:hover,
.play-cta:focus-visible {
    filter: brightness(1.08);
}

.play-cta:disabled {
    opacity: 0.65;
    cursor: wait;
}

.experience-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: start;
    width: 100%;
    max-width: 260px;
    margin-top: 14px;
}

.experience-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
    min-height: 48px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 0.75rem;
    line-height: 1;
    cursor: pointer;
}

.experience-chip svg {
    display: block;
    flex: 0 0 22px;
}

.experience-chip span {
    display: block;
    min-height: 1em;
    line-height: 1;
    white-space: nowrap;
}

.experience-chip.is-on,
.experience-chip:hover,
.experience-chip:focus-visible {
    color: var(--fg);
}

.experience-chip.is-on svg {
    color: var(--accent);
}

.experience-chip.is-locked {
    opacity: 0.55;
}

.experience-summary {
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

.vote-hint {
    margin: 10px 0 0;
    max-width: 260px;
    color: var(--muted-soft);
    font-size: 0.8rem;
}

.confirm-dialog {
    width: min(92vw, 380px);
    padding: 1.5rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg-soft);
    color: var(--fg);
    box-shadow: var(--shadow-lg);
}

.confirm-dialog[open] {
    animation: dialog-in var(--med);
}

.confirm-dialog::backdrop {
    background: rgba(3, 4, 8, 0.6);
    backdrop-filter: blur(4px);
}

.confirm-dialog h2 {
    margin: 0 0 0.4rem;
    font-family: "Plus Jakarta Sans", Inter, sans-serif;
    font-size: 1.2rem;
}

.confirm-dialog p {
    margin: 0 0 1.25rem;
    color: var(--muted);
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
}

@keyframes dialog-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
}

@media (prefers-reduced-motion: reduce) {
    .confirm-dialog[open] { animation: none; }
}

button.experience-chip:focus-visible {
    outline: none;
    color: var(--fg);
}

.experience-meta > .status {
    min-height: 0;
    margin-top: 12px;
}

.experience-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin: var(--space-2) 0 var(--space-4);
    border-bottom: 1px solid var(--line);
}

.experience-tab {
    position: relative;
    min-height: 48px;
    padding: 0.7rem 0.5rem;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
}

.experience-tab.is-active {
    color: var(--fg);
}

.experience-tab.is-active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 3px;
    background: var(--fg);
}

.experience-section-title {
    margin: 0 0 var(--space-2);
    font-size: 1.05rem;
    font-weight: 700;
}

.experience-description {
    margin: 0 0 var(--space-4);
    color: var(--muted);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.6;
}

.servers-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.servers-count {
    margin: 0;
    color: var(--muted-soft);
    font-size: 0.85rem;
}

.servers-toolbar-actions {
    display: flex;
    gap: var(--space-2);
}

.rbx-server {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel-alt);
}

.rbx-server-meta strong {
    display: block;
}

.rbx-server-meta span {
    color: var(--muted-soft);
    font-size: 0.82rem;
}

.game-detail-grid,
.create-layout {
    display: grid;
    grid-template-columns: minmax(280px, 0.85fr) minmax(320px, 1.15fr);
    gap: var(--space-3);
    align-items: start;
}

.launch-panel {
    grid-column: 1 / -1;
}

.launch-command {
    margin: 0;
    padding: var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.45);
    color: #d6e2ff;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 0.88rem;
    line-height: 1.6;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.my-game-row,
.server-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel-alt);
    transition: border-color var(--med), background var(--med), transform var(--med);
}

.my-game-row:hover,
.server-row:hover {
    border-color: var(--line-strong);
    background: var(--panel);
    transform: translateX(3px);
}

.server-row {
    grid-template-columns: minmax(0, 1fr) auto;
}

.server-row strong,
.server-row span {
    overflow-wrap: anywhere;
}

/* Live dot on active server rows */
.server-row strong::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 0.5rem;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
    animation: live-pulse 2s ease-out infinite;
}

@keyframes live-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6); }
    70%  { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.search-layout {
    grid-template-columns: minmax(260px, 0.55fr) minmax(320px, 1.45fr);
}

.search-panel {
    display: grid;
    gap: var(--space-3);
}

.profile-layout {
    grid-template-columns: minmax(300px, 0.9fr) minmax(300px, 1.1fr);
}

.profile-friends-panel {
    grid-column: 1 / -1;
}

/* ---------------------------------------------------------
   Focus visibility (keyboard users)
   --------------------------------------------------------- */

:is(a, button, input, textarea, select, [tabindex]):focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: var(--radius-sm);
}

/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */

/* The profile column of the dashboard gets too narrow for a side-by-side
   avatar + text layout well before the main 820px breakpoint. */
@media (max-width: 1040px) {
    .profile-summary {
        grid-template-columns: 1fr;
        justify-items: start;
    }
}

@media (max-width: 820px) {
    .topbar,
    .dashboard-head {
        align-items: flex-start;
        flex-direction: column;
        border-radius: var(--radius);
    }

    .topbar {
        position: static;
    }

    .hero,
    .grid,
    .avatar-layout,
    .social-dashboard,
    .search-layout,
    .profile-layout,
    .game-detail-grid,
    .create-layout {
        grid-template-columns: 1fr;
    }

    .hero {
        min-height: auto;
    }

    .info-stack {
        padding-left: 0;
        padding-top: var(--space-4);
        border-left: 0;
        border-top: 1px solid var(--line);
    }

    .page-title {
        font-size: clamp(2.4rem, 14vw, 4.5rem);
    }

    .color-picker-panel,
    .dashboard-search,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .profile-friends-panel {
        grid-column: auto;
    }

    .experience-head {
        grid-template-columns: 1fr;
    }

    .play-cta,
    .experience-actions {
        width: 100%;
        max-width: none;
    }
}

@media (max-width: 520px) {
    .panel-heading,
    .profile-summary,
    .user-card,
    .game-card-body,
    .my-game-row,
    .server-row,
    .servers-toolbar {
        grid-template-columns: 1fr;
    }

    .servers-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .panel-heading {
        display: grid;
    }

    .nav {
        gap: 2px;
    }

    .nav a {
        padding: 0 var(--space-2);
        font-size: 0.88rem;
    }
}

/* ---------------------------------------------------------
   Reduced motion
   --------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* =========================================================
   App shell: sidebar + app bar
   ========================================================= */

:root {
    --appbar-h: 62px;
    --side-w: 250px;
}

/* Full-bleed: the shell owns the whole viewport, no centred max-width. */
.page.has-shell {
    width: 100%;
    margin: 0;
    padding: 0;
}

.shell-main {
    min-width: 0;
    margin-left: var(--side-w);
    padding: calc(var(--appbar-h) + var(--space-4)) var(--space-4) var(--space-6);
}

/* Pinned to the left edge, full height, flush against the app bar. */
.sidebar {
    position: fixed;
    left: 0;
    top: var(--appbar-h);
    bottom: 0;
    z-index: 30;
    width: var(--side-w);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-2);
    overflow-y: auto;
    overscroll-behavior: contain;
    border-right: 1px solid var(--line);
    background: rgba(9, 11, 16, 0.92);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
}

.side-nav {
    display: grid;
    gap: 2px;
}

.side-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    min-height: 44px;
    padding: 0 var(--space-3);
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: color var(--fast), background var(--fast), transform var(--fast);
}

.side-link:hover,
.side-link:focus-visible {
    color: var(--fg);
    background: var(--panel);
    transform: translateX(3px);
    outline: none;
}

.side-link .nav-icon {
    flex: 0 0 auto;
    opacity: 0.85;
}

.side-link[aria-current="page"] {
    color: #fff;
    background: var(--accent-soft);
}

.side-link[aria-current="page"]::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 50%;
    width: 3px;
    height: 20px;
    border-radius: 3px;
    background: var(--accent-grad);
    transform: translateY(-50%);
}

.side-foot {
    display: grid;
    gap: var(--space-2);
    margin-top: auto;
    padding-top: var(--space-3);
    border-top: 1px solid var(--soft-line);
}

.side-logout:hover,
.side-logout:focus-visible {
    color: var(--danger);
    background: rgba(255, 95, 109, 0.1);
}

/* App bar */

.appbar {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    z-index: 50;
    height: var(--appbar-h);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0 var(--space-4) 0 var(--space-3);
    border-bottom: 1px solid var(--line);
    background: rgba(9, 11, 16, 0.9);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
}

.appbar .brand {
    flex: 0 0 auto;
    width: calc(var(--side-w) - var(--space-4));
    padding-left: var(--space-1);
}

.icon-button {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--panel);
    color: var(--fg);
    cursor: pointer;
    transition: background var(--fast);
}

.icon-button:hover {
    background: var(--panel-hover);
}

.appbar-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 1 1 auto;
    min-width: 0;
    max-width: 420px;
    padding: 0 var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted-soft);
    transition: border-color var(--fast), background var(--fast), box-shadow var(--fast);
}

.appbar-search:focus-within {
    border-color: var(--accent-line);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.appbar-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 40px;
    border: 0;
    background: transparent;
    color: var(--fg);
    outline: none;
}

.appbar-input::placeholder {
    color: var(--muted-soft);
}

.appbar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-left: auto;
}

/* User chip + dropdown */

.chip-wrap {
    position: relative;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    height: 42px;
    padding: 0 var(--space-2) 0 5px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--panel);
    color: var(--fg);
    font-weight: 600;
    cursor: pointer;
    transition: background var(--fast), border-color var(--fast);
}

.user-chip:hover {
    background: var(--panel-hover);
    border-color: var(--line-strong);
}

.chip-avatar {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    overflow: hidden;
    border-radius: 50%;
    background: var(--accent-grad);
    color: #fff;
    font-weight: 800;
    font-size: 0.9rem;
}

.chip-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chip-name {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    z-index: 60;
    display: grid;
    gap: 2px;
    min-width: 190px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(14, 16, 24, 0.94);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    box-shadow: var(--shadow-lg);
    animation: fade-up 200ms var(--ease) both;
}

.user-menu[hidden] {
    display: none;
}

.user-menu a,
.user-menu button {
    display: block;
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: color var(--fast), background var(--fast);
}

.user-menu a:hover,
.user-menu button:hover,
.user-menu a:focus-visible,
.user-menu button:focus-visible {
    color: var(--fg);
    background: var(--panel-hover);
    outline: none;
}

.user-menu button:hover {
    color: var(--danger);
}

.sidebar-scrim {
    display: none;
}

/* =========================================================
   Skeleton loaders
   ========================================================= */

.skeleton {
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
}

.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.09), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    100% { transform: translateX(100%); }
}

.skeleton-card {
    pointer-events: none;
}

.skeleton-card:hover {
    transform: none;
    border-color: var(--line);
    box-shadow: var(--shadow), var(--sheen);
}

.skeleton-media {
    aspect-ratio: 16 / 9;
    border-radius: 0;
}

.skeleton-icon {
    width: 84px;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-sm);
}

.skeleton-mini {
    width: 92px;
    height: 132px;
    border-radius: var(--radius-sm);
}

.skeleton-line {
    height: 12px;
    margin-bottom: 10px;
}

.skeleton-pill {
    border-radius: var(--radius-pill);
}

/* =========================================================
   Games page rail
   ========================================================= */

.games-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 328px;
    gap: var(--space-4);
    align-items: start;
}

.games-main {
    min-width: 0;
}

.games-rail {
    position: sticky;
    top: calc(var(--appbar-h) + var(--space-4));
    display: grid;
    gap: var(--space-3);
}

.games-rail[hidden] {
    display: none;
}

.rail-panel {
    padding: var(--space-3);
}

.rail-panel h2 {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0 0 var(--space-1);
    font-size: 1.1rem;
}

.rail-me {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: var(--space-3);
    align-items: center;
}

.rail-meta {
    margin: 0.2rem 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.rail-count {
    display: inline-grid;
    place-items: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.4rem;
    border-radius: var(--radius-pill);
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
}

.rail-list {
    display: grid;
    gap: 4px;
}

.rail-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: var(--space-2);
    align-items: center;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    color: inherit;
    text-decoration: none;
    transition: background var(--fast), transform var(--fast);
}

.rail-row:hover,
.rail-row:focus-visible {
    background: var(--panel-hover);
    transform: translateX(3px);
    outline: none;
}

.rail-row-text {
    display: grid;
    min-width: 0;
}

.rail-row-text strong {
    overflow: hidden;
    font-size: 0.94rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rail-row-text span {
    color: var(--muted-soft);
    font-size: 0.8rem;
}

/* The blocky avatar is built from absolutely positioned parts with fixed pixel
   offsets, so `transform: scale` would shrink each part without moving it.
   `zoom` scales the whole box and its layout size together. */
.mini-avatar.rail-mini {
    zoom: 0.41;
}

.mini-avatar.rail-mini-lg {
    zoom: 0.7;
}

/* =========================================================
   Settings
   ========================================================= */

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
    gap: var(--space-3);
    align-items: start;
}

.setting-list {
    display: grid;
    gap: 2px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    min-height: 46px;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sm);
}

.setting-row:nth-child(odd) {
    background: var(--panel-alt);
}

.setting-row strong {
    overflow-wrap: anywhere;
    text-align: right;
}

.swatches {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: var(--space-2) 0 var(--space-4);
}

.swatch {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 42px;
    padding: 0 var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--panel-alt);
    color: var(--muted);
    font: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--fast);
}

.swatch:hover {
    color: var(--fg);
    border-color: var(--line-strong);
    transform: translateY(-2px);
}

.swatch.active {
    color: #fff;
    border-color: var(--accent-line);
    background: var(--accent-soft);
}

.swatch-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.setting-toggle {
    padding-top: var(--space-3);
    border-top: 1px solid var(--soft-line);
}

.setting-hint {
    margin: 0;
    color: var(--muted-soft);
    font-size: 0.86rem;
}

/* =========================================================
   Shell responsive
   ========================================================= */

@media (max-width: 1180px) {
    .games-layout {
        grid-template-columns: 1fr;
    }

    .games-rail {
        position: static;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
}

@media (max-width: 960px) {
    .shell-main {
        margin-left: 0;
        padding-left: var(--space-3);
        padding-right: var(--space-3);
    }

    .icon-button {
        display: inline-flex;
    }

    .appbar .brand {
        width: auto;
    }

    .sidebar {
        z-index: 80;
        width: 264px;
        background: rgba(10, 12, 18, 0.97);
        transform: translateX(-102%);
        transition: transform 280ms var(--ease);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 70;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(2px);
        animation: fade-up 200ms var(--ease) both;
    }

    .sidebar-scrim[hidden] {
        display: none;
    }
}

@media (max-width: 620px) {
    .chip-name {
        display: none;
    }

    /* At this width the hamburger, wordmark, search, bell and avatar no longer
       fit on one row, and the actions were being pushed off-screen. Drop the
       wordmark to its logo square and let the search field shrink. */
    .appbar .brand span {
        display: none;
    }

    .appbar {
        gap: var(--space-2);
        padding-right: var(--space-2);
    }

    .appbar-search {
        max-width: none;
        min-width: 0;
        padding: 0 var(--space-2);
    }

    .appbar-actions {
        flex: 0 0 auto;
    }

    .rail-me {
        grid-template-columns: 1fr;
    }
}

/* =========================================================
   Reduce motion preference (Settings > Appearance)
   ========================================================= */

:root[data-reduce-motion] *,
:root[data-reduce-motion] *::before,
:root[data-reduce-motion] *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

/* =========================================================
   Home: friends strip + recommended sections
   ========================================================= */

.home-section {
    margin-bottom: var(--space-5);
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.section-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
    font-family: "Plus Jakarta Sans", Inter, sans-serif;
    font-size: 1.22rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.section-count {
    display: inline-grid;
    place-items: center;
    min-width: 1.6rem;
    height: 1.6rem;
    padding: 0 0.45rem;
    border-radius: var(--radius-pill);
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 700;
}

/* Horizontal friend rail */

.friend-strip {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    padding: var(--space-1) 2px var(--space-3);
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
}

.friend-strip::-webkit-scrollbar {
    height: 8px;
}

.friend-chip {
    display: grid;
    justify-items: center;
    gap: 0.45rem;
    flex: 0 0 auto;
    width: 88px;
    color: var(--muted);
    text-decoration: none;
    scroll-snap-align: start;
}

.friend-avatar {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 72px;
    height: 72px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    transition: transform var(--med), border-color var(--med), box-shadow var(--med);
}

.friend-chip:hover .friend-avatar,
.friend-chip:focus-visible .friend-avatar {
    transform: translateY(-4px) scale(1.05);
    border-color: var(--accent-line);
    box-shadow: var(--accent-glow);
}

/* The blocky avatar is 92x132; zooming it and clipping to the circle gives a
   head-and-shoulders portrait rather than the full body. */
.friend-avatar .mini-avatar {
    zoom: 1.55;
    background: none;
}

.friend-name {
    max-width: 100%;
    overflow: hidden;
    font-size: 0.82rem;
    font-weight: 600;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color var(--fast);
}

.friend-chip:hover .friend-name,
.friend-chip:focus-visible .friend-name {
    color: var(--fg);
}

.friend-chip:focus-visible {
    outline: none;
}

/* "Add friends" tile */

.friend-add .friend-avatar {
    display: grid;
    place-items: center;
    border-style: dashed;
    border-color: var(--line-strong);
    background: transparent;
    color: var(--muted);
    font-size: 1.9rem;
    font-weight: 300;
    line-height: 1;
}

.friend-add:hover .friend-avatar {
    color: var(--accent);
}

.friend-strip-empty {
    margin: 0;
    padding: var(--space-4);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    color: var(--muted-soft);
}

/* Home welcome heading sits tighter than a full page title. */
.home-heading {
    margin: 0 0 var(--space-4);
    font-size: clamp(1.9rem, 4vw, 2.6rem);
}

/* =========================================================
   Notification bell + panel
   ========================================================= */

.appbar-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--panel);
    color: var(--muted);
    cursor: pointer;
    transition: color var(--fast), background var(--fast), border-color var(--fast);
}

.appbar-icon:hover,
.appbar-icon[aria-expanded="true"] {
    color: var(--fg);
    background: var(--panel-hover);
    border-color: var(--line-strong);
}

.bell-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    display: grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-pill);
    background: var(--accent-grad);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 0 0 2px rgba(9, 11, 16, 0.9);
    animation: badge-pop 320ms var(--ease) both;
}

.bell-badge[hidden] {
    display: none;
}

@keyframes badge-pop {
    from { transform: scale(0.4); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

.notif-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    z-index: 60;
    width: min(380px, calc(100vw - 32px));
    max-height: min(520px, calc(100vh - 100px));
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(14, 16, 24, 0.96);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    box-shadow: var(--shadow-lg);
    animation: fade-up 200ms var(--ease) both;
}

.notif-panel[hidden] {
    display: none;
}

.notif-head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3);
    border-bottom: 1px solid var(--soft-line);
    background: inherit;
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
}

.notif-head strong {
    font-family: "Plus Jakarta Sans", Inter, sans-serif;
    font-size: 1rem;
    letter-spacing: -0.01em;
}

.notif-head a {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: color var(--fast);
}

.notif-head a:hover {
    color: var(--accent);
}

.notif-list {
    display: grid;
    gap: var(--space-2);
    padding: var(--space-2);
}

.notif-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: var(--space-2);
    padding: var(--space-2);
    border: 1px solid var(--soft-line);
    border-radius: var(--radius-sm);
    background: var(--panel-alt);
    transition: background var(--fast), border-color var(--fast);
}

.notif-item:hover {
    background: var(--panel);
    border-color: var(--line);
}

.notif-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: linear-gradient(135deg, #131722, #1c2333);
}

.notif-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Friend requests show the blocky avatar cropped to a portrait. */
.notif-icon-avatar {
    align-items: start;
    border-radius: 50%;
}

.notif-icon-avatar .mini-avatar {
    zoom: 0.95;
    background: none;
}

.notif-body {
    min-width: 0;
}

.notif-title {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.notif-text {
    margin: 0.2rem 0 0;
    color: var(--muted-soft);
    font-size: 0.78rem;
}

.notif-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin-top: var(--space-2);
}

.notif-actions .button.small {
    min-height: 32px;
    padding: 0.3rem 0.8rem;
    font-size: 0.82rem;
}

.notif-empty {
    margin: 0;
    padding: var(--space-5) var(--space-3);
    color: var(--muted-soft);
    text-align: center;
}

/* The panel is anchored to the bell, which sits close enough to the right edge
   that a 380px panel hangs off the left of a phone screen. Pin it to the
   viewport instead once there is no room. */
@media (max-width: 620px) {
    .notif-panel {
        position: fixed;
        left: var(--space-2);
        right: var(--space-2);
        top: calc(var(--appbar-h) + var(--space-2));
        width: auto;
        max-height: calc(100vh - var(--appbar-h) - var(--space-5));
    }
}

/* =========================================================
   Currency + wallet
   ========================================================= */

.coin {
    display: inline-block;
    flex: 0 0 auto;
    width: 1em;
    height: 1em;
    border-radius: 50%;
    background: linear-gradient(145deg, #ffd869 0%, #f2a33c 55%, #c97b1e 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.65),
        inset 0 -2px 3px rgba(0, 0, 0, 0.28);
}

.currency-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    height: 42px;
    padding: 0 var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--panel);
    color: var(--fg);
    font-weight: 700;
    font-size: 0.92rem;
    font-variant-numeric: tabular-nums;
    text-decoration: none;
    transition: background var(--fast), border-color var(--fast), transform var(--fast);
}

.currency-chip:hover,
.currency-chip:focus-visible {
    background: var(--panel-hover);
    border-color: var(--line-strong);
    transform: translateY(-1px);
    outline: none;
}

.currency-chip .coin {
    font-size: 1.05rem;
}

/* Wallet page */

.wallet-balance-card {
    margin-bottom: var(--space-5);
    padding: var(--space-4);
}

.wallet-balance {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: var(--space-1) 0 var(--space-2);
    font-family: "Plus Jakarta Sans", Inter, sans-serif;
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.wallet-balance .coin {
    font-size: 0.8em;
}

.wallet-notice {
    margin: 0 0 var(--space-3);
    padding: var(--space-2) var(--space-3);
    border: 1px solid rgba(87, 166, 255, 0.35);
    border-radius: var(--radius-sm);
    background: rgba(87, 166, 255, 0.1);
    color: var(--info);
    font-size: 0.86rem;
}

.wallet-notice[hidden] {
    display: none;
}

.pack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: var(--space-3);
}

.pack-card {
    display: grid;
    gap: var(--space-1);
    padding: var(--space-3);
    text-align: center;
    justify-items: center;
}

.pack-card .label {
    margin: 0;
}

.pack-amount {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    font-family: "Plus Jakarta Sans", Inter, sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.pack-card .setting-hint {
    margin-bottom: var(--space-2);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--muted);
}

/* Transaction history */

.tx-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel-alt);
    transition: background var(--fast), border-color var(--fast);
}

.tx-row:hover {
    background: var(--panel);
    border-color: var(--line-strong);
}

.tx-row strong {
    display: block;
    font-size: 0.95rem;
}

.tx-row .game-meta {
    white-space: normal;
}

.tx-amount {
    flex: 0 0 auto;
    font-family: "Plus Jakarta Sans", Inter, sans-serif;
    font-size: 1.05rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.tx-amount.positive {
    color: var(--success);
}

.tx-amount.negative {
    color: var(--danger);
}

@media (max-width: 620px) {
    /* The bar cannot hold both the search field and the balance. The balance
       wins here because it is also the entry point to buying and history;
       search stays reachable from the Friends page in the sidebar. */
    .appbar-search {
        display: none;
    }
}

/* =========================================================
   Currency dropdown
   ========================================================= */

.currency-chip {
    cursor: pointer;
}

.currency-chip[aria-expanded="true"] {
    background: var(--panel-hover);
    border-color: var(--line-strong);
}

.currency-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    z-index: 60;
    display: grid;
    gap: 2px;
    min-width: 232px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(14, 16, 24, 0.96);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    box-shadow: var(--shadow-lg);
    animation: fade-up 200ms var(--ease) both;
}

.currency-menu[hidden] {
    display: none;
}

/* The chip may only say "10K+", so the exact figure lives here. */
.currency-menu-head {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    padding: var(--space-2) 0.8rem var(--space-3);
    margin-bottom: 4px;
    border-bottom: 1px solid var(--soft-line);
}

.currency-menu-head .coin {
    align-self: center;
    font-size: 1.15rem;
}

.currency-menu-head strong {
    font-family: "Plus Jakarta Sans", Inter, sans-serif;
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.currency-menu-unit {
    color: var(--muted-soft);
    font-size: 0.82rem;
    font-weight: 600;
}

.currency-menu a {
    display: block;
    padding: 0.6rem 0.8rem;
    border-radius: 9px;
    color: var(--muted);
    font-weight: 600;
    text-decoration: none;
    transition: color var(--fast), background var(--fast);
}

.currency-menu a:hover,
.currency-menu a:focus-visible {
    color: var(--fg);
    background: var(--panel-hover);
    outline: none;
}

/* Jumping to #buy / #history must clear the fixed app bar. */
.home-section[id] {
    scroll-margin-top: calc(var(--appbar-h) + var(--space-4));
}

@media (max-width: 620px) {
    .currency-menu {
        position: fixed;
        left: var(--space-2);
        right: var(--space-2);
        top: calc(var(--appbar-h) + var(--space-2));
        min-width: 0;
    }
}

/* =========================================================
   Profile page
   ========================================================= */

.profile-hero {
    position: relative;
    margin-bottom: var(--space-3);
    animation: fade-up 520ms var(--ease) both;
}

.profile-banner {
    height: 120px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        radial-gradient(60% 140% at 12% 0%, var(--accent-soft), transparent 70%),
        radial-gradient(50% 120% at 88% 100%, rgba(87, 120, 255, 0.12), transparent 70%),
        linear-gradient(135deg, #151924, #1d2231);
}

.profile-head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: end;
    gap: var(--space-4);
    padding: 0 var(--space-3);
    /* Pull the headshot up so it overlaps the banner, as on Roblox. */
    margin-top: -64px;
}

.profile-headshot {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 136px;
    height: 136px;
    overflow: hidden;
    border: 4px solid var(--bg);
    border-radius: 50%;
    background:
        radial-gradient(70% 60% at 50% 30%, rgba(255, 255, 255, 0.10), transparent 70%),
        #1a1f2b;
    box-shadow: 0 0 0 1px var(--line), var(--shadow);
}

/* 92x132 blocky figure zoomed so the head fills the circle and the
   shoulders show underneath - a headshot rather than a full body. */
.profile-headshot .mini-avatar {
    zoom: 2.4;
    background: none;
}

.profile-ident {
    min-width: 0;
    padding-bottom: var(--space-2);
}

.profile-name {
    margin: 0;
    overflow: hidden;
    font-family: "Plus Jakarta Sans", Inter, sans-serif;
    font-size: clamp(1.6rem, 3.4vw, 2.1rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-handle {
    margin: 0.15rem 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.profile-actions {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding-bottom: var(--space-2);
}

.profile-actions .user-actions {
    margin: 0;
}

.profile-more {
    min-width: 44px;
    padding: 0 0.9rem;
    letter-spacing: 0.08em;
}

/* Menu items here are ordinary actions; the danger hover belongs to Log out. */
.profile-menu button:hover,
.profile-menu button:focus-visible {
    color: var(--fg);
}

.profile-pills {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin: var(--space-3) var(--space-3) 0;
}

.profile-pill {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 0.9rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--panel-alt);
    color: var(--muted);
    font: inherit;
    font-size: 0.86rem;
    font-weight: 600;
}

.profile-pill.strong {
    color: var(--fg);
    background: var(--panel);
    cursor: pointer;
    transition: background var(--fast), border-color var(--fast);
}

.profile-pill.strong:hover {
    background: var(--panel-hover);
    border-color: var(--line-strong);
}

/* Bio */

.profile-bio {
    margin: var(--space-3) var(--space-3) 0;
    max-width: 72ch;
}

.profile-bio-text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    margin: 0;
    overflow: hidden;
    color: var(--fg);
    font-size: 0.95rem;
    line-height: 1.6;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.profile-bio-text.expanded {
    display: block;
    -webkit-line-clamp: unset;
}

.profile-bio-text.empty {
    color: var(--muted-soft);
}

.profile-more-link {
    margin-top: 0.2rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.profile-more-link:hover {
    color: var(--fg);
}

.profile-bio-input {
    min-height: 110px;
}

.profile-bio-edit {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-top: var(--space-2);
}

.profile-bio-edit .actions {
    margin: 0;
}

/* Tabs */

.profile-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin: var(--space-4) 0 var(--space-4);
    border-bottom: 1px solid var(--line);
}

.profile-tab {
    position: relative;
    padding: 0.85rem 1rem;
    border: 0;
    background: none;
    color: var(--muted);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: color var(--fast), background var(--fast);
}

.profile-tab:hover {
    color: var(--fg);
    background: var(--panel-alt);
}

.profile-tab.active {
    color: var(--fg);
}

.profile-tab::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    border-radius: 2px;
    background: var(--accent-grad);
    transform: scaleX(0);
    transition: transform var(--med);
}

.profile-tab.active::after {
    transform: scaleX(1);
}

/* Currently wearing */

.wearing-row {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    padding-bottom: var(--space-2);
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
}

.wear-tile {
    display: grid;
    gap: 0.2rem;
    flex: 0 0 150px;
    scroll-snap-align: start;
}

.wear-visual {
    display: grid;
    place-items: center;
    aspect-ratio: 1 / 1;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background:
        radial-gradient(70% 60% at 50% 35%, rgba(255, 255, 255, 0.08), transparent 70%),
        var(--panel);
    transition: border-color var(--fast), transform var(--fast);
}

.wear-tile:hover .wear-visual {
    border-color: var(--line-strong);
    transform: translateY(-2px);
}

.wear-tile strong {
    margin-top: 0.35rem;
    overflow: hidden;
    font-size: 0.88rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wear-tile span {
    color: var(--muted-soft);
    font-size: 0.76rem;
    font-variant-numeric: tabular-nums;
}

.wear-face {
    width: 62%;
    aspect-ratio: 1 / 1;
    padding: 6px;
    border: 1px solid rgba(0, 0, 0, 0.45);
    border-radius: 14px;
    object-fit: contain;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), inset 0 -3px 6px rgba(0, 0, 0, 0.25);
}

/* Each body part drawn as a block in its own proportions. */
.wear-part {
    display: block;
    border: 1px solid rgba(0, 0, 0, 0.45);
    border-radius: 6px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        inset 0 -4px 8px rgba(0, 0, 0, 0.28);
}

.wear-part-head { width: 60px; height: 60px; border-radius: 10px; }
.wear-part-torso { width: 78px; height: 86px; }
.wear-part-leftArm,
.wear-part-rightArm { width: 32px; height: 86px; }
.wear-part-leftLeg,
.wear-part-rightLeg { width: 38px; height: 80px; }

.wear-tile-skeleton {
    flex: 0 0 150px;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-sm);
}

/* Friends strip "See all" expands to a wrapped grid. */
.friend-strip.expanded {
    flex-wrap: wrap;
    overflow-x: visible;
}

.friend-strip > .empty-state {
    flex: 1 1 100%;
}

/* An empty message inside any game grid should span the whole row. */
.game-grid > .empty-state {
    grid-column: 1 / -1;
}

@media (max-width: 720px) {
    .profile-head {
        grid-template-columns: 1fr;
        align-items: start;
        gap: var(--space-2);
        margin-top: -56px;
    }

    .profile-headshot {
        width: 112px;
        height: 112px;
    }

    .profile-headshot .mini-avatar {
        zoom: 1.95;
    }

    .profile-actions {
        flex-wrap: wrap;
    }
}

/* =========================================================
   Sign-up birthday picker + captcha slot
   ========================================================= */

.birthday-field {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.birthday-field legend {
    margin-bottom: var(--space-1);
    padding: 0;
    font-weight: 600;
    font-size: 0.92rem;
}

.birthday-row {
    display: grid;
    grid-template-columns: 1.5fr 0.9fr 1.1fr;
    gap: var(--space-1);
}

select.input {
    appearance: none;
    padding-right: 2.1rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23949cb0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    cursor: pointer;
}

select.input option {
    background: #10131b;
    color: var(--fg);
}

.captcha-slot {
    display: flex;
    justify-content: center;
    min-height: 78px;
}

/* Captcha disabled on this server: nothing is rendered, so take no space. */
.captcha-slot:empty {
    display: none;
}

/* =========================================================
   Marketplace
   ========================================================= */

.market-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.market-head .home-heading {
    margin: 0;
}

.market-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
}

.market-query {
    width: 260px;
}

.market-category-select {
    width: 170px;
}

.market-filter-toggle {
    display: none;
    margin-bottom: var(--space-3);
}

.market-layout {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    gap: var(--space-4);
    align-items: start;
}

.market-filters {
    position: sticky;
    top: calc(var(--appbar-h) + var(--space-4));
    display: grid;
    gap: var(--space-4);
    max-height: calc(100vh - var(--appbar-h) - var(--space-5));
    overflow-y: auto;
    padding: var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-alt);
    scrollbar-width: thin;
}

.market-filter-title {
    margin: 0 0 var(--space-1);
    color: var(--muted-soft);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.market-categories {
    display: grid;
    gap: 2px;
}

.market-category {
    padding: 0.5rem 0.7rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: color var(--fast), background var(--fast);
}

.market-category:hover {
    color: var(--fg);
    background: var(--panel);
}

.market-category.active {
    color: #fff;
    background: var(--accent-soft);
}

.market-options {
    display: grid;
    gap: 2px;
}

.market-radio {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 30px;
    color: var(--muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: color var(--fast);
}

.market-radio:hover {
    color: var(--fg);
}

.market-radio input {
    width: 1rem;
    height: 1rem;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.market-inline {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.market-inline .input {
    min-width: 0;
    min-height: 36px;
    padding: 0.4rem 0.6rem;
    font-size: 0.88rem;
}

.market-count {
    color: var(--muted-soft);
    font-size: 0.88rem;
    font-variant-numeric: tabular-nums;
}

/* Item tiles */

.market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--space-3);
}

.market-grid > .market-empty {
    grid-column: 1 / -1;
}

.market-tile {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.market-tile-media {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background:
        radial-gradient(70% 60% at 50% 35%, rgba(255, 255, 255, 0.08), transparent 70%),
        var(--panel);
    transition: border-color var(--fast), transform var(--fast);
}

.market-tile:hover .market-tile-media {
    border-color: var(--line-strong);
    transform: translateY(-3px);
}

.market-tile-media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.market-badge {
    position: absolute;
    left: 8px;
    bottom: 8px;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: rgba(0, 0, 0, 0.65);
    color: var(--success);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.market-tile-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-top: 6px;
    overflow: hidden;
    font-size: 0.9rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.market-tile-creator {
    overflow: hidden;
    color: var(--muted-soft);
    font-size: 0.78rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.market-tile-price {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.88rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Empty catalogue / no matches */

.market-empty {
    display: grid;
    justify-items: center;
    gap: var(--space-2);
    padding: var(--space-6) var(--space-4);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    text-align: center;
}

.market-empty-icon {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
}

.market-empty-icon .nav-icon {
    width: 30px;
    height: 30px;
}

.market-empty h3 {
    margin: 0;
    font-family: "Plus Jakarta Sans", Inter, sans-serif;
    font-size: 1.2rem;
    letter-spacing: -0.01em;
}

.market-empty p {
    max-width: 42ch;
    margin: 0;
    color: var(--muted);
}

.market-empty .actions {
    justify-content: center;
    margin-top: var(--space-2);
}

@media (max-width: 900px) {
    .market-layout {
        grid-template-columns: 1fr;
    }

    .market-filter-toggle {
        display: inline-flex;
    }

    /* Filters fold away behind the toggle on narrow screens. */
    .market-filters {
        display: none;
        position: static;
        max-height: none;
    }

    .market-filters.open {
        display: grid;
    }
}

@media (max-width: 620px) {
    .market-toolbar {
        width: 100%;
    }

    .market-query {
        flex: 1 1 100%;
        width: auto;
    }

    .market-category-select {
        flex: 1 1 auto;
        width: auto;
    }
}

/* ---------------------------------------------------------
   Avatar Studio
   --------------------------------------------------------- */

.studio-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
}

.studio-head-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.studio-head-actions .status {
    min-height: 0;
    margin: 0;
}

.studio-layout {
    display: grid;
    grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
    gap: var(--space-4);
    align-items: start;
}

.studio-preview {
    position: sticky;
    top: var(--space-3);
    display: grid;
    gap: var(--space-2);
}

.studio-stage {
    aspect-ratio: 4 / 5;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 24px;
    background:
        radial-gradient(60% 45% at 50% 38%, var(--accent-soft), transparent 72%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01)),
        var(--bg-soft);
    box-shadow: var(--shadow), var(--sheen);
}

.studio-hint {
    margin: 0;
    color: var(--muted-soft);
    font-size: 0.82rem;
    text-align: center;
}

.studio-wearing h2 {
    margin: var(--space-2) 0 var(--space-1);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.wearing-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.wearing-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 32px;
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--panel);
    font-size: 0.85rem;
    font-weight: 600;
}

.wearing-chip button {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    margin-right: -0.4rem;
    border: 0;
    border-radius: 50%;
    background: var(--panel-hover);
    color: var(--muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.wearing-chip button:hover,
.wearing-chip button:focus-visible {
    background: var(--accent-soft);
    color: var(--fg);
}

.studio .page-title {
    font-size: clamp(1.9rem, 3.2vw, 2.6rem);
}

.studio-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.35rem;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--panel-alt);
}

.studio-tab {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 0.45rem 1rem;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background var(--fast), color var(--fast);
}

.studio-tab:hover,
.studio-tab:focus-visible {
    color: var(--fg);
    background: var(--panel-hover);
    outline: none;
}

.studio-tab.is-active {
    color: #fff;
    background: var(--accent-grad);
    box-shadow: var(--accent-glow);
}

.studio-crumb {
    margin: var(--space-3) 0 var(--space-2);
    color: var(--muted);
    font-size: 0.85rem;
}

.studio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
    gap: var(--space-2);
}

.studio-grid.is-paint {
    display: block;
}

.studio-card {
    display: grid;
    gap: 0.5rem;
    padding: 0.5rem;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel-alt);
    color: var(--fg);
    text-align: left;
    cursor: pointer;
    transition: transform var(--fast), border-color var(--fast), background var(--fast);
}

.studio-card:hover,
.studio-card:focus-visible {
    transform: translateY(-3px);
    border-color: var(--line-strong);
    background: var(--panel);
    outline: none;
}

.studio-card.is-equipped {
    border-color: var(--accent-line);
    background: var(--accent-soft);
    box-shadow: 0 0 0 2px var(--accent-line) inset;
}

.studio-card-media {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 13px;
    background: radial-gradient(70% 70% at 50% 40%, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.02));
}

.studio-card-media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.studio-card-badge {
    position: absolute;
    left: 8px;
    bottom: 8px;
    padding: 0.15rem 0.55rem;
    border-radius: var(--radius-pill);
    background: var(--accent-grad);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
}

.studio-card-label {
    padding: 0 0.2rem 0.2rem;
    font-size: 0.86rem;
    font-weight: 600;
    line-height: 1.25;
}

.studio-swatch {
    width: 62%;
    height: 62%;
    border-radius: 50%;
    box-shadow: inset 0 -6px 12px rgba(0, 0, 0, 0.25), 0 6px 18px -8px rgba(0, 0, 0, 0.8);
}

.studio-none {
    color: var(--muted-soft);
    font-size: 0.9rem;
    font-weight: 600;
}

.studio-paint .color-picker-panel {
    max-width: 460px;
}

@media (max-width: 860px) {
    .studio-layout {
        grid-template-columns: 1fr;
    }

    .studio-preview {
        position: static;
    }

    .studio-stage {
        aspect-ratio: 1 / 1;
        max-height: 420px;
    }
}
