:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #ec4899;
    --accent: #8b5cf6;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --card-bg: rgba(255, 255, 255, 0.05);
    --sidebar-bg: rgba(15, 23, 42, 0.95);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --sidebar-width: 360px;
}

.badge-results {
    background: var(--secondary);
    color: white;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 4px;
    display: inline-block;
    min-width: 18px;
    text-align: center;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
}

/* Sidebar Styling */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    box-shadow: var(--glass-shadow);
    z-index: 1000;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.sidebar.hidden {
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Tabs */
.tabs {
    display: flex;
    padding: 12px 24px;
    gap: 8px;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--card-bg);
    color: var(--text-main);
    border-color: var(--border);
}

.tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: none;
}

.tab-content.active {
    display: block;
}

/* Entries Tab */
.entries-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.entry-count {
    font-size: 0.75rem;
    background: var(--primary);
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
}

.textarea-container {
    position: relative;
    margin-bottom: 16px;
}

textarea {
    width: 100%;
    height: 300px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    color: var(--text-main);
    font-size: 0.9375rem;
    resize: none;
    transition: border-color 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.btn {
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-outline {
    background: transparent;
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--card-bg);
}

/* Multi-Wheel Support */
.wheel-manager {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.wheel-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.wheel-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.wheel-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

.btn-delete-wheel {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.6;
}

.btn-delete-wheel:hover {
    background: #ef4444;
    color: white;
    opacity: 1;
}

/* Results Tab */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    padding: 12px;
    background: var(--card-bg);
    border-left: 3px solid var(--secondary);
    border-radius: 0 8px 8px 0;
}

.history-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.history-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Content */
.main-viewport {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-viewport.full {
    margin-left: 0;
}

.content-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    width: 100%;
}

.wheels-grid {
    display: grid;
    gap: 40px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

/* 1 Wheel -> Centered */
.wheels-grid.count-1 {
    grid-template-columns: 1fr;
    max-width: 500px;
}

/* 2 Wheels -> Side by side */
.wheels-grid.count-2 {
    grid-template-columns: 1fr 1fr;
    max-width: 1000px;
}

/* 3 Wheels -> 2 top, 1 below */
.wheels-grid.count-3 {
    grid-template-columns: 1fr 1fr;
    max-width: 1000px;
}

.wheels-grid.count-3 .wheel-card:last-child:nth-child(3) {
    grid-column: 1 / span 2;
    justify-self: center;
    max-width: 450px;
    width: 100%;
}

/* 4 Wheels -> 2x2 grid */
.wheels-grid.count-4 {
    grid-template-columns: 1fr 1fr;
    max-width: 1000px;
}

/* 5+ Wheels -> Responsive grid */
.wheels-grid.count-5plus {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.wheel-card {
    background: var(--card-bg);
    border: none;
    border-radius: 32px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    cursor: pointer;
    width: 100%;
}

.wheel-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
}

.wheel-card.active {
    border-color: var(--primary);
    box-shadow: 0 20px 40px rgba(99, 102, 241, 0.2);
    background: rgba(99, 102, 241, 0.05);
}

.wheel-container-inner {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    margin-bottom: 20px;
}

.wheel-pointer {
    position: absolute;
    top: 5%;
    /* Aligned with wheel edge */
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    width: 0;
    height: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-top: 30px solid var(--secondary);
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

.spin-center-small {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20%;
    max-width: 80px;
    aspect-ratio: 1;
    background: var(--text-main);
    color: #0f172a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: clamp(0.6rem, 2vw, 0.9rem);
    cursor: pointer;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
    z-index: 5;
    transition: transform 0.2s;
}

.spin-center-small:hover {
    transform: translate(-50%, -50%) scale(1.1);
}

.wheel-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    text-align: center;
    letter-spacing: -0.025em;
}

canvas {
    width: 100%;
    height: 100%;
}

.spin-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    background: var(--text-main);
    color: #0f172a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 0 40px rgba(99, 102, 241, 0.5);
    transition: transform 0.2s;
    font-size: 0.9rem;
}

.spin-center:hover {
    transform: translate(-50%, -50%) scale(1.1);
}

/* Status Bar */
.status-bar {
    height: 48px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.badge-new {
    background: #22c55e;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    margin-right: 8px;
}

.toggle-sidebar-btn-inner {
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-sidebar-btn-inner:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

.open-sidebar-btn {
    position: fixed;
    left: 20px;
    top: 20px;
    z-index: 999;
    background: var(--primary);
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.open-sidebar-btn:hover {
    transform: scale(1.05);
    background: var(--primary-hover);
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal {
    background: #1e293b;
    border: 1px solid var(--border);
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    max-width: 500px;
    width: 90%;
}

.winner-name {
    font-size: 3rem;
    font-weight: 800;
    color: var(--secondary);
    margin: 20px 0;
}

/* Advanced Settings Overlay */
.advanced-settings {
    margin-top: 16px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.875rem;
}

/* Toggle Switch */
.switch {
    width: 40px;
    height: 20px;
    background: #334155;
    border-radius: 20px;
    position: relative;
    cursor: pointer;
}

.switch::after {
    content: '';
    position: absolute;
    left: 2px;
    top: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.switch.on {
    background: var(--primary);
}

.switch.on::after {
    transform: translateX(20px);
}