/* ==========================================================================
   MGM Renown — Public Styles
   ========================================================================== */

:root {
    /* Gold-on-navy palette — matched to the Multiverse Shop / Community theme. */
    --mgma-primary: #e8c96b;
    --mgma-primary-dark: #c9a83e;
    --mgma-accent: #f0d47b;
    --mgma-bg: #0e0e1a;
    --mgma-bg-card: #16162a;
    --mgma-bg-card-hover: #1e1e2e;
    --mgma-text: #c8d0e8;
    --mgma-text-muted: #808098;
    --mgma-border: rgba(232, 201, 107, .3);
    --mgma-danger: #ef4444;
    --mgma-success: #22c55e;
    --mgma-gold: #f0d47b;
    --mgma-radius: 8px;
    --mgma-radius-lg: 12px;
}

/* Layout ------------------------------------------------------------------ */

.mgma-page,
.mgma-dashboard {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
    color: var(--mgma-text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.mgma-section {
    margin-bottom: 32px;
}

.mgma-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.mgma-section-header h3 { margin: 0; }

/* Profile Header ---------------------------------------------------------- */

.mgma-profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    background: linear-gradient(135deg, var(--mgma-bg-card) 0%, var(--mgma-bg-card-hover) 100%);
    border-radius: var(--mgma-radius-lg);
    border: 1px solid var(--mgma-border);
    border-left: 4px solid var(--mgma-primary);
    margin-bottom: 24px;
    box-shadow: 0 4px 24px rgba(0,0,0,.4), 0 0 60px rgba(232,201,107,.06);
}

.mgma-avatar-wrap { flex-shrink: 0; }

.mgma-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--mgma-primary);
}

.mgma-username {
    margin: 0 0 4px;
    font-size: 1.5rem;
}

.mgma-title-badge {
    display: inline-block;
    background: var(--mgma-primary);
    color: #1a1a2e;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.mgma-rank-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
}

.mgma-rank-icon-sm {
    width: 24px;
    height: 24px;
}

.mgma-rank-icon-xs {
    width: 16px;
    height: 16px;
    vertical-align: middle;
}

/* Tabs -------------------------------------------------------------------- */

.mgma-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--mgma-border);
    margin-bottom: 24px;
    overflow-x: auto;
}

.mgma-tab {
    padding: 12px 20px;
    text-decoration: none;
    color: var(--mgma-text-muted);
    font-weight: 600;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}

.mgma-tab:hover {
    color: var(--mgma-text);
    background: var(--mgma-bg-card);
}

.mgma-tab-active {
    color: var(--mgma-primary);
    border-bottom-color: var(--mgma-primary);
}

/* Filter tabs (game tabs on achievements/badges pages) */

.mgma-filter-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.mgma-filter-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--mgma-bg-card);
    border: 1px solid var(--mgma-border);
    border-radius: 20px;
    color: var(--mgma-text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.mgma-filter-tab:hover {
    border-color: var(--mgma-accent);
    color: var(--mgma-text);
}

.mgma-filter-active {
    background: var(--mgma-primary);
    border-color: var(--mgma-primary);
    color: #1a1a2e;
    font-weight: 700;
}

.mgma-game-icon-sm {
    width: 18px;
    height: 18px;
    border-radius: 3px;
}

/* Progress Bar ------------------------------------------------------------ */

.mgma-renown-progress {
    background: var(--mgma-bg-card);
    padding: 24px;
    border-radius: var(--mgma-radius-lg);
    border: 1px solid var(--mgma-border);
}

.mgma-progress-bar-wrap {
    width: 100%;
    height: 28px;
    background: var(--mgma-bg);
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--mgma-border);
    margin: 12px 0;
}

.mgma-progress-bar {
    height: 100%;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    transition: width 0.6s ease;
}

.mgma-progress-text {
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.mgma-xp-text {
    color: var(--mgma-text-muted);
    font-size: 0.95rem;
    margin: 0;
}

/* Grids ------------------------------------------------------------------- */

.mgma-grid {
    display: grid;
    gap: 16px;
}

.mgma-grid-3 { grid-template-columns: repeat(3, 1fr); }
.mgma-grid-4 { grid-template-columns: repeat(4, 1fr); }
.mgma-grid-5 { grid-template-columns: repeat(5, 1fr); }

@media (max-width: 900px) {
    .mgma-grid-4, .mgma-grid-5 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 640px) {
    .mgma-grid-3, .mgma-grid-4, .mgma-grid-5 { grid-template-columns: repeat(2, 1fr); }
    .mgma-profile-header { flex-direction: column; text-align: center; }
}

@media (max-width: 420px) {
    .mgma-grid-3, .mgma-grid-4, .mgma-grid-5 { grid-template-columns: 1fr; }
}

/* Item Cards (achievements / badges) -------------------------------------- */

.mgma-item-card {
    display: flex;
    gap: 12px;
    padding: 14px;
    background: var(--mgma-bg-card);
    border: 1px solid var(--mgma-border);
    border-radius: var(--mgma-radius);
    transition: all 0.2s;
}

.mgma-item-card:hover {
    background: var(--mgma-bg-card-hover);
    border-color: var(--mgma-accent);
}

.mgma-item-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
}

.mgma-item-icon img {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
}

.mgma-icon-placeholder {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--mgma-bg);
    border-radius: 6px;
    font-size: 1.5rem;
    color: var(--mgma-gold);
}

.mgma-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mgma-item-info strong {
    font-size: 0.95rem;
}

.mgma-item-info small {
    color: var(--mgma-text-muted);
    font-size: 0.8rem;
    line-height: 1.3;
}

.mgma-xp-badge {
    display: inline-block;
    margin-top: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--mgma-gold);
}

.mgma-title-reward {
    font-size: 0.8rem;
    color: var(--mgma-accent);
    font-style: italic;
}

.mgma-earned-label {
    font-size: 0.8rem;
    color: var(--mgma-success);
    font-weight: 700;
    margin-top: 2px;
}

/* Locked / greyed out */
.mgma-locked .mgma-item-icon img,
.mgma-locked .mgma-icon-placeholder {
    filter: grayscale(100%);
    opacity: 0.4;
}

.mgma-locked .mgma-item-info strong {
    color: var(--mgma-text-muted);
}

/* Badge cards — slightly larger icon */
.mgma-badge-icon {
    width: 56px;
    height: 56px;
}

.mgma-badge-icon img,
.mgma-badge-icon .mgma-icon-placeholder {
    width: 56px;
    height: 56px;
}

/* Rank Showcase (demo page) ----------------------------------------------- */

.mgma-rank-showcase {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.mgma-rank-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    background: var(--mgma-bg-card);
    border: 2px solid;
    border-radius: var(--mgma-radius);
    min-width: 200px;
    flex: 1 1 200px;
}

.mgma-rank-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mgma-rank-card-icon img {
    width: 32px;
    height: 32px;
}

.mgma-rank-card-number {
    color: #fff;
    font-weight: 900;
    font-size: 1.2rem;
}

.mgma-rank-card-info strong {
    display: block;
    font-size: 1rem;
}

.mgma-rank-card-info small {
    color: var(--mgma-text-muted);
    font-size: 0.8rem;
}

/* Game Cards (demo page) -------------------------------------------------- */

.mgma-game-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: var(--mgma-bg-card);
    border: 1px solid var(--mgma-border);
    border-radius: var(--mgma-radius);
    text-align: center;
}

.mgma-game-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 6px;
}

/* Demo Hero --------------------------------------------------------------- */

.mgma-demo-hero {
    text-align: center;
    padding: 48px 20px;
    margin-bottom: 32px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border-radius: var(--mgma-radius-lg);
    border: 1px solid var(--mgma-border);
}

.mgma-demo-hero h1 {
    font-size: 2.5rem;
    margin: 0 0 8px;
    background: linear-gradient(90deg, var(--mgma-accent), var(--mgma-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.mgma-hero-subtitle {
    color: var(--mgma-text-muted);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

/* Demo Steps */

.mgma-demo-step {
    text-align: center;
    padding: 24px;
    background: var(--mgma-bg-card);
    border: 1px solid var(--mgma-border);
    border-radius: var(--mgma-radius);
}

.mgma-demo-step-num {
    width: 48px;
    height: 48px;
    background: var(--mgma-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 900;
    margin: 0 auto 12px;
}

.mgma-demo-card {
    border-style: dashed;
    opacity: 0.85;
}

/* Widget ------------------------------------------------------------------ */

.mgma-widget-preview {
    display: flex;
    justify-content: center;
    padding: 24px;
}

.mgma-widget {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: var(--mgma-bg-card);
    border: 1px solid var(--mgma-border);
    border-radius: var(--mgma-radius);
    min-width: 280px;
}

.mgma-widget-avatar img {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid var(--mgma-primary);
}

.mgma-widget-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mgma-widget-name { font-size: 1rem; }

.mgma-widget-rank {
    font-size: 0.85rem;
    font-weight: 600;
}

.mgma-widget-title {
    font-size: 0.8rem;
    color: var(--mgma-accent);
    font-style: italic;
}

/* Forms ------------------------------------------------------------------- */

.mgma-form { max-width: 600px; }

.mgma-form-row { margin-bottom: 12px; }

.mgma-input,
.mgma-select,
.mgma-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--mgma-bg);
    border: 1px solid var(--mgma-border);
    border-radius: var(--mgma-radius);
    color: var(--mgma-text);
    font-size: 0.95rem;
    font-family: inherit;
    box-sizing: border-box;
}

.mgma-input:focus,
.mgma-select:focus,
.mgma-textarea:focus {
    outline: none;
    border-color: var(--mgma-primary);
    box-shadow: 0 0 0 3px rgba(232, 201, 107, 0.2);
}

.mgma-textarea { resize: vertical; min-height: 120px; }

.mgma-btn {
    display: inline-block;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: var(--mgma-radius);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.mgma-btn-primary {
    background: linear-gradient(135deg, var(--mgma-primary-dark) 0%, var(--mgma-primary) 100%);
    color: #1a1a2e;
    font-weight: 700;
}

.mgma-btn-primary:hover { opacity: .9; }

.mgma-btn-secondary {
    background: var(--mgma-bg);
    color: var(--mgma-text);
    border: 1px solid var(--mgma-border);
}

.mgma-btn-secondary:hover { border-color: var(--mgma-accent); }

.mgma-btn-danger {
    background: var(--mgma-danger);
    color: #fff;
}

.mgma-btn-danger:hover { background: #dc2626; }

.mgma-help {
    font-size: 0.8rem;
    color: var(--mgma-text-muted);
    margin-top: 4px;
}

.mgma-inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.mgma-inline-form .mgma-input { flex: 1; }

/* Checkbox Group */

.mgma-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.mgma-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--mgma-bg);
    border: 1px solid var(--mgma-border);
    border-radius: var(--mgma-radius);
    cursor: pointer;
    transition: border-color 0.2s;
}

.mgma-checkbox-label:hover { border-color: var(--mgma-accent); }

.mgma-checkbox-label input:checked + .mgma-game-icon-sm,
.mgma-checkbox-label input:checked ~ * {
    color: var(--mgma-primary);
}

/* Avatar Upload */

.mgma-avatar-upload {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mgma-avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--mgma-border);
}

/* Danger Zone */

.mgma-danger-zone {
    background: rgba(239, 68, 68, 0.08);
    padding: 20px;
    border-radius: var(--mgma-radius);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.mgma-warning {
    color: var(--mgma-danger);
    font-weight: 600;
}

/* Save Status */

.mgma-save-status {
    margin-left: 12px;
    font-size: 0.9rem;
    color: var(--mgma-success);
}

/* Game Section Heading */

.mgma-game-heading {
    font-size: 1.15rem;
    margin: 24px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--mgma-border);
}

/* Links */

.mgma-link {
    color: var(--mgma-accent);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
}

.mgma-link:hover { text-decoration: underline; }

/* Notice */

.mgma-notice {
    padding: 16px;
    background: var(--mgma-bg-card);
    border: 1px solid var(--mgma-border);
    border-radius: var(--mgma-radius);
    text-align: center;
    color: var(--mgma-text-muted);
}

.mgma-empty {
    color: var(--mgma-text-muted);
    font-style: italic;
}

.mgma-subtitle {
    color: var(--mgma-text-muted);
    margin-top: -8px;
    margin-bottom: 24px;
}

/* ==========================================================================
   Achievements & Badges pages — themed to match the Multiverse Shop /
   Community profile (gold-on-navy). Scoped to .mgmr-wrap so it never touches
   the legacy .mgma-* dashboard/demo styles above.
   ========================================================================== */

.mgmr-wrap {
    --g:        #e8c96b;
    --g-light:  #f0d47b;
    --g-dark:   #c9a83e;
    --g-rgb:    232, 201, 107;
    --bg:       #0e0e1a;
    --surface:  #16162a;
    --surface2: #1e1e2e;
    --border:   rgba(232,201,107,.35);
    --text:     #c8d0e8;
    --muted:    #808098;
    --radius:   12px;
    --t:        .2s ease;

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* ── Profile / progress strip ─────────────────────────────────────────── */

.mgmr-profile-card {
    display: flex;
    align-items: center;
    gap: 24px;
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface2) 100%);
    border: 1px solid var(--border);
    border-left: 4px solid var(--rank-color, var(--g));
    border-radius: var(--radius);
    padding: 22px 26px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0,0,0,.4), 0 0 60px rgba(var(--g-rgb),.06);
    flex-wrap: wrap;
}

.mgmr-profile-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at top left, rgba(var(--g-rgb),.12) 0%, transparent 60%);
    pointer-events: none;
}

.mgmr-profile-avatar-wrap { position: relative; flex-shrink: 0; }

.mgmr-profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3px solid var(--rank-color, var(--g));
    object-fit: cover;
    display: block;
    box-shadow: 0 0 20px rgba(var(--g-rgb),.4);
}

.mgmr-rank-badge {
    position: absolute;
    bottom: -4px;
    right: -4px;
    min-width: 24px;
    height: 24px;
    padding: 0 5px;
    border-radius: 12px;
    border: 2px solid var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #1a1a2e;
    box-sizing: border-box;
}

.mgmr-profile-info { flex: 1; min-width: 180px; }

.mgmr-profile-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.mgmr-profile-rank {
    font-size: .9rem;
    font-weight: 600;
    margin-top: 4px;
    opacity: .9;
}

.mgmr-xp-bar-wrap {
    margin-top: 10px;
    height: 6px;
    background: rgba(255,255,255,.08);
    border-radius: 3px;
    overflow: hidden;
    max-width: 320px;
}

.mgmr-xp-bar { height: 100%; border-radius: 3px; transition: width .6s ease; }

.mgmr-progress-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: rgba(var(--g-rgb),.1);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 22px;
    margin-left: auto;
}

.mgmr-progress-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
}

.mgmr-progress-count {
    font-size: 1.9rem;
    font-weight: 800;
    color: var(--g-light);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.mgmr-progress-total { font-size: 1rem; color: var(--muted); font-weight: 600; }
.mgmr-progress-sub   { font-size: .72rem; color: var(--muted); }

/* ── Panel ────────────────────────────────────────────────────────────── */

.mgmr-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.mgmr-panel-header { padding: 26px 28px 0; }

.mgmr-panel-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 4px;
}

.mgmr-panel-subtitle {
    color: #aeb6cc;
    font-size: 1.02rem;
    line-height: 1.55;
    margin: 0 0 20px;
    max-width: 760px;
}

/* ── Game tiles ───────────────────────────────────────────────────────── */

.mgmr-game-tabs {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 8px 28px 20px;
    border-bottom: 1px solid var(--border);
}

.mgmr-game-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 130px;
    padding: 14px 16px 10px;
    background: var(--surface2);
    border: 2px solid transparent;
    border-radius: 10px;
    color: var(--muted);
    font-size: .8rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--t);
}

.mgmr-game-tab:hover {
    color: var(--text);
    background: rgba(var(--g-rgb),.08);
    border-color: rgba(var(--g-rgb),.2);
}

.mgmr-game-tab--active {
    color: #fff;
    background: rgba(var(--g-rgb),.15);
    border-color: var(--g);
    box-shadow: 0 0 16px rgba(var(--g-rgb),.25);
}

.mgmr-wrap .mgmr-game-tab img.mgmr-game-tab-logo {
    width: 110px !important;
    height: 70px !important;
    max-width: 110px !important;
    border-radius: 10px;
    object-fit: contain;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
}

.mgmr-game-tab-emoji {
    font-size: 2.6rem;
    line-height: 1;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,.3));
}

.mgmr-game-tab-name {
    text-align: center;
    line-height: 1.2;
    max-width: 110px;
}

/* Earned / Locked status filter (pills) */
.mgmr-statefilter {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 16px 28px 2px;
}

.mgmr-statefilter-btn {
    padding: 6px 18px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--t);
}

.mgmr-statefilter-btn:hover {
    color: var(--text);
    border-color: rgba(var(--g-rgb),.45);
}

.mgmr-statefilter-btn.is-active {
    background: linear-gradient(135deg, var(--g-dark) 0%, var(--g-light) 100%);
    border-color: var(--g);
    color: #1a1a2e;
}

/* Sync button row (achievements page) */
.mgmr-syncrow {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 16px 28px 0;
}

.mgmr-sync-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--g);
    background: linear-gradient(135deg, var(--g-dark) 0%, var(--g-light) 100%);
    color: #1a1a2e;
    font-size: .85rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: opacity var(--t);
}

.mgmr-sync-btn:hover:not(:disabled) { opacity: .9; }
.mgmr-sync-btn:disabled { opacity: .55; cursor: default; }

.mgmr-sync-btn--all {
    background: var(--surface2);
    color: var(--g-light);
    border-color: var(--border);
}

.mgmr-sync-status {
    font-size: .85rem;
    font-weight: 600;
    color: var(--muted);
}

.mgmr-sync-status.is-busy { color: var(--g-light); }
.mgmr-sync-status.is-ok   { color: #7CFC7C; }
.mgmr-sync-status.is-err  { color: #ff6b6b; }

/* ── Grid + section heading ───────────────────────────────────────────── */

.mgmr-section { padding: 0 28px; }

.mgmr-section-heading {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--g-light);
    letter-spacing: .01em;
    margin: 26px 0 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    text-shadow: 0 0 18px rgba(232,201,107,.25);
}

/* High specificity + !important to defeat themes that force img { max-width:100% } */
.mgmr-wrap .mgmr-section-heading img.mgmr-section-logo {
    height: 42px !important;
    width: auto !important;
    max-width: 84px !important;
    min-width: 0 !important;
    object-fit: contain;
    border-radius: 6px;
    margin: 0;
    display: inline-block;
    vertical-align: middle;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,.4));
}

.mgmr-section-emoji { font-size: 1.7rem; line-height: 1; }

.mgmr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
    padding-bottom: 24px;
}

.mgmr-grid-pad { padding: 24px 28px 28px; }

.mgmr-empty {
    text-align: center;
    color: var(--muted);
    padding: 50px 0;
}

/* ── Cards ────────────────────────────────────────────────────────────── */

.mgmr-item {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}

.mgmr-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0,0,0,.5), 0 0 20px rgba(var(--g-rgb),.15);
    border-color: rgba(var(--g-rgb),.5);
}

/* Locked cards read back a touch; earned cards glow gold. */
.mgmr-item:not(.mgmr-item--earned) .mgmr-item-icon-wrap { opacity: .8; }

.mgmr-item--earned {
    border-color: rgba(var(--g-rgb),.55);
    box-shadow: 0 0 0 1px rgba(var(--g-rgb),.25), 0 4px 18px rgba(0,0,0,.4);
}

.mgmr-item-icon-wrap {
    position: relative;
    background: linear-gradient(135deg, var(--bg) 0%, var(--surface2) 100%);
    height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.mgmr-item-icon-img {
    width: 72px;
    height: 72px;
    object-fit: contain;
    filter: drop-shadow(0 0 12px rgba(var(--g-rgb),.5));
}

.mgmr-item-icon-placeholder {
    font-size: 2.6rem;
    line-height: 1;
    color: var(--g-light);
    filter: drop-shadow(0 0 12px rgba(var(--g-rgb),.4));
}

.mgmr-item--earned .mgmr-item-icon-placeholder {
    text-shadow: 0 0 14px rgba(var(--g-rgb),.8);
}

.mgmr-item-tag {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,.6);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--g-light);
}

.mgmr-item-check {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #22c55e;
    color: #06230f;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    box-shadow: 0 0 12px rgba(34,197,94,.5);
}

.mgmr-item-body {
    padding: 14px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.mgmr-item-name {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.3;
}

.mgmr-item-desc {
    font-size: .82rem;
    color: var(--muted);
    margin: 0;
    line-height: 1.5;
    flex: 1;
}

.mgmr-item-title-reward {
    font-size: .76rem;
    font-weight: 600;
    color: var(--g-light);
}

.mgmr-item-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 16px;
    border-top: 1px solid var(--border);
    background: rgba(0,0,0,.2);
}

.mgmr-item-xp {
    font-size: .92rem;
    font-weight: 700;
    color: var(--g-light);
}

.mgmr-item-status {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 3px 10px;
    border-radius: 20px;
}

.mgmr-item-status.is-earned {
    color: #86efac;
    background: rgba(34,197,94,.15);
    border: 1px solid rgba(34,197,94,.3);
}

.mgmr-item-status.is-locked {
    color: var(--muted);
    background: rgba(255,255,255,.04);
    border: 1px solid var(--border);
}

/* ── Combined header stats (Achievements + Badges) ────────────────────── */

.mgmr-stats {
    display: flex;
    gap: 12px;
    margin-left: auto;
    flex-wrap: wrap;
}

.mgmr-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: rgba(var(--g-rgb),.1);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 20px;
    min-width: 108px;
}

.mgmr-stat-icon { font-size: 1.15rem; line-height: 1; }

.mgmr-stat-count {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--g-light);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.mgmr-stat-total { font-size: .95rem; color: var(--muted); font-weight: 600; }

.mgmr-stat-label {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
}

/* ── Large Achievements / Badges switcher ─────────────────────────────── */

.mgmr-maintabs {
    display: flex;
    gap: 12px;
    padding: 24px 28px 6px;
}

.mgmr-maintab {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 22px;
    background: var(--surface2);
    border: 2px solid var(--border);
    border-radius: 14px;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: all var(--t);
}

.mgmr-maintab:hover {
    border-color: rgba(var(--g-rgb),.45);
    background: rgba(var(--g-rgb),.06);
}

.mgmr-maintab.is-active {
    border-color: var(--g);
    background: linear-gradient(135deg, rgba(var(--g-rgb),.18) 0%, rgba(var(--g-rgb),.05) 100%);
    box-shadow: 0 0 24px rgba(var(--g-rgb),.22);
}

.mgmr-maintab-icon {
    font-size: 2rem;
    line-height: 1;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,.4));
}

.mgmr-maintab-text { display: flex; flex-direction: column; gap: 3px; }

.mgmr-maintab-name {
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: .02em;
}

.mgmr-maintab.is-active .mgmr-maintab-name { color: var(--g-light); }

.mgmr-maintab-meta { font-size: .78rem; color: var(--muted); }

/* ── Views + explanation ──────────────────────────────────────────────── */

.mgmr-view[hidden],
[data-game-section][hidden] { display: none; }

.mgmr-explain {
    margin: 18px 28px 8px;
    padding: 16px 20px;
    background: rgba(var(--g-rgb),.06);
    border: 1px solid var(--border);
    border-left: 3px solid var(--g);
    border-radius: 10px;
    font-size: 1.05rem;
    line-height: 1.7;
    color: #d4dbef;
}

.mgmr-explain strong { color: var(--g-light); }

/* ── Demo page: hero, steps, rank roadmap ─────────────────────────────── */

.mgmr-demo .mgmr-panel { margin-bottom: 24px; }

.mgmr-hero {
    text-align: center;
    padding: 40px 28px 44px;
    margin-bottom: 24px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: radial-gradient(ellipse at center, rgba(10,10,20,.86) 0%, rgba(10,10,20,.6) 55%, rgba(10,10,20,.2) 100%);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    box-shadow: 0 8px 40px rgba(0,0,0,.45);
}

.mgmr-hero h1 {
    font-size: 2.7rem;
    font-weight: 800;
    color: #fff;
    margin: 0 0 12px;
    letter-spacing: .01em;
    text-shadow: 0 0 32px rgba(var(--g-rgb),.28);
}

.mgmr-hero p {
    font-size: 1.18rem;
    line-height: 1.65;
    color: #d4dbef;
    max-width: 780px;
    margin: 0 auto;
}

/* How-it-works steps — three equal cards that fill the row (grid 1fr always
   fills regardless of theme flex/justify overrides; stretch = equal heights). */
.mgmr-steps {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    justify-items: stretch !important;
    align-items: stretch !important;
    gap: 20px;
    margin: 0 auto;
    padding: 8px 28px 28px;
}

@media (max-width: 760px) {
    .mgmr-steps {
        grid-template-columns: 1fr !important;
        max-width: 420px;
    }
}

.mgmr-step {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    box-sizing: border-box;
    background: linear-gradient(160deg, var(--surface2) 0%, #181826 100%);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 26px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: 0 4px 18px rgba(0,0,0,.35);
}

.mgmr-step-num {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--g-dark) 0%, var(--g-light) 100%);
    color: #1a1a2e;
    font-weight: 800;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    flex-shrink: 0;
    box-shadow: 0 0 16px rgba(var(--g-rgb),.35);
}

.mgmr-step h4 {
    margin: 0 0 10px;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
}

.mgmr-step p {
    margin: 0;
    font-size: 1rem;
    line-height: 1.6;
    color: #c2cae0;
}

/* Rank stat chips */
.mgmr-rank-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding: 2px 28px 4px;
}

.mgmr-rank-stat {
    display: flex;
    flex-direction: column;
    gap: 3px;
    background: rgba(var(--g-rgb),.08);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 22px;
}

.mgmr-rank-stat-num {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--g-light);
    line-height: 1;
}

.mgmr-rank-stat-x { font-size: .9rem; color: var(--muted); font-weight: 600; }

.mgmr-rank-stat-lbl {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
}

/* Rank progression — animated line with hover tooltips */
.mgmr-rankline {
    padding: 10px 60px 18px;
}

.mgmr-rankline-track {
    position: relative;
    height: 6px;
    margin: 70px 0 0;
    border-radius: 3px;
    background: rgba(var(--g-rgb),.16);
}

.mgmr-rankline-fill {
    position: absolute;
    inset: 0;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--g-dark) 0%, var(--g-light) 100%);
    box-shadow: 0 0 14px rgba(var(--g-rgb),.55);
    transform-origin: left center;
    animation: mgmr-rankline-fill 1.9s cubic-bezier(.5,.05,.2,1) forwards;
}

@keyframes mgmr-rankline-fill {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}

/* Cursor-following light — a soft beam that tracks the mouse along the bar. */
.mgmr-rankline-glow {
    position: absolute;
    inset: -10px 0;
    border-radius: 8px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .3s ease;
    background: radial-gradient(80px 30px at var(--mx, 50%) 50%,
                rgba(232,201,107,.7) 0%, rgba(232,201,107,.25) 35%, rgba(232,201,107,0) 75%);
    mix-blend-mode: screen;
    z-index: 1;
}

.mgmr-rankline:hover .mgmr-rankline-glow { opacity: 1; }

.mgmr-rankline:hover .mgmr-rankline-fill {
    filter: brightness(1.3) saturate(1.15);
    box-shadow: 0 0 22px rgba(var(--g-rgb),.8);
}

.mgmr-rankline:hover .mgmr-rankline-track {
    background: rgba(var(--g-rgb),.28);
}

.mgmr-rankline-track { transition: background .3s ease; }

.mgmr-rankline-dot {
    position: absolute;
    top: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    padding: 0;
    border-radius: 50%;
    background: var(--g-light);
    border: 2px solid #14141f;
    cursor: pointer;
    z-index: 2;
    transition: transform .15s ease, box-shadow .15s ease;
    animation: mgmr-rankline-pop .4s ease backwards;
}

@keyframes mgmr-rankline-pop {
    from { opacity: 0; transform: scale(0); }
    to   { opacity: 1; transform: scale(1); }
}

.mgmr-rankline-dot:hover,
.mgmr-rankline-dot:focus-visible {
    transform: scale(1.7);
    box-shadow: 0 0 14px rgba(var(--g-rgb),.9);
    z-index: 6;
    outline: none;
}

.mgmr-rankline-tip {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%);
    min-width: 116px;
    padding: 9px 12px;
    background: #0c0c16;
    border: 1px solid var(--border);
    border-radius: 9px;
    box-shadow: 0 8px 24px rgba(0,0,0,.65);
    text-align: center;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .14s ease;
    z-index: 10;
}

.mgmr-rankline-tip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #0c0c16;
}

.mgmr-rankline-dot:hover .mgmr-rankline-tip,
.mgmr-rankline-dot:focus-visible .mgmr-rankline-tip {
    opacity: 1;
}

.mgmr-tip-rank {
    display: block;
    font-size: .64rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
}

.mgmr-tip-name {
    display: block;
    font-size: .98rem;
    font-weight: 800;
    color: #fff;
    margin: 1px 0;
}

.mgmr-tip-xp {
    display: block;
    font-size: .82rem;
    font-weight: 700;
    color: var(--g-light);
    font-variant-numeric: tabular-nums;
}

.mgmr-rankline-marklabel {
    position: absolute;
    top: calc(100% + 7px);
    left: 50%;
    transform: translateX(-50%);
    font-size: .74rem;
    font-weight: 800;
    color: var(--muted);
    pointer-events: none;
    transition: color .15s ease;
}

.mgmr-rankline-dot:hover .mgmr-rankline-marklabel { color: var(--g-light); }

.mgmr-rankline-ends {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 34px;
    font-size: .82rem;
    font-weight: 700;
    color: var(--g-light);
}

.mgmr-rankline-hint {
    color: var(--muted);
    font-weight: 500;
    font-style: italic;
}

/* Rank carousel — scroll / arrow through a spread of rank cards */
.mgmr-rankcar {
    position: relative;
    padding: 10px 56px 12px;
}

.mgmr-rankcar-track {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    padding: 8px 4px 16px;
}

.mgmr-rankcar-track::-webkit-scrollbar { display: none; }

.mgmr-rankcar-card {
    flex: 0 0 auto;
    width: 188px;
    box-sizing: border-box;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    padding: 22px 18px;
    background: linear-gradient(160deg, var(--surface2) 0%, #181826 100%);
    border: 1px solid var(--border);
    border-top: 3px solid var(--g);
    border-radius: 14px;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.mgmr-rankcar-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 32px rgba(0,0,0,.5), 0 0 26px rgba(var(--g-rgb),.25);
    border-color: var(--g-light);
}

.mgmr-rankcar-num {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--g-dark) 0%, var(--g-light) 100%);
    color: #1a1a2e;
    font-size: 1.5rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 18px rgba(var(--g-rgb),.4);
}

.mgmr-rankcar-rank {
    font-size: .66rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
}

.mgmr-rankcar-name {
    font-size: 1.08rem;
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
}

.mgmr-rankcar-xp {
    font-size: .9rem;
    font-weight: 700;
    color: var(--g-light);
    font-variant-numeric: tabular-nums;
}

.mgmr-rankcar-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--g-light);
    font-size: 1.3rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 4;
    transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.mgmr-rankcar-btn:hover {
    background: rgba(var(--g-rgb),.18);
    border-color: var(--g);
    box-shadow: 0 0 16px rgba(var(--g-rgb),.3);
}

.mgmr-rankcar-prev { left: 6px; }
.mgmr-rankcar-next { right: 6px; }

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    .mgmr-profile-card { flex-direction: column; align-items: flex-start; }
    .mgmr-progress-panel { width: 100%; align-items: flex-start; }
    .mgmr-stats { width: 100%; }
    .mgmr-stat { flex: 1; }
    .mgmr-maintabs { flex-direction: column; padding: 16px 16px 4px; }
    .mgmr-explain { margin: 16px 16px 4px; }
    .mgmr-panel-header { padding: 20px 16px 0; }
    .mgmr-game-tabs { padding: 8px 16px 16px; gap: 8px; }
    .mgmr-game-tab { min-width: 100px; padding: 12px 10px 8px; }
    .mgmr-wrap .mgmr-game-tab img.mgmr-game-tab-logo { width: 88px !important; height: 54px !important; max-width: 88px !important; }
    .mgmr-game-tab-emoji { font-size: 2rem; }
    .mgmr-section { padding: 0 16px; }
    .mgmr-section-heading { font-size: 1.35rem; gap: 10px; }
    .mgmr-wrap .mgmr-section-heading img.mgmr-section-logo { height: 34px !important; }
    .mgmr-grid { grid-template-columns: 1fr; }
    .mgmr-grid-pad { padding: 16px; }
    .mgmr-hero { padding: 16px 12px 22px; }
    .mgmr-hero h1 { font-size: 2rem; }
    .mgmr-hero p { font-size: 1.05rem; }
    .mgmr-steps { padding: 6px 16px 20px; }
    .mgmr-rank-stats { padding: 2px 16px 4px; }
    .mgmr-rankline { padding: 8px 30px 16px; }
    .mgmr-rankline-dot { width: 10px; height: 10px; margin: -6px 0 0 -6px; }
    .mgmr-rankcar { padding: 8px 14px; }
    .mgmr-rankcar-btn { display: none; }
    .mgmr-hero { padding: 28px 18px 30px; }
}
