/* === Базовые стили === */
* {
    box-sizing: border-box;
}
body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(145deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: #eee;
}
#app {
    min-height: 100vh;
    padding: 1rem;
}
#screen-container {
    max-width: 640px;
    margin: 0 auto;
    min-height: 80vh;
    position: relative;
}

/* === Экраны === (накладываются в одном месте, виден только активный) */
.screen {
    display: none;
    animation: fadeIn 0.3s ease;
}
.screen.active {
    display: block;
    position: relative;
    z-index: 1;
}
/* неактивный экран логина не должен быть виден поверх кабинета */
.screen-login:not(.active) {
    display: none !important;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* === Логин (flex только когда экран активен, иначе скрыт как .screen) === */
.screen.active.screen-login,
.screen-login.active {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}
.login-box {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 16px;
    padding: 2rem;
    width: 100%;
    max-width: 360px;
}
.login-box h1 {
    margin: 0 0 0.5rem;
    font-size: 1.75rem;
    text-align: center;
}
.subtitle {
    text-align: center;
    color: #aaa;
    margin-bottom: 1.5rem;
}
.auth-form input {
    width: 100%;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    background: rgba(0,0,0,0.3);
    color: #fff;
    font-size: 1rem;
}
.auth-form input::placeholder {
    color: #888;
}
.auth-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}
.auth-actions .btn { flex: 1; }
.auth-message {
    margin-top: 1rem;
    text-align: center;
    min-height: 1.5em;
    font-size: 0.9rem;
}
.auth-message.error { color: #e74c3c; }
.auth-message.success { color: #2ecc71; }

/* === Кнопки === */
.btn {
    padding: 0.65rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
}
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.btn-primary {
    background: #3498db;
    color: #fff;
}
.btn-secondary {
    background: rgba(255,255,255,0.15);
    color: #eee;
}
.btn-danger {
    background: #c0392b;
    color: #fff;
    font-size: 1.2rem;
    padding: 1rem 2rem;
}
.btn-big { padding: 1rem 2rem; }
.btn-small { padding: 0.4rem 0.8rem; font-size: 0.9rem; }

/* === Меню === */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding: 0.5rem 0;
}
.user-name { font-weight: 600; }
.balance { color: #2ecc71; }
.menu-content {
    text-align: center;
}
.menu-content h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}
.menu-desc {
    color: #aaa;
    margin-bottom: 2rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}
.menu-content .btn {
    margin: 0.5rem;
}

/* === Бомба и провода === */
.bomb-container {
    display: flex;
    justify-content: center;
    margin: 2rem 0;
}
.bomb-body {
    position: relative;
    width: 280px;
    padding: 24px;
    background: linear-gradient(180deg, #2c2c2c 0%, #1a1a1a 100%);
    border-radius: 50% 50% 45% 45%;
    box-shadow:
        inset 0 4px 20px rgba(255,255,255,0.08),
        inset 0 -4px 20px rgba(0,0,0,0.5),
        0 8px 24px rgba(0,0,0,0.6);
    border: 4px solid #444;
}
.bomb-timer {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: #e74c3c;
    text-shadow: 0 0 10px rgba(231,76,60,0.6);
    margin-bottom: 16px;
    font-family: 'Courier New', monospace;
}
.bomb-wires {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
}
.wire {
    height: 28px;
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
    border: 2px solid rgba(0,0,0,0.3);
    box-shadow: inset 0 2px 4px rgba(255,255,255,0.2);
}
.wire:hover:not(.cut):not(.disabled) {
    transform: scale(1.03);
    box-shadow: 0 0 12px currentColor;
}
.wire.cut {
    opacity: 0.4;
    cursor: default;
    background: transparent !important; /* обрезанный провод без фона */
    border-color: #555;
    box-shadow: none;
}
.wire.disabled {
    pointer-events: none;
    cursor: default;
}
.game-hint {
    text-align: center;
    color: #888;
    margin-top: 1rem;
}
.game-result {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: 12px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
}

/* PvP лог событий */
.pvp-log {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.4);
    max-height: 180px;
    overflow-y: auto;
    font-size: 0.85rem;
}
.pvp-log-line {
    margin-bottom: 0.25rem;
    color: #ddd;
}

/* PvP счётчик раундов */
#pvp-score {
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(192, 57, 43, 0.45); /* базово красный фон */
    color: #fff;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}
#pvp-score.pvp-score-win {
    background: rgba(46, 204, 113, 0.4); /* зелёный при победе раунда */
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.7);
}

/* PvP таймеры */
#pvp-timer,
#pvp-bomb-timer {
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(192, 57, 43, 0.18); /* базовый фон таймера */
    color: #fff;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}
#pvp-timer.pvp-timer-win,
#pvp-bomb-timer.pvp-timer-win {
    background: rgba(46, 204, 113, 0.35); /* зелёный при победе раунда */
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.7);
}

/* Краткая вспышка экрана при boom */
.screen-pvp.pvp-flash-boom {
    animation: pvpFlashBoom 0.5s ease;
}
@keyframes pvpFlashBoom {
    0% {
        background-color: rgba(192, 57, 43, 0.9);
    }
    100% {
        background-color: transparent;
    }
}

.pvp-home-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

#pvp-list {
    margin-top: 1.5rem;
}

#pvp-matches .pvp-match-item {
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
}

#pvp-matches .pvp-match-meta {
    display: flex;
    flex-direction: column;
}

.game-result.win {
    background: rgba(46, 204, 113, 0.2);
    border: 1px solid #2ecc71;
    color: #2ecc71;
}
.game-result.lose {
    background: rgba(231, 76, 60, 0.2);
    border: 1px solid #e74c3c;
    color: #e74c3c;
}

/* === Профиль === */
.profile-content {
    padding: 1rem 0;
}
.profile-content h1 { margin-bottom: 1rem; }
.profile-content h2 { margin: 1.5rem 0 0.75rem; font-size: 1.1rem; color: #aaa; }
.profile-stats p {
    margin: 0.5rem 0;
    font-size: 1.05rem;
}
.profile-history {
    background: rgba(0,0,0,0.25);
    border-radius: 12px;
    padding: 1rem;
    max-height: 300px;
    overflow-y: auto;
}
.profile-history .history-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
}
.profile-history .history-item:last-child { border-bottom: none; }
.profile-history .win { color: #2ecc71; }
.profile-history .lose { color: #e74c3c; }

/* === Home (главный экран) === */
.home-header { margin-bottom: 1rem; }
.balance-item { margin-right: 0.75rem; }
.balance-item strong { color: #2ecc71; }
.online { color: #888; margin-right: auto; }
.home-bomb-preview { display: flex; justify-content: center; margin: 1.5rem 0; }
.bomb-preview { width: 200px; padding: 16px; }
.bomb-label { text-align: center; font-size: 0.9rem; color: #888; margin-bottom: 10px; }
.bomb-wires-preview { display: flex; flex-direction: column; gap: 3px; }
.bomb-wires-preview .wire-preview { height: 12px; border-radius: 6px; }
.tab-bar {
    display: flex;
    gap: 0.25rem;
    margin: 1rem 0;
    padding: 0.25rem;
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
}
.tab-bar .tab-btn {
    flex: 1;
    padding: 0.6rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #aaa;
    cursor: pointer;
    font-size: 0.95rem;
}
.tab-bar .tab-btn.active { background: rgba(255,255,255,0.15); color: #fff; }
#home-tab-content { min-height: 120px; }
#home-tab-content .tab-inner { padding: 1rem 0; text-align: center; }
#home-tab-content .tab-inner .btn { margin: 0.5rem; }

/* === Solo === */
.solo-tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.solo-tabs .solo-tab {
    flex: 1;
    padding: 0.6rem;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    background: rgba(0,0,0,0.2);
    color: #ccc;
    cursor: pointer;
}
.solo-tabs .solo-tab.active { background: rgba(231, 76, 60, 0.3); border-color: #e74c3c; color: #fff; }
.solo-currency { margin-bottom: 1.5rem; }
.solo-currency label { margin-right: 1rem; cursor: pointer; }
.solo-mode-block h2 { margin-bottom: 0.5rem; font-size: 1.2rem; }
.solo-desc { color: #aaa; font-size: 0.95rem; margin-bottom: 1rem; }
.level-select, .bet-row { margin-bottom: 1rem; }
select, .bet-row input {
    padding: 0.5rem;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(0,0,0,0.3);
    color: #fff;
    min-width: 200px;
}
.solo-mode-block .btn-big { margin-top: 0.5rem; }
.mult-table { margin-bottom: 1rem; }
.mult-table label { display: block; margin-bottom: 0.4rem; }
.mult-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.mult-grid span { background: rgba(243,156,18,0.2); padding: 0.35rem 0.6rem; border-radius: 6px; font-size: 0.9rem; }

/* === Game progress / mult === */
.game-progress { text-align: center; margin-bottom: 0.5rem; }
.game-progress span { margin: 0 0.5rem; }
.game-mult { color: #f39c12; font-weight: 700; }
.game-actions { text-align: center; margin-top: 1rem; }
.game-actions #btn-cashout { font-size: 1.1rem; padding: 0.75rem 1.5rem; }
.pvp-placeholder, .shop-placeholder { padding: 2rem; text-align: center; color: #aaa; }
.pvp-placeholder h2, .shop-placeholder h2 { color: #eee; margin-bottom: 0.5rem; }
