:root {
    --bg-color: #0d0d1a;
    --panel-color: #1a1a2e;
    --accent-color: #00e676;
    --text-primary: #ffffff;
    --text-secondary: #8888aa;
    --font-main: 'Inter', sans-serif;
    --font-logo: 'Orbitron', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    touch-action: none;
    -webkit-tap-highlight-color: transparent; /* [MINIAPP] Убираем синюю подсветку при тапе */
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    height: 100vh;
    height: 100dvh; /* [MINIAPP] Динамическая высота для мобильных */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    /* [MINIAPP] Safe area для Telegram */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

#game-container {
    width: 100%;
    max-width: 500px;
    height: 100%;
    max-height: none; /* [MINIAPP] Убираем ограничение 800px */
    display: flex;
    flex-direction: column;
    padding: 8px; /* [MINIAPP] Было 16px — компактнее на мобиле */
    position: relative;
}

#ui-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px; /* [MINIAPP] Было 24px */
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px; /* [MINIAPP] Было 12px */
}

.stat-box {
    display: flex;
    flex-direction: column;
    position: relative;
}

.stat-box .label {
    font-size: 10px; /* [MINIAPP] Было 12px */
    color: var(--text-secondary);
    letter-spacing: 1px;
}

.stat-box .value {
    font-size: 20px; /* [MINIAPP] Было 24px */
    font-weight: bold;
}

.combo-badge {
    position: absolute;
    top: -8px;
    right: -40px;
    background: #00e676;
    color: #000;
    font-size: 12px; /* [MINIAPP] Было 14px */
    font-weight: bold;
    padding: 3px 6px;
    border-radius: 12px;
    box-shadow: 0 0 15px rgba(0, 230, 118, 0.5);
    animation: combo-pulse 0.8s ease-in-out infinite;
}
.combo-badge.combo-low { background: #FFD700; box-shadow: 0 0 15px rgba(255, 215, 0, 0.5); }
.combo-badge.combo-high { background: #FF8C00; box-shadow: 0 0 15px rgba(255, 140, 0, 0.5); }
.combo-badge.combo-max { background: #FF3B3B; color: #fff; box-shadow: 0 0 20px rgba(255, 59, 59, 0.7); animation: combo-pulse-max 0.5s ease-in-out infinite; }
.combo-badge.hidden { display: none; }
@keyframes combo-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
@keyframes combo-pulse-max { 0%, 100% { transform: scale(1) rotate(0deg); } 25% { transform: scale(1.15) rotate(-2deg); } 75% { transform: scale(1.15) rotate(2deg); } }

/* [MINIAPP] Адаптивный размер поля */
#grid-wrapper {
    position: relative;
    width: min(320px, calc(100vw - 100px));
    height: min(320px, calc(100vw - 100px));
    background: var(--panel-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    margin: 24px auto; /* [MINIAPP] Было 40px */
}

.shooters {
    position: absolute;
    display: flex;
    justify-content: space-around;
    pointer-events: auto;
}
.shooters.horizontal { width: 100%; height: 36px; left: 0; } /* [MINIAPP] Было 40px */
.shooters.vertical { height: 100%; width: 36px; top: 0; flex-direction: column; }

#shooters-top { top: -38px; } /* [MINIAPP] Было -42px */
#shooters-bottom { bottom: -38px; }
#shooters-left { left: -38px; }
#shooters-right { right: -38px; }

/* [MINIAPP] Кнопки-стрелки чуть больше для пальцев */
.shooter-btn {
    width: 34px; /* [MINIAPP] Было 32px — увеличиваем тач-зону */
    height: 34px;
    background: #2a2a4a;
    border: 1px solid #3a3a5a;
    border-radius: 6px; /* [MINIAPP] Было 4px — округлённее для мобиля */
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s;
}
.shooter-btn.valid { border: 1px solid rgba(0, 230, 118, 0.5); box-shadow: 0 0 8px rgba(0, 230, 118, 0.3); opacity: 1; }
.shooter-btn.invalid { opacity: 0.7; border: 1px solid rgba(255, 255, 255, 0.2); cursor: not-allowed; }
.shooter-btn.tutorial-highlight {
    animation: tutorialPulse 1.5s ease-in-out infinite;
    border: 2px solid #FFD700 !important;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6) !important;
    opacity: 1 !important;
    background: rgba(255, 215, 0, 0.15) !important;
    cursor: pointer !important;
    z-index: 100;
}
@keyframes tutorialPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(255, 215, 0, 0.6); transform: scale(1); }
    50% { box-shadow: 0 0 30px rgba(255, 215, 0, 0.9); transform: scale(1.1); }
}
.shooter-btn:hover { background: #3a3a6a; color: white; }
.shooter-btn:active { background: #4a4a8a; transform: scale(0.95); } /* [MINIAPP] Feedback при тапе */
.shooter-btn.invalid:hover { background: #2a2a4a; color: var(--text-secondary); }

#ui-footer {
    margin-top: 12px; /* [MINIAPP] Было 24px */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#next-queue {
    display: flex;
    align-items: center;
    gap: 8px; /* [MINIAPP] Было 12px */
    cursor: pointer;
    user-select: none;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}
#next-queue:hover { background: rgba(255, 255, 255, 0.05); }
#queue-dots { display: flex; gap: 8px; }
.dot-preview { width: 24px; height: 24px; border-radius: 50%; cursor: pointer; transition: transform 0.2s; }
.dot-preview:hover { transform: scale(1.1); }

.cycles-badge {
    background: #FF3B3B; color: white; font-size: 10px; font-weight: bold;
    padding: 2px 6px; border-radius: 10px; min-width: 20px; text-align: center;
    box-shadow: 0 0 10px rgba(255, 59, 59, 0.3); border: 1px solid rgba(255, 255, 255, 0.2);
    animation: badge-appear 0.3s ease-out; opacity: 1; transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.cycles-badge.bump { transform: scale(1.4); background: #fff; color: #FF3B3B; }
.cycles-badge.hidden { display: none; }
@keyframes badge-appear { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.cycles-badge.warning { background: #FFD700; color: #000; animation: pulse 1s infinite; }
.cycles-badge.empty { background: #333; opacity: 0.5; }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }

.overlay {
    position: absolute; inset: 0;
    background: rgba(13, 13, 26, 0.95);
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.4s ease;
}
.overlay.active { opacity: 1; pointer-events: auto; }
.overlay.hidden { display: none; }

#game-over-overlay { background: rgba(13, 13, 26, 0.125); }
.game-over-content {
    background: rgba(26, 26, 46, 0.95); padding: 24px 32px; /* [MINIAPP] Компактнее */
    border-radius: 16px; border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); backdrop-filter: blur(10px); text-align: center;
}
.game-over-content h2 { margin-bottom: 12px; }
.game-over-content .final-score-display { font-size: 20px; margin-bottom: 20px; }

.restart-btn {
    width: 100%; padding: 12px 32px; font-size: 18px; margin-bottom: 12px;
    background: var(--accent-color); color: #000; border: none;
}
.restart-btn:hover { background: #00ff88; }

/* [MINIAPP] Кнопка "Поделиться" */
.tg-share-row { margin-bottom: 12px; }
.tg-share-btn {
    width: 100%; padding: 12px 32px; font-size: 16px;
    background: #0088cc; color: white; border: none; border-radius: 8px;
    cursor: pointer; transition: all 0.2s;
}
.tg-share-btn:hover { background: #0099dd; transform: translateY(-1px); }

.logo {
    font-family: var(--font-logo);
    font-size: 36px; /* [MINIAPP] Было 48px */
    text-align: center; margin-bottom: 32px; /* [MINIAPP] Было 48px */
    background: linear-gradient(45deg, #FF3B3B, #3B8BFF, #FFD700);
    background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

button {
    background: var(--panel-color); color: white; border: 1px solid #2a2a4a;
    padding: 14px 28px; border-radius: 8px; font-size: 16px; /* [MINIAPP] Немного компактнее */
    cursor: pointer; transition: all 0.2s ease; margin: 6px;
}
button:hover { background: #2a2a4a; transform: translateY(-2px); }

#start-game, #show-how-to {
    border: 2px solid #00e676; box-shadow: 0 0 15px rgba(0, 230, 118, 0.3);
    background: linear-gradient(135deg, #1a1a2e 0%, #2a2a4a 100%);
}
#start-game:hover, #show-how-to:hover {
    box-shadow: 0 0 20px rgba(0, 230, 118, 0.5);
    background: linear-gradient(135deg, #2a2a4a 0%, #3a3a5a 100%);
}

#controls { display: flex; gap: 8px; }
#pause-btn, #sound-btn, #help-btn { padding: 8px 12px; margin: 0; font-size: 16px; min-width: 40px; }
#help-btn { font-size: 20px; font-weight: bold; padding: 4px 10px; }

.undo-button {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    background: linear-gradient(135deg, #1a1a2e 0%, #2a2a4a 100%);
    border: 2px solid #00e676; border-radius: 12px; padding: 8px 16px; margin: 0 8px;
    cursor: pointer; transition: all 0.3s ease; box-shadow: 0 0 15px rgba(0, 230, 118, 0.3); position: relative;
}
.undo-button:hover:not(.disabled) { background: linear-gradient(135deg, #2a2a4a 0%, #3a3a5a 100%); box-shadow: 0 0 20px rgba(0, 230, 118, 0.5); transform: translateY(-2px); }
.undo-button.disabled { border-color: #555; background: #1a1a2e; box-shadow: none; opacity: 0.5; cursor: not-allowed; }
.undo-icon { font-size: 24px; font-weight: bold; color: #00e676; }
.undo-button.disabled .undo-icon { color: #555; }
.undo-count { font-size: 16px; font-weight: bold; color: #fff; min-width: 20px; text-align: center; }
.undo-button.undo-earned { animation: undo-earn-flash 0.6s ease-out; }
.undo-button.undo-used { animation: undo-use-bounce 0.3s ease-out; }
@keyframes undo-earn-flash { 0%, 100% { box-shadow: 0 0 15px rgba(0, 230, 118, 0.3); transform: scale(1); } 50% { box-shadow: 0 0 30px rgba(255, 215, 0, 0.9), 0 0 50px rgba(255, 215, 0, 0.5); transform: scale(1.1); border-color: #FFD700; } }
@keyframes undo-use-bounce { 0%, 100% { transform: scale(1); } 50% { transform: scale(0.85); } }

#toast-container {
    position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
    z-index: 10000; display: flex; flex-direction: column; gap: 12px; pointer-events: none;
}
.toast {
    background: linear-gradient(135deg, #FFD700 0%, #FF8C00 100%); color: #000;
    padding: 12px 20px; border-radius: 12px; font-weight: bold; font-size: 14px; /* [MINIAPP] Компактнее */
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.6);
    animation: toast-slide-in 0.4s ease-out, toast-slide-out 0.3s ease-in 1.2s;
    pointer-events: all; text-align: center; min-width: 200px;
}
@keyframes toast-slide-in { 0% { opacity: 0; transform: translateY(-30px) scale(0.8); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toast-slide-out { 0% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translateY(-20px) scale(0.9); } }

.tutorial-steps { max-width: 85%; margin: 16px 0; line-height: 1.5; color: #c4c4d5; font-size: 14px; } /* [MINIAPP] */
.tutorial-steps p { margin-bottom: 10px; }
.merge-rules-title { margin-top: 12px; margin-bottom: 6px; }
.merge-rules { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; padding: 12px; background: rgba(255, 255, 255, 0.05); border-radius: 8px; }
.merge-rule { display: flex; align-items: center; justify-content: center; gap: 6px; }
.merge-dot { width: 28px; height: 28px; border-radius: 50%; box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); } /* [MINIAPP] Было 32px */
.merge-plus, .merge-equals { font-size: 16px; font-weight: bold; color: var(--text-primary); min-width: 18px; text-align: center; }
.tutorial-buttons { display: flex; gap: 12px; margin-top: 12px; }
.tutorial-buttons button { flex: 1; padding: 10px 20px; font-size: 14px; } /* [MINIAPP] Компактнее */

.demo-banner {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: linear-gradient(180deg, rgba(13, 13, 26, 0.95) 0%, rgba(13, 13, 26, 0.98) 100%);
    backdrop-filter: blur(10px); border-top: 3px solid #FFD700;
    padding: 12px 16px; /* [MINIAPP] Было 20px 24px */
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    z-index: 999; box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5); animation: slideUpBanner 0.4s ease-out;
    /* [MINIAPP] Safe area */
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
.demo-banner.hidden { display: none; }
@keyframes slideUpBanner { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.demo-hint-text { flex: 1; font-size: 14px; font-weight: bold; color: #FFD700; text-align: left; line-height: 1.4; } /* [MINIAPP] Было 18px */
.demo-next-btn { background: #00E676 !important; color: white !important; border: none !important; padding: 10px 24px !important; font-size: 14px !important; border-radius: 8px !important; cursor: pointer !important; white-space: nowrap; transition: all 0.2s ease; margin-right: 8px; }
.demo-next-btn:hover { background: #00ff88 !important; transform: translateY(-2px); }
.demo-next-btn.hidden { display: none; }
.demo-stop-btn { background: #FF3B3B !important; color: white !important; border: none !important; padding: 10px 24px !important; font-size: 14px !important; border-radius: 8px !important; cursor: pointer !important; white-space: nowrap; transition: all 0.2s ease; }
.demo-stop-btn:hover { background: #ff5555 !important; }

.tutorial-hint {
    position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); /* [MINIAPP] Было 100px */
    background: linear-gradient(135deg, #1a1a2e 0%, #2a2a4a 100%);
    border: 2px solid #00e676; border-radius: 12px; padding: 12px 16px; /* [MINIAPP] Компактнее */
    max-width: 500px; width: 92%; box-shadow: 0 8px 32px rgba(0, 230, 118, 0.3); z-index: 2000;
}
.tutorial-hint.visible { animation: hint-slide-up 0.3s ease-out; }
.tutorial-hint.hidden { display: none !important; }
@keyframes hint-slide-up { from { opacity: 0; transform: translateX(-50%) translateY(20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.hint-content { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#hint-text { margin: 0; color: #ffffff; font-size: 14px; line-height: 1.4; flex: 1; } /* [MINIAPP] Было 16px */
.close-hint-btn {
    background: rgba(255, 59, 59, 0.2); border: 1px solid #ff3b3b; color: #ff6b6b;
    padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 12px; /* [MINIAPP] Компактнее */
    white-space: nowrap; transition: all 0.2s ease;
}
.close-hint-btn:hover { background: rgba(255, 59, 59, 0.3); border-color: #ff5555; }
.tutorial-highlight { animation: tutorial-pulse 1.5s ease-in-out infinite; box-shadow: 0 0 0 0 rgba(0, 230, 118, 0.7) !important; border: 3px solid #00e676 !important; }
@keyframes tutorial-pulse { 0% { box-shadow: 0 0 0 0 rgba(0, 230, 118, 0.7); } 50% { box-shadow: 0 0 0 15px rgba(0, 230, 118, 0); } 100% { box-shadow: 0 0 0 0 rgba(0, 230, 118, 0); } }
