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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 50%, #2c3e50 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 100%;
}

h1 {
    color: #333;
    margin-bottom: 8px;
    font-size: 2.2em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.counter-display {
    margin: 8px 0 10px;
    font-size: 4.5em;
    font-weight: bold;
    color: #e74c3c;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
}

@keyframes counterBump {
    0% { transform: scale(1); }
    40% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.counter-display.bump {
    animation: counterBump 0.3s ease;
}

/* Guard display — stacked vertically, positioned left of Joshua inside the scene */
.guard-display {
    display: none;
    flex-direction: column-reverse;
    align-items: center;
    gap: 0;
    position: absolute;
    bottom: 40%;
    left: -10px;
    z-index: 5;
}

.guard-display.active {
    display: flex;
}

.guard-display.bump {
    animation: counterBump 0.3s ease;
}

.guard-icon-svg {
    width: 32px;
    height: 32px;
    opacity: 0.9;
    margin-bottom: -4px;
}

.guard-display.active .guard-icon-svg {
    opacity: 1;
}

@media (max-width: 600px) {
    .guard-icon-svg {
        width: 24px;
        height: 24px;
        margin-bottom: -3px;
    }
    .guard-display {
        left: -6px;
    }
}

.subtitle {
    color: #666;
    margin-top: 20px;
    font-size: 1.1em;
}

/* Action buttons container */
.action-buttons {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

/* Shared action button styles */
.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    outline: none;
    border-radius: 16px;
    transition: transform 0.1s ease;
}

.action-btn:focus-visible {
    outline: 3px solid #e74c3c;
    outline-offset: 4px;
}

.action-icon {
    width: 150px;
    height: auto;
    display: block;
    margin: 0 auto;
    transition: transform 0.1s ease;
    user-select: none;
    pointer-events: none;
}

.action-btn:hover .action-icon {
    transform: scale(1.1);
}

.action-btn:active .action-icon {
    transform: scale(0.95);
}

/* Ambulance wrapper for cooldown timer positioning */
.ambulance-wrapper {
    position: relative;
    display: inline-block;
}

/* Ambulance cooldown timer */
.ambulance-cooldown {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 1.4em;
    font-weight: bold;
    text-align: center;
    pointer-events: none;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.ambulance-cooldown.active {
    display: block;
}

/* Joshua figure — scene container for guards + Joshua + bus */
.joshua-figure {
    position: relative;
    display: inline-block;
    cursor: pointer;
    padding: 8px;
    border-radius: 16px;
    outline: none;
}

.joshua-figure:focus-visible {
    outline: 3px solid #e74c3c;
    outline-offset: 4px;
}

.joshua-svg {
    width: 180px;
    height: auto;
    display: block;
    margin: 0 auto;
    user-select: none;
    pointer-events: none;
    transition: width 0.3s ease, transform 0.3s ease;
}

/* When guards are present, Joshua is smaller and shifted right */
.joshua-figure.has-guards .joshua-svg {
    width: 120px;
    transform: translateX(20px);
}

/* Throw animation shifts Joshua up and to the right of the guard stack */
@keyframes joshuaThrowGuarded {
    0% { transform: translateX(20px) translateY(0) rotate(0); }
    25% { transform: translateX(40px) translateY(-60px) rotate(-10deg); }
    50% { transform: translateX(50px) translateY(-80px) rotate(5deg); }
    75% { transform: translateX(30px) translateY(-30px) rotate(-3deg); }
    100% { transform: translateX(20px) translateY(0) rotate(0); }
}

.joshua-figure.has-guards.throwing .joshua-svg {
    animation: joshuaThrowGuarded 0.8s ease;
}

/* Bus SVG — positioned over Joshua, hidden by default */
.bus-svg {
    position: absolute;
    width: 200px;
    height: auto;
    top: 40%;
    right: 120%;
    transform: translateY(-50%);
    opacity: 0;
    pointer-events: none;
    z-index: 10;
}

/* Bus drive animation — no guards: drives through */
@keyframes busDrive {
    0% { right: 120%; opacity: 1; }
    40% { right: -10%; opacity: 1; }
    60% { right: -10%; opacity: 1; }
    100% { right: -150%; opacity: 0; }
}

.bus-svg.bus-drive {
    animation: busDrive 1.2s ease-in-out;
}

/* Bus stopped animation — guards present: bus drives in and stops at guard stack */
@keyframes busStopped {
    0% { right: 120%; opacity: 1; }
    40% { right: 55%; opacity: 1; }
    80% { right: 55%; opacity: 1; }
    100% { right: 55%; opacity: 0; }
}

.bus-svg.bus-stopped {
    animation: busStopped 1.4s ease-in-out;
}

/* Throw animation — Joshua flies up then falls back */
@keyframes joshuaThrow {
    0% { transform: translateY(0) rotate(0); }
    25% { transform: translateY(-60px) rotate(-10deg); }
    50% { transform: translateY(-80px) rotate(5deg); }
    75% { transform: translateY(-30px) rotate(-3deg); }
    100% { transform: translateY(0) rotate(0); }
}

.joshua-figure.throwing .joshua-svg {
    animation: joshuaThrow 0.8s ease;
}

/* Guard animation */
@keyframes guardPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); filter: drop-shadow(0 6px 15px rgba(243, 156, 18, 0.6)); }
    100% { transform: scale(1); }
}

.guard-btn.guarding .action-icon {
    animation: guardPulse 0.3s ease;
}

/* Ambulance animation */
@keyframes ambulanceFlash {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); filter: drop-shadow(0 6px 15px rgba(231, 76, 60, 0.6)); }
    100% { transform: scale(1); }
}

.ambulance-btn.rescuing .action-icon {
    animation: ambulanceFlash 0.3s ease;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #333;
    color: #fff;
    padding: 14px 28px;
    border-radius: 10px;
    font-size: 0.95em;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 1000;
    max-width: 90vw;
    text-align: center;
}

.toast.toast-error {
    background: #c62828;
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

/* Footer */
.footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82em;
    color: rgba(0, 0, 0, 0.5);
}

.footer a.version-link {
    color: rgba(0, 0, 0, 0.5);
    text-decoration: none;
}

.footer a.version-link:hover {
    color: #e74c3c;
    text-decoration: underline;
}

/* User count display */
.user-count-display {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: rgba(0, 0, 0, 0.5);
    transition: color 0.2s;
}

.user-count-display:hover {
    color: #e74c3c;
}

.user-icon {
    width: 18px;
    height: 18px;
}

#user-count {
    font-weight: bold;
    font-variant-numeric: tabular-nums;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s;
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.2em;
    color: #333;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.8em;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-body .loading {
    text-align: center;
    color: #999;
}

/* User location list */
.user-location-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-location-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #eee;
}

.location-name {
    font-weight: 500;
    color: #333;
}

.user-count-badge {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
    min-width: 24px;
    text-align: center;
}

.user-total {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #eee;
    text-align: center;
    color: #999;
    font-size: 0.9em;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Responsive design */
@media (max-width: 600px) {
    .container {
        padding: 15px;
    }

    h1 {
        font-size: 1.7em;
    }

    .counter-display {
        font-size: 3.5em;
    }

    .joshua-svg {
        width: 120px;
    }

    .joshua-figure.has-guards .joshua-svg {
        width: 80px;
        transform: translateX(14px);
    }

    .action-icon {
        width: 80px;
    }

    .action-btn {
        padding: 4px;
    }

    .joshua-figure {
        padding: 4px;
    }

    .action-buttons {
        gap: 2px;
    }

    .ambulance-cooldown {
        font-size: 1em;
    }

    .bus-svg {
        width: 140px;
    }
}
