@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700;800&family=JetBrains+Mono:wght@700&display=swap');

:root {
    --bg: #09090b;
    --card-bg: rgba(24, 24, 27, 0.6);
    --card-border: rgba(255, 255, 255, 0.08);
    --primary: #8b5cf6;
    --primary-dark: #6d28d9;
    --primary-glow: rgba(139, 92, 246, 0.5);
    --cashout: #22c55e;
    --cashout-glow: rgba(34, 197, 94, 0.5);
    --danger: #ef4444;
    --text-muted: #a1a1aa;
    --nav-height: 70px;
}

body {
    background-color: var(--bg);
    color: #fff;
    font-family: 'Inter', sans-serif;
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    background-image: radial-gradient(circle at top center, #1e1b4b 0%, #09090b 50%);
}

.hidden { display: none !important; }

/* MODAL STYLES */
#modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(5px);
    z-index: 2000; display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.2s;
}
.modal-box {
    background: #18181b; border: 1px solid var(--card-border);
    width: 80%; max-width: 300px; padding: 20px; border-radius: 20px;
    text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.modal-box h3 { margin: 0 0 15px; }
.modal-btns { display: flex; gap: 10px; margin-top: 15px; }
.btn-pri { flex:1; background: var(--primary); color:white; border:none; padding:10px; border-radius:10px; font-weight:bold; }
.btn-sec { flex:1; background: #27272a; color:white; border:none; padding:10px; border-radius:10px; }

/* SWITCH TOGGLE */
.switch { position: relative; display: inline-block; width: 34px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: #3f3f46; transition: .4s; border-radius: 20px;
}
.slider:before {
    position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px;
    background-color: white; transition: .4s; border-radius: 50%;
}
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(14px); }

/* TOASTS */
#toast-container {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    z-index: 9999; display: flex; flex-direction: column; gap: 10px; width: 90%; pointer-events: none;
}
.toast {
    background: rgba(20, 20, 25, 0.95); backdrop-filter: blur(12px);
    border: 1px solid var(--card-border); padding: 12px 16px;
    border-radius: 12px; display: flex; align-items: center; gap: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5); animation: slideDown 0.3s ease-out; pointer-events: auto;
}
.toast.success { border-left: 4px solid var(--cashout); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.win { background: linear-gradient(90deg, #14532d, #052e16); border: 1px solid var(--cashout); }
@keyframes slideDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: scale(0.9); } }

/* TABS */
.tab-pane {
    display: none; height: 100%; flex-direction: column;
    padding-bottom: var(--nav-height); box-sizing: border-box; width: 100%;
}
.tab-pane.active { display: flex; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* HEADER */
.game-header {
    height: 60px; padding: 0 20px;
    display: flex; align-items: center; justify-content: space-between;
    z-index: 10;
}
.logo { font-weight: 800; font-size: 20px; display:flex; align-items:center; gap:8px; text-shadow: 0 0 10px rgba(139,92,246,0.3); }
.balance-pill {
    font-family: 'JetBrains Mono', monospace;
    background: rgba(139, 92, 246, 0.1); color: #ddd6fe;
    padding: 6px 14px; border-radius: 20px;
    border: 1px solid rgba(139, 92, 246, 0.3); font-size: 15px;
    display: flex; align-items: center; gap: 8px; font-weight: bold;
}

/* GAME AREA */
.game-container { flex: 1; position: relative; overflow: hidden; }
canvas { width: 100%; height: 100%; display: block; }
.hud-center {
    position: absolute; top: 40%; left: 50%;
    transform: translate(-50%, -50%); text-align: center; pointer-events: none; z-index: 5;
}
.multiplier-big {
    font-family: 'JetBrains Mono', monospace; font-size: 72px; font-weight: 800;
    text-shadow: 0 0 40px rgba(139, 92, 246, 0.6); transition: color 0.1s;
}
.status-text { 
    font-size: 14px; font-weight: 700; letter-spacing: 3px; 
    margin-top: 10px; color: var(--text-muted); text-transform: uppercase;
    background: rgba(0,0,0,0.3); padding: 4px 10px; border-radius: 6px;
}

/* CONTROLS (FIXED) */
.control-panel {
    background: #18181b; padding: 20px;
    border-top: 1px solid var(--card-border);
    border-radius: 24px 24px 0 0; box-shadow: 0 -10px 40px rgba(0,0,0,0.5); z-index: 20;
}
.input-row { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 15px; 
    margin-bottom: 16px; 
}
.input-group { 
    display: flex; 
    flex-direction: column; 
}
.input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 24px;
    margin-bottom: 8px;
}
.input-group label {
    font-size: 11px; color: var(--text-muted);
    font-weight: 700; text-transform: uppercase; margin: 0;
}
.pretty-input {
    width: 100%; background: #27272a; border: 1px solid #3f3f46;
    color: white; padding: 16px; border-radius: 14px;
    font-family: 'JetBrains Mono'; font-size: 18px; box-sizing: border-box; outline: none;
    transition: 0.2s; height: 55px;
}
.pretty-input:focus { border-color: var(--primary); background: #2e2e33; }
.pretty-input:disabled { opacity: 0.5; background: #18181b; }

.btn-main {
    width: 100%; padding: 20px; border: none; border-radius: 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white; font-size: 18px; font-weight: 800; cursor: pointer;
    box-shadow: 0 4px 20px var(--primary-glow); transition: 0.1s; text-transform: uppercase; letter-spacing: 1px;
}
.btn-main:active { transform: scale(0.98); }
.btn-main:disabled { background: #3f3f46; box-shadow: none; color: #71717a; cursor: not-allowed; opacity: 0.7; }
.btn-main.cashout {
    background: linear-gradient(135deg, #22c55e 0%, #15803d 100%); color: white;
    box-shadow: 0 0 30px var(--cashout-glow);
}
.btn-main.crashed { background: #ef4444; box-shadow: 0 0 20px rgba(239, 68, 68, 0.4); }

/* PROFILE */
.scroll-content { padding: 20px; overflow-y: auto; flex: 1; padding-bottom: 100px; }
.profile-card {
    background: linear-gradient(145deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
    backdrop-filter: blur(10px); border: 1px solid var(--card-border);
    border-radius: 24px; padding: 20px; margin-bottom: 20px;
    display: flex; flex-direction: column; align-items: center; text-align: center;
}
.profile-avatar-wrap { position: relative; margin-bottom: 15px; }
.profile-avatar { 
    width: 80px; height: 80px; border-radius: 50%; 
    background: linear-gradient(135deg, #2e1065, #000);
    display:flex; align-items:center; justify-content:center;
    font-size: 36px; color: var(--primary); border: 3px solid var(--primary);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
}
.edit-btn {
    position: absolute; bottom: 0; right: 0; background: #fff; color: #000;
    width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 12px; cursor: pointer;
}
.profile-name { font-size: 20px; font-weight: 700; margin: 0; }
.profile-id { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-family: 'JetBrains Mono'; }

/* ---- ОБНОВЛЕННЫЕ СТИЛИ ДЛЯ ВЫРАВНИВАНИЯ ---- */
.stats-row { 
    display: flex; /* Используем flex для ровного распределения */
    justify-content: center;
    gap: 15px; 
    width: 100%; 
    margin-top: 20px; 
}
.stat-box { 
    background: rgba(0,0,0,0.3); 
    padding: 15px; 
    border-radius: 16px; 
    border: 1px solid var(--card-border);
    flex: 1; /* Растягиваем блоки равномерно */
    display: flex;
    flex-direction: column;
    align-items: center; /* Центрируем по горизонтали */
    justify-content: center; /* Центрируем по вертикали */
    text-align: center;
}
/* ------------------------------------------- */

.stat-box .val { font-family: 'JetBrains Mono'; font-size: 16px; font-weight: bold; color: white; }
.stat-box .lbl { font-size: 10px; color: var(--text-muted); text-transform: uppercase; margin-top: 4px; }
.menu-section { margin-top: 25px; }
.section-header { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; margin-bottom: 10px; padding-left: 5px; }
.menu-list { background: rgba(24, 24, 27, 0.6); border: 1px solid var(--card-border); border-radius: 16px; overflow: hidden; }
.menu-item { padding: 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,0.05); }
.menu-item:last-child { border-bottom: none; }
.ref-box {
    background: rgba(139, 92, 246, 0.1); border: 1px dashed rgba(139, 92, 246, 0.4);
    border-radius: 12px; padding: 12px; margin-top: 10px;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.ref-link-text { font-family: 'JetBrains Mono'; font-size: 11px; color: #c4b5fd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.copy-btn { background: var(--primary); color: white; border: none; padding: 6px 12px; border-radius: 6px; font-size: 10px; font-weight: bold; cursor: pointer; }

/* NAV */
.nav-bottom {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--nav-height); background: rgba(9, 9, 11, 0.85);
    backdrop-filter: blur(20px); border-top: 1px solid var(--card-border);
    display: flex; justify-content: space-around; z-index: 100;
}
.nav-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: #52525b; font-size: 10px; gap: 6px; cursor: pointer; transition: 0.2s;
}
.nav-item.active { color: var(--primary); text-shadow: 0 0 15px rgba(139,92,246,0.4); }
.nav-item i { font-size: 22px; transition: 0.2s; }
.nav-item.active i { transform: translateY(-2px); }

/* History Bar */
.history-bar {
    height: 40px; background: rgba(0,0,0,0.2); backdrop-filter: blur(5px);
    display: flex; align-items: center; padding: 0 15px; gap: 8px;
    overflow-x: auto; white-space: nowrap; border-bottom: 1px solid rgba(255,255,255,0.03);
}
.history-bar::-webkit-scrollbar { display: none; }
.history-pill {
    font-family: 'JetBrains Mono'; font-size: 12px; padding: 4px 10px;
    border-radius: 6px; background: #27272a; color: #a1a1aa; font-weight: bold;
}
.history-pill.high { color: var(--cashout); background: rgba(34, 197, 94, 0.1); border: 1px solid rgba(34, 197, 94, 0.2); }
.history-pill.low { color: var(--danger); background: rgba(239, 68, 68, 0.1); }

/* Shake Animation */
.shake-screen { animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both; border: 2px solid var(--danger); }
@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}