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

html, body {
    width: 100%; 
    height: 100%; 
    margin: 0; 
    padding: 0; 
    overflow: hidden;
    font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

body { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
}

header {
    background: rgba(255, 182, 193, 0.9);
    color: white; 
    padding: 8px 15px;
    text-align: center; 
    width: 100%; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 100; 
    flex-shrink: 0; 
    box-sizing: border-box;
}

header h1 { 
    margin: 0; 
    font-size: 2em; 
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3); 
    font-weight: 600;
}

#score-board { 
    font-size: 1.3em; 
    margin-top: 8px; 
    font-weight: 600; 
}

#back-button, #enable-motion-button {
    padding: 10px 18px; 
    font-size: 1.1em; 
    margin: 6px; 
    cursor: pointer; 
    background-color: rgba(255, 255, 255, 0.9); 
    color: #333;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 12px; 
    font-family: inherit;
    font-weight: 500;
    transition: all 0.3s ease;
}

#back-button:hover, #enable-motion-button:hover { 
    background-color: white; 
    transform: translateY(-2px);
}

#enable-motion-button:disabled { 
    background-color: #ccc; 
    color: #666; 
    cursor: not-allowed; 
}

main { 
    flex-grow: 1; 
    width: 100%; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    position: relative; 
}

#play-area {
    width: 95%;
    height: 95%;
    background-image: url('assets/coffee-shop-background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 3px solid rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    position: relative; 
    overflow: hidden; 
    box-sizing: border-box;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

#order-items {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 8px 0;
    flex-wrap: wrap;
}

.order-item {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 2px solid #ff6b6b;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3px;
}

.order-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#order-count {
    font-size: 1.1em;
    font-weight: 600;
    color: #333;
    margin-top: 6px;
}

#items-needed {
    color: #ff6b6b;
    font-size: 1.3em;
    font-weight: 700;
}

.character {
    position: absolute;
    width: clamp(120px, 18vw, 180px);
    height: auto;
    z-index: 15;
    will-change: transform, left, top;
    transition: opacity 0.1s ease-in-out;
    filter: drop-shadow(4px 4px 8px rgba(0,0,0,0.4));
    --character-scaleX: 1;
    transform: scaleX(var(--character-scaleX));
    object-fit: cover;
    object-position: center;
    clip-path: inset(0 30% 0 30%);
    animation: subtleJiggle 2s ease-in-out infinite;
}

@keyframes subtleJiggle {
    0%, 100% {
        transform: scaleX(var(--character-scaleX)) translateY(0px) rotate(0deg);
    }
    25% {
        transform: scaleX(var(--character-scaleX)) translateY(-1px) rotate(0.5deg);
    }
    50% {
        transform: scaleX(var(--character-scaleX)) translateY(0px) rotate(0deg);
    }
    75% {
        transform: scaleX(var(--character-scaleX)) translateY(-1px) rotate(-0.5deg);
    }
}

.station {
    position: absolute;
    background: rgba(78, 205, 196, 0.95);
    border: 4px solid #4ecdc4;
    border-radius: 20px;
    padding: 20px;
    text-align: center;
    width: 200px;
    z-index: 5;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

#coffee-station {
    left: 30px;
    top: 10px;
}

#cupcake-station {
    left: 30px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 107, 107, 0.95);
    border-color: #ff6b6b;
}

#donut-station {
    left: 30px;
    bottom: 10px;
    background: rgba(255, 193, 7, 0.95);
    border-color: #ffc107;
}


.station-items {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    padding: 10px;
}

.station-item {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    border: 4px solid white;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px;
    object-fit: contain;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: transform 0.2s ease;
}

.station-item:hover {
    transform: scale(1.05);
}

.floating-inventory {
    position: absolute;
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid #9b59b6;
    border-radius: 15px;
    padding: 12px;
    min-width: 180px;
    z-index: 20;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transform-origin: center bottom;
    transition: all 0.1s ease-out;
    pointer-events: none;
}

.inventory-title {
    text-align: center;
    font-size: 1.1em;
    font-weight: 700;
    color: #9b59b6;
    margin-bottom: 8px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.inventory-items {
    display: flex;
    justify-content: space-around;
    gap: 8px;
}

.inventory-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    opacity: 0.5;
    transition: all 0.3s ease;
}

.inventory-item.has-items {
    opacity: 1;
    transform: scale(1.1);
}

.inventory-item img {
    width: 35px;
    height: 35px;
    object-fit: contain;
    border-radius: 8px;
    border: 2px solid #ddd;
    background: white;
    padding: 2px;
}

.inventory-item.has-items img {
    border-color: #9b59b6;
    box-shadow: 0 2px 6px rgba(155, 89, 182, 0.3);
}

.inventory-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    font-weight: 800;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transform: scale(0);
    transition: transform 0.3s ease;
}

.inventory-item.has-items .inventory-count {
    transform: scale(1);
}

.progress-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 10;
}

.station.active .progress-container {
    opacity: 1;
    visibility: visible;
}

.progress-circle {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-svg {
    position: absolute;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.progress-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.3);
    stroke-width: 6;
    stroke-linecap: round;
}

.progress-bar {
    fill: none;
    stroke: #e74c3c;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 314.16; /* 2π × 50 (radius) */
    stroke-dashoffset: 314.16;
    transition: stroke-dashoffset 0.1s ease;
}

.station.active .progress-bar {
    animation: progressFill 2s linear forwards;
}

@keyframes progressFill {
    from {
        stroke-dashoffset: 314.16;
        stroke: #e74c3c;
    }
    50% {
        stroke: #f39c12;
    }
    to {
        stroke-dashoffset: 0;
        stroke: #27ae60;
    }
}

.progress-text {
    position: absolute;
    font-size: 1.4em;
    font-weight: 800;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    text-align: center;
    pointer-events: none;
    animation: textPulse 2s ease-in-out infinite;
    letter-spacing: 0.5px;
}

@keyframes textPulse {
    0%, 100% { 
        transform: scale(1); 
        opacity: 0.8; 
    }
    50% { 
        transform: scale(1.1); 
        opacity: 1; 
    }
}

.station.active .progress-text {
    animation: textPulse 0.8s ease-in-out infinite;
}

.station.completing .progress-circle {
    animation: completionBurst 0.5s ease-out forwards;
}

.station.active.completing .progress-bar {
    animation: progressFill 2s linear forwards, completionPulse 0.5s ease-out;
}

@keyframes completionPulse {
    0% { stroke-width: 8; }
    50% { stroke-width: 12; filter: brightness(1.3); }
    100% { stroke-width: 8; }
}

@keyframes completionBurst {
    0% { 
        transform: scale(1) rotate(0deg); 
    }
    50% { 
        transform: scale(1.3) rotate(180deg); 
        filter: brightness(1.5);
    }
    100% { 
        transform: scale(1) rotate(360deg); 
        opacity: 0;
    }
}

#customer-area {
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 107, 107, 0.95);
    border: 4px solid #ff6b6b;
    border-radius: 20px;
    padding: 25px;
    text-align: center;
    width: 220px;
    z-index: 5;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

#current-customer {
    width: 120px;
    height: auto;
    margin-bottom: 15px;
    filter: drop-shadow(3px 3px 6px rgba(0,0,0,0.4));
}

#delivery-zone {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    text-align: center;
}

.delivery-title {
    font-weight: 700;
    color: #ff6b6b;
    font-size: 1.3em;
    margin-bottom: 8px;
}

#customer-speech {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 10px;
    font-size: 1.1em;
    color: #333;
    font-style: italic;
    font-weight: 500;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

#celebration-container { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    pointer-events: none; 
    overflow: hidden; 
    z-index: 20; 
}

.firework-particle {
    position: absolute; 
    will-change: transform, opacity;
    width: 8px; 
    height: 8px; 
    border-radius: 50%; 
    animation: explodeAnim 1s ease-out forwards;
}

@keyframes explodeAnim { 
    0% { 
        transform: translate(var(--particle-start-x, -50%), var(--particle-start-y, -50%)) scale(1) rotate(0deg); 
        opacity: 1; 
    } 
    100% { 
        transform: translate(var(--particle-end-x), var(--particle-end-y)) scale(0.3) rotate(var(--particle-end-rotate, 0deg)); 
        opacity: 0; 
    } 
}

footer {
    background: rgba(255, 182, 193, 0.9); 
    color: white; 
    text-align: center;
    padding: 12px 0; 
    width: 100%; 
    font-size: 1em; 
    font-weight: 500;
    flex-shrink: 0;
    box-sizing: border-box; 
    z-index: 100;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.2);
}

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

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 30px;
    border-radius: 15px;
    width: 80%;
    max-width: 500px;
    text-align: center;
    position: relative;
}

.modal-content h2 {
    color: #ff6b6b;
    margin-bottom: 25px;
    font-size: 2.4rem;
    font-weight: 700;
}

.modal-content p {
    margin: 15px 0;
    font-size: 1.3rem;
    color: #333;
    font-weight: 500;
}

.close {
    position: absolute;
    right: 15px;
    top: 15px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #ff6b6b;
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    
    header {
        padding: 6px 10px;
    }
    
    header h1 {
        font-size: 1.4em;
    }
    
    #score-board {
        font-size: 1em;
        margin-top: 4px;
    }
    
    #back-button, #enable-motion-button {
        padding: 8px 12px;
        font-size: 0.9em;
        margin: 3px;
    }
    
    #play-area {
        width: 98%;
        height: 92%;
    }
    
    .order-item {
        width: 35px;
        height: 35px;
        border-width: 2px;
    }
    
    #order-count {
        font-size: 1em;
    }
    
    #items-needed {
        font-size: 1.2em;
    }
    
    .delivery-title {
        font-size: 1.1em;
        margin-bottom: 6px;
    }
    
    .station {
        width: 100px;
        padding: 8px;
        top: 8px;
    }
    
    #coffee-station {
        left: 10px;
        top: 10px;
    }
    
    #cupcake-station {
        left: 50%;
        top: 10px;
        transform: translateX(-50%);
    }
    
    #donut-station {
        right: 10px;
        left: auto;
        top: 10px;
        bottom: auto;
    }
    
    .station-item {
        width: 50px;
        height: 50px;
        border-width: 3px;
        padding: 6px;
    }
    
    .progress-circle {
        width: 60px;
        height: 60px;
    }
    
    .progress-text {
        font-size: 0.8em;
    }
    
    #customer-area {
        position: absolute;
        right: 10px;
        bottom: 10px;
        top: auto;
        transform: none;
        width: 130px;
        padding: 8px;
    }
    
    #current-customer {
        width: 60px;
        margin-bottom: 8px;
    }
    
    #delivery-zone {
        padding: 6px;
        margin-bottom: 6px;
    }
    
    #customer-speech {
        font-size: 0.8em;
        padding: 6px;
    }
    
    .delivery-title {
        font-size: 0.9em;
        margin-bottom: 4px;
    }
    
    .character {
        width: clamp(80px, 20vw, 120px);
    }
    
    .floating-inventory {
        min-width: 150px;
        padding: 8px;
    }
    
    .inventory-item img {
        width: 28px;
        height: 28px;
    }
    
    .inventory-count {
        width: 18px;
        height: 18px;
        font-size: 0.8em;
        top: -6px;
        right: -6px;
    }
    
    footer {
        padding: 8px 0;
        font-size: 0.85em;
    }
    
    .modal-content {
        width: 90%;
        margin: 10% auto;
        padding: 20px;
    }
    
    .modal-content h2 {
        font-size: 1.8rem;
        margin-bottom: 15px;
    }
    
    .modal-content p {
        font-size: 1.1rem;
        margin: 10px 0;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 12px;
    }
    
    header {
        padding: 4px 8px;
    }
    
    header h1 {
        font-size: 1.2em;
    }
    
    #score-board {
        font-size: 0.9em;
    }
    
    #back-button, #enable-motion-button {
        padding: 6px 10px;
        font-size: 0.8em;
        margin: 2px;
    }
    
    #play-area {
        width: 99%;
        height: 90%;
        border-width: 2px;
    }
    
    .order-item {
        width: 30px;
        height: 30px;
        border-width: 1px;
    }
    
    #order-count {
        font-size: 0.9em;
    }
    
    #items-needed {
        font-size: 1.1em;
    }
    
    .delivery-title {
        font-size: 1em;
        margin-bottom: 4px;
    }
    
    .station {
        width: 85px;
        padding: 6px;
        border-width: 2px;
        top: 5px;
    }
    
    #coffee-station {
        left: 8px;
        top: 8px;
    }
    
    #cupcake-station {
        left: 50%;
        top: 8px;
        transform: translateX(-50%);
    }
    
    #donut-station {
        right: 8px;
        left: auto;
        top: 8px;
        bottom: auto;
    }
    
    .station-item {
        width: 40px;
        height: 40px;
        border-width: 2px;
        padding: 4px;
    }
    
    .progress-circle {
        width: 50px;
        height: 50px;
    }
    
    .progress-text {
        font-size: 0.7em;
    }
    
    #customer-area {
        position: absolute;
        right: 8px;
        bottom: 8px;
        top: auto;
        transform: none;
        width: 100px;
        padding: 6px;
        border-width: 2px;
    }
    
    #current-customer {
        width: 45px;
        margin-bottom: 6px;
    }
    
    #delivery-zone {
        padding: 4px;
        margin-bottom: 4px;
    }
    
    #customer-speech {
        font-size: 0.7em;
        padding: 4px;
    }
    
    .delivery-title {
        font-size: 0.8em;
        margin-bottom: 3px;
    }
    
    .character {
        width: clamp(60px, 18vw, 100px);
    }
    
    .floating-inventory {
        min-width: 120px;
        padding: 6px;
        border-width: 2px;
    }
    
    .inventory-title {
        font-size: 0.9em;
        margin-bottom: 6px;
    }
    
    .inventory-item img {
        width: 25px;
        height: 25px;
        border-width: 1px;
    }
    
    .inventory-count {
        width: 16px;
        height: 16px;
        font-size: 0.7em;
        top: -5px;
        right: -5px;
    }
    
    footer {
        padding: 6px 0;
        font-size: 0.75em;
    }
    
    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 15px;
    }
    
    .modal-content h2 {
        font-size: 1.5rem;
        margin-bottom: 12px;
    }
    
    .modal-content p {
        font-size: 1rem;
        margin: 8px 0;
    }
    
    .close {
        font-size: 24px;
        right: 10px;
        top: 10px;
    }
}

@media (max-width: 320px) {
    header h1 {
        font-size: 1em;
    }
    
    #score-board {
        font-size: 0.8em;
    }
    
    .order-item {
        width: 25px;
        height: 25px;
        border-width: 1px;
    }
    
    .delivery-title {
        font-size: 0.9em;
    }
    
    .station {
        width: 75px;
        padding: 4px;
        border-width: 2px;
        top: 3px;
    }
    
    #coffee-station {
        left: 3px;
    }
    
    #cupcake-station {
        left: 50%;
        transform: translateX(-50%);
    }
    
    #donut-station {
        right: 3px;
        left: auto;
    }
    
    .station-item {
        width: 35px;
        height: 35px;
        border-width: 2px;
        padding: 3px;
    }
    
    .progress-circle {
        width: 40px;
        height: 40px;
    }
    
    .progress-text {
        font-size: 0.6em;
    }
    
    #customer-area {
        right: 3px;
        bottom: 3px;
        top: auto;
        width: 85px;
        padding: 4px;
        border-width: 2px;
    }
    
    #current-customer {
        width: 35px;
        margin-bottom: 4px;
    }
    
    #delivery-zone {
        padding: 3px;
        margin-bottom: 3px;
    }
    
    #customer-speech {
        font-size: 0.6em;
        padding: 3px;
    }
    
    .delivery-title {
        font-size: 0.7em;
        margin-bottom: 2px;
    }
    
    .character {
        width: clamp(50px, 16vw, 80px);
    }
    
    .floating-inventory {
        min-width: 100px;
        padding: 4px;
    }
    
    .inventory-item img {
        width: 20px;
        height: 20px;
    }
    
    .inventory-count {
        width: 14px;
        height: 14px;
        font-size: 0.6em;
    }
}