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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.container {
    max-width: 600px;
    width: 100%;
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 20px;
    font-size: 2em;
}

p {
    text-align: center;
    color: #666;
    margin-bottom: 15px;
}

/* Screen Management */
.screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.screen.hidden {
    display: none;
}

/* Wheel Screen Layout */
#wheelScreen {
    width: 100%;
    max-width: 1400px;
    align-items: center;
    padding: 20px;
    gap: 20px;
    position: relative;
    min-height: 100vh;
}

#wheelScreen .main-content {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

#wheelScreen .container {
    margin: 0;
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 100%;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: white;
    border-radius: 20px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    align-self: stretch;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(-320px);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.sidebar-header h2 {
    font-size: 1.4em;
    color: #333;
    margin: 0;
}

.sidebar-footer {
    border-top: 2px solid #f0f0f0;
    padding-top: 20px;
    margin-top: 10px;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    color: #667eea;
    transition: all 0.3s;
    border-radius: 5px;
}

.btn-icon:hover {
    background: #f0f0f0;
}

.wheels-list {
    flex: 1;
    overflow-y: auto;
    margin: 20px 0;
    padding-right: 8px;
}

.wheels-list::-webkit-scrollbar {
    width: 8px;
}

.wheels-list::-webkit-scrollbar-track {
    background: #f8f8f8;
    border-radius: 4px;
}

.wheels-list::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.wheels-list::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.wheel-item {
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
    background: #f8f9fa;
}

.wheel-item:hover {
    background: #e9ecef;
    transform: translateX(3px);
}

.wheel-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.wheel-item-name {
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 1em;
    word-wrap: break-word;
}

.wheel-item-count {
    font-size: 0.88em;
    opacity: 0.75;
}

.btn-block {
    width: 100%;
    margin-bottom: 10px;
    justify-content: center;
    text-align: center;
}

/* Sidebar Toggle Button (inside sidebar header - close button) */
.sidebar-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.sidebar-toggle-btn:hover {
    background: #f0f0f0;
}

.sidebar-toggle-btn svg {
    width: 24px;
    height: 24px;
    color: #667eea;
    transition: all 0.3s ease;
}

.sidebar-toggle-btn:hover svg {
    color: #764ba2;
}

/* Hide close icon by default, show open icon */
.sidebar-toggle-btn .icon-close {
    display: none;
}

.sidebar-toggle-btn .icon-open {
    display: block;
}

/* On desktop: hide both icons (button not visible) */
@media (min-width: 901px) {
    .sidebar-toggle-btn {
        display: none;
    }
}

/* On mobile when sidebar is closed: show open icon */
@media (max-width: 900px) {
    .sidebar-toggle-btn .icon-open {
        display: block;
    }

    .sidebar-toggle-btn .icon-close {
        display: none;
    }

    /* When sidebar is active: show close icon, hide open icon */
    .sidebar.active .sidebar-toggle-btn .icon-open {
        display: none;
    }

    .sidebar.active .sidebar-toggle-btn .icon-close {
        display: block;
    }
}

/* Mobile Toggle Button (floating button that appears when sidebar is closed) */
.mobile-toggle-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 998;
    background: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.mobile-toggle-btn:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    transform: scale(1.05);
}

.mobile-toggle-btn svg {
    width: 24px;
    height: 24px;
    color: #667eea;
}

/* Show mobile toggle button only on mobile when sidebar is closed */
@media (max-width: 900px) {
    .mobile-toggle-btn {
        display: flex;
    }

    .sidebar.active ~ .mobile-toggle-btn {
        display: none;
    }
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Input */
.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    font-size: 16px;
}

input[type="text"] {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.3s;
}

input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 20px;
    transition: border-color 0.3s;
}

textarea:focus {
    outline: none;
    border-color: #667eea;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-danger {
    background: #ff4757;
    color: white;
}

.btn-danger:hover {
    background: #ee5a6f;
}

.btn-large {
    font-size: 24px;
    padding: 20px 50px;
    margin: 20px 0;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Wheel Container */
.wheel-container {
    position: relative;
    width: 500px;
    height: 500px;
    margin: 30px auto;
    max-width: 100%;
}

#wheelCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.wheel-pointer {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 40px;
    color: #ff4757;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    z-index: 10;
}

/* Result Display */
.result {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    margin: 30px 0;
    animation: slideIn 0.5s ease-out;
}

.result.hidden {
    display: none;
}

.result h2 {
    color: white;
    margin-bottom: 15px;
    font-size: 1.5em;
}

.result p {
    color: white;
    font-size: 1.8em;
    font-weight: bold;
    margin: 0;
}

/* Items List */
.items-list {
    margin-top: 20px;
    border-top: 2px solid #eee;
    padding-top: 20px;
}

.items-list summary {
    cursor: pointer;
    font-weight: 600;
    color: #667eea;
    padding: 10px;
    user-select: none;
}

.items-list summary:hover {
    background: #f5f5f5;
    border-radius: 5px;
}

#itemsList {
    list-style: none;
    padding: 15px 0 0 0;
}

#itemsList li {
    padding: 10px;
    border-bottom: 1px solid #eee;
    color: #555;
}

#itemsList li:last-child {
    border-bottom: none;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #333;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Responsive */
@media (max-width: 900px) {
    #wheelScreen {
        padding: 0;
        min-height: 100vh;
        align-items: stretch;
    }

    #wheelScreen .main-content {
        width: 100%;
        padding: 20px;
    }

    #wheelScreen .container {
        box-shadow: none;
        border-radius: 0;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 1000;
        width: 100%;
        max-width: 320px;
        transform: translateX(-100%);
        border-radius: 0 20px 20px 0;
        height: 100vh;
        align-self: auto;
    }

    .sidebar.active {
        transform: translateX(0);
    }
}

@media (max-width: 600px) {
    .container {
        padding: 15px;
    }

    h1 {
        font-size: 1.5em;
    }

    .wheel-container {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
        max-width: 350px;
    }

    .btn-large {
        font-size: 18px;
        padding: 15px 30px;
    }

    .result p {
        font-size: 1.2em;
    }

    .left-panel,
    .right-panel {
        padding: 20px;
    }

    .btn-block {
        font-size: 14px;
        padding: 10px;
    }

    .panel-header h2 {
        font-size: 1.5em;
    }
}
