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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 0;
    color: #e2e8f0;
}

.view {
    display: none;
    width: 100%;
    max-width: 640px;
    padding: 3rem 2rem;
    animation: fadeIn 0.4s ease-in-out;
}

.view.active {
    display: block;
}

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

h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #06b6d4 0%, #0ea5e9 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: #f1f5f9;
}

.subtitle {
    font-size: 1.1rem;
    color: #94a3b8;
    text-align: center;
    margin-bottom: 2.5rem;
}

.btn {
    display: inline-block;
    padding: 0.875rem 1.75rem;
    background: linear-gradient(135deg, #06b6d4 0%, #0ea5e9 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 20px rgba(6, 182, 212, 0.3);
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(6, 182, 212, 0.4);
}

.btn-secondary {
    background: rgba(51, 65, 85, 0.8);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.btn-secondary:hover {
    background: rgba(71, 85, 105, 0.8);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
    box-shadow: none;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.3);
    box-shadow: none;
}

.btn-ghost {
    background: none;
    box-shadow: none;
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: #94a3b8;
    padding: 0.4rem 0.875rem;
    font-size: 0.8rem;
}

.btn-ghost:hover {
    background: rgba(148, 163, 184, 0.1);
    box-shadow: none;
    transform: none;
    color: #e2e8f0;
}

.home-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    margin-top: 2rem;
}

.home-actions .btn {
    width: 100%;
    max-width: 300px;
    text-align: center;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #94a3b8;
    margin-bottom: 0.5rem;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: #06b6d4;
}

.form-group select {
    cursor: pointer;
}

.form-group select option {
    background: #1e293b;
    color: #e2e8f0;
}

.card {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.question-card {
    position: relative;
}

.question-card .question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.question-card .question-number {
    font-size: 0.8rem;
    color: #06b6d4;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.choices-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.choice-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.choice-row input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 0.9rem;
}

.choice-row input:focus {
    outline: none;
    border-color: #06b6d4;
}

.remove-choice {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.25rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.remove-choice:hover {
    opacity: 1;
}

.add-choice-btn {
    background: none;
    border: 1px dashed rgba(148, 163, 184, 0.3);
    color: #94a3b8;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    transition: all 0.2s;
}

.add-choice-btn:hover {
    border-color: #06b6d4;
    color: #06b6d4;
}

.hint {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 0.25rem;
    font-style: italic;
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: #fca5a5;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    display: none;
}

.error-message.visible {
    display: block;
}

.success-box {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
}

.success-box h2 {
    color: #4ade80;
    margin-bottom: 1rem;
}

.share-url {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: #06b6d4;
    font-family: monospace;
    font-size: 0.9rem;
    word-break: break-all;
    margin: 1rem 0;
}

.copy-btn {
    margin-top: 0.5rem;
}

.back-link {
    display: inline-block;
    margin-bottom: 1.5rem;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.9rem;
    cursor: pointer;
    transition: color 0.2s;
}

.back-link:hover {
    color: #06b6d4;
}

.join-form {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.join-form .form-group {
    flex: 1;
    margin-bottom: 0;
}

.join-form .btn {
    margin-bottom: 0;
}

/* Toggle switch */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.toggle-row label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #94a3b8;
    cursor: pointer;
    user-select: none;
}

.toggle {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(51, 65, 85, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.3);
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: #94a3b8;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle input:checked + .toggle-slider {
    background-color: rgba(6, 182, 212, 0.3);
    border-color: #06b6d4;
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(18px);
    background-color: #06b6d4;
}

/* Active group banner */
.active-group-banner {
    background: rgba(6, 182, 212, 0.08);
    border: 1px solid rgba(6, 182, 212, 0.25);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.active-group-banner .banner-info {
    flex: 1;
    min-width: 0;
}

.active-group-banner .banner-label {
    font-size: 0.75rem;
    color: #06b6d4;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.2rem;
}

.active-group-banner .banner-name {
    font-size: 1rem;
    font-weight: 600;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.active-group-banner .banner-sub {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 0.15rem;
}

.banner-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* History list */
.history-section {
    margin-top: 2rem;
}

.history-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-item {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.history-item .history-name {
    font-size: 0.9rem;
    color: #cbd5e1;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.history-item .history-date {
    font-size: 0.75rem;
    color: #475569;
}

.history-item .history-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

/* Dashboard */
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.stat-badge {
    background: rgba(6, 182, 212, 0.15);
    border: 1px solid rgba(6, 182, 212, 0.3);
    color: #06b6d4;
    border-radius: 20px;
    padding: 0.35rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
}

.dashboard-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1.5rem;
}

.participants-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.participants-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    color: #64748b;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}

.participants-table td {
    padding: 0.6rem 0.75rem;
    color: #cbd5e1;
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
    vertical-align: top;
}

.participants-table tr:last-child td {
    border-bottom: none;
}

.participants-table tr:hover td {
    background: rgba(148, 163, 184, 0.04);
}

.answer-chip {
    display: inline-block;
    background: rgba(51, 65, 85, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 4px;
    padding: 0.15rem 0.45rem;
    font-size: 0.78rem;
    color: #94a3b8;
    margin-bottom: 0.2rem;
}

.empty-state {
    text-align: center;
    color: #475569;
    padding: 2rem;
    font-size: 0.9rem;
}

.refresh-spin {
    animation: spin 1s linear infinite;
}

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

.created-groups-section {
    margin-top: 1.5rem;
}

.created-groups-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

@media (max-width: 480px) {
    .view { padding: 2rem 1rem; }
    h1 { font-size: 2.25rem; }
    .join-form { flex-direction: column; align-items: stretch; }
    .dashboard-header { flex-direction: column; align-items: flex-start; }
}
