* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-dark: #1a0a2e;
    --bg-card: #251447;
    --accent-primary: #a855f7;
    --accent-secondary: #7c3aed;
    --accent-light: #c084fc;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --gradient-purple: linear-gradient(135deg, #7c3aed 0%, #a855f7 50%, #c084fc 100%);
    --gradient-bg: linear-gradient(180deg, #2d1b4e 0%, #1a0a2e 50%, #0f0618 100%);
}

body {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gradient-bg);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Top Section - Wheel Area */
.wheel-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    padding-top: env(safe-area-inset-top, 40px);
    background: 
        radial-gradient(ellipse at 50% 30%, rgba(168, 85, 247, 0.3) 0%, transparent 50%),
        radial-gradient(ellipse at 20% 80%, rgba(124, 58, 237, 0.2) 0%, transparent 40%),
        radial-gradient(ellipse at 80% 80%, rgba(192, 132, 252, 0.2) 0%, transparent 40%);
    position: relative;
}

/* Settings Button */
.settings-btn {
    position: absolute;
    top: env(safe-area-inset-top, 20px);
    right: 20px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    backdrop-filter: blur(10px);
    z-index: 10;
}

/* Wheel Container */
.wheel-wrapper {
    position: relative;
    width: 280px;
    height: 280px;
    margin-bottom: 20px;
}

.wheel-container {
    position: relative;
    width: 100%;
    height: 100%;
}

#wheelCanvas {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.5));
    transition: filter 0.3s ease, transform 0.1s ease;
}

.wheel-wrapper.spinning #wheelCanvas {
    filter: drop-shadow(0 15px 40px rgba(168, 85, 247, 0.5));
}

.wheel-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70px;
    height: 70px;
    background: linear-gradient(145deg, #3d2b5e 0%, #1a0a2e 100%);
    border-radius: 50%;
    border: 4px solid var(--accent-light);
    box-shadow: 
        0 0 30px rgba(192, 132, 252, 0.6),
        0 0 60px rgba(168, 85, 247, 0.3),
        inset 0 4px 15px rgba(0, 0, 0, 0.6),
        inset 0 -2px 10px rgba(192, 132, 252, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.wheel-center::before {
    content: '';
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.2) 0%, transparent 60%);
}

.wheel-center-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.wheel-pointer {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.wheel-pointer::before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-left: 18px solid transparent;
    border-right: 18px solid transparent;
    border-top: 35px solid #ffffff;
    filter: drop-shadow(0 4px 15px rgba(168, 85, 247, 0.8));
}

.wheel-pointer::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 24px solid var(--accent-light);
}

/* Decorative Diamonds */
.diamonds-row {
    display: flex;
    gap: 20px;
    margin-top: 10px;
}

.diamond {
    width: 40px;
    height: 40px;
    border: 2px solid var(--accent-light);
    border-radius: 8px;
    transform: rotate(45deg);
    opacity: 0.6;
    transition: all 0.3s ease;
}

.diamond.active {
    background: var(--accent-primary);
    opacity: 1;
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.6);
}

/* Main Card */
.main-card {
    background: var(--bg-card);
    border-radius: 24px 24px 0 0;
    padding: 24px 20px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 20px));
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.card-title {
    text-align: center;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 20px;
    background: var(--gradient-purple);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 16px;
    text-align: center;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.stat-value .icon {
    font-size: 1.2rem;
}

/* Info Row */
.info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.info-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Spin Button */
.spin-btn {
    width: 100%;
    height: 56px;
    border: none;
    border-radius: 16px;
    background: var(--gradient-purple);
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 2px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(168, 85, 247, 0.4);
}

.spin-btn:active {
    transform: scale(0.98);
}

.spin-btn:disabled {
    background: linear-gradient(135deg, #444 0%, #333 100%);
    box-shadow: none;
    cursor: not-allowed;
}

.spin-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    animation: btn-shine 2s infinite;
}

@keyframes btn-shine {
    0% { left: -100%; }
    50%, 100% { left: 100%; }
}

.spin-btn:disabled::before {
    display: none;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(26, 10, 46, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 0;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    display: flex;
    justify-content: space-around;
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nav-item.active {
    color: var(--accent-light);
}

.nav-item .nav-icon {
    font-size: 1.4rem;
}

/* Popup Styles */
.popup {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.popup.hidden {
    display: none;
}

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

.popup-content {
    background: linear-gradient(180deg, #2d1b4e 0%, #1a0a2e 100%);
    border-radius: 24px;
    padding: 40px 30px;
    text-align: center;
    max-width: 320px;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.popup-emoji {
    font-size: 4rem;
    margin-bottom: 15px;
    animation: bounce 0.6s ease;
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

.popup-content h2 {
    font-size: 1.6rem;
    margin-bottom: 8px;
    background: var(--gradient-purple);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.popup-content p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 25px;
}

.popup-content p strong {
    color: var(--text-primary);
}

.popup-btn {
    background: var(--gradient-purple);
    border: none;
    color: white;
    padding: 14px 50px;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.popup-btn:active {
    transform: scale(0.95);
}

/* Settings Popup */
.settings-content {
    max-height: 80vh;
    overflow-y: auto;
    text-align: left;
}

.settings-content h2 {
    text-align: center;
    margin-bottom: 20px;
}

.segments-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    max-height: 280px;
    overflow-y: auto;
}

.segment-item {
    display: flex;
    gap: 8px;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.segment-item input[type="text"] {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.segment-item input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.segment-item input[type="color"] {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: none;
}

.segment-item .remove-btn {
    width: 44px;
    height: 44px;
    background: rgba(255, 71, 87, 0.2);
    border: 1px solid rgba(255, 71, 87, 0.3);
    border-radius: 8px;
    color: #ff4757;
    font-size: 1.2rem;
    cursor: pointer;
}

.settings-actions {
    display: flex;
    gap: 10px;
}

.add-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    color: var(--text-secondary);
    padding: 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    cursor: pointer;
}

.save-btn {
    flex: 1;
    background: var(--gradient-purple);
    border: none;
    color: white;
    padding: 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

/* Confetti */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    animation: confetti-fall 3s ease-out forwards;
    z-index: 300;
    pointer-events: none;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Responsive */
@media (max-height: 700px) {
    .wheel-wrapper {
        width: 240px;
        height: 240px;
    }
    
    .diamonds-row {
        margin-top: 5px;
    }
    
    .diamond {
        width: 32px;
        height: 32px;
    }
    
    .main-card {
        padding: 20px 16px;
        padding-bottom: calc(70px + env(safe-area-inset-bottom, 20px));
    }
    
    .card-title {
        font-size: 1.2rem;
        margin-bottom: 15px;
    }
    
    .stat-value {
        font-size: 1.6rem;
    }
}

@media (max-height: 600px) {
    .wheel-wrapper {
        width: 200px;
        height: 200px;
    }
    
    .wheel-area {
        padding-top: 10px;
    }
}
