* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-user-select: none; }
html, body { height: 100%; }
body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: radial-gradient(ellipse at top, #6e3a1f 0%, #2a1408 60%, #100600 100%);
    color: #fff;
    overflow: hidden;
    min-height: 100vh;
}
#backBtn {
    position: fixed; top: 16px; left: 16px; z-index: 50;
    color: #fff; text-decoration: none;
    background: rgba(0,0,0,0.45); padding: 8px 14px; border-radius: 8px;
    font-weight: 600; letter-spacing: 1px; font-size: 13px;
    border: 1px solid rgba(255,255,255,0.15);
}
.hidden { display: none !important; }

#hud {
    position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 10px; z-index: 30;
    background: rgba(20,10,5,0.85);
    border: 1px solid rgba(255,170,80,0.25);
    padding: 8px 14px; border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
}
.hud-stat { display: flex; gap: 6px; font-size: 14px; align-items: center; }
.hud-stat .lbl { color: #ffaa66; font-weight: 600; font-size: 11px; letter-spacing: 1px; }
.hud-stat span:not(.lbl) { font-weight: 700; }

#board {
    position: fixed; inset: 70px 240px 16px 16px;
    display: flex; align-items: center; justify-content: center;
}
#stations {
    display: grid; gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    width: 100%; max-width: 800px;
    padding: 16px;
}
.station {
    background: linear-gradient(180deg, #3a2418, #1f1308);
    border: 2px solid #5a3a22;
    border-radius: 14px;
    padding: 14px;
    cursor: pointer;
    position: relative;
    transition: transform .12s, border-color .15s;
    overflow: hidden;
    min-height: 130px;
}
.station:hover { transform: translateY(-2px); border-color: #ffaa66; }
.station.locked {
    background: rgba(0,0,0,0.5);
    border-style: dashed; border-color: rgba(255,255,255,0.15);
    cursor: pointer; opacity: 0.7;
}
.station .head {
    display: flex; gap: 8px; align-items: center;
    margin-bottom: 8px;
}
.station .icon { font-size: 32px; }
.station .name { font-weight: 700; letter-spacing: 1px; flex: 1; }
.station .lvl {
    background: rgba(255,170,80,0.15); color: #ffaa66;
    padding: 2px 8px; border-radius: 6px;
    font-size: 11px; font-weight: 700;
}
.station .info {
    font-size: 11px; color: #ccaa88; line-height: 1.4;
}
.station .progress {
    margin-top: 10px; height: 8px; background: rgba(0,0,0,0.5); border-radius: 4px; overflow: hidden;
    border: 1px solid rgba(255,255,255,0.08);
}
.station .progress .fill {
    height: 100%; background: linear-gradient(90deg, #c97a3d, #ffaa66);
    width: 0%; transition: width .1s linear;
}
.station .actions {
    margin-top: 10px; display: flex; gap: 6px;
}
.station .upBtn {
    flex: 1;
    background: rgba(255,170,80,0.15);
    border: 1px solid rgba(255,170,80,0.3);
    color: #ffaa66;
    padding: 6px 8px; border-radius: 6px;
    font-size: 11px; font-weight: 700; letter-spacing: 1px; cursor: pointer;
    transition: all .15s;
}
.station .upBtn:hover:not(.disabled) { background: rgba(255,170,80,0.3); }
.station .upBtn.disabled { opacity: 0.4; cursor: not-allowed; }
.station.busy::before {
    content: ""; position: absolute; inset: 0;
    background: radial-gradient(circle at 50% 50%, rgba(255,170,80,0.08), transparent 70%);
    pointer-events: none;
    animation: stPulse 1.2s ease-in-out infinite;
}
@keyframes stPulse {
    0%, 100% { opacity: 0.4; }
    50%      { opacity: 1; }
}

#shop {
    position: fixed; right: 16px; top: 70px; bottom: 16px;
    width: 220px;
    background: linear-gradient(180deg, rgba(40,20,10,0.92), rgba(20,10,5,0.92));
    border: 1px solid rgba(255,170,80,0.18);
    border-radius: 14px;
    padding: 14px 12px;
    overflow-y: auto;
    box-shadow: 0 8px 28px rgba(0,0,0,0.5);
    z-index: 20;
}
#shop h2 {
    font-size: 13px; letter-spacing: 2px; text-align: center;
    color: #ffaa66; margin-bottom: 10px;
}
.shop-item {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all .15s;
}
.shop-item:hover:not(.disabled) {
    background: rgba(255,170,80,0.12);
    transform: translateX(-2px);
}
.shop-item.disabled { opacity: 0.45; cursor: not-allowed; }
.shop-item .name { font-weight: 700; font-size: 13px; }
.shop-item .desc { font-size: 11px; color: #ccaa88; margin-top: 2px; }
.shop-item .cost { margin-top: 4px; font-size: 12px; color: #ffd866; font-weight: 700; }
.shop-item .lvl { float: right; font-size: 11px; color: #ffaa66; }

#overlay {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 18px;
    background: radial-gradient(ellipse, rgba(0,0,0,0.6), rgba(0,0,0,0.95));
    backdrop-filter: blur(8px);
}
#overlay.visible { display: flex; }
#overlay:not(.visible) { display: none; }
#overlay h1 {
    font-size: 80px; letter-spacing: 16px; font-weight: 800;
    background: linear-gradient(135deg, #ffaa66, #ffd866 70%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
#overlay .tagline { color: #ffaa66; font-size: 14px; letter-spacing: 4px; }
#overlay .controls { color: #aaa; font-size: 12px; }
#menuButtons { display: flex; gap: 12px; margin-top: 10px; }
#overlay button {
    background: linear-gradient(135deg, #c97a3d, #6e3a1f);
    color: #fff; border: 2px solid #ffaa66;
    padding: 14px 28px; border-radius: 10px;
    font-size: 16px; font-weight: 700; letter-spacing: 2px; cursor: pointer;
    transition: all .15s;
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
#overlay button:hover { transform: translateY(-2px); }
#overlay button.ghost {
    background: transparent; border-color: rgba(255,255,255,0.3); color: #ccc;
}
#hsBox {
    margin-top: 20px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.12);
    padding: 10px 24px; border-radius: 10px;
    text-align: center;
}
.hs-label { color: #ffaa66; font-size: 11px; letter-spacing: 2px; }
#hsValue { font-size: 26px; font-weight: 700; color: #ffd866; }

#floats { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
.float-num {
    position: absolute;
    color: #ffd866;
    font-weight: 800;
    font-size: 16px;
    text-shadow: 0 2px 6px rgba(0,0,0,0.7);
    animation: floatUp 1.0s ease-out forwards;
}
@keyframes floatUp {
    0%   { transform: translate(-50%, 0); opacity: 1; }
    100% { transform: translate(-50%, -50px); opacity: 0; }
}

@media (max-width: 720px) {
    #board { inset: 70px 16px 130px 16px; }
    #shop {
        right: 16px; left: 16px; top: auto; bottom: 16px;
        width: auto; height: 100px;
        display: flex; gap: 8px; overflow-x: auto;
    }
    #shop h2 { display: none; }
    .shop-item { flex: 0 0 auto; min-width: 130px; margin-bottom: 0; }
    #overlay h1 { font-size: 50px; letter-spacing: 8px; }
}

/* ===== Customer queue ===== */
#queue {
    position: fixed; bottom: 16px; left: 16px; right: 250px;
    height: 100px;
    display: flex; gap: 8px; align-items: center; justify-content: flex-start;
    padding: 0 14px;
    z-index: 22;
    overflow: hidden;
    pointer-events: none;
}
#queue.hidden { display: none; }
.customer {
    position: relative;
    width: 70px; min-width: 70px; height: 88px;
    background: linear-gradient(180deg, rgba(255,170,80,0.1), rgba(255,170,80,0.04));
    border: 2px solid rgba(255,170,80,0.3);
    border-radius: 12px;
    cursor: pointer;
    transition: transform .25s, opacity .25s;
    pointer-events: auto;
    text-align: center;
    padding-top: 6px;
}
.customer.entering { animation: custIn .35s ease-out; }
@keyframes custIn { 0% { transform: translateX(60px); opacity: 0; } 100% { transform: translateX(0); opacity: 1; } }
.customer.leaving { transform: translateX(-40px); opacity: 0; }
.customer .face { font-size: 28px; }
.customer .order { font-size: 18px; }
.customer .pat {
    position: absolute; left: 4px; right: 4px; bottom: 4px;
    height: 4px; background: rgba(0,0,0,0.4); border-radius: 2px; overflow: hidden;
}
.customer .pat-fill {
    height: 100%; width: 100%;
    background: linear-gradient(90deg, #44dd66, #ffaa00 50%, #ff4444);
    transition: width .15s linear;
}
.customer.angry { border-color: #ff4444; animation: angryShake .3s; }
@keyframes angryShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}
.customer.happy {
    border-color: #44ff88; box-shadow: 0 0 12px rgba(80,255,140,0.5);
}

/* Rush banner */
#rushBanner {
    position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
    z-index: 35;
    background: linear-gradient(135deg, #ff3333, #ffaa00);
    padding: 10px 20px; border-radius: 12px;
    color: #fff; font-weight: 800; letter-spacing: 2px; font-size: 16px;
    box-shadow: 0 6px 24px rgba(255,80,0,0.6);
    animation: rushPulse 0.6s ease-in-out infinite;
}
#rushBanner.hidden { display: none; }
@keyframes rushPulse {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50%      { transform: translateX(-50%) scale(1.04); }
}

/* Tip jar */
#tipJar {
    position: fixed; right: 250px; top: 16px; z-index: 35;
    background: linear-gradient(180deg, rgba(255,215,100,0.2), rgba(255,170,80,0.1));
    border: 2px solid #ffd866;
    padding: 6px 12px; border-radius: 12px;
    cursor: pointer;
    display: flex; align-items: center; gap: 8px;
    transition: transform .15s, box-shadow .15s;
}
#tipJar.hidden { display: none; }
#tipJar:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(255,215,100,0.5); }
#tipJar .jar-icon { font-size: 20px; }
#tipJar .jar-amt { font-weight: 800; color: #ffd866; font-size: 14px; }
#tipJar.full { animation: jarFull 0.7s ease-in-out infinite; }
@keyframes jarFull {
    0%, 100% { box-shadow: 0 0 0 rgba(255,215,100,0.5); }
    50%      { box-shadow: 0 0 22px rgba(255,215,100,0.9); }
}

/* Adjust shop bottom to make room for queue */
@media (min-width: 721px) {
    #board { bottom: 130px; }
}
