:root {
    --red: #c41e3a;
    --red-dark: #99132b;
    --green: #165b33;
    --green-dark: #0f4225;
    --gold: #f4b942;
    --gold-soft: #fff6db;
    --cream: #fffdf7;
    --surface: #ffffff;
    --text: #1f2937;
    --muted: #5b6472;
    --border: #e5dfd3;
    --radius: 16px;
    --shadow: 0 10px 28px rgba(22, 91, 51, 0.12);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(196, 30, 58, 0.10), transparent 40%),
        radial-gradient(circle at top right, rgba(22, 91, 51, 0.12), transparent 42%),
        var(--cream);
    line-height: 1.5;
    min-height: 100vh;
}

.confetti-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

.candy-bar {
    height: 10px;
    background: repeating-linear-gradient(
        -45deg,
        var(--red),
        var(--red) 14px,
        #ffffff 14px,
        #ffffff 28px,
        var(--green) 28px,
        var(--green) 42px,
        #ffffff 42px,
        #ffffff 56px
    );
}

.garland {
    display: flex;
    justify-content: center;
    gap: 18px;
    padding: 10px 16px 0;
}

.bulb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    animation: twinkle 2.2s infinite ease-in-out;
}

.bulb-red {
    background: var(--red);
    box-shadow: 0 0 10px rgba(196, 30, 58, 0.7);
}

.bulb-gold {
    background: var(--gold);
    box-shadow: 0 0 10px rgba(244, 185, 66, 0.8);
    animation-delay: 0.7s;
}

.bulb-green {
    background: #239b56;
    box-shadow: 0 0 10px rgba(35, 155, 86, 0.7);
    animation-delay: 1.4s;
}

@keyframes twinkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.45; transform: scale(0.85); }
}

.container {
    max-width: 640px;
    margin: 0 auto;
    padding: 16px 16px 40px;
}

.site-header {
    text-align: center;
    margin: 8px 0 20px;
}

.eyebrow {
    display: inline-block;
    margin: 0 0 6px;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--red);
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.site-header h1 {
    margin: 0;
    font-size: clamp(1.75rem, 5vw, 2.25rem);
    color: var(--green-dark);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.card h2,
.card h3 {
    margin-top: 0;
    color: var(--green-dark);
}

.card-gold {
    background: linear-gradient(135deg, #fffdf4, var(--gold-soft));
    border-color: #eed28b;
}

.card-celebrate {
    border-top: 5px solid var(--gold);
}

.card-danger {
    border-color: #f3c4cc;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 0.85rem;
}

.countdown-card {
    text-align: center;
}

.countdown-label {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--red-dark);
}

.countdown-date {
    margin: 4px 0 12px;
    font-weight: 600;
    color: var(--green-dark);
}

.countdown-unlocked {
    margin: 8px 0 0;
    font-weight: 700;
    color: var(--green-dark);
}

.countdown-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.countdown-unit {
    background: var(--surface);
    border: 1px solid #ead8a6;
    border-radius: 12px;
    padding: 8px 4px;
}

.countdown-value {
    display: block;
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--red);
    font-variant-numeric: tabular-nums;
}

.countdown-caption {
    display: block;
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
}

.flash {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-weight: 600;
}

.flash-success {
    background: #e6f5ec;
    border: 1px solid #9fd4b4;
    color: var(--green-dark);
}

.flash-error {
    background: #fdebec;
    border: 1px solid #efb3bc;
    color: var(--red-dark);
}

.saved-badge {
    background: #eef8f1;
    border-left: 4px solid var(--green);
    padding: 10px 12px;
    border-radius: 8px;
    font-weight: 600;
    color: var(--green-dark);
}

.ranking-list {
    list-style: none;
    padding: 0;
    margin: 16px 0 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rank-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #fdfcf9;
    border: 2px solid var(--border);
    border-radius: 14px;
    cursor: grab;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.rank-item.is-dragging {
    opacity: 0.6;
    border-color: var(--gold);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.drag-handle {
    color: #9ca3af;
    font-weight: 700;
    letter-spacing: -1px;
    user-select: none;
}

.rank-badge {
    min-width: 44px;
    text-align: center;
    padding: 6px 8px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 0.85rem;
    background: #eef2f6;
    color: var(--text);
}

.rank-badge.rank-1 {
    background: var(--gold);
    color: #3f2b00;
}

.rank-badge.rank-2 {
    background: #e2e8f0;
    color: #1e293b;
}

.rank-badge.rank-3 {
    background: #f2d0b6;
    color: #5c2b0a;
}

.rank-info {
    flex: 1;
    min-width: 0;
}

.rank-title {
    display: block;
    font-weight: 700;
    font-size: 1rem;
}

.rank-season {
    display: block;
    font-size: 0.82rem;
    color: var(--muted);
}

.rank-controls {
    display: flex;
    gap: 6px;
}

.btn-move {
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--green-dark);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
}

.btn-move:hover:not(:disabled) {
    background: #eef8f1;
    border-color: var(--green);
}

.btn-move:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 12px;
    padding: 12px 18px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--red);
    color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--red-dark);
}

.btn-secondary {
    background: var(--green);
    color: #ffffff;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--green-dark);
}

.btn-danger {
    background: #b91c1c;
    color: #ffffff;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 0.88rem;
}

.btn-lg {
    padding: 14px 20px;
    font-size: 1.05rem;
}

.btn-block {
    width: 100%;
}

.progress-list,
.admin-list,
.timeline-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.progress-row,
.admin-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #faf9f5;
    border: 1px solid var(--border);
}

.admin-person {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.admin-url-box {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.url-input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
    background: #faf9f5;
}

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.card-header-row h3 {
    margin: 0;
}

.pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
}

.pill-done {
    background: #dcfce7;
    color: var(--green-dark);
}

.pill-wait {
    background: #fef3c7;
    color: #92400e;
}

.pill-choice {
    background: #fdebec;
    color: var(--red-dark);
}

.timeline-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #fdfcf9;
}

.timeline-mine {
    background: linear-gradient(135deg, #fffdf3, #fff4d1);
    border: 2px solid var(--gold);
}

.timeline-window {
    display: flex;
    align-items: center;
    gap: 12px;
}

.timeline-icon,
.break-icon {
    font-size: 1.5rem;
}

.timeline-person {
    font-size: 0.95rem;
    color: var(--green-dark);
}

.timeline-badges {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.timeline-break {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px dashed #cbd5e1;
    background: #f8fafc;
    color: var(--muted);
}

.timeline-break p {
    margin: 2px 0 0;
    font-size: 0.85rem;
}

.confirm-dialog {
    border: none;
    border-radius: var(--radius);
    padding: 22px;
    max-width: 420px;
    width: calc(100% - 32px);
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
}

.confirm-dialog::backdrop {
    background: rgba(15, 23, 42, 0.55);
}

.info-dialog {
    max-width: 480px;
    text-align: left;
}

.info-dialog h3 {
    margin-top: 0;
    color: var(--green-dark);
}

.info-steps {
    margin: 12px 0;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.site-footer {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 20px;
}

.footer-link-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--green-dark);
    text-decoration: underline;
    cursor: pointer;
}

.footer-link-btn:hover {
    color: var(--red);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 480px) {
    .timeline-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .timeline-badges {
        flex-direction: row;
        align-items: center;
    }

    .admin-url-box {
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bulb,
    .rank-item,
    .btn {
        animation: none;
        transition: none;
    }
}
