* { box-sizing: border-box; }

/* The hidden attribute's UA default (display:none) loses to any author rule
   that sets display on the same element (e.g. .modal-overlay's display:flex),
   so it must be reasserted here with priority. */
[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    background: #1a1a2e;
    color: #eee;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: #16213e;
    border-bottom: 2px solid #e94560;
    flex-wrap: wrap;
    gap: 12px;
}

.brand {
    font-weight: bold;
    color: #e94560;
    text-decoration: none;
    font-size: 1.1em;
}

.nav-links a {
    color: #eee;
    text-decoration: none;
    margin-left: 16px;
    font-size: 0.95em;
}

.nav-links a:hover {
    color: #e94560;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px;
}

.card {
    background: #16213e;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.center-card {
    text-align: center;
    max-width: 480px;
    margin: 80px auto;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
}

.muted {
    color: #999;
    font-size: 0.9em;
}

.error {
    color: #e94560;
}

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

.dex-card {
    background: #16213e;
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}

.dex-card img {
    max-width: 100%;
    height: 100px;
    object-fit: contain;
}

.dex-name {
    font-weight: bold;
    margin-top: 8px;
}

.item-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #2a2a4a;
}

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

code {
    background: #0f0f23;
    padding: 2px 6px;
    border-radius: 4px;
}

/* ---------- Trainer profile ---------- */

.section-label {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75em;
    color: #9adcff;
    font-weight: bold;
    margin-bottom: 6px;
}

.trainer-card {
    position: relative;
    display: grid;
    grid-template-columns: 1.3fr 0.9fr 1.3fr;
    gap: 40px;
    align-items: center;
    padding: 48px 40px;
    margin-bottom: 20px;
}

.trainer-visual {
    position: relative;
    display: flex;
    justify-content: center;
}

.trainer-sprite-frame {
    position: relative;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, #22314f 0%, #16213e 70%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.level-watermark {
    position: absolute;
    font-size: 6em;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.07);
    white-space: nowrap;
}

.trainer-sprite {
    position: relative;
    width: 220px;
    height: 220px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.trainer-vertical-name {
    position: absolute;
    left: -6px;
    bottom: 0;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    color: #666;
    font-size: 0.75em;
    letter-spacing: 0.2em;
}

.favorite-visual {
    text-align: center;
}

.favorite-circle {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, #22314f 0%, #16213e 70%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    overflow: hidden;
}

.favorite-circle img {
    width: 150px;
    height: 150px;
    object-fit: contain;
}

.favorite-empty {
    font-size: 3em;
    color: #555;
}

.favorite-label {
    text-transform: uppercase;
    font-size: 0.8em;
    letter-spacing: 0.06em;
    color: #999;
}

.favorite-name {
    font-weight: bold;
    font-size: 1.5em;
    color: #e94560;
    margin: 4px 0 8px;
}

.favorite-types {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}

.type-badge {
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.75em;
    color: #fff;
    background: #666;
}

.type-normal { background: #A8A878; } .type-fire { background: #F08030; }
.type-water { background: #6890F0; } .type-grass { background: #78C850; }
.type-electric { background: #F8D030; color: #222; } .type-ice { background: #98D8D8; color: #222; }
.type-fighting { background: #C03028; } .type-poison { background: #A040A0; }
.type-ground { background: #E0C068; color: #222; } .type-flying { background: #A890F0; }
.type-psychic { background: #F85888; } .type-bug { background: #A8B820; }
.type-rock { background: #B8A038; } .type-ghost { background: #705898; }
.type-dragon { background: #7038F8; } .type-dark { background: #705848; }
.type-steel { background: #B8B8D0; color: #222; } .type-fairy { background: #EE99AC; color: #222; }

.trainer-info h1 {
    margin: 6px 0 0;
    font-size: 3em;
}

.trainer-tagline {
    color: #9adcff;
    font-size: 1.1em;
    margin: 8px 0 4px;
}

.trainer-level-tag {
    color: #999;
    font-size: 0.95em;
    margin: 0 0 16px;
}

.trainer-info hr {
    border: none;
    border-top: 1px solid #2a2a4a;
    margin: 16px 0;
}

.trainer-stats {
    display: flex;
    gap: 28px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stat-value {
    font-size: 2.1em;
    font-weight: bold;
}

.stat-label {
    color: #999;
    font-size: 0.85em;
}

.trainer-discord-avatar {
    position: absolute;
    top: 20px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid #e94560;
}

.btn-primary, .btn-secondary {
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.95em;
}

.btn-primary {
    background: #a4e864;
    color: #16213e;
}

.btn-secondary {
    background: #2a2a4a;
    color: #eee;
}

.trajectory-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
}

.trajectory-header h2 {
    margin: 2px 0 0;
}

.xp-bar {
    background: #0f0f23;
    border-radius: 20px;
    height: 12px;
    overflow: hidden;
}

.xp-bar-fill {
    background: linear-gradient(90deg, #a4e864, #6ee0c0);
    height: 100%;
}

.xp-caption {
    display: flex;
    justify-content: space-between;
    color: #999;
    font-size: 0.85em;
    margin-top: 6px;
}

.trajectory-card hr {
    border: none;
    border-top: 1px solid #2a2a4a;
    margin: 20px 0 12px;
}

.achievements-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.achievements-subtitle {
    margin: 4px 0 16px;
}

.achievement-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.achievement-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 10px 0;
    border-bottom: 1px solid #22314f;
}

.achievement-row:last-child {
    border-bottom: none;
}

.achievement-label {
    font-weight: bold;
}

.achievement-badges {
    display: flex;
    gap: 6px;
}

.badge-tier {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75em;
    font-weight: bold;
    background: #0f0f23;
    color: #444;
    border: 2px solid #2a2a4a;
}

.badge-tier.unlocked {
    color: #16213e;
    border-color: transparent;
}

.badge-bronze.unlocked { background: #cd7f32; }
.badge-silver.unlocked { background: #c0c0c0; }
.badge-gold.unlocked { background: #ffd700; }
.badge-platinum.unlocked { background: #e5e4e2; }
.badge-diamond.unlocked { background: linear-gradient(135deg, #b9f2ff, #6ee0c0); }

.achievement-progress {
    font-size: 0.85em;
    min-width: 90px;
    text-align: right;
}

/* ---------- Customize modal ---------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}

.modal {
    background: #16213e;
    border-radius: 12px;
    max-width: 640px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #2a2a4a;
    position: sticky;
    top: 0;
    background: #16213e;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2em;
}

.modal-close {
    background: none;
    border: none;
    color: #eee;
    font-size: 1.5em;
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 20px;
}

.modal-body hr {
    border: none;
    border-top: 1px solid #2a2a4a;
    margin: 24px 0;
}

.search-input {
    flex: 1;
    background: #0f0f23;
    border: 1px solid #2a2a4a;
    color: #eee;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9em;
}

.favorite-actions {
    display: flex;
    gap: 8px;
    margin: 10px 0 14px;
}

.picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    max-height: 320px;
    overflow-y: auto;
}

.picker-item {
    background: #0f0f23;
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 8px;
    text-align: center;
    cursor: pointer;
    color: #eee;
    font-size: 0.85em;
}

.picker-item:hover {
    border-color: #e94560;
}

.picker-item.selected {
    border-color: #a4e864;
}

.picker-item img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    image-rendering: pixelated;
}

@media (max-width: 800px) {
    .trainer-card {
        grid-template-columns: 1fr;
        text-align: center;
    }
    .trainer-discord-avatar {
        position: static;
        margin: 0 auto 12px;
    }
    .trainer-stats {
        justify-content: center;
    }
}

/* ---------- Trainers directory ---------- */

.trainer-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.trainer-list-item {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #16213e;
    border-radius: 10px;
    padding: 12px 16px;
    text-decoration: none;
    color: #eee;
    border: 1px solid transparent;
}

.trainer-list-item:hover {
    border-color: #e94560;
}

.trainer-list-item.is-you {
    border-color: #a4e864;
}

.trainer-list-sprite {
    width: 48px;
    height: 48px;
    object-fit: contain;
    image-rendering: pixelated;
}

.trainer-list-info {
    flex: 1;
}

.trainer-list-name {
    font-weight: bold;
}

.trainer-list-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}
