:root {
    --primary-color: #ffb347;
    --primary-light: #ffcc33;
    --primary-dark: #e6a040;
    --secondary-color: #ff9e6d;
    --accent-color: #ff6b8b;
    --light-bg: #fff9e6;
    --light-card: #ffffff;
    --light-text: #4a5568;
    --light-border: #ffe4b3;
    --success-color: #4ade80;
    --warning-color: #f59e0b;
    --error-color: #ff6b8b;
    --shadow: 0 4px 12px rgba(255, 179, 71, 0.15);
    --shadow-hover: 0 8px 25px rgba(255, 179, 71, 0.25);
}

body {
    background-color: var(--light-bg);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(255, 204, 51, 0.1) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(255, 204, 51, 0.1) 0%, transparent 20%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.system-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    margin: 20px auto;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    flex: 1;
    width: 95%;
    max-width: 1200px;
}

.tool-header {
    position: relative;
    text-align: center;
    margin-bottom: 30px;
}

.tool-title {
    color: var(--primary-color);
    font-size: 2.2rem;
    margin-bottom: 10px;
}

.tool-subtitle {
    color: var(--light-text);
    font-size: 1.1rem;
    margin-bottom: 20px;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.control-panel {
    background: linear-gradient(135deg, #fffaf0 0%, #fff5e6 100%);
    padding: 25px;
    border-radius: 15px;
    border: 2px solid var(--light-border);
    box-shadow: var(--shadow);
}

.result-panel {
    background: linear-gradient(135deg, #fffaf0 0%, #fff5e6 100%);
    padding: 25px;
    border-radius: 15px;
    border: 2px solid var(--light-border);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.panel-title {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--light-border);
    font-weight: 600;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--primary-color);
}

select, input, button {
    width: 100%;
    padding: 12px 15px;
    border-radius: 10px;
    border: 2px solid var(--light-border);
    font-size: 1rem;
    background-color: #fff;
}

select:focus, input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.tool-btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}

.tool-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.tool-btn:disabled {
    background: linear-gradient(135deg, #cccccc 0%, #999999 100%);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.tool-btn.secondary {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #ff9e6d 100%);
}

.tool-btn.reset {
    background: linear-gradient(135deg, var(--error-color) 0%, #ff8fa3 100%);
}

.result-display {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    min-height: 300px;
}

.current-result {
    font-size: 3rem;
    font-weight: bold;
    color: var(--primary-color);
    margin: 20px 0;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.result-history {
    margin-top: 30px;
    max-height: 200px;
    overflow-y: auto;
    width: 100%;
}

.history-title {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 10px;
    font-weight: 600;
}

.history-list {
    list-style-type: none;
    background: white;
    border-radius: 10px;
    padding: 15px;
    border: 1px solid var(--light-border);
    max-height: 150px;
    overflow-y: auto;
}

.history-list li {
    padding: 8px 10px;
    border-bottom: 1px solid var(--light-border);
    display: flex;
    justify-content: space-between;
}

.history-list li:last-child {
    border-bottom: none;
}

.student-count {
    background: var(--primary-color);
    color: white;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.9rem;
    margin-top: 10px;
}

.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.random-animation {
    animation: randomBlink 0.5s infinite;
}

@keyframes randomBlink {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}

.stats-panel {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    gap: 10px;
}

.stat-item {
    flex: 1;
    text-align: center;
    background: white;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--light-border);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--light-text);
}

.mode-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.mode-option {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mode-option input {
    width: auto;
}

.student-selector {
    margin-bottom: 20px;
}

.selector-toggle {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #ff9e6d 100%);
    color: white;
    border: none;
    padding: 12px 15px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.selector-toggle:hover {
    background: linear-gradient(135deg, #ff8d5c 0%, #ff8d5c 100%);
}

.selector-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: white;
    border-radius: 0 0 10px 10px;
    margin-top: -5px;
}

.selector-content.expanded {
    max-height: 300px;
    border: 2px solid var(--light-border);
    border-top: none;
}

.selector-controls {
    padding: 15px;
    border-bottom: 1px solid var(--light-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.selector-controls button {
    width: auto;
    padding: 8px 15px;
    font-size: 0.9rem;
    margin: 0;
}

.student-checkboxes {
    padding: 15px;
    max-height: 200px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.student-checkbox {
    display: flex;
    align-items: center;
    gap: 5px;
}

.student-checkbox input {
    width: auto;
}

.student-checkbox label {
    margin: 0;
    font-weight: normal;
    font-size: 0.9rem;
    cursor: pointer;
}

.selected-count {
    font-size: 0.9rem;
    color: var(--primary-color);
    font-weight: 600;
}

.group-result {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--accent-color);
    margin: 20px 0;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.group-number {
    font-size: 4rem;
    font-weight: bold;
    color: var(--accent-color);
    margin: 10px 0;
}

.group-info {
    font-size: 1.2rem;
    color: var(--light-text);
    margin-top: 10px;
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .mode-controls {
        grid-template-columns: 1fr;
    }
    
    .current-result {
        font-size: 2.2rem;
    }
    
    .tool-title {
        font-size: 1.8rem;
    }
    
    .student-checkboxes {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    
    .group-number {
        font-size: 3rem;
    }
}