/**
 * Flex Your Wealth - Styles
 * Fully responsive design for all Apple devices
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: fixed;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
    background: #000;
    color: #fff;
}

body {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    background: linear-gradient(135deg, #000428 0%, #004e92 100%);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Username Screen */
.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    z-index: 9999;
    transition: opacity 0.5s, transform 0.5s;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.fullscreen.hidden {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

.welcome-box {
    text-align: center;
    padding: 30px;
    max-width: 400px;
    width: 90%;
}

.game-title {
    font-size: clamp(32px, 8vw, 48px);
    font-weight: 900;
    color: #FFD700;
    margin-bottom: 20px;
    text-shadow: 0 0 30px rgba(255,215,0,0.6);
    animation: glow 2s ease-in-out infinite alternate;
    letter-spacing: 1px;
}

@keyframes glow {
    from { text-shadow: 0 0 20px rgba(255,215,0,0.4); }
    to { text-shadow: 0 0 40px rgba(255,215,0,0.8); }
}

.welcome-text {
    font-size: clamp(18px, 4vw, 24px);
    color: #aaa;
    margin-bottom: 25px;
    font-weight: 500;
}

#usernameInput {
    width: 100%;
    padding: 16px 20px;
    font-size: clamp(16px, 4vw, 20px);
    background: rgba(255,255,255,0.05);
    border: 3px solid #FFD700;
    border-radius: 12px;
    color: #FFD700;
    text-align: center;
    font-weight: 600;
    margin-bottom: 10px;
    outline: none;
    transition: all 0.3s;
    -webkit-user-select: text;
    user-select: text;
}

#usernameInput:focus {
    background: rgba(255,255,255,0.08);
    border-color: #FFA500;
    box-shadow: 0 0 20px rgba(255,215,0,0.3);
}

.username-hint {
    font-size: 13px;
    color: #888;
    margin-bottom: 20px;
    font-weight: 400;
}

.start-btn {
    width: 100%;
    padding: 18px;
    font-size: clamp(18px, 4vw, 24px);
    font-weight: 700;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border: none;
    border-radius: 12px;
    color: #000;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(255,215,0,0.4);
    transition: all 0.3s;
}

.start-btn:active {
    transform: scale(0.96);
    box-shadow: 0 3px 10px rgba(255,215,0,0.3);
}

.error-text {
    color: #ff4444;
    font-size: 14px;
    margin-top: 10px;
    min-height: 20px;
    font-weight: 500;
}

/* Game Container */
.game-container {
    width: 100%;
    height: 100%;
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    transition: opacity 0.5s;
    position: relative;
}

.game-container.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Top Bar */
.top-bar {
    flex-shrink: 0;
    padding: max(env(safe-area-inset-top), 12px) 16px 12px;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.user-badge {
    text-align: center;
    margin-bottom: 12px;
}

.username-display {
    display: inline-block;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #000;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 16px;
}

.currency-bar {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.currency-item {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 2px solid;
    border-radius: 12px;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    max-width: 280px;
}

.currency-item.money {
    border-color: #FFD700;
}

.currency-item.gems {
    border-color: #00FFFF;
}

.currency-icon {
    font-size: 24px;
}

.currency-value {
    font-size: clamp(16px, 4vw, 20px);
    font-weight: 700;
}

.currency-item.money .currency-value {
    color: #FFD700;
}

.currency-item.gems .currency-value {
    color: #00FFFF;
}

/* Stats Panel */
.stats-panel {
    flex-shrink: 0;
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    justify-content: center;
}

.stat-card {
    flex: 1;
    max-width: 185px;
    background: rgba(255,255,255,0.05);
    border: 2px solid rgba(255,215,0,0.2);
    border-radius: 10px;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.stat-icon {
    font-size: 24px;
}

.stat-info {
    text-align: center;
}

.stat-label {
    font-size: 10px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-value {
    font-size: clamp(12px, 3vw, 15px);
    font-weight: 700;
    color: #FFD700;
}

/* Tap Zone */
.tap-zone {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    min-height: 0;
}

.tap-button {
    width: min(300px, 70vw);
    height: min(300px, 70vw);
    max-width: 350px;
    max-height: 350px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border: 6px solid #fff;
    box-shadow: 0 12px 40px rgba(255,215,0,0.5);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
    position: relative;
    overflow: hidden;
}

.tap-button::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
    animation: rotate 4s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.tap-button:active {
    transform: scale(0.9);
}

.tap-emoji {
    font-size: clamp(70px, 15vw, 100px);
    position: relative;
    z-index: 1;
}

.tap-text {
    font-size: clamp(22px, 5vw, 28px);
    font-weight: 900;
    color: #000;
    margin-top: 10px;
    position: relative;
    z-index: 1;
}

/* Navigation Bar */
.nav-bar {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    padding: 12px 16px max(env(safe-area-inset-bottom), 12px);
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    justify-content: center;
}

.nav-btn {
    flex: 1;
    max-width: 185px;
    padding: 14px 8px;
    background: rgba(255,255,255,0.05);
    border: 2px solid #FFD700;
    border-radius: 12px;
    color: #FFD700;
    font-weight: 700;
    font-size: clamp(12px, 3vw, 14px);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}

.nav-btn span:first-child {
    font-size: 28px;
}

.nav-btn:active {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #000;
    transform: scale(0.96);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-container {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 3px solid #FFD700;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 2px solid rgba(255,215,0,0.2);
}

.modal-header h2 {
    font-size: clamp(20px, 5vw, 26px);
    color: #FFD700;
    font-weight: 700;
}

.close-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: 2px solid #FFD700;
    color: #FFD700;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.close-btn:active {
    background: #FFD700;
    color: #000;
}

.gem-notice {
    flex-shrink: 0;
    padding: 12px 20px;
    background: rgba(0,255,255,0.1);
    border-bottom: 2px solid rgba(0,255,255,0.3);
    color: #00FFFF;
    font-size: 12px;
    text-align: center;
    font-weight: 500;
    line-height: 1.4;
}

.tab-bar {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    border-bottom: 2px solid rgba(255,215,0,0.2);
}

.tab {
    flex: 1;
    padding: 10px 8px;
    background: rgba(255,255,255,0.05);
    border: 2px solid #666;
    border-radius: 8px;
    color: #888;
    font-weight: 600;
    font-size: clamp(11px, 2.5vw, 13px);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.tab.active {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border-color: #FFD700;
    color: #000;
}

.your-rank {
    flex-shrink: 0;
    padding: 12px 20px;
    background: rgba(255,215,0,0.1);
    border-bottom: 2px solid rgba(255,215,0,0.2);
    text-align: center;
    color: #FFD700;
    font-weight: 600;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 20px;
    -webkit-overflow-scrolling: touch;
}

/* Upgrade Card */
.upgrade-card {
    background: rgba(255,255,255,0.05);
    border: 2px solid #333;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    transition: all 0.2s;
}

.upgrade-card.affordable {
    border-color: #4CAF50;
    background: rgba(76,175,80,0.1);
}

.upgrade-card.maxed {
    opacity: 0.5;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 10px;
}

.card-name {
    font-size: clamp(15px, 3.5vw, 18px);
    font-weight: 700;
    color: #FFD700;
    flex: 1;
    min-width: 0;
}

.card-level {
    font-size: 12px;
    background: rgba(255,215,0,0.2);
    padding: 3px 10px;
    border-radius: 10px;
    color: #FFD700;
    white-space: nowrap;
    flex-shrink: 0;
}

.card-desc {
    font-size: 13px;
    color: #aaa;
    margin: 6px 0;
    line-height: 1.4;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    gap: 10px;
}

.card-cost {
    font-size: clamp(14px, 3.5vw, 17px);
    font-weight: 700;
    color: #4CAF50;
}

.card-cost.gems {
    color: #00FFFF;
}

.buy-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.buy-btn:disabled {
    background: #555;
    color: #888;
    cursor: not-allowed;
}

.buy-btn.gem-btn {
    background: linear-gradient(135deg, #00FFFF, #00CED1);
    color: #000;
}

.buy-btn:not(:disabled):active {
    transform: scale(0.96);
}

/* Leaderboard */
.rank-card {
    background: rgba(255,255,255,0.05);
    border: 2px solid #333;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.rank-card.you {
    border-color: #FFD700;
    background: rgba(255,215,0,0.1);
}

.rank-position {
    font-size: clamp(20px, 5vw, 26px);
    font-weight: 900;
    color: #FFD700;
    min-width: 50px;
    text-align: center;
    flex-shrink: 0;
}

.rank-username {
    flex: 1;
    font-size: clamp(14px, 3.5vw, 16px);
    font-weight: 700;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-score {
    font-size: clamp(14px, 3.5vw, 16px);
    font-weight: 700;
    color: #4CAF50;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Toast */
.toast {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: #FFD700;
    padding: 14px 24px;
    border-radius: 10px;
    border: 2px solid #FFD700;
    font-weight: 700;
    font-size: 14px;
    z-index: 3000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    max-width: 90%;
    text-align: center;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Loading */
.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 4000;
    transition: opacity 0.3s;
}

.loading-indicator.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,215,0,0.2);
    border-top-color: #FFD700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Particle */
.money-particle {
    position: fixed;
    color: #FFD700;
    font-size: clamp(22px, 5vw, 28px);
    font-weight: 900;
    pointer-events: none;
    z-index: 999;
    text-shadow: 0 0 10px rgba(255,215,0,0.8);
    animation: floatUp 1s ease-out forwards;
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0) translateX(-50%);
    }
    100% {
        opacity: 0;
        transform: translateY(-120px) translateX(-50%);
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
}

::-webkit-scrollbar-thumb {
    background: #FFD700;
    border-radius: 10px;
}

/* Desktop */
@media (min-width: 768px) {
    body {
        padding: 20px;
    }
    
    .game-container {
        border: 3px solid #FFD700;
        border-radius: 20px;
        overflow: hidden;
        max-height: 900px;
        box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    }
}

/* Large screens */
@media (min-width: 1024px) {
    .game-container {
        max-height: 800px;
    }
}

/* Input selection */
input {
    -webkit-user-select: text;
    user-select: text;
}