:root {
    --bg: #f7f2e7;
    --surface: #fffaf0;
    --text: #2b2a27;
    --primary: #8b5e34;
    --accent: #c27c3d;
    --ring: #8b5e34;
    --muted: #e9e7e2;
    --soft: #fffdf8;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    --border: rgba(0, 0, 0, 0.1);
    --pillBg: rgba(194, 124, 61, 0.16);
    --pillBorder: rgba(194, 124, 61, 0.35);
    --pillText: #8b5e34;
    --pillMutedBg: rgba(0, 0, 0, 0.035);
    --pillMutedBorder: rgba(0, 0, 0, 0.08);
    --pillMutedText: rgba(43, 42, 39, 0.65);
    --pillMutedHover: rgba(0, 0, 0, 0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "SF Pro Display", "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    position: relative;
}

body.dark .sticky {
    background: rgba(0,0,0,0.3) !important;
}

/* Gradient animation */
@keyframes driftBG {
    0%, 100% { transform: rotate(0deg) translateX(0); }
    50% { transform: rotate(180deg) translateX(50px); }
}

.dark-bg-gradient {
    position: fixed;
    inset: -50%;
    width: 200%;
    height: 200%;
    pointer-events: none;
    z-index: -1;
    background: radial-gradient(circle at 20% 50%, rgba(0,217,255,0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(184,134,11,0.06) 0%, transparent 50%);
    animation: driftBG 40s ease-in-out infinite;
    display: none;
}

body.dark .dark-bg-gradient {
    display: block;
}

/* Light mode gradient (subtle) */
body:not(.dark) .dark-bg-gradient {
    display: block;
    background: radial-gradient(circle at 20% 50%, rgba(139,94,52,0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(194,124,61,0.03) 0%, transparent 50%);
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

body.dark .card {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

body:not(.dark) .card {
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.card-hover {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-hover:hover {
    transform: translateY(-4px);
}

/* Special gradient card for defenses */
body.dark .card-gradient {
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.08), rgba(184, 134, 11, 0.04));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 217, 255, 0.15);
}

body:not(.dark) .card-gradient {
    background: linear-gradient(135deg, rgba(139, 94, 52, 0.08), rgba(194, 124, 61, 0.04));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(139, 94, 52, 0.15);
}

/* Buttons */
.btn {
    padding: 6px 16px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.2px;
    transition: all 0.2s ease;
    border: 1px solid var(--pillMutedBorder);
    background: var(--pillMutedBg);
    color: var(--pillMutedText);
    cursor: pointer;
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon .icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
}

body[data-density="compact"] .btn {
    padding: 4px 12px;
}

body[data-density="compact"] .btn-icon {
    width: 34px;
    height: 34px;
}

.btn:hover {
    background: var(--pillMutedHover);
    border-color: var(--pillBorder);
    color: var(--text);
}

.btn-primary {
    background: var(--pillBg);
    border: 1px solid var(--pillBorder);
    color: var(--pillText);
}

.btn-primary:hover {
    filter: brightness(1.05);
}

/* Small pill buttons */
.btn-sm {
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pill-btn {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid transparent;
    background: var(--pillMutedBg);
    color: var(--text);
    transition: all 0.2s ease;
    cursor: pointer;
}

.pill-btn:hover {
    background: var(--pillMutedHover);
    border-color: var(--pillBorder);
}

.pill-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    border-color: transparent;
}

.pill-btn.decrease {
    background: rgba(244, 63, 94, 0.12);
    border-color: rgba(244, 63, 94, 0.2);
    color: #e11d48;
}

.pill-btn.decrease:hover {
    background: rgba(244, 63, 94, 0.18);
    border-color: rgba(244, 63, 94, 0.35);
}

.pill-btn.increase {
    background: rgba(16, 185, 129, 0.14);
    border-color: rgba(16, 185, 129, 0.26);
    color: #059669;
}

.pill-btn.increase:hover {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.4);
}

.pill-btn.level {
    background: var(--pillBg);
    border-color: var(--pillBorder);
    color: var(--pillText);
}

.pill-btn.level:hover {
    filter: brightness(1.05);
}

/* Adaptive navigation */
.nav-surface {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.nav-surface .icon {
    display: none;
}

.nav-surface .nav-label {
    display: inline;
}

.nav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    border-radius: 999px;
    font-weight: 500;
    font-size: 14px;
    color: var(--pillMutedText);
    border: 1px solid var(--pillMutedBorder);
    background: var(--pillMutedBg);
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    transition: all 0.2s ease;
    cursor: pointer;
}

.nav-link:hover {
    background: var(--pillMutedHover);
    color: var(--text);
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}

.nav-link.active {
    background: var(--pillBg);
    color: var(--pillText);
    border-color: var(--pillBorder);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.05) inset, 0 8px 24px rgba(139,94,52,0.25);
}

.nav-link:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(194,124,61,0.28), 0 10px 24px rgba(0,0,0,0.14);
}

body.dark .nav-link {
    border-color: rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.08);
    box-shadow: 0 2px 10px rgba(0,0,0,0.35);
    color: rgba(255,255,255,0.78);
}

body.dark .nav-link:hover {
    background: rgba(255,255,255,0.12);
    box-shadow: 0 6px 20px rgba(0,0,0,0.55);
    color: #fff;
}

body.dark .nav-link.active {
    box-shadow: 0 0 0 1px rgba(0,217,255,0.18) inset, 0 8px 26px rgba(0,217,255,0.28);
    border-color: rgba(0,217,255,0.35);
}

body.dark .nav-link:focus-visible {
    box-shadow: 0 0 0 2px rgba(0,217,255,0.4), 0 12px 28px rgba(0,0,0,0.55);
}

body[data-density="compact"] .nav-link {
    padding: 8px 14px;
    gap: 8px;
}

.nav-link .icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    color: currentColor;
}

.nav-link .nav-label {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.nav-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 20px 12px;
    border-radius: 26px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: visible;
}

.nav-rail .nav-link {
    width: 100%;
    padding: 14px 12px;
    border-radius: 20px;
    flex-direction: column;
    font-size: 12px;
    letter-spacing: 0.3px;
    box-shadow: none;
    position: relative;
}

body[data-density="compact"] .nav-rail .nav-link {
    padding: 12px 10px;
}

.nav-rail .nav-link .nav-label {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 12px);
    transform: translate3d(-50%, 6px, 0);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px 10px;
    box-shadow: 0 12px 28px rgba(0,0,0,0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    color: var(--text);
    z-index: 60;
}

.nav-rail .nav-link:hover .nav-label,
.nav-rail .nav-link:focus-visible .nav-label {
    opacity: 1;
    transform: translate3d(-50%, 0, 0);
}

.nav-rail .nav-link:hover,
.nav-rail .nav-link.active {
    box-shadow: 0 10px 24px rgba(0,0,0,0.12);
}

.nav-rail .nav-link .icon {
    width: 2rem;
    height: 2rem;
}

body.dark .nav-rail .nav-link .nav-label {
    background: rgba(15, 15, 20, 0.92);
    border-color: rgba(0,217,255,0.18);
    color: #e8f9ff;
    box-shadow: 0 12px 28px rgba(0,0,0,0.55);
}

.nav-bottom-sheet {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 20px;
    width: min(520px, 92%);
    z-index: 40;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 26px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.24);
    padding: 14px 18px 20px;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-bottom-sheet.collapsed {
    transform: translateX(-50%) translateY(calc(100% - 32px));
}

.nav-bottom-sheet.collapsed .nav-bottom-sheet-content {
    opacity: 0;
    pointer-events: none;
}

.nav-bottom-sheet-content {
    transition: opacity 0.2s ease;
}

.nav-bottom-sheet .nav-link {
    flex-direction: column;
    gap: 6px;
    padding: 12px 10px;
    border-radius: 18px;
    font-size: 12px;
    letter-spacing: 0.2px;
    box-shadow: none;
}

body[data-density="compact"] .nav-bottom-sheet .nav-link {
    padding: 10px 8px;
}

.nav-bottom-sheet .nav-link .nav-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.nav-bottom-sheet .nav-link.active,
.nav-bottom-sheet .nav-link:hover {
    box-shadow: 0 12px 28px rgba(0,0,0,0.18);
}

.nav-bottom-sheet .nav-link .icon {
    width: 2rem;
    height: 2rem;
}

.nav-bottom-sheet-handle {
    width: 48px;
    height: 4px;
    border-radius: 999px;
    background: var(--pillMutedBorder);
    margin: 0 auto 12px;
    opacity: 0.65;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.nav-bottom-sheet-handle:hover {
    opacity: 1;
    transform: scaleX(1.2);
}

.nav-bottom-sheet-handle:active {
    transform: scaleX(1.4) scaleY(1.5);
}

.nav-bottom-sheet-glow {
    position: absolute;
    inset: -20px;
    background: radial-gradient(circle, rgba(0,0,0,0.18) 0%, transparent 70%);
    border-radius: 32px;
    z-index: -1;
    pointer-events: none;
}

/* System selection */
.system-selection {
    position: relative;
    padding: 64px 48px;
    margin-bottom: 48px;
    border-radius: 28px;
    overflow: hidden;
    background: linear-gradient(145deg, rgba(13,19,33,0.92), rgba(45,29,23,0.75));
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 40px 80px rgba(0,0,0,0.28);
    color: #f8f5f1;
}

.system-selection::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top center, rgba(255,215,128,0.18), transparent 55%),
    radial-gradient(circle at bottom right, rgba(64,141,241,0.22), transparent 60%);
    opacity: 0.8;
    pointer-events: none;
}

.system-selection-header {
    position: relative;
    text-align: center;
    margin-bottom: 42px;
}

.system-selection-header h1 {
    font-size: clamp(32px, 4vw, 44px);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 700;
}

.system-selection-header p {
    margin-top: 10px;
    font-size: 14px;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: rgba(248,245,241,0.7);
}

.system-grid {
    position: relative;
    display: grid;
    gap: 28px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    align-items: stretch;
    z-index: 1;
}

.system-card {
    position: relative;
    border-radius: 26px;
    padding: 28px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 18px;
    background: rgba(12, 17, 27, 0.82);
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 24px 50px rgba(0,0,0,0.28);
    overflow: hidden;
    min-height: 420px;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.2s ease;
}

.system-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-image: var(--system-image, none);
    filter: brightness(0.5) saturate(0.9);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.system-card.active::before {
    opacity: 0.95;
    filter: brightness(0.82) saturate(1.05);
}

.system-card.active {
    border-color: rgba(255,200,120,0.55);
    background: rgba(32, 22, 14, 0.78);
    box-shadow: 0 32px 70px rgba(255, 140, 70, 0.28);
}

.system-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 34px 60px rgba(0,0,0,0.32);
    border-color: rgba(255,255,255,0.18);
}

.system-card.locked {
    filter: grayscale(1) saturate(0.4) brightness(0.72);
    border-color: rgba(255,255,255,0.06);
    box-shadow: 0 18px 36px rgba(0,0,0,0.25);
    cursor: not-allowed;
}

.system-card.locked:hover {
    transform: none;
    box-shadow: 0 18px 36px rgba(0,0,0,0.25);
    border-color: rgba(255,255,255,0.08);
}

.system-card.locked::before {
    background-image: radial-gradient(circle at 30% 30%, rgba(140,140,140,0.35), transparent 60%),
    radial-gradient(circle at 70% 70%, rgba(90,90,90,0.28), transparent 65%);
    opacity: 0.65;
    filter: grayscale(1) brightness(0.75);
}

.system-card .card-overlay {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.system-card .card-pill {
    align-self: flex-start;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 11px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    border: 1px solid rgba(255,255,255,0.25);
    background: rgba(6,8,12,0.6);
    color: rgba(255,255,255,0.72);
}

.system-card.active .card-pill {
    background: rgba(255,177,66,0.22);
    border-color: rgba(255,177,66,0.65);
    color: #ffd08a;
}

.system-card.locked .card-pill {
    background: rgba(28,31,40,0.8);
    border-color: rgba(255,255,255,0.12);
    color: rgba(220,222,230,0.38);
}

.system-card h2 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.system-card p {
    font-size: 14px;
    line-height: 1.6;
    color: rgba(248,245,241,0.72);
}

.system-card.locked p {
    color: rgba(240,240,245,0.35);
}

.system-card.locked .locked-icon {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    border: 1px solid rgba(255,255,255,0.18);
    background: rgba(23,25,32,0.86);
    display: grid;
    place-items: center;
    font-size: 28px;
    color: rgba(255,255,255,0.55);
    margin-bottom: 12px;
}

.system-actions {
    position: relative;
    margin-top: 36px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    z-index: 1;
}

.system-actions .cta {
    padding: 12px 28px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.18);
    background: rgba(12,16,24,0.75);
    color: rgba(255,255,255,0.85);
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    font-size: 12px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.system-actions .cta.primary {
    background: linear-gradient(135deg, rgba(255,180,82,0.9), rgba(255,126,82,0.85));
    border-color: rgba(255,200,120,0.65);
    color: #2d1d17;
}

.system-actions .cta:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 32px rgba(0,0,0,0.28);
}

@media (max-width: 1024px) {
    .system-selection {
        padding: 48px 28px;
    }

    .system-card {
        min-height: 360px;
    }

    .system-card .nav-label {
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    .system-selection {
        padding: 36px 24px;
    }

    .system-selection-header p {
        letter-spacing: 0.16em;
    }

    .system-card {
        padding: 22px;
        min-height: 320px;
    }

    .system-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .system-actions .cta {
        text-align: center;
    }
}

/* Progress bar */
.progress-bar {
    height: 4px;
    background: var(--muted);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #00ff88, #00d9ff);
    transition: width 0.3s ease;
}

body:not(.dark) .progress-fill {
    background: linear-gradient(90deg, #00ff88, var(--primary));
}

/* Attribute items */
.attr-item {
    background: var(--soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 4px;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

body.dark .attr-item {
    background: rgba(255,255,255,0.04);
    border-color: rgba(255,255,255,0.06);
}

.attr-item:hover {
    transform: translateY(-2px);
    border-color: var(--pillBorder);
    background: var(--pillMutedHover);
}

.attr-header {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.attr-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: var(--pillMutedText);
    line-height: 1.2;
}

.attr-name {
    font-size: 10px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
}

body.dark .attr-name { color: rgba(255,255,255,0.88); }

.attr-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.attr-value {
    font-size: 18px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    line-height: 1;
}

body.dark .attr-value { color: rgba(255,255,255,0.95); }

.attr-controls {
    display: flex;
    gap: 3px;
}

/* Skills */
.skill-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 5px 7px;
    background: var(--soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

body.dark .skill-item {
    background: rgba(255,255,255,0.03);
    border-color: rgba(255,255,255,0.06);
}

.skill-item:hover {
    background: var(--pillMutedHover);
    border-color: var(--pillBorder);
    transform: translateY(-2px);
}

.skill-item.master { border-left: 4px solid rgba(255, 215, 0, 0.8); }
.skill-item.expert { border-left: 4px solid rgba(184, 134, 11, 0.5); }
.skill-item.trained { border-left: 4px solid rgba(0, 217, 255, 0.5); }
.skill-item.legendary { border-left: 4px solid rgba(179, 102, 255, 0.8); }

body:not(.dark) .skill-item.master { border-left: 4px solid #ffd700; }
body:not(.dark) .skill-item.expert { border-left: 4px solid var(--accent); }
body:not(.dark) .skill-item.trained { border-left: 4px solid var(--primary); }
body:not(.dark) .skill-item.legendary { border-left: 4px solid rgba(179, 102, 255, 0.85); }

.skill-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
}

body.dark .skill-name {
    color: rgba(255,255,255,0.92);
}

.skill-attrs {
    display: flex;
    gap: 2px;
}

.skill-attr-btn {
    padding: 1px 5px;
    border-radius: 999px;
    font-size: 8px;
    font-weight: 600;
    letter-spacing: 0.2px;
    text-transform: uppercase;
    border: 1px solid var(--pillMutedBorder);
    background: var(--pillMutedBg);
    color: var(--pillMutedText);
    transition: all 0.2s ease;
    cursor: pointer;
    line-height: 1.3;
}

.skill-attr-btn:hover {
    background: var(--pillMutedHover);
    border-color: var(--pillBorder);
}

.skill-attr-btn.active {
    background: var(--pillBg);
    border-color: var(--pillBorder);
    color: var(--pillText);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.06) inset;
}

.skill-rank {
    padding: 1px 5px;
    border-radius: 999px;
    font-size: 8px;
    font-weight: 600;
    letter-spacing: 0.2px;
    text-transform: uppercase;
    line-height: 1.3;
}

.rank-trained { background: rgba(0, 217, 255, 0.15); color: #00bcd4; }
.rank-expert { background: rgba(184, 134, 11, 0.2); color: #c27c3d; }
.rank-master { background: rgba(255, 215, 0, 0.2); color: #b8860b; }
.rank-legendary { background: rgba(179, 102, 255, 0.2); color: #b366ff; }
.rank-untrained { background: rgba(0,0,0,0.04); color: rgba(0,0,0,0.45); }

body.dark .rank-untrained { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.55); }

.skill-modifier {
    font-weight: 700;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    line-height: 1;
    min-width: 20px;
    text-align: right;
}

body.dark .skill-modifier { color: rgba(255,255,255,0.9); }

.skill-modifier.muted { opacity: 0.45; }

.skill-controls {
    display: flex;
    gap: 2px;
}

/* Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
    transition: all 0.2s ease;
}

.badge-primary {
    background: var(--primary);
    color: white;
}

.badge-outline {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
}

/* Tabs */
.tab-btn {
    padding: 8px 16px;
    border-radius: 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text);
    opacity: 0.6;
}

.tab-btn.active {
    background: var(--soft);
    opacity: 1;
}

.tab-btn:hover:not(.active) {
    opacity: 0.8;
}

.tab-content {
    display: none;
}

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

/* Icons (using emoji for simplicity) */
.icon {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    text-align: center;
}

/* Scrollable area */
.scrollable {
    max-height: 500px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--muted) transparent;
    padding-right: 6px;
}

.scrollable::-webkit-scrollbar {
    width: 6px;
}

.scrollable::-webkit-scrollbar-track {
    background: transparent;
}

.scrollable::-webkit-scrollbar-thumb {
    background: var(--muted);
    border-radius: 3px;
}

.scrollable::-webkit-scrollbar-thumb:hover {
    background: var(--border);
}

/* Screen navigation */
.screen-view {
    display: none;
}

.screen-view.active {
    display: block;
}

/* Utility classes */
.space-y-1 > * + * {
    margin-top: 0.25rem;
}

.space-y-3 > * + * {
    margin-top: 0.75rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.cursor-pointer {
    cursor: pointer;
}

/* Character Screen Responsive Layout */
/* Small screens (<696px): 1-panel vertical layout */
.character-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.character-layout > .card {
    min-height: 0;
}

.character-avatar {
    width: 100%;
    aspect-ratio: 1 / 1;
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 1rem;
    overflow: hidden;
}

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

.primary-stats-grid {
    display: grid;
    gap: 1rem;
}

@media (min-width: 768px) {
    .primary-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.stat-panel {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.stat-panel .icon {
    color: inherit;
}


.perks-row {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(260px, 1fr);
    gap: 1rem;
    padding-bottom: 0.5rem;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    min-height: 170px;
}

.perks-row::-webkit-scrollbar {
    height: 8px;
}

.perks-row::-webkit-scrollbar-thumb {
    background: var(--muted);
    border-radius: 999px;
}

.perks-row > .perk-card,
.perks-row > .perk-empty {
    scroll-snap-align: start;
    height: 100%;
}

.perk-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.perk-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: inherit;
    background: var(--soft);
    border: 1px dashed var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    min-height: 140px;
}

#availablePerksList .perk-card,
#acquiredPerksItems .perk-card,
#availablePerksList .perk-empty,
#acquiredPerksItems .perk-empty {
    width: 100%;
}

.health-card-grid {
    display: grid;
    gap: 1rem;
}

@media (min-width: 768px) {
    .health-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }
}

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

/* Medium screens (696px-1191px): 2-panel layout with skills underneath */
@media (min-width: 696px) {
    .character-layout {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1rem;
        margin-bottom: 1.5rem;
    }

    .character-health-card,
    .character-defenses-card,
    .character-skills-card {
        grid-column: 1 / -1;
    }

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

/* Desktop screens (≥1192px): 3-panel layout with skills to right of HP */
@media (min-width: 1192px) {
    .character-layout {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
        margin-bottom: 1.5rem;
    }

    .character-health-card {
        grid-column: 1;
    }

    .character-defenses-card {
        grid-column: 2;
    }

    .character-skills-card {
        grid-column: 3;
    }

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

/* Extra large screens (≥1440px): optimize skills grid further */
@media (min-width: 1440px) {
    .skills-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Beckoning slot animation */
.skill-item.beckoning {
    border: 2px dashed var(--border);
    background: var(--soft);
    cursor: pointer;
    transition: all 0.3s ease;
}

.skill-item.beckoning:hover {
    border-color: var(--primary);
    background: var(--surface);
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* Character List Modal */
.character-list-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.character-list-modal.active {
    display: flex;
}

.character-list-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease;
}

.character-list-container {
    position: relative;
    width: 100%;
    max-width: 900px;
    max-height: 85vh;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.character-list-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid var(--border);
}

.character-list-search {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    align-items: center;
}

.character-list-search .relative {
    flex: 1;
}

.character-list-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    align-content: start;
}

@media (min-width: 640px) {
    .character-list-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Character Card in List */
.character-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--soft);
    border: 2px solid var(--border);
    border-radius: 16px;
    transition: all 0.25s ease;
    cursor: pointer;
    overflow: hidden;
}

.character-card:hover {
    transform: translateY(-4px);
    border-color: var(--pillBorder);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.15);
}

.character-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.character-card-avatar {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    background: var(--pillBg);
    border: 2px solid var(--pillBorder);
    color: var(--pillText);
    flex-shrink: 0;
}

.character-card-info {
    flex: 1;
    min-width: 0;
}

.character-card-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.character-card-class {
    font-size: 12px;
    font-weight: 600;
    color: var(--pillMutedText);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.character-card-menu {
    position: relative;
}

.character-card-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.character-card-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 0.5rem;
    background: var(--pillMutedBg);
    border: 1px solid var(--pillMutedBorder);
    border-radius: 8px;
}

.character-card-stat-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--pillMutedText);
}

.character-card-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.character-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.character-card-date {
    font-size: 11px;
    color: var(--pillMutedText);
}

.character-card-actions {
    display: flex;
    gap: 0.25rem;
}

.character-card-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--pillMutedText);
}

.character-card-empty-icon {
    font-size: 48px;
    margin-bottom: 1rem;
    opacity: 0.3;
}

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Dark mode adjustments */
body.dark .character-card {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}

body.dark .character-card:hover {
    border-color: var(--pillBorder);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
}

/* Main content padding for nav rail on medium screens */
@media (min-width: 768px) and (max-width: 1023px) {
    main {
        padding-left: 100px !important;
    }
}

/* FAB (Floating Action Button) for quick navigation */
.fab-container {
    position: fixed;
    right: 20px;
    bottom: 140px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

@media (min-width: 768px) {
    .fab-container {
        display: none;
    }
}

.fab-menu {
    display: flex;
    flex-direction: column;
    gap: 10px;
    opacity: 0;
    transform: translateY(20px) scale(0.8);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.fab-container.open .fab-menu {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.fab-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

body.dark .fab-menu-item {
    box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}

.fab-menu-item:hover {
    background: var(--pillBg);
    border-color: var(--pillBorder);
    transform: translateX(-4px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.28);
}

.fab-menu-item .icon {
    width: 20px;
    height: 20px;
    color: var(--pillText);
}

.fab-menu-item span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.fab-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--pillBg);
    border: 1px solid var(--pillBorder);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

body.dark .fab-button {
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.fab-button:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 32px rgba(0,0,0,0.32);
}

.fab-button:active {
    transform: scale(0.95);
}

.fab-button .icon {
    width: 24px;
    height: 24px;
    color: var(--pillText);
    transition: transform 0.3s ease;
}

.fab-container.open .fab-button .icon {
    transform: rotate(45deg);
}
