/* Profile View Styles */
#profile-view {
    position: absolute;
    inset: 0;
    z-index: 40;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 140px;
    /* Space for tabbar */
    opacity: 0;
    visibility: hidden;
    transform: scale(0.96);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.4s;
    pointer-events: none;
}

#profile-view.is-active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    pointer-events: auto;
}

/* Header Section */
.profile-header {
    position: relative;
    padding: 20px 24px 30px;
    background: linear-gradient(180deg, rgba(255, 122, 26, 0.15) 0%, rgba(22, 25, 34, 0) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.profile-avatar-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 16px;
    cursor: pointer;
}

.profile-avatar {
    width: 100%;
    height: 100%;
    border-radius: 24px;
    /* Rounded square */
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s;
    overflow: hidden;
    /* Ensure video stays inside border radius */
}

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

.profile-avatar-container:active .profile-avatar {
    transform: scale(0.95);
}

.edit-badge {
    position: absolute;
    top: 0;
    right: 0;
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
    border: 2px solid #161922;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

/* Character Stage */
.character-preview-container {
    position: relative;
    width: 100%;
    height: 320px;
    margin-bottom: 20px;
    perspective: 1000px;
}

.character-stage {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.character-model {
    height: 100%;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: transform;
}

.character-controls {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    z-index: 10;
}

.char-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.char-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

.profile-rank-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 40px;
    height: 40px;
    background: #1a1d26;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.profile-rank-badge img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.profile-name {
    font-size: 24px;
    font-weight: 800;
    margin: 0 0 4px;
    letter-spacing: 0.5px;
    color: #fff;
}

.profile-title {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    margin: 0 0 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

/* Stats Grid */
.profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 400px;
    margin-bottom: 24px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}

.stat-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-section-title {
    font-size: 16px;
    font-weight: 800;
    color: #fff;
    margin: 0 0 14px;
    letter-spacing: 0.04em;
}

.profile-armors {
    width: 100%;
    padding: 16px 24px 32px;
}

.profile-armors__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
}

.profile-armor-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 230px;
}

.profile-armor-card__viewer {
    width: 100%;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(120% 100% at 50% 0%, rgba(255, 122, 26, 0.12), rgba(22, 25, 34, 0.9));
    border-radius: 14px;
    overflow: hidden;
}

.profile-armor-card__viewer canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.profile-armor-card__meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.profile-armor-card__title {
    font-weight: 700;
    color: #fff;
    font-size: 15px;
}

.profile-armor-card__tag {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.profile-armor-card__desc {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
    line-height: 1.4;
    flex: 1 1 auto;
}

/* Level Progress */
.level-container {
    width: 100%;
    max-width: 400px;
    padding: 0 8px;
    margin-bottom: 10px;
}

.level-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
}

.level-bar-bg {
    height: 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 99px;
    overflow: hidden;
}

.level-bar-fill {
    height: 100%;
    width: 0%;
    /* Animated via JS */
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border-radius: 99px;
    box-shadow: 0 0 12px rgba(255, 122, 26, 0.4);
    transition: width 1s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Editor Overlay */
.editor-overlay {
    position: fixed;
    inset: 0;
    background: #161922;
    z-index: 2000;
    /* Ensure it's above everything including tabbar */
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.editor-overlay.is-active {
    transform: translateY(0);
}

.editor-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.editor-title {
    font-size: 18px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.editor-close,
.editor-save {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    padding: 8px;
    cursor: pointer;
}

.editor-save {
    color: var(--accent);
}

.editor-viewport {
    flex: 1;
    position: relative;
    background: radial-gradient(circle at 50% 50%, rgba(255, 122, 26, 0.1), #161922);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fake-3d-model {
    height: 80%;
    width: auto;
    filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.6));
    transition: transform 0.1s;
    /* Fast for touch */
    animation: breathe 4s ease-in-out infinite;
}

@keyframes breathe {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.02) translateY(-5px);
    }
}

.editor-controls {
    background: rgba(28, 30, 39, 0.95);
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

.editor-tabs {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

.editor-tab {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 16px;
    font-weight: 600;
    padding: 0 0 10px;
    position: relative;
    cursor: pointer;
}

.editor-tab.active {
    color: #fff;
}

.editor-tab.active::after {
    content: '';
    position: absolute;
    bottom: -11px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
}

.editor-panel.hidden {
    display: none;
}

.toggle-group.large .toggle-btn {
    flex: 1;
    padding: 12px;
    font-size: 16px;
}

.outfit-grid.large {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.outfit-grid.large .outfit-btn {
    width: auto;
    height: auto;
    padding: 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.outfit-grid.large .outfit-btn.active {
    background: rgba(255, 122, 26, 0.15);
    border-color: var(--accent);
}

.outfit-grid.large .outfit-preview {
    height: 60px;
    width: 60px;
    border-radius: 12px;
}

/* Customizer Panel */
.menu-section-title {
    font-size: 13px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 16px 0 8px;
    padding-left: 8px;
}

.customizer-panel {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.customizer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.customizer-row:last-child {
    margin-bottom: 0;
}

.customizer-label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 600;
}

.toggle-group {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 2px;
}

.toggle-btn {
    padding: 6px 16px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn.active {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.outfit-grid {
    display: flex;
    gap: 8px;
}

.outfit-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    padding: 2px;
    border: 2px solid transparent;
    background: transparent;
    cursor: pointer;
}

.outfit-btn.active {
    border-color: var(--accent);
}

.outfit-preview {
    width: 100%;
    height: 100%;
    border-radius: 6px;
}

/* Menu List */
.profile-menu {
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    color: #fff;
    text-decoration: none;
    transition: transform 0.2s, background 0.2s;
    cursor: pointer;
}

.menu-item:active {
    transform: scale(0.98);
    background: rgba(255, 255, 255, 0.06);
}

.menu-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.menu-icon svg {
    width: 24px;
    height: 24px;
    display: block;
}

.menu-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.menu-title {
    font-size: 15px;
    font-weight: 600;
}

.menu-subtitle {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.menu-arrow {
    color: rgba(255, 255, 255, 0.3);
}

/* Currency Display */
.currency-pill {
    display: flex;
    align-items: center;
    gap: 12px;
    background: radial-gradient(circle at 30% 30%, rgba(255, 122, 26, 0.18), rgba(0, 0, 0, 0.4));
    padding: 8px 16px 8px 10px;
    border-radius: 99px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 16px;
}

.currency-icon {
    width: 24px;
    height: 24px;
    background: url('/static/img/fan_coin.png') center/contain no-repeat;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4));
}

.currency-details {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.currency-label {
    font-size: 11px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 0.1em;
}

.currency-amount {
    font-size: 16px;
    font-weight: 700;
    color: #ffb347;
    font-variant-numeric: tabular-nums;
}

/* Sub-Page Overlay (Settings, etc.) */
.sub-page {
    position: fixed;
    inset: 0;
    background: #161922;
    z-index: 1900;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.sub-page.is-active {
    transform: translateX(0);
}

.sub-page-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sub-page-back {
    background: none;
    border: none;
    color: #fff;
    padding: 8px;
    margin-left: -8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sub-page-title {
    font-size: 18px;
    font-weight: 700;
}

.sub-page-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* History List Styles */
.history-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.history-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-item-timestamp {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.history-item-message {
    font-size: 14px;
    color: #fff;
    line-height: 1.4;
}

/* History Empty State */
.history-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.6);
}

.history-empty-icon {
    width: 80px;
    height: auto;
    opacity: 0.3;
    margin-bottom: 20px;
}

.history-empty-state p {
    margin: 0;
    font-size: 16px;
    line-height: 1.5;
}

.history-empty-sub {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 8px;
}


/* Feedback Form Styles */
.feedback-form-container {
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.feedback-form-container p {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 0;
    margin-bottom: 15px;
}

.feedback-textarea {
    width: 100%;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #fff;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.feedback-textarea::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.feedback-textarea:focus {
    border-color: var(--accent);
}

.feedback-submit-btn {
    width: 100%;
    padding: 12px 20px;
    margin-top: 15px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(255, 122, 26, 0.3);
}

.feedback-submit-btn:hover {
    filter: brightness(1.1);
}

.feedback-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}