:root {
    --primary: #4a6fa5;
    --primary-dark: #3a5a8a;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #17a2b8;
    --bg: #f0f2f5;
    --card: #fff;
    --text: #333;
    --border: #ddd;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--primary);
}

h2 {
    margin: 1.5rem 0 0.75rem;
    color: var(--text);
}

h3 {
    margin: 1rem 0 0.5rem;
    font-size: 0.95rem;
    color: #555;
}

/* State Message */
.state-message {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
    font-weight: 500;
}

.phase-setup .state-message, .state-message.setup {
    background: #e9ecef;
    color: #495057;
}

.phase-voting .state-message, .state-message.voting {
    background: #fff3cd;
    color: #856404;
}

.phase-result .state-message, .state-message.result {
    background: #d4edda;
    color: #155724;
}

/* Steps & Phases */
.phase {
    background: var(--card);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.step {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Form Elements */
select, input[type="text"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}

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

button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--primary);
    color: white;
}

button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

button.primary { background: var(--primary); }
button.success { background: var(--success); }
button.warning { background: var(--warning); color: #212529; }
button.danger { background: var(--danger); }
button.back-btn {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
    margin-left: 0.5rem;
}

/* Checkbox Grid */
.preference-section {
    margin: 1.5rem 0;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    border: 2px solid transparent;
}

.checkbox-item:hover {
    background: #e9ecef;
}

.checkbox-item input {
    margin-right: 0.5rem;
    width: 1.2rem;
    height: 1.2rem;
    accent-color: var(--primary);
}

.checkbox-item.selected {
    border-color: var(--primary);
    background: #e8f0fe;
}

/* Validation */
.validation {
    min-height: 1.5rem;
    color: var(--danger);
    font-size: 0.9rem;
    margin: 0.5rem 0;
}

/* Result Card */
.result-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 16px;
    text-align: center;
    margin: 1rem 0;
}

.group-number {
    font-size: 3rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.members-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

.member-tag {
    background: rgba(255,255,255,0.2);
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    font-size: 1.25rem;
    font-weight: 500;
}

/* Admin */
.admin-grid {
    display: grid;
    gap: 1rem;
}

.panel {
    background: var(--card);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.panel.wide {
    grid-column: 1 / -1;
}

.state-badge {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    border-radius: 50px;
    font-weight: bold;
    margin-bottom: 1rem;
}

.state-badge.setup { background: #e9ecef; }
.state-badge.voting { background: #fff3cd; }
.state-badge.result { background: #d4edda; }

.input-row {
    display: flex;
    gap: 0.5rem;
}

.input-row input {
    flex: 1;
    margin-bottom: 0;
}

.input-row button {
    white-space: nowrap;
}

.list {
    max-height: 300px;
    overflow: auto;
    margin: 1rem 0;
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.list-item button {
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
}

.empty {
    color: #6c757d;
    font-style: italic;
    text-align: center;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.size-setting {
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.size-setting input[type="range"] {
    width: 100%;
    margin: 0.5rem 0 0.25rem;
    accent-color: var(--primary);
    cursor: pointer;
}

.size-preview {
    font-size: 0.9rem;
    color: #6c757d;
}

.admin-message .notice {
    color: #856404;
}

.admin-message {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 8px;
    min-height: 3rem;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.stat-box {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

.group-result {
    background: #e8f0fe;
    padding: 0.75rem;
    border-radius: 8px;
    margin: 0.25rem 0;
}

/* Responsive */
@media (min-width: 600px) {
    .admin-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .checkbox-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 400px) {
    .members-list {
        flex-direction: column;
    }
}