:root {
    --bg-color: #0d0221;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent-primary: #f72585;
    --accent-secondary: #7209b7;
    --accent-glow: #4cc9f0;
    --text-color: #e0e1dd;
    --text-muted: #8d99ae;
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.8);
    --font-main: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 20% 30%, rgba(114, 9, 183, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(76, 201, 240, 0.1) 0%, transparent 40%);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    width: 100%;
}

.container {
    width: 100%;
    max-width: 1400px;
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
    padding: 2rem;
    min-height: 100vh;
}

.container.shared-mode {
    grid-template-columns: 1fr;
    max-width: 900px;
}

.shared-title {
    display: none;
    text-align: center;
    margin-bottom: 2rem;
    font-size: 2.5rem;
    font-weight: 900;
    text-transform: uppercase;
    background: linear-gradient(45deg, var(--accent-primary), var(--accent-glow));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(247, 37, 133, 0.3));
}

.container.shared-mode .shared-title {
    display: block;
}

.container.shared-mode .sidebar {
    display: none;
}

.shared-legend {
    display: none;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    padding: 1rem 2rem;
    margin-top: 1rem;
    max-width: 100%;
}

.container.shared-mode .shared-legend {
    display: flex;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
}

@media (max-width: 1000px) {
    .container {
        grid-template-columns: 1fr;
        height: auto;
        overflow-y: auto;
    }
}

.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--card-shadow);
}

/* Wheel Area */
.wheel-area {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    position: relative;
}

.wheel-container {
    position: relative;
    width: 90vmin;
    max-width: 600px;
    aspect-ratio: 1;
    filter: drop-shadow(0 0 30px rgba(0, 0, 0, 0.5));
}

#wheelCanvas {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.wheel-pointer {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 50px;
    background: white;
    clip-path: polygon(50% 100%, 0 0, 100% 0);
    z-index: 10;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
}

.btn-spin {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 100px;
    background: var(--bg-color);
    border: 4px solid var(--glass-border);
    border-radius: 50%;
    color: white;
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    z-index: 15;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 0 30px rgba(0, 0, 0, 1);
}

.btn-spin:hover {
    transform: translate(-50%, -50%) scale(1.1);
    background: var(--accent-primary);
    border-color: white;
    box-shadow: 0 0 40px var(--accent-primary);
}

.btn-spin:active {
    transform: translate(-50%, -50%) scale(0.95);
}

.result-display {
    padding: 1.5rem 3rem;
    text-align: center;
    min-width: 300px;
}

.result-display h2 {
    font-size: 2rem;
    background: linear-gradient(45deg, var(--accent-glow), #ffffff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
}

.panel {
    padding: 2rem;
}

.header {
    margin-bottom: 2rem;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(45deg, var(--accent-primary), var(--accent-glow));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header p {
    color: var(--text-muted);
}

.options-manager h2 {
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.config-item {
    margin-bottom: 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.config-item label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.config-item input[type="range"] {
    width: 100%;
    accent-color: var(--accent-glow);
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.option-item {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    transition: all 0.2s;
    width: 100%;
}

.option-item:hover {
    background: rgba(255, 255, 255, 0.07);
}

.option-color {
    flex-shrink: 0;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.option-item input[type="text"] {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-weight: 600;
    font-family: inherit;
    outline: none;
    min-width: 0;
    /* Critical for flex shrinking */
}

.option-item input[type="number"] {
    width: 50px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: var(--accent-glow);
    text-align: center;
    padding: 4px;
    outline: none;
}

.btn-remove {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
}

.btn-remove:hover {
    color: #ff4d4d;
}

.btn-add {
    width: 100%;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed var(--glass-border);
    border-radius: 12px;
    color: var(--text-color);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-add:hover {
    background: rgba(255, 255, 255, 0.1);
    border-style: solid;
    border-color: var(--accent-glow);
    color: white;
}

/* Saved Wheels List */
.saved-wheels-manager {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.saved-sets-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    max-height: 250px;
    overflow-y: auto;
}

.saved-set-item {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.8rem 1rem;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.saved-set-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--glass-border);
}

.saved-set-item .set-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-color);
}

.saved-set-item .set-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 0.8rem;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    font-weight: 600;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: var(--text-muted);
}

.btn-save-current {
    width: 100%;
    background: var(--glass-bg);
    border: 1px dashed var(--glass-border);
    color: var(--text-color);
    padding: 1rem;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.btn-save-current:hover {
    background: rgba(255, 255, 255, 0.1);
    border-style: solid;
    border-color: var(--accent-glow);
}

.share-container {
    width: 100%;
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sharing-name-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.8rem;
    color: white;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.8rem;
    outline: none;
    transition: all 0.3s;
}

.sharing-name-input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-glow);
    box-shadow: 0 0 15px rgba(247, 37, 133, 0.2);
}

.sharing-name-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.btn-share {
    width: 100%;
    padding: 1.2rem;
    background: linear-gradient(45deg, var(--accent-secondary), var(--accent-primary));
    border: none;
    border-radius: 16px;
    color: white;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(247, 37, 133, 0.3);
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-share:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(247, 37, 133, 0.5);
    filter: brightness(1.1);
}

/* Modal System */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 1rem;
}

.modal {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    text-align: center;
}

.modal h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(45deg, var(--accent-primary), var(--accent-glow));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal input {
    width: 100%;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    margin-bottom: 1.5rem;
    outline: none;
}

.modal input:focus {
    border-color: var(--accent-glow);
}

.modal-btns {
    display: flex;
    gap: 1rem;
}

.modal-btns button {
    flex: 1;
    padding: .8rem;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

/* Nav Panel & Hub Link */
.nav-panel {
    margin-top: auto;
    padding: 0 !important;
    overflow: hidden;
}

.btn-hub-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.25rem;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.03);
    transition: all 0.2s;
    border-top: 1px solid var(--glass-border);
}

.btn-hub-link:hover {
    background: var(--accent-primary);
    color: white;
}

.hub-icon {
    font-size: 1.2rem;
}

.btn-cancel {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
}

.btn-confirm {
    background: var(--accent-primary);
    border: none;
    color: white;
    box-shadow: 0 4px 15px rgba(247, 37, 133, 0.3);
}

.btn-confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(247, 37, 133, 0.5);
}

@media (max-width: 600px) {
    .container {
        padding: 1rem;
        gap: 1rem;
    }

    .panel {
        padding: 1.5rem;
    }

    .wheel-container {
        width: 100%;
        max-width: 350px;
    }

    .header h1 {
        font-size: 2rem;
    }

    .option-item {
        padding: 0.5rem;
    }

    .option-item input[type="text"] {
        font-size: 0.9rem;
    }

    .btn-spin {
        width: 70px;
        height: 70px;
        font-size: 0.9rem;
    }
}

.notification {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 1rem 2rem;
    z-index: 1000;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.notification.show {
    transform: translateX(-50%) translateY(0);
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}