/* ===== ПЕРЕМЕННЫЕ ===== */
:root {
    --bg-wall: #f5ead5;
    --wood: #c49a6c;
    --wood-dark: #a0714f;
    --wood-light: #dbb98b;
    --text: #3d2e1e;
    --gold: #f4b731;
    --gold-dark: #c98d1a;
    --gold-light: #ffe5a0;
    --green: #5a9e5a;
    --red: #d94a4a;
    --card-bg: #fffef9;
    --radius: clamp(8px, 1.5vw, 12px);
    --radius-sm: clamp(6px, 1.2vw, 10px);
    --gap: clamp(3px, 0.8vw, 8px);
}

* { margin:0; padding:0; box-sizing:border-box; }

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #e8dcc8;
    background-image: 
        repeating-linear-gradient(45deg, transparent, transparent 20px, rgba(0,0,0,0.02) 20px, rgba(0,0,0,0.02) 40px),
        repeating-linear-gradient(-45deg, transparent, transparent 20px, rgba(0,0,0,0.02) 20px, rgba(0,0,0,0.02) 40px);
    color: var(--text);
    display: flex;
    justify-content: center;
    align-items: stretch;
    padding: clamp(4px, 1vw, 10px);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

#game-container {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
}

/* ===== СТЕНА МАГАЗИНА ===== */
.store-wall {
    background: var(--bg-wall);
    background-image: linear-gradient(0deg, transparent 95%, rgba(0,0,0,0.03) 95%),
                      linear-gradient(90deg, transparent 95%, rgba(0,0,0,0.03) 95%);
    background-size: clamp(20px, 4vw, 30px) clamp(20px, 4vw, 30px);
    border-radius: var(--radius);
    padding: clamp(6px, 1.5vw, 14px) clamp(6px, 1.5vw, 12px);
    box-shadow: 
        inset 0 0 40px rgba(0,0,0,0.05),
        0 3px 16px rgba(0,0,0,0.1);
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

/* ===== ПОЛКИ ===== */
.shelf-unit {
    position: relative;
    margin-bottom: clamp(4px, 1vw, 10px);
    flex-shrink: 0;
}

.shelf-board {
    background: linear-gradient(180deg, var(--wood-light) 0%, var(--wood) 30%, var(--wood-dark) 100%);
    height: clamp(8px, 1.5vw, 14px);
    border-radius: 3px;
    box-shadow: 
        0 2px 4px rgba(0,0,0,0.2),
        inset 0 1px 1px rgba(255,255,255,0.3);
}

.shelf-board::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30%;
    background: linear-gradient(180deg, transparent, rgba(0,0,0,0.2));
    border-radius: 0 0 3px 3px;
}

.shelf-items {
    display: flex;
    gap: var(--gap);
    padding: clamp(2px, 0.5vw, 4px) clamp(2px, 0.5vw, 4px) clamp(4px, 1vw, 8px);
    min-height: clamp(40px, 10vw, 65px);
    align-items: flex-end;
    flex-wrap: wrap;
}

.shelf-bracket {
    position: absolute;
    bottom: clamp(-6px, -1.2vw, -8px);
    width: clamp(6px, 1.2vw, 10px);
    height: clamp(6px, 1.4vw, 10px);
    background: var(--wood-dark);
    border-radius: 0 0 2px 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.shelf-bracket.left { left: clamp(8px, 2vw, 16px); }
.shelf-bracket.right { right: clamp(8px, 2vw, 16px); }

/* ===== ТОВАР ===== */
.shelf-item {
    width: clamp(42px, 10vw, 65px);
    height: clamp(42px, 10vw, 65px);
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(20px, 5vw, 34px);
    cursor: pointer;
    position: relative;
    transition: transform 0.15s;
    flex-shrink: 0;
}

.shelf-item:active { transform: scale(0.9); }

/* ===== ЦЕННИК НА ТОВАРЕ ===== */
.price-tag {
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border: 1.5px solid var(--gold);
    border-radius: 4px;
    padding: 0px 4px;
    font-size: clamp(9px, 1.8vw, 13px);
    font-weight: 700;
    color: #3d2e1e;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    z-index: 2;
}

/* ===== КАРТОЧКА ЦЕННИКА ===== */
.price-card {
    width: clamp(50px, 11vw, 75px);
    background: #fff;
    border: 2px solid var(--gold);
    border-radius: var(--radius-sm);
    padding: clamp(3px, 0.6vw, 6px);
    text-align: center;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(244,183,49,0.3);
    transition: transform 0.15s;
    font-weight: 700;
    flex-shrink: 0;
}

.price-card .price-num {
    font-size: clamp(18px, 4vw, 26px);
    color: #3d2e1e;
}

.price-card .price-rub {
    font-size: clamp(9px, 1.8vw, 14px);
    color: #888;
}

.price-card.selected {
    transform: scale(1.06);
    box-shadow: 0 0 10px rgba(244,183,49,0.5);
    border-color: var(--gold-dark);
    background: #fffdf5;
}

/* ===== МОНЕТА ===== */
.coin {
    width: clamp(22px, 5vw, 34px);
    height: clamp(22px, 5vw, 34px);
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold) 50%, var(--gold-dark) 100%);
    box-shadow: 0 1px 3px rgba(244,183,49,0.4), inset 0 -1px 1px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(11px, 2.2vw, 17px);
    font-weight: 800;
    color: #fff;
    text-shadow: 0 1px 1px rgba(0,0,0,0.2);
    flex-shrink: 0;
}

/* ===== ЗОНА СКЛАДА / КОРЗИНЫ ===== */
.warehouse-zone {
    background: #e8d5c0;
    border: 1.5px dashed #c49a6c;
    border-radius: var(--radius);
    padding: clamp(4px, 1vw, 8px);
    display: flex;
    gap: var(--gap);
    flex-wrap: wrap;
    min-height: clamp(30px, 8vw, 50px);
    align-items: center;
}

/* ===== КНОПКИ ===== */
.btn {
    padding: clamp(8px, 1.5vw, 14px) clamp(14px, 3vw, 24px);
    border-radius: 24px;
    font-size: clamp(14px, 3vw, 19px);
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: transform 0.15s;
    text-align: center;
    display: inline-block;
    white-space: nowrap;
}

.btn:active { transform: scale(0.93); }

.btn-primary {
    background: var(--gold);
    color: #fff;
    box-shadow: 0 2px 8px rgba(244,183,49,0.4);
}

.btn-green {
    background: var(--green);
    color: #fff;
    box-shadow: 0 2px 8px rgba(90,158,90,0.4);
}

.btn-red {
    background: var(--red);
    color: #fff;
    box-shadow: 0 2px 8px rgba(217,74,74,0.4);
}

/* ===== ТИПОГРАФИКА ===== */
.store-title {
    text-align: center;
    font-size: clamp(18px, 4.5vw, 26px);
    font-weight: 800;
    color: #3d2e1e;
    margin-bottom: 1px;
    flex-shrink: 0;
}

.store-subtitle {
    text-align: center;
    font-size: clamp(11px, 2.5vw, 15px);
    color: #8b7355;
    margin-bottom: clamp(4px, 1vw, 8px);
    flex-shrink: 0;
}

.instruction {
    text-align: center;
    font-size: clamp(13px, 2.8vw, 18px);
    font-weight: 700;
    color: #3d2e1e;
    margin-bottom: clamp(4px, 1vw, 8px);
    background: #fffef9;
    padding: clamp(4px, 0.8vw, 8px) clamp(8px, 1.5vw, 14px);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    width: 100%;
    flex-shrink: 0;
}

.zone-label {
    font-size: clamp(9px, 1.8vw, 13px);
    color: #8b7355;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 1px;
    display: block;
    font-weight: 600;
}

/* ===== ПОДСКАЗКА ===== */
[data-tooltip] { position: relative; }

@media (min-width: 769px) {
    [data-tooltip]:hover::after {
        content: attr(data-tooltip);
        position: absolute;
        bottom: 110%;
        left: 50%;
        transform: translateX(-50%);
        background: #3d2e1e;
        color: #fff;
        padding: 4px 10px;
        border-radius: 8px;
        font-size: clamp(11px, 2vw, 14px);
        white-space: nowrap;
        z-index: 10;
        pointer-events: none;
        box-shadow: 0 3px 8px rgba(0,0,0,0.3);
    }
}

/* ===== POPUP ===== */
#popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* ===== АНИМАЦИИ ===== */
@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 0 0 rgba(90,158,90,0.5); }
    50% { box-shadow: 0 0 12px 4px rgba(90,158,90,0.3); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-3px); }
    40% { transform: translateX(3px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

@keyframes confetti-fall {
    0%   { top:-20px; opacity:1; transform:rotate(0deg) translateX(0); }
    100% { top:110vh; opacity:0; transform:rotate(720deg) translateX(50px); }
}

.success-glow { animation: pulse-green 0.6s ease 3; }
.error-shake { animation: shake 0.5s ease; }
.float { animation: float 2s ease-in-out infinite; }