/* ============================================================
   VRChess Indonesia — Frontend Design System

   Theme-agnostic: every color/font/radius/shadow below is a
   var(--...) defined by whichever theme file is linked before this
   one (see assets/css/theme-dark.css). Swapping themes never
   requires touching this file.
   ============================================================ */

/* ── Reset & Base ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    /* Root font-size is intentionally NOT set here — it's a theme concern.
       theme-8bit.css scales it down to compensate for its pixel fonts
       reading larger than their px value suggests; other themes fall back
       to the browser default (16px), matching this file's rem values as
       originally designed. */
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.55;
    overflow-x: hidden;
}

svg.icon {
    width: 1em;
    height: 1em;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    /* square caps/joins read chunkier and more "pixel" than the rounded
       default — a cheap, app-wide way to make the existing icon set fit
       the 8-bit theme without redrawing every icon as a sprite */
    stroke-linecap: square;
    stroke-linejoin: miter;
    flex-shrink: 0;
    vertical-align: -0.125em;
}

/* ── Pixel-notch mixin (used inline by .card / .modal-content / .tab-nav) ──
   --pixel-notch is only defined by the 8-bit theme; other themes leave it
   unset, so `var(--pixel-notch, 0px)` resolves to 0px and the clip-path
   traces a plain rectangle — identical to having no clip-path at all. */
:root {
    --pn: var(--pixel-notch, 0px);
}

/* ── App Shell ── */
.app-wrapper {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ── Header ── */
.app-header {
    padding: 32px 0 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Faint checkerboard texture — only the 8-bit theme sets --checker-tile,
   so this paints nothing (transparent) for every other theme. */
.app-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(45deg, var(--checker-tile, transparent) 25%, transparent 25%, transparent 75%, var(--checker-tile, transparent) 75%),
        linear-gradient(45deg, var(--checker-tile, transparent) 25%, transparent 25%, transparent 75%, var(--checker-tile, transparent) 75%);
    background-size: 32px 32px;
    background-position: 0 0, 16px 16px;
    pointer-events: none;
    z-index: 0;
}

.app-header > * {
    position: relative;
    z-index: 1;
}

.hero-banner {
    display: var(--show-hero-banner, none);
    margin: 0 auto 18px;
    max-width: 760px;
    border: var(--pixel-notch, 0px) solid var(--accent-primary);
}

.hero-banner img {
    display: block;
    width: 100%;
    height: auto;
}

.app-header__logo {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 6px;
}

.app-header__icon {
    width: 52px;
    height: 52px;
    background: var(--bg-card);
    border: 2px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    font-size: 22px;
    overflow: hidden;
}

.app-header__icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.app-header__title {
    font-family: var(--font-display);
    font-size: 1.85rem;
    font-weight: 400;
    letter-spacing: 0;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4);
    color: var(--text-primary);
}

.app-header__subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: 0.01em;
}

.app-header__actions {
    position: absolute;
    right: 0;
    top: 32px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── Site Nav (Leaderboard / Gallery — separate routed pages) ── */
.site-nav {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.site-nav .site-nav__link--active {
    background: var(--accent-primary);
    color: var(--btn-primary-text);
    border-color: var(--accent-primary);
}

/* ── Tab Navigation ── */
.tab-nav {
    display: flex;
    /* No flex-wrap here on purpose — wrapping to a second row fights with
       overflow-x below (a wrapped multi-row flex container inside a
       horizontal-scroll container is exactly the kind of layout that
       breaks first on narrow/foldable screens). One row that scrolls
       sideways is the more robust mobile pattern for a tab strip. */
    gap: 4px;
    padding: 4px;
    margin-bottom: 24px;
    background: var(--bg-card);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-nav::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 400;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-glass);
}

.tab-btn.active {
    background: var(--accent-primary);
    color: var(--bg-primary);
    font-weight: 400;
}

.tab-btn__icon {
    font-size: 0.85rem;
    display: inline-flex;
}

.tab-btn__count {
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 99px;
    font-family: var(--font-mono);
}

.tab-btn.active .tab-btn__count {
    background: rgba(0, 0, 0, 0.2);
    color: var(--bg-primary);
}

/* ── Tab Content ── */
.tab-content {
    display: none;
    animation: fadeSlideIn 0.25s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Cards ──
   clip-path traces a plain rectangle when --pixel-notch is unset (see the
   :root --pn mixin above), so this is safe for every theme, not just 8-bit. */
.card {
    background: var(--bg-card);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    clip-path: polygon(
        0 var(--pn), var(--pn) var(--pn), var(--pn) 0,
        calc(100% - var(--pn)) 0, calc(100% - var(--pn)) var(--pn), 100% var(--pn),
        100% calc(100% - var(--pn)), calc(100% - var(--pn)) calc(100% - var(--pn)), calc(100% - var(--pn)) 100%,
        var(--pn) 100%, var(--pn) calc(100% - var(--pn)), 0 calc(100% - var(--pn))
    );
    padding: 22px;
    margin-bottom: 16px;
    transition: border-color var(--transition-normal);
}

.card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.card__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.02rem;
    font-weight: 400;
    letter-spacing: 0;
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--accent-primary);
}

.card__title svg.icon {
    color: var(--text-secondary);
}

.card__badge {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 99px;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.card__badge--purple {
    background: color-mix(in srgb, var(--accent-primary) 16%, transparent);
    color: var(--accent-primary);
}

.card__badge--green {
    background: color-mix(in srgb, var(--accent-green) 14%, transparent);
    color: var(--accent-green);
}

.card__badge--orange {
    background: color-mix(in srgb, var(--accent-orange) 14%, transparent);
    color: var(--accent-orange);
}

/* Referenced by app.js for inactive-token status ("Tidak Aktif") but never
   actually defined — badge rendered with no color/background at all. */
.card__badge--red {
    background: color-mix(in srgb, var(--accent-red) 14%, transparent);
    color: var(--accent-red);
}

/* ── Leaderboard Table ── */
.leaderboard-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 3px;
}

.leaderboard-table th {
    padding: 10px 14px;
    text-align: left;
    font-family: var(--font-display);
    font-size: 0.68rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--accent-primary);
    border-bottom: 2px solid var(--border-subtle);
}

.leaderboard-table td {
    padding: 11px 14px;
    font-size: 0.875rem;
    vertical-align: middle;
}

.leaderboard-table tbody tr {
    background: transparent;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
    cursor: pointer;
}

.leaderboard-table tbody tr:hover {
    background: var(--bg-glass);
}

.leaderboard-table tbody tr:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: -2px;
}

.leaderboard-table tbody tr td:first-child {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.leaderboard-table tbody tr td:last-child {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Rank badges */
.rank-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: var(--radius-badge);
    font-size: 0.75rem;
    font-weight: 700;
    font-family: var(--font-mono);
    background: var(--bg-input);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
    transition: transform var(--transition-fast);
}

/* The box-shadow chess-piece sprite that used to render here (via
   .rank-badge__piece) was pulled — it produced a visible artifact at this
   size (a handful of 1-2px shadow offsets don't hold together as a
   recognizable glyph, they just read as stray dark smudges). The markup in
   app.js still emits the span for now; keeping it permanently display:none
   here is simpler and safer than touching app.js again for a decoration
   that didn't work out. Badges are back to plain colored circles + number. */
.rank-badge__piece {
    display: none;
}

.rank-badge--gold {
    color: var(--accent-gold);
    border-color: color-mix(in srgb, var(--accent-gold) 35%, transparent);
    background: color-mix(in srgb, var(--accent-gold) 10%, transparent);
}

.rank-badge--silver {
    color: var(--accent-silver);
    border-color: color-mix(in srgb, var(--accent-silver) 30%, transparent);
    background: color-mix(in srgb, var(--accent-silver) 8%, transparent);
}

.rank-badge--bronze {
    color: var(--accent-bronze);
    border-color: color-mix(in srgb, var(--accent-bronze) 35%, transparent);
    background: color-mix(in srgb, var(--accent-bronze) 10%, transparent);
}

.rank-badge--default {
    background: var(--bg-glass);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
}

.leaderboard-table tbody tr:hover .rank-badge--gold,
.leaderboard-table tbody tr:hover .rank-badge--silver,
.leaderboard-table tbody tr:hover .rank-badge--bronze {
    transform: scale(1.06);
}

/* Player name & rating */
.player-name {
    font-weight: 600;
    color: var(--text-primary);
}

.player-rating {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.stat-win { color: var(--accent-green); }
.stat-draw { color: var(--accent-orange); }
.stat-loss { color: var(--accent-red); }

/* Win rate bar */
.winrate-bar {
    width: 80px;
    height: 5px;
    background: var(--bg-input);
    border-radius: 99px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin-left: 6px;
}

.winrate-bar__fill {
    height: 100%;
    background: var(--accent-green);
    border-radius: 99px;
    transition: width var(--transition-slow);
}

/* ── Match Filter Bar ── */
.filter-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: calc(6px * var(--compact-scale, 1)) calc(14px * var(--compact-scale, 1));
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: calc(0.78rem * var(--compact-scale, 1));
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-sans);
}

.filter-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.filter-btn.active {
    background: color-mix(in srgb, var(--accent-primary) 14%, transparent);
    border-color: color-mix(in srgb, var(--accent-primary) 40%, transparent);
    color: var(--accent-primary);
    font-weight: 600;
}

/* ── Match History ── */
.match-card {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    transition: all var(--transition-fast);
    position: relative;
}

.match-card:hover {
    border-color: var(--border-strong);
}

.match-card.is-invalid {
    opacity: 0.6;
    background: color-mix(in srgb, var(--accent-red) 3%, transparent);
    border-color: color-mix(in srgb, var(--accent-red) 20%, transparent);
    border-style: dashed;
}

.match-card.is-invalid:hover {
    opacity: 0.85;
    border-color: color-mix(in srgb, var(--accent-red) 40%, transparent);
}

.match-card__player {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.match-card__player--white {
    text-align: left;
}

.match-card__player--black {
    text-align: right;
}

.match-card__player-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 600;
}

.match-card__player--white .match-card__player-label { justify-content: flex-start; }
.match-card__player--black .match-card__player-label { justify-content: flex-end; }

.match-card__player-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.match-card__vs {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.match-card__result {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
}

.match-card__result--white { background: color-mix(in srgb, var(--accent-green) 14%, transparent); color: var(--accent-green); }
.match-card__result--draw { background: color-mix(in srgb, var(--accent-orange) 14%, transparent); color: var(--accent-orange); }
.match-card__result--black { background: color-mix(in srgb, var(--accent-cyan) 14%, transparent); color: var(--accent-cyan); }

.match-card__date {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.match-card__link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.match-card__link:hover {
    color: var(--accent-primary-hover);
    text-decoration: underline;
}

.match-card__status-tag {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    font-family: var(--font-mono);
}

.match-card__status-tag--invalid {
    background: color-mix(in srgb, var(--accent-red) 16%, transparent);
    color: var(--accent-red);
}

.match-card__actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

/* ── Forms ── */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.01em;
}

.form-input,
.form-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary) 15%, transparent);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-select {
    cursor: pointer;
    appearance: none;
    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='%239a9ba3' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-select option {
    background: #18181c;
    color: var(--text-primary);
    padding: 8px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    clip-path: polygon(
        0 var(--pn), var(--pn) var(--pn), var(--pn) 0,
        calc(100% - var(--pn)) 0, calc(100% - var(--pn)) var(--pn), 100% var(--pn),
        100% calc(100% - var(--pn)), calc(100% - var(--pn)) calc(100% - var(--pn)), calc(100% - var(--pn)) 100%,
        var(--pn) 100%, var(--pn) calc(100% - var(--pn)), 0 calc(100% - var(--pn))
    );
    font-family: var(--font-display);
    font-size: 0.875rem;
    font-weight: 400;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.btn--primary {
    background: var(--accent-primary);
    color: var(--btn-primary-text);
    box-shadow: inset var(--pn, 0px) var(--pn, 0px) 0 var(--pixel-bevel-light, transparent),
        inset calc(var(--pn, 0px) * -1) calc(var(--pn, 0px) * -1) 0 var(--pixel-bevel-dark, transparent);
}

.btn--primary:hover {
    background: var(--accent-primary-hover);
}

.btn--primary:active {
    box-shadow: inset calc(var(--pn, 0px) * -1) calc(var(--pn, 0px) * -1) 0 var(--pixel-bevel-light, transparent),
        inset var(--pn, 0px) var(--pn, 0px) 0 var(--pixel-bevel-dark, transparent);
}

.btn--secondary {
    background: var(--bg-input);
    border-color: var(--border-subtle);
    color: var(--text-secondary);
}

.btn--secondary:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.btn--full {
    width: 100%;
}

.btn--danger {
    background: color-mix(in srgb, var(--accent-red) 12%, transparent);
    border-color: color-mix(in srgb, var(--accent-red) 30%, transparent);
    color: var(--accent-red);
}

.btn--danger:hover {
    background: color-mix(in srgb, var(--accent-red) 20%, transparent);
    border-color: color-mix(in srgb, var(--accent-red) 50%, transparent);
}

.btn--warning {
    background: color-mix(in srgb, var(--accent-orange) 12%, transparent);
    border-color: color-mix(in srgb, var(--accent-orange) 30%, transparent);
    color: var(--accent-orange);
}

.btn--warning:hover {
    background: color-mix(in srgb, var(--accent-orange) 20%, transparent);
}

.btn--success {
    background: color-mix(in srgb, var(--accent-green) 12%, transparent);
    border-color: color-mix(in srgb, var(--accent-green) 30%, transparent);
    color: var(--accent-green);
}

.btn--success:hover {
    background: color-mix(in srgb, var(--accent-green) 20%, transparent);
}

.btn--sm {
    padding: calc(6px * var(--compact-scale, 1)) calc(14px * var(--compact-scale, 1));
    font-size: calc(0.78rem * var(--compact-scale, 1));
    border-radius: var(--radius-sm);
}

.btn--xs {
    padding: calc(3px * var(--compact-scale, 1)) calc(8px * var(--compact-scale, 1));
    font-size: calc(0.7rem * var(--compact-scale, 1));
    border-radius: var(--radius-sm);
    gap: 4px;
}

.btn--icon {
    padding: calc(5px * var(--compact-scale, 1)) calc(8px * var(--compact-scale, 1));
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: calc(0.75rem * var(--compact-scale, 1));
}

.btn--icon:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ── Result Reveal ── */
.result-panel {
    margin-top: 20px;
    padding: 20px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    animation: fadeSlideIn 0.3s ease;
}

.result-panel__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-green);
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-panel__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.result-player {
    padding: 14px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.result-player__name {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.result-player__rating {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.result-player__change {
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
}

.result-player__change.positive {
    background: color-mix(in srgb, var(--accent-green) 14%, transparent);
    color: var(--accent-green);
}

.result-player__change.negative {
    background: color-mix(in srgb, var(--accent-red) 14%, transparent);
    color: var(--accent-red);
}

.result-player__change.neutral {
    background: color-mix(in srgb, var(--accent-orange) 14%, transparent);
    color: var(--accent-orange);
}


/* ── Player Autocomplete Dropdown ── */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    max-height: 220px;
    overflow-y: auto;
    background: var(--bg-card-hover);
    border: 1px solid var(--border-strong);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: var(--shadow-lg);
    scrollbar-width: thin;
    scrollbar-color: var(--border-subtle) transparent;
}

.autocomplete-dropdown.show {
    display: block;
    animation: acDropIn 0.15s ease-out;
}

@keyframes acDropIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.autocomplete-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.875rem;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background: color-mix(in srgb, var(--accent-primary) 12%, transparent);
}

.autocomplete-item__name {
    font-weight: 600;
    color: var(--text-primary);
}

.autocomplete-item:hover .autocomplete-item__name,
.autocomplete-item.active .autocomplete-item__name {
    color: var(--accent-primary);
}

.autocomplete-item__rating {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-secondary);
}

.autocomplete-hint {
    padding: 10px 14px;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
    font-style: italic;
}

/* ── Settings Panel ── */
.settings-field {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.settings-field .form-input {
    flex: 1;
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    width: 44px;
    height: 44px;
    font-size: 1.5rem;
    color: var(--text-muted);
    opacity: 0.7;
}

.empty-state__text {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.empty-state__sub {
    font-size: 0.78rem;
    margin-top: 4px;
    color: var(--text-muted);
}

/* ── Loading Spinner ── */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-subtle);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ── Toast / Notifications ── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    font-weight: 500;
    animation: slideInRight 0.25s ease, fadeOut 0.3s ease 3.5s forwards;
    max-width: 360px;
    border: 1px solid;
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-md);
}

.toast--success {
    color: var(--accent-green);
    border-color: color-mix(in srgb, var(--accent-green) 30%, transparent);
}

.toast--error {
    color: var(--accent-red);
    border-color: color-mix(in srgb, var(--accent-red) 30%, transparent);
}

.toast--info {
    color: var(--accent-primary);
    border-color: color-mix(in srgb, var(--accent-primary) 30%, transparent);
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateY(-10px); }
}

/* ── Search ── */
.search-wrapper {
    position: relative;
    margin-bottom: 16px;
}

.search-wrapper__icon {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.8rem;
    pointer-events: none;
    display: flex;
}

.search-input {
    /* Deliberately NOT using --compact-scale here like the other small
       controls do — a search field is something people read and type
       into, so it needs to stay comfortably sized even when the buttons
       around it go compact. */
    width: 100%;
    padding: 9px 14px 9px 36px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    outline: none;
    transition: all var(--transition-fast);
}

.search-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary) 15%, transparent);
}

.search-input::placeholder {
    color: var(--text-muted);
}

/* ── Footer ── */
.app-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px 20px;
    margin-top: 24px;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.app-footer__main {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    opacity: 0.7;
}

.app-footer__brand,
.app-footer__sep,
.app-footer__tagline {
    color: inherit;
    font-weight: 400;
}

.app-footer__links {
    display: flex;
    align-items: center;
    opacity: 0.7;
}

.app-footer__link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    text-decoration: none;
    transition: opacity var(--transition-fast);
}

.app-footer__link:hover {
    opacity: 1;
    color: var(--text-secondary);
}

/* ── Modal Overlay ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.15s ease;
}

.modal-content {
    background: var(--bg-secondary);
    border: 2px solid var(--border-strong);
    border-radius: var(--radius-xl);
    clip-path: polygon(
        0 var(--pn), var(--pn) var(--pn), var(--pn) 0,
        calc(100% - var(--pn)) 0, calc(100% - var(--pn)) var(--pn), 100% var(--pn),
        100% calc(100% - var(--pn)), calc(100% - var(--pn)) calc(100% - var(--pn)), calc(100% - var(--pn)) 100%,
        var(--pn) 100%, var(--pn) calc(100% - var(--pn)), 0 calc(100% - var(--pn))
    );
    padding: 28px;
    max-width: 480px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: fadeSlideIn 0.25s ease;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content--wide {
    max-width: 560px;
}

.modal-content h3 {
    font-family: var(--font-display);
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 1.05rem;
    font-weight: 400;
    margin-bottom: 16px;
    color: var(--accent-primary);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
    margin-bottom: 0;
}

.modal-header__profile {
    display: flex;
    align-items: center;
    gap: 14px;
}

.modal-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: var(--accent-primary);
    overflow: hidden;
}

.player-rating-badge {
    display: inline-block;
    margin-top: 4px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.modal-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    line-height: 1;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.modal-close-btn:hover {
    color: var(--text-primary);
    background: var(--bg-glass);
}

.stats-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.stat-box {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 10px;
    text-align: center;
    transition: border-color var(--transition-fast);
}

.stat-box:hover {
    border-color: var(--border-strong);
}

.stat-box__val {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-box__lbl {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Admin: VRChat Gallery Management ── */
.gallery-admin-section {
    margin-bottom: 22px;
}

.gallery-admin-section:last-child {
    margin-bottom: 0;
}

.gallery-admin-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.gallery-admin-section__title {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.gallery-admin-section__empty {
    font-size: 0.78rem;
    color: var(--text-muted);
    padding: 10px 0;
}

.gallery-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.gallery-admin-card {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: opacity var(--transition-fast);
}

.gallery-admin-card--hidden {
    opacity: 0.5;
}

.gallery-admin-card__photo {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block;
}

.gallery-admin-card__meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 8px 0;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.gallery-admin-card__toggle {
    margin: 8px;
    justify-content: center;
}

/* ── Admin: Newsletter (VRChat Group Posts) Management ── */
.newsletter-admin-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.newsletter-admin-card {
    display: flex;
    gap: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px;
}

.newsletter-admin-card__photo {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.newsletter-admin-card__body {
    flex: 1 1 auto;
    min-width: 0;
}

.newsletter-admin-card__header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.newsletter-admin-card__text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.newsletter-admin-card__meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.newsletter-admin-card__actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .app-header__title {
        font-size: 1.4rem;
    }

    .tab-btn__label {
        display: none;
    }

    .tab-btn {
        /* flex:1 on the desktop rule is really "flex: 1 1 0%" — items start
           at zero size and grow, which lets them shrink arbitrarily thin
           too (combined with the old min-width:0). "1 1 auto" instead:
           still grows to fill the bar when there's room (so tabs stretch
           edge-to-edge on a normal phone width), but shrinking is bounded
           by min-width — once that floor is hit, .tab-nav's overflow-x
           takes over as a scroll instead of squeezing further. */
        flex: 1 1 auto;
        min-width: 44px;
        padding: 10px 12px;
    }

    .tab-btn__icon {
        font-size: 1.15rem;
    }

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

    .result-panel__grid {
        grid-template-columns: 1fr;
    }

    .match-card {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .match-card__player--white,
    .match-card__player--black {
        text-align: center;
    }

    .match-card__player--white .match-card__player-label,
    .match-card__player--black .match-card__player-label {
        justify-content: center;
    }

    /* .match-card collapses to one centered column above, but
       .match-card__actions is a flex row with no justify-content — it was
       defaulting to flex-start, so the Anulir/Edit/Hapus buttons sat
       pinned to the left edge while everything else in the card was
       centered. Admin-only, so this only ever shows logged in as admin. */
    .match-card__actions {
        justify-content: center;
        flex-wrap: wrap;
        margin-top: 8px;
        padding-top: 10px;
        border-top: 1px dashed var(--border-subtle);
    }

    .leaderboard-table {
        font-size: 0.8rem;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 8px 8px;
    }

    /* ── Analysis tab mobile fixes ── */
    /* Stack board + right panel vertically */
    .chesscom-layout {
        flex-direction: column !important;
        gap: 16px !important;
    }

    /* Board area: full width, no sticky */
    .chesscom-layout > div:first-child {
        flex: none !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        position: static !important;
    }

    /* Right panel: full width, no fixed height, no sticky */
    .chesscom-layout > div:last-child {
        flex: none !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        position: static !important;
        /* panel sub-items stack normally */
    }

    /* Move list: fixed scrollable height instead of flex-grow */
    #moveListContainer {
        max-height: 280px !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
        /* Prevent repaint jitter during live updates */
        contain: layout style;
        will-change: scroll-position;
    }

    /* Eval chart shrink a bit */
    #evalChart {
        height: 50px !important;
    }
}

/* Wide foldables/tablets have enough room for a compact board and analysis sidebar. Keep the
   move history fixed beside the board instead of letting it wrap underneath — this covers
   everything from a small unfolded foldable up through where the default (unmedia-queried)
   desktop layout already fits both at their natural max-width without any help
   (board 600px + sidebar 400px + gap fits any viewport past ~1024px on its own). */
@media (min-width: 600px) and (max-width: 1024px) {
    .chesscom-layout {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        gap: 16px !important;
    }

    .chesscom-layout > div:first-child {
        flex: 1 1 0 !important;
        width: auto !important;
        max-width: 600px !important;
        min-width: 0 !important;
        position: sticky !important;
        top: 20px !important;
    }

    .chesscom-layout > div:last-child {
        flex: 0 0 280px !important;
        width: 280px !important;
        max-width: 280px !important;
        min-width: 0 !important;
        height: calc(100vh - 40px) !important;
        position: sticky !important;
        top: 20px !important;
    }

    #moveListContainer {
        max-height: none !important;
    }
}

@media (max-width: 480px) {
    .app-wrapper {
        padding: 0 12px;
    }

    .card {
        padding: 16px;
    }

    /* Narrow phones / a folded foldable's cover screen: the centered title can run under the
       absolutely-positioned Admin Login button. Drop it back into normal flow, stacked below
       the title, instead of floating over it. */
    .app-header__actions {
        position: static;
        justify-content: center;
        margin-top: 12px;
    }

    .leaderboard-table .hide-mobile {
        display: none;
    }

    /* The admin dashboard's stat grid always has exactly 4 boxes — at
       narrow widths auto-fit's minmax(78px,1fr) only fits 3 per row, so
       the 4th wraps onto a row by itself and (having nothing beside it to
       stretch against) ends up visibly shorter than the row above it.
       Force a clean 2x2 instead. Scoped to #tab-admin specifically since
       the player-profile modal reuses .stats-overview-grid with 5 boxes,
       where auto-fit's wrapping is fine. */
    #tab-admin .stats-overview-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ── Estimated Rating Performance (accuracy-derived, like Chess.com's Game Report) ── */
.est-rating-badge {
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}

/* ── Real-Time Engine Stream Badge ── */
.pulse-dot {
    width: 7px;
    height: 7px;
    background-color: var(--accent-green);
    border-radius: 50%;
    display: inline-block;
    animation: pulse-stream 0.8s infinite alternate ease-in-out;
}

@keyframes pulse-stream {
    from { opacity: 0.35; transform: scale(0.8); }
    to   { opacity: 1; transform: scale(1.15); }
}

.engine-stream-badge {
    display: none;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    background: color-mix(in srgb, var(--accent-green) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent-green) 30%, transparent);
    color: var(--accent-green);
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 12px;
    transition: all var(--transition-fast);
    /* Long text ("Browser+Server · Depth 12/18 · 2.1M nps") must wrap within the sidebar
       instead of forcing it wider — narrow/foldable-width columns rely on this. */
    max-width: 100%;
    white-space: normal;
}

/* ── Player Profile: avatars ── */
.player-avatar-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    font-family: var(--font-mono);
    margin-right: 8px;
    vertical-align: middle;
    flex-shrink: 0;
}

.leaderboard-row__player {
    display: flex;
    align-items: center;
}

/* ── Player Profile Modal ── */
.modal-header__badges {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.player-rating-badge--rank {
    color: var(--accent-gold);
    background: color-mix(in srgb, var(--accent-gold) 10%, transparent);
    border-color: color-mix(in srgb, var(--accent-gold) 25%, transparent);
}

/* Recent-form dots (last 5 valid results) */
.form-guide {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.form-guide__label {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.form-guide__dots {
    display: flex;
    gap: 5px;
}

.form-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    font-weight: 700;
    font-family: var(--font-mono);
    transition: transform var(--transition-fast);
}

.form-dot:hover {
    transform: scale(1.15);
}

.form-dot--win { background: color-mix(in srgb, var(--accent-green) 18%, transparent); color: var(--accent-green); }
.form-dot--draw { background: color-mix(in srgb, var(--accent-orange) 18%, transparent); color: var(--accent-orange); }
.form-dot--loss { background: color-mix(in srgb, var(--accent-red) 18%, transparent); color: var(--accent-red); }

/* Segmented Win / Draw / Loss proportion bar */
.wdl-bar {
    display: flex;
    width: 100%;
    height: 10px;
    border-radius: 99px;
    overflow: hidden;
    background: var(--bg-input);
    margin-bottom: 10px;
    border: 1px solid var(--border-subtle);
}

.wdl-bar__seg {
    height: 100%;
    transition: width var(--transition-slow);
}

.wdl-bar__seg--win { background: var(--accent-green); }
.wdl-bar__seg--draw { background: var(--accent-orange); }
.wdl-bar__seg--loss { background: var(--accent-red); }

.wdl-bar__legend {
    display: flex;
    gap: 16px;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.wdl-bar__legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.wdl-bar__legend-item b {
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.wdl-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.wdl-dot--win { background: var(--accent-green); }
.wdl-dot--draw { background: var(--accent-orange); }
.wdl-dot--loss { background: var(--accent-red); }

/* Modal-scoped tabs — visually match .tab-btn, but kept as a separate class
   (not .tab-btn itself) so the app's global tab-navigation click handler,
   which is bound to every .tab-btn and expects a top-level data-tab panel,
   doesn't also fire for these. */
.tab-nav--modal {
    margin-bottom: 16px;
    padding: 4px;
}

.modal-tab-btn {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.modal-tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-glass);
}

.modal-tab-btn.active {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    font-weight: 600;
}

.modal-tab-content {
    display: none;
}

.modal-tab-content.active {
    display: block;
    animation: fadeSlideIn 0.25s ease;
}

.profile-meta-row {
    display: flex;
    justify-content: center;
    gap: 14px;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Match history list inside the profile modal */
.profile-history-list {
    max-height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 2px;
}

.profile-history-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    transition: border-color var(--transition-fast);
}

.profile-history-row:hover {
    border-color: var(--border-strong);
}

.profile-history-row.is-invalid {
    opacity: 0.55;
}

.profile-history-row__result {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    font-family: var(--font-mono);
    flex-shrink: 0;
}

.profile-history-row__result--win { background: color-mix(in srgb, var(--accent-green) 16%, transparent); color: var(--accent-green); }
.profile-history-row__result--draw { background: color-mix(in srgb, var(--accent-orange) 16%, transparent); color: var(--accent-orange); }
.profile-history-row__result--loss { background: color-mix(in srgb, var(--accent-red) 16%, transparent); color: var(--accent-red); }

.profile-history-row__main {
    min-width: 0;
}

.profile-history-row__opponent {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    font-family: var(--font-sans);
}

.profile-history-row__opponent:hover {
    color: var(--accent-primary);
    text-decoration: underline;
}

.profile-history-row__opponent--deleted {
    color: var(--text-muted);
    cursor: default;
    font-weight: 500;
    font-style: italic;
}

.profile-history-row__meta {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
    flex-wrap: wrap;
}

.profile-history-row__invalid-tag {
    color: var(--accent-red);
    font-weight: 600;
}

.profile-history-row__end {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.profile-history-row__rating {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.8rem;
}

.profile-history-row__rating--pos { color: var(--accent-green); }
.profile-history-row__rating--neg { color: var(--accent-red); }
.profile-history-row__rating--zero { color: var(--text-muted); }

.profile-history-row__link {
    font-size: 0.68rem;
    color: var(--accent-cyan);
    text-decoration: none;
    white-space: nowrap;
}

.profile-history-row__link:hover {
    text-decoration: underline;
}

@media (max-width: 480px) {
    .profile-history-row {
        grid-template-columns: auto 1fr;
    }

    .profile-history-row__end {
        grid-column: 1 / -1;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        margin-top: 6px;
        padding-top: 6px;
        border-top: 1px dashed var(--border-subtle);
    }
}

/* Avatar <img> variant (falls back to the initials <span> on load error) */
img.player-avatar-sm {
    object-fit: cover;
}

.modal-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

/* ── Admin: VRChat account linking (Edit Pemain modal) ── */
.vrchat-link-section {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}

.vrchat-link-status {
    margin: 8px 0 12px;
}

.vrchat-link-status__empty {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

.vrchat-link-status__linked {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 8px 10px;
    font-size: 0.82rem;
}

.vrchat-link-status__linked > span {
    flex: 1;
    min-width: 0;
    color: var(--text-secondary);
}

.vrchat-search-row {
    display: flex;
    gap: 8px;
}

.vrchat-search-row .form-input {
    flex: 1;
}

.vrchat-search-results {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
}

.vrchat-search-results__loading,
.vrchat-search-results__empty {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 8px 2px;
}

.vrchat-candidate {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 8px 10px;
    cursor: pointer;
    font-family: var(--font-sans);
    text-align: left;
    transition: all var(--transition-fast);
}

.vrchat-candidate:hover {
    border-color: var(--border-strong);
    background: var(--bg-card-hover);
}

.vrchat-candidate__name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ── Analysis board scope reset ──
   #analysisMainLayout is a deliberately separate chess.com-style skin (its
   own brown/olive palette, hardcoded inline throughout) — it predates the
   theme system and was never meant to pick up whichever theme is active.
   Its buttons DO still inherit .btn's clip-path/font-family from the
   global rules though (inline styles there only ever pinned background/
   color/border, not shape or type), which is what actually broke: gold
   pixel-notched corners and Press Start 2P on an otherwise untouched brown
   button. Reset the box/type properties specifically back to plain. */
#analysisMainLayout .btn {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    clip-path: none;
    box-shadow: none;
    border-radius: 4px;
}

#analysisMainLayout .btn:active {
    box-shadow: none;
}
