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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    padding: 20px;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
}

.container.wide { max-width: 960px; }

header {
    background:
        linear-gradient(180deg, rgba(28, 18, 42, 0.38) 0%, rgba(28, 18, 42, 0.52) 100%),
        url('/assets/header-banner.jpg') center 42% / cover no-repeat;
    color: white;
    padding: 36px 20px;
    text-align: center;
    text-shadow: 0 1px 10px rgba(0, 0, 0, 0.4);
}

header.left { text-align: left; }

h1 { font-size: 2rem; margin-bottom: 8px; font-weight: 700; }
.sub { opacity: 0.9; font-weight: 500; }

.content { padding: 30px 20px; }

.form-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 24px;
    border-left: 4px solid #667eea;
}

.form-section h2, .form-section h3 {
    color: #333;
    margin-bottom: 16px;
    font-size: 1.25rem;
}

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

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #555;
}

input, select, textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 16px;
    font-family: inherit;
}

textarea { min-height: 80px; resize: vertical; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

input[type="checkbox"] { width: auto; margin-right: 8px; }

.check-row { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 16px; }
.check-row label { font-weight: 500; }

button, .btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

button:hover, .btn:hover { transform: translateY(-1px); }
button.full, .btn.full { width: 100%; }
button.danger, .btn.danger { background: #dc3545; }
button.ok, .btn.ok { background: #28a745; }
button.secondary, .btn.secondary { background: #6c757d; }
button.small, .btn.small { padding: 6px 12px; font-size: 0.85em; }

.notice {
    border-radius: 6px;
    padding: 12px 14px;
    margin-bottom: 16px;
}
.notice.ok { background: #d4edda; color: #155724; }
.notice.err { background: #f8d7da; color: #721c24; }
.notice.info { background: #e3f2fd; color: #1565c0; }
.notice.warn { background: #fff3cd; color: #856404; }

.creds {
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}
.creds code {
    display: block;
    background: #fff;
    padding: 6px 8px;
    margin: 6px 0 12px;
    border-radius: 4px;
    word-break: break-all;
}

table { width: 100%; border-collapse: collapse; font-size: 0.95em; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #eee; vertical-align: top; }
th { color: #666; font-size: 0.85em; }

.participant, .feed-post {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
}

.participant.winner {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    border-color: #ffc107;
}

.participant-header, .feed-post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
}

.participant-name, .feed-post-author { font-weight: 700; }
.participant-score { font-weight: 600; color: #667eea; }
.feed-post-date { color: #999; font-size: 0.9em; }

progress {
    width: 100%;
    height: 20px;
    border-radius: 10px;
    border: none;
    background-color: #e1e5e9;
}
progress::-webkit-progress-bar { background-color: #e1e5e9; border-radius: 10px; }
progress::-webkit-progress-value {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

.activity-row {
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.feed-post-thumbnail {
    width: 100%;
    max-width: 300px;
    height: auto;
    border-radius: 8px;
    cursor: pointer;
}

.lightbox {
    display: none;
    position: fixed;
    z-index: 9999;
    inset: 0;
    background: rgba(0,0,0,0.9);
    cursor: pointer;
}
.lightbox-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90%;
    max-height: 90%;
}
.lightbox-image { max-width: 100%; max-height: 90vh; border-radius: 8px; }
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    font-weight: bold;
}

.nav-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.nav-row a { color: white; opacity: 0.9; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-types { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input { width: auto; min-width: 120px; padding: 6px 10px; }

.muted { color: #666; font-size: 0.9em; }
.danger-box {
    margin-top: 24px;
    padding: 20px;
    background: #f8d7da;
    border: 2px solid #dc3545;
    border-radius: 6px;
}

.group-progress {
    margin: 16px auto 0;
    max-width: 360px;
    height: 8px;
    background: rgba(255,255,255,0.25);
    border-radius: 8px;
    overflow: hidden;
}
.group-progress-bar {
    height: 100%;
    background: #ffd700;
    border-radius: 8px;
    transition: width 0.6s ease;
}

.notice.celebrate {
    background: linear-gradient(135deg, #fff3cd 0%, #ffe082 100%);
    color: #5d4300;
    border: 1px solid #ffc107;
    animation: pop-in 0.45s ease;
}

.stats-card {
    background: linear-gradient(180deg, #f4f1ff 0%, #fff 70%);
    border: 1px solid #ddd6fe;
    border-radius: 12px;
    padding: 22px;
    margin-bottom: 24px;
}
.stats-card h2 { margin-bottom: 14px; font-size: 1.25rem; }
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}
.stat {
    background: white;
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 1px 4px rgba(102, 126, 234, 0.12);
}
.stat-value {
    display: block;
    font-size: 1.6rem;
    font-weight: 800;
    color: #5b4bdb;
    line-height: 1.1;
}
.stat-label { color: #666; font-size: 0.85em; }
.remain { margin-bottom: 12px; }

.milestone-track {
    position: relative;
    height: 10px;
    background: #e8e4f8;
    border-radius: 8px;
    margin: 18px 8px 28px;
}
.milestone-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    transition: width 0.5s ease;
}
.milestone-track .tick {
    position: absolute;
    top: 14px;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: #999;
    white-space: nowrap;
}
.milestone-track .tick.done { color: #5b4bdb; font-weight: 700; }

.badge-row { display: flex; flex-wrap: wrap; gap: 8px; }
.badge {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
}
.badge.on {
    background: #ede9fe;
    color: #4c1d95;
    border-color: #c4b5fd;
}
.badge.off {
    background: #f3f4f6;
    color: #9ca3af;
}

.section-title { text-align: center; margin-bottom: 16px; }
.empty-state {
    text-align: center;
    color: #666;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 18px;
}
.feed-tag {
    color: #667eea;
    font-size: 0.85em;
    font-weight: 600;
    margin-left: 6px;
}

.participant { animation: rise 0.4s ease; }
.participant.me {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.18);
}
.participant.rank-1 { background: linear-gradient(135deg, #fff6c2 0%, #fff 55%); }
.participant.rank-2 { background: linear-gradient(135deg, #eef2f6 0%, #fff 55%); }
.participant.rank-3 { background: linear-gradient(135deg, #f8e8d8 0%, #fff 55%); }
.rank-num { display: inline-block; min-width: 1.6em; color: #667eea; }
.you-pill {
    display: inline-block;
    margin-left: 6px;
    background: #667eea;
    color: white;
    font-size: 0.7rem;
    padding: 1px 7px;
    border-radius: 999px;
    vertical-align: middle;
}

.bar-wrap {
    position: relative;
    height: 14px;
    background: #e1e5e9;
    border-radius: 8px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    transition: width 0.5s ease;
}
.bar-tick {
    position: absolute;
    top: 0;
    width: 1px;
    height: 100%;
    background: rgba(255,255,255,0.7);
}

.streak-today {
    margin-top: 16px;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid #ddd6fe;
    border-radius: 10px;
}
.streak-today.done {
    background: #f5f3ff;
    border-color: #c4b5fd;
}
.streak-today-bars {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 10px 0 8px;
}
.streak-today-bar {
    height: 8px;
    background: #eee9fb;
    border-radius: 8px;
    overflow: hidden;
}
.streak-today-bar div {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
}
.streak-today-bar.minutes div {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
}
.streak-rule { text-align: center; margin: -8px 0 16px; }
.streak-row .flame {
    display: inline-block;
    width: 0.7em;
    height: 0.9em;
    margin-right: 4px;
    vertical-align: -1px;
    background: linear-gradient(180deg, #fbbf24 0%, #ef4444 70%);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.35);
}
.streak-row.status-off .flame { opacity: 0.25; filter: grayscale(1); }
.streak-row.status-at_risk .flame {
    background: linear-gradient(180deg, #fdba74 0%, #f59e0b 70%);
    animation: flicker 1.1s ease-in-out infinite;
}
.streak-state {
    margin-left: 8px;
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 600;
}
.streak-row.status-on .streak-state { color: #b45309; }
.streak-row.status-at_risk .streak-state { color: #c2410c; }
.streak-score strong {
    font-size: 1.15rem;
    color: #c2410c;
}
.streak-score .best { display: block; font-size: 0.75rem; font-weight: 500; }
@keyframes flicker {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.92); }
}

.photo-card { background: #f0f8ff; border-left-color: #4a90e2; }
.join-card { border-left-color: #ffc107; }

.celebrate-canvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10000;
}

@keyframes pop-in {
    from { transform: scale(0.96); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
@keyframes rise {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 640px) {
    body { padding: 10px; }
    .grid-2, .grid-types, .stats-grid { grid-template-columns: 1fr; }
    h1 { font-size: 1.6rem; }
    .activity-row { flex-direction: column; align-items: flex-start; }
}
