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

:root {
    --bg-dark: #0a0a0f;
    --text-light: #ffffff;
    --accent-1: #ff6b6b;
    --accent-2: #4ecdc4;
    --accent-3: #ffe66d;
    --accent-4: #a8e6cf;
    --accent-5: #ff8b94;
    --banner-safe: 96px; /* запас под VK banner снизу */
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-dark);
    color: var(--text-light);
    position: relative;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.app-container {
    width: 100%;
    height: 100%;
    min-height: 100vh;
    overflow: hidden;
    position: relative;
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
    position: relative;
}

/* На мобильных WebView лучше использовать динамическую высоту */
@supports (height: 100dvh) {
    .app-container { min-height: 100dvh; }
}

.screen.active {
    display: block;
}

/* Важно: экраны, которым нужен flex, не должны ломаться правилом выше */
#mainMenu.screen.active {
    display: flex;
}

#gameScreen.screen.active {
    display: flex;
}

/* Главное меню */
#mainMenu {
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 100%);
}

.menu-content {
    max-width: 600px;
    width: 100%;
    text-align: center;
    padding-bottom: calc(var(--banner-safe) + env(safe-area-inset-bottom, 0px));
}

.menu-title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #ff6b6b, #4ecdc4, #ffe66d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.menu-subtitle {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 40px;
}


.ads-controls {
    margin-top: -18px;
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.ads-reward-btn {
    width: 100%;
    max-width: 560px;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.95) 0%, rgba(22, 163, 74, 0.95) 100%);
    color: #ffffff;
    border: none;
    padding: 9px 14px;
    border-radius: 14px;
    font-weight: 800;
    font-size: 0.85rem;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(34, 197, 94, 0.25);
    transition: all 0.2s ease;
    white-space: normal;
    line-height: 1.2;
    text-align: center;
}

.ads-reward-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(34, 197, 94, 0.35);
}

.ads-reward-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}


.subscription-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    margin-bottom: 8px;
}

.subscription-btn {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: linear-gradient(135deg, rgba(91, 140, 255, 0.95), rgba(46, 114, 255, 0.9));
    color: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.group-member .subscribe-action-btn {
    display: none !important;
}

.subscription-btn.subscription-subscribe {
    width: auto;
    height: auto;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-color: rgba(255, 255, 255, 0.25);
    color: #0b1020;
}

.subscription-btn.subscription-notify {
    background: linear-gradient(135deg, #5b8cff, #6ca1ff);
    border-color: rgba(91, 140, 255, 0.6);
}

.subscription-btn.subscription-recommend {
    background: linear-gradient(135deg, #ff6b6b, #ff8b94);
    border-color: rgba(255, 107, 107, 0.55);
}

.subscription-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.subscription-btn:active {
    transform: translateY(0);
}

.subscription-btn svg {
    width: 20px;
    height: 20px;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 30px;
}


.game-card {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 25px 15px;
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.game-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.game-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.game-name {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.game-desc {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
}

/* Игровой экран */
#gameScreen {
    background: var(--bg-dark);
    flex-direction: column;
}

.game-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-wrap: wrap;
    gap: 10px;
    position: relative;
    z-index: 1500;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hud-label {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.7);
}

.hud-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-light);
}

.hud-actions-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.back-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, rgba(255, 230, 109, 0.9), rgba(255, 138, 148, 0.9));
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 10px;
    color: #0b1020;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.menu-arrow {
    font-size: 1.3em;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.1em;
}

.help-top-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, rgba(46, 213, 191, 0.95), rgba(88, 204, 205, 0.95));
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 10px;
    color: #0b1020;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.help-top-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.6);
}

.hud-subscription-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hud-subscription-row .subscription-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    padding: 0;
}

.subscribe-game-btn {
    align-self: center;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.95), rgba(16, 185, 129, 0.95));
    color: #0b1020;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.hud-subscription-row .subscription-btn svg {
    width: 18px;
    height: 18px;
}

.hud-ads-row {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding-top: 6px;
}

.hud-ads-row .ads-reward-btn {
    max-width: 620px;
}

.game-area {
    width: 100%;
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding-top: 10px;
    padding-bottom: calc(var(--banner-safe) + env(safe-area-inset-bottom, 0px));
}

.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.game-overlay.active {
    display: flex;
}

.overlay-content {
    text-align: center;
    padding: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.overlay-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 20px;
}

.overlay-message {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 30px;
}

.overlay-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.other-apps-btn {
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, #38bdf8, #6366f1);
    border: none;
    border-radius: 15px;
    color: #0b1020;
    cursor: pointer;
    transition: all 0.3s ease;
}

.other-apps-btn:hover {
    transform: scale(1.04);
    box-shadow: 0 10px 24px rgba(56, 189, 248, 0.35);
}

.other-apps-modal {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1100;
}

.other-apps-modal.active {
    display: flex;
}

.other-apps-card {
    width: min(420px, 90vw);
    background: rgba(20, 24, 40, 0.95);
    border-radius: 18px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.other-apps-title {
    font-size: 1.4rem;
    font-weight: 700;
}

.other-apps-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.other-apps-item {
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.other-apps-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.other-apps-close {
    padding: 12px 16px;
    border-radius: 12px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
}

.restart-btn {
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #ff6b6b, #4ecdc4);
    border: none;
    border-radius: 15px;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.3s ease;
}

.restart-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(255, 107, 107, 0.4);
}

.menu-btn {
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.95), rgba(78, 205, 196, 0.95));
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-radius: 15px;
    color: #0b1020;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
}

.menu-btn:hover {
    background: linear-gradient(135deg, rgba(255, 107, 107, 1), rgba(78, 205, 196, 1));
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(255, 107, 107, 0.3);
}

/* ИГРА 1 - ПОРОГ */
.porog-container {
    width: 90%;
    max-width: 600px;
    position: relative;
    margin-top: 20px;
}

.rules-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(8, 8, 12, 0.92);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 0;
    padding: 72px 24px 20px;
    overflow: hidden;
}

.porog-rules {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    margin-top: 20px;
}

.rules-overlay.porog-rules,
.rules-overlay.dva-rules,
.rules-overlay.chain-rules {
    margin-top: 0;
    border-radius: 0;
}

.rules-overlay {
    position: fixed;
    inset: 0;
    z-index: 1500;
    width: 100%;
    height: 100%;
    margin: 0;
    border-radius: 0;
    max-height: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 72px 24px 20px;
    background: rgba(0, 0, 0, 0.92);
}

.rules-overlay .rules-content {
    padding-right: 4px;
}

.rules-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(var(--banner-safe) + env(safe-area-inset-bottom, 0px) + 12px);
}

.rules-back-btn {
    position: absolute;
    top: 16px;
    left: 24px;
    padding: 8px 14px;
    background: linear-gradient(135deg, rgba(255, 230, 109, 0.95), rgba(255, 183, 77, 0.95));
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 12px;
    color: #0b1020;
    font-weight: 700;
    cursor: pointer;
}

.rules-overlay h3 {
    margin-top: 20px;
}

.dva-rules h3,
.chain-rules h3 {
    margin-top: 30px;
}

.porog-rules h3 {
    font-size: 1.2rem;
    margin-bottom: 12px;
    color: var(--accent-3);
    text-align: center;
}

.rules-content {
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.5;
    font-size: 0.85rem;
    text-align: left;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

.rules-content p {
    margin-bottom: 10px;
}

.rules-content ul {
    margin-left: 15px;
    margin-bottom: 10px;
}

.rules-content li {
    margin-bottom: 5px;
}

.porog-start-btn {
    width: 100%;
    padding: 15px 30px;
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-1), var(--accent-3));
    border: none;
    border-radius: 15px;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 12px;
}

.porog-start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(255, 107, 107, 0.4);
}

.porog-game-content {
    width: 100%;
    margin-top: 35px;
}

.porog-controls {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
}

/* (удалено) старый стиль .porog-stop-btn — заменён на градиентный ниже */

.porog-bar {
    width: 100%;
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 30px;
    position: relative;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, 0.2);
    margin-top: 12px;
}

.porog-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-1), #ff8b94);
    border-radius: 30px;
    width: 0%;
    transition: none;
}

.porog-threshold {
    position: absolute;
    top: 0;
    left: 80%;
    width: 4px;
    height: 100%;
    background: var(--accent-3);
    box-shadow: 0 0 20px var(--accent-3);
    z-index: 10;
}

.porog-threshold.thin {
    width: 2px;
}

.porog-threshold.very-thin {
    width: 1px;
}

.porog-hit-zone {
    position: absolute;
    top: 0;
    left: 72%;
    width: 16%;
    height: 100%;
    background: rgba(255, 230, 109, 0.2);
    border-left: 2px dashed var(--accent-3);
    border-right: 2px dashed var(--accent-3);
    z-index: 5;
}

.porog-tap-area {
    width: 100%;
    height: 80px;
    margin-top: 30px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    padding-left: 20px;
    padding-right: 14px;
}

.porog-tap-area.stopped {
    font-size: 1.1rem;
}

.porog-tap-area.active {
    background: rgba(255, 107, 107, 0.2);
    border-color: var(--accent-1);
    color: var(--text-light);
}

.porog-game-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
    width: 100%;
}

.porog-start-game-btn {
    width: 100%;
    padding: 16px 30px;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #36d1dc 0%, #5b86e5 100%);
    border: none;
    border-radius: 18px;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 22px rgba(54, 209, 220, 0.35);
    text-transform: uppercase;
}

.porog-start-game-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 30px rgba(54, 209, 220, 0.5);
}

.porog-stop-btn {
    padding: 12px 24px;
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, #ff5f6d 0%, #ffc371 100%);
    border: none;
    border-radius: 14px;
    color: #1a1a1a;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 18px rgba(255, 95, 109, 0.35);
    text-transform: uppercase;
}

.porog-stop-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 10px 26px rgba(255, 95, 109, 0.5);
}

.rules-actions {
    display: flex;
    gap: 12px;
    margin-top: 18px;
}

.rules-actions button {
    white-space: normal;
    line-height: 1.2;
    text-align: center;
    font-size: clamp(0.95rem, 3.2vw, 1.1rem);
}

.porog-close-rules-btn {
    flex: 1;
    padding: 14px 16px;
    border-radius: 16px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    background: linear-gradient(135deg, rgba(91, 140, 255, 0.95), rgba(88, 204, 205, 0.95));
    color: #0b1020;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
}

.porog-close-rules-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    transform: translateY(-1px);
}

.porog-rules-btn {
    width: 100%;
    padding: 12px 24px;
    font-size: 1.05rem;
    font-weight: 700;
    background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.05));
    border: 2px dashed rgba(255, 255, 255, 0.45);
    border-radius: 14px;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 0.3px;
}

.porog-rules-btn:hover {
    background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.12));
    transform: translateY(-1px) scale(1.01);
    border-color: rgba(255, 255, 255, 0.7);
}

.porog-feedback {
    position: fixed;
    top: 96px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.7rem;
    font-weight: 800;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    text-align: center;
    padding: 10px 18px;
    max-width: calc(100% - 24px);
    width: max-content;
    background: rgba(255, 255, 255, 0.95);
    color: #0f172a;
    border-radius: 999px;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
    z-index: 3500;
    pointer-events: none;
}

/* ===========================
   ДВА УСЛОВИЯ — уникальные кнопки
=========================== */
.dva-game-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 18px;
    width: 100%;
}

.dva-start-btn {
    width: 100%;
    padding: 16px 30px;
    font-size: 1.15rem;
    font-weight: 800;
    background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
    border: none;
    border-radius: 18px;
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(236, 72, 153, 0.35);
    transition: all 0.25s ease;
    text-transform: uppercase;
}

.dva-start-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 14px 34px rgba(236, 72, 153, 0.5);
}

.dva-stop-btn {
    width: 100%;
    padding: 12px 24px;
    font-size: 1.05rem;
    font-weight: 800;
    background: linear-gradient(135deg, #f97316 0%, #fde047 100%);
    border: none;
    border-radius: 14px;
    color: #1a1a1a;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(249, 115, 22, 0.35);
    transition: all 0.25s ease;
    text-transform: uppercase;
}

.dva-stop-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 28px rgba(249, 115, 22, 0.5);
}

.dva-help-btn {
    width: 100%;
    padding: 12px 24px;
    font-size: 1.05rem;
    font-weight: 800;
    background: rgba(0, 0, 0, 0.35);
    border: 2px dotted rgba(168, 230, 207, 0.65);
    border-radius: 14px;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.25s ease;
}

.dva-help-btn:hover {
    transform: translateY(-1px);
    background: rgba(0, 0, 0, 0.45);
    border-color: rgba(168, 230, 207, 0.9);
}

.dva-rules .rules-actions .dva-close-rules-btn,
.dva-rules .rules-actions .dva-launch-btn {
    flex: 1;
    padding: 14px 16px;
    border-radius: 16px;
    border: 2px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.95);
    font-weight: 800;
    cursor: pointer;
    transition: all 0.25s ease;
}

.dva-rules .rules-actions .dva-launch-btn {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.9), rgba(236, 72, 153, 0.9));
    border: none;
}

.dva-rules .rules-actions .dva-close-rules-btn:hover,
.dva-rules .rules-actions .dva-launch-btn:hover {
    transform: translateY(-1px);
}

/* ===========================
   ЦЕПОЧКА — уникальные кнопки
=========================== */
.chain-game-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 18px;
    width: 100%;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}

.chain-start-btn {
    width: 100%;
    padding: 16px 30px;
    font-size: 1.15rem;
    font-weight: 900;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #22c55e 0%, #06b6d4 100%);
    border: none;
    border-radius: 20px;
    color: #00110b;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(6, 182, 212, 0.35);
    transition: all 0.25s ease;
    text-transform: uppercase;
}

.chain-start-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 14px 34px rgba(6, 182, 212, 0.5);
}

.chain-stop-btn {
    width: 100%;
    padding: 12px 24px;
    font-size: 1.05rem;
    font-weight: 900;
    background: linear-gradient(135deg, #ef4444 0%, #fb7185 100%);
    border: none;
    border-radius: 14px;
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(239, 68, 68, 0.35);
    transition: all 0.25s ease;
    text-transform: uppercase;
}

.chain-stop-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 28px rgba(239, 68, 68, 0.5);
}

.chain-help-btn {
    width: 100%;
    padding: 12px 24px;
    font-size: 1.05rem;
    font-weight: 900;
    background: rgba(255, 255, 255, 0.08);
    border: 2px dashed rgba(255, 230, 109, 0.7);
    border-radius: 14px;
    color: #fff;
    cursor: pointer;
    transition: all 0.25s ease;
}

.chain-help-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 230, 109, 0.95);
    background: rgba(255, 255, 255, 0.12);
}

.chain-rules .rules-actions .chain-close-rules-btn,
.chain-rules .rules-actions .chain-launch-btn {
    flex: 1;
    padding: 14px 16px;
    border-radius: 16px;
    border: 2px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.95);
    font-weight: 900;
    cursor: pointer;
    transition: all 0.25s ease;
}

.chain-rules .rules-actions .chain-launch-btn {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.9), rgba(6, 182, 212, 0.9));
    border: none;
    color: #00110b;
}

.chain-rules .rules-actions .chain-close-rules-btn:hover,
.chain-rules .rules-actions .chain-launch-btn:hover {
    transform: translateY(-1px);
}

.porog-feedback.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-6px);
}

.porog-feedback.perfect {
    color: #0f172a;
    box-shadow: 0 16px 32px rgba(251, 191, 36, 0.35);
}

.porog-feedback.good {
    color: #0f172a;
    box-shadow: 0 16px 32px rgba(34, 197, 94, 0.3);
}

.porog-feedback.bad {
    color: #0f172a;
    box-shadow: 0 16px 32px rgba(248, 113, 113, 0.35);
}

/* ИГРА 2 - ДВА УСЛОВИЯ */
.dva-usloviya-container {
    width: 90%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.dva-rules .rules-content {
    text-align: left;
}

.chain-rules .rules-content {
    text-align: left;
}

.dva-game-content {
    margin-top: 14px;
    width: 100%;
}

.dva-game-content {
    margin-top: 26px;
}

.conditions-display {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 8px 12px;
    margin-bottom: 2px;
    text-align: center;
    border: 2px solid rgba(255, 255, 255, 0.2);
    width: 100%;
}

.condition-item {
    font-size: 1.05rem;
    margin: 6px 0;
    font-weight: 600;
}

.condition-item.active {
    color: var(--accent-2);
}

.object-display {
    width: min(144px, 44vw);
    height: min(144px, 44vw);
    margin: 8px auto;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(2.6rem, 8vw, 3.6rem);
    font-weight: 700;
    border: 4px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    color: #ffffff;
}

/* (удалено) оформление правила со стрелками */

.object-display.correct {
    border-color: var(--accent-4);
    box-shadow: 0 0 30px var(--accent-4);
}

.object-display.incorrect {
    border-color: var(--accent-1);
    box-shadow: 0 0 30px var(--accent-1);
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.dva-usloviya-tap-area {
    width: 100%;
    height: clamp(84px, 12vh, 120px);
    background: rgba(255, 255, 255, 0.05);
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.05rem, 3.2vw, 1.2rem);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    margin-top: 6px;
}

.dva-usloviya-tap-area.stopped {
    justify-content: flex-start;
    padding-left: 20px;
    padding-right: 14px;
    font-size: 0.95rem;
}

.dva-usloviya-container {
    margin-top: 16px;
}

/* При очень низкой высоте экрана дополнительно уплотняем */
@media (max-height: 720px) {
    .object-display {
        width: min(120px, 38vw);
        height: min(120px, 38vw);
        border-radius: 18px;
    }
    .dva-usloviya-tap-area {
        height: 88px;
    }
}

/* Тост уведомления о смене правила */
.rule-toast {
    position: fixed;
    left: 50%;
    top: 18%;
    transform: translateX(-50%) translateY(-10px);
    opacity: 0;
    pointer-events: none;
    z-index: 2000;
    max-width: min(560px, calc(100vw - 40px));
    padding: 12px 18px;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(10px);
    color: rgba(255, 255, 255, 0.95);
    font-weight: 800;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    transition: all 0.25s ease;
}

.rule-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ИГРА 3 - ЦЕПОЧКА */
.cepочka-container,
.chain-container {
    width: 90%;
    max-width: 500px;
}

.chain-element {
    width: 150px;
    height: 150px;
    margin: 20px auto;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    border: 4px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.chain-element.current {
    border-color: var(--accent-3);
    box-shadow: 0 0 30px var(--accent-3);
    transform: scale(1.1);
}

.chain-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 30px;
}

.chain-btn {
    padding: 20px 40px;
    font-size: 1.3rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.1);
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 150px;
}

.chain-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

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

.chain-btn.correct {
    background: var(--accent-4);
    border-color: var(--accent-4);
}

.chain-btn.incorrect {
    background: var(--accent-1);
    border-color: var(--accent-1);
    animation: shake 0.3s ease;
}

/* Адаптивность */
/* ===== МОБИЛЬНАЯ АДАПТАЦИЯ ===== */

@media (max-width: 768px) {
    .menu-title {
        font-size: 2.5rem;
    }
    
    .menu-subtitle {
        font-size: 1rem;
        margin-bottom: 20px;
    }
    
    .menu-content {
        padding: 15px;
    }
    
    /* Компактный баннер на мобильных */
    .ads-controls {
        margin-top: -10px;
        margin-bottom: 12px;
        gap: 6px;
    }
    
    .ads-reward-btn {
        padding: 8px 10px;
        font-size: 0.78rem;
        line-height: 1.3;
        max-width: 100%;
        min-height: 36px;
    }
    
    
    .subscription-controls {
        margin-top: 8px;
        margin-bottom: 8px;
        gap: 10px;
    }
    
    .games-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        margin-top: 20px;
    }
    
    .game-card {
        padding: 20px 10px;
    }
    
    .game-icon {
        font-size: 2.5rem;
    }
    
    .game-name {
        font-size: 1.1rem;
    }
    
    /* HUD адаптация */
    .game-hud {
        padding: 12px 15px;
        gap: 8px;
    }
    
    .hud-item {
        gap: 6px;
    }
    
    .hud-label {
        font-size: 0.9rem;
    }
    
    .hud-value {
        font-size: 1.3rem;
    }
    
    .hud-actions-row {
        gap: 6px;
    }
    
    .help-top-btn,
    .back-btn {
        padding: 10px 14px;
        font-size: 0.85rem;
        min-height: 44px; /* Минимальный размер для тач-интерфейса */
    }
    
    .hud-subscription-row .subscription-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }
    
    .hud-subscription-row .subscription-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .hud-ads-row {
        padding-top: 8px;
    }
    
    .ads-reward-btn {
        padding: 10px 12px;
        font-size: 0.82rem;
        min-height: 38px;
    }
    

    .porog-container {
        margin-top: 70px;
    }

    .dva-usloviya-container {
        margin-top: 50px;
    }
}

@media (max-width: 480px) {
    .menu-title {
        font-size: 2rem;
    }
    
    .menu-subtitle {
        font-size: 0.9rem;
        margin-bottom: 15px;
    }
    
    .menu-content {
        padding: 12px;
    }
    
    /* Ещё более компактный баннер на маленьких экранах */
    .ads-controls {
        margin-top: -8px;
        margin-bottom: 10px;
        gap: 5px;
    }
    
    .ads-reward-btn {
        padding: 8px 8px;
        font-size: 0.72rem;
        line-height: 1.25;
        border-radius: 12px;
        min-height: 34px;
    }
    
    
    .subscription-controls {
        margin-top: 6px;
        margin-bottom: 6px;
        gap: 8px;
    }
    
    .subscription-btn {
        width: 42px;
        height: 42px;
    }
    
    .subscription-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .games-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        margin-top: 15px;
    }
    
    .game-card {
        padding: 10px 4px;
    }
    
    .game-icon {
        font-size: 1.6rem;
        margin-bottom: 3px;
    }
    
    .game-name {
        font-size: 0.85rem;
        margin-bottom: 2px;
    }
    
    .game-desc {
        font-size: 0.65rem;
        line-height: 1.1;
    }
    
    /* HUD для очень маленьких экранов */
    .game-hud {
        padding: 10px 12px;
        gap: 6px;
        flex-direction: column;
        align-items: stretch;
    }
    
    .hud-item {
        justify-content: space-between;
        width: 100%;
    }
    
    .hud-label {
        font-size: 0.85rem;
    }
    
    .hud-value {
        font-size: 1.2rem;
    }
    
    .hud-actions-row {
        width: 100%;
        justify-content: space-between;
        gap: 6px;
        margin-top: 4px;
    }
    
    .help-top-btn,
    .back-btn {
        flex: 1;
        padding: 12px 10px;
        font-size: 0.8rem;
        min-height: 44px;
    }
    
    .hud-subscription-row {
        gap: 4px;
    }
    
    .hud-subscription-row .subscription-btn {
        width: 40px;
        height: 40px;
    }
    
    .hud-ads-row {
        width: 100%;
        padding-top: 6px;
    }
    
    .hud-ads-row .ads-reward-btn {
        width: 100%;
        max-width: 100%;
        padding: 10px 12px;
        font-size: 0.78rem;
        min-height: 38px;
    }
    
    /* Подписка в меню */
    .subscription-controls {
        gap: 10px;
        margin-top: 10px;
        margin-bottom: 6px;
    }
    
    .subscription-btn {
        width: 44px;
        height: 44px;
    }
    
    .subscription-btn svg {
        width: 20px;
        height: 20px;
    }
    
    /* Игровые элементы */
    .game-area {
        padding: 10px;
    }
}

/* Для очень маленьких экранов (iPhone SE и подобные) */
@media (max-width: 375px) {
    .menu-title {
        font-size: 1.8rem;
    }
    
    .menu-subtitle {
        font-size: 0.85rem;
    }
    
    .hud-value {
        font-size: 1.1rem;
    }
    
    .help-top-btn,
    .back-btn {
        font-size: 0.75rem;
        padding: 10px 8px;
    }
    
    .hud-subscription-row .subscription-btn {
        width: 38px;
        height: 38px;
    }
    
    .hud-subscription-row .subscription-btn svg {
        width: 18px;
        height: 18px;
    }
}

/* Для портретной ориентации на мобильных */
@media (max-width: 768px) and (orientation: portrait) {
    .menu-content {
        max-height: calc(100vh - 120px);
        overflow-y: auto;
    }
    
    .game-area {
        padding-bottom: calc(var(--banner-safe) + env(safe-area-inset-bottom, 0px));
    }
}

/* Для ландшафтной ориентации на мобильных */
@media (max-width: 768px) and (orientation: landscape) {
    .game-hud {
        padding: 8px 12px;
    }
    
    .hud-value {
        font-size: 1.1rem;
    }
    
    .help-top-btn,
    .back-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    .hud-subscription-row .subscription-btn {
        width: 40px;
        height: 40px;
    }
}

/* Адаптация игровых элементов для мобильных */
@media (max-width: 480px) {
    /* Порог */
    .porog-container {
        width: 95%;
        max-width: 100%;
        margin-top: 70px;
    }
    
    .porog-rules {
        padding: 15px 12px;
        border-radius: 12px;
        margin-top: 10px;
    }
    
    .porog-rules h3 {
        font-size: 1rem;
        margin-bottom: 10px;
    }
    
    .rules-content {
        font-size: 0.75rem;
    }
    
    .rules-content p {
        margin-bottom: 8px;
    }
    
    .rules-content ul {
        margin-left: 12px;
        margin-bottom: 8px;
    }
    
    .rules-content li {
        margin-bottom: 4px;
    }
    
    .porog-game-content {
        margin-top: 25px;
    }
    
    .porog-start-btn,
    .porog-stop-btn,
    .porog-rules-btn {
        padding: 14px 20px;
        font-size: 1.1rem;
        min-height: 48px;
    }
    
    .porog-tap-area {
        min-height: 60px;
    }
    
    /* Два условия */
    .dva-usloviya-container {
        width: 95%;
        max-width: 100%;
    }

    .dva-game-content {
        margin-top: 10px;
    }
    
    .conditions-display {
        font-size: 0.9rem;
        padding: 12px;
    }
    
    .object-display {
        width: min(112px, 36vw);
        height: min(112px, 36vw);
    }
    
    .dva-usloviya-tap-area {
        height: 80px;
        font-size: 0.95rem;
    }
    
    .dva-start-btn,
    .dva-stop-btn,
    .dva-help-btn {
        padding: 14px 20px;
        font-size: 1rem;
        min-height: 48px;
    }
    
    /* Цепочка */
    .chain-container,
    .cepочka-container {
        width: 95%;
        max-width: 100%;
    }
    
    .chain-element {
        width: 130px;
        height: 130px;
        font-size: 2.5rem;
    }
    
    .chain-btn {
        padding: 16px 30px;
        font-size: 1.1rem;
        min-height: 48px;
        min-width: 120px;
    }
    
    .chain-game-buttons {
        gap: 10px;
    }
    
    .chain-start-btn,
    .chain-stop-btn,
    .chain-help-btn {
        padding: 14px 20px;
        font-size: 1rem;
        min-height: 48px;
    }
    
    /* Правила игр */
    .dva-rules,
    .chain-rules {
        padding: 20px 15px;
    }
    
    .dva-rules h3,
    .chain-rules h3 {
        font-size: 1.4rem;
    }
    
    .dva-rules .rules-content,
    .chain-rules .rules-content {
        font-size: 0.9rem;
    }
    
    /* Тост уведомлений */
    .rule-toast {
        max-width: calc(100vw - 30px);
        padding: 10px 14px;
        font-size: 0.9rem;
        top: 15%;
    }
}

@media (max-width: 375px) {
    .porog-tap-area {
        min-height: 50px;
    }
    
    .object-display {
        width: min(96px, 34vw);
        height: min(96px, 34vw);
    }
    
    .chain-element {
        width: 110px;
        height: 110px;
        font-size: 2rem;
    }
    
    .chain-btn {
        padding: 14px 24px;
        font-size: 1rem;
        min-width: 100px;
    }
}
