/* =========================================================
   Snake Game — Las Casas v1.0
   Mobile-first · Ticker · Prize system
   ========================================================= */

.sg-wrapper { position:relative; display:inline-block; width:100%; font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; }

/* --- Темы --- */
.sg-modal[data-theme="teal"]   { --sg-accent:#1abc9c; --sg-glow:rgba(26,188,156,.4); --sg-food:#1abc9c; }
.sg-modal[data-theme="green"]  { --sg-accent:#6fcf7b; --sg-glow:rgba(111,207,123,.4); --sg-food:#6fcf7b; }
.sg-modal[data-theme="purple"] { --sg-accent:#d96cd9; --sg-glow:rgba(217,108,217,.4); --sg-food:#d96cd9; }
.sg-modal[data-theme="orange"] { --sg-accent:#f0a35e; --sg-glow:rgba(240,163,94,.4);  --sg-food:#f0a35e; }

/* --- Кнопка --- */
.sg-open-btn {
    width:100%; background:linear-gradient(135deg,#1a1a2e,#16213e);
    border:2px solid var(--sg-accent,#1abc9c); padding:14px 24px;
    font-size:16px; font-weight:700; color:var(--sg-accent,#1abc9c);
    border-radius:50px; cursor:pointer; transition:all .3s;
    letter-spacing:1px; box-shadow:0 4px 20px var(--sg-glow,rgba(26,188,156,.25));
    -webkit-tap-highlight-color:transparent; touch-action:manipulation;
}
.sg-open-btn:active { transform:scale(.98); }

/* --- Модальное окно --- */
.sg-modal {
    --sg-accent:#1abc9c; --sg-glow:rgba(26,188,156,.4); --sg-food:#1abc9c;
    position:fixed; inset:0; z-index:99999;
    overflow-y:auto; -webkit-overflow-scrolling:touch;
    background:rgba(0,0,0,.92);
    display:flex; align-items:flex-start; justify-content:center;
    padding-bottom:40px;
    animation:sgFadeIn .2s ease;
}
@keyframes sgFadeIn { from{opacity:0} to{opacity:1} }

.sg-modal-inner {
    background:linear-gradient(160deg,#0d1b2a,#1a1a2e);
    border-radius:0 0 24px 24px;
    width:100%; max-width:480px;
    border-top:2px solid var(--sg-accent);
    box-shadow:0 -4px 30px var(--sg-glow);
    animation:sgSlideDown .3s ease;
    overflow:hidden;
}
@keyframes sgSlideDown { from{transform:translateY(-30px);opacity:0} to{transform:translateY(0);opacity:1} }

/* --- Шапка --- */
.sg-header {
    display:flex; justify-content:space-between; align-items:center;
    padding:14px 16px 10px;
    border-bottom:1px solid rgba(255,255,255,.07);
    position:sticky; top:0; background:#0d1b2a; z-index:2;
}
.sg-logo { font-size:14px; font-weight:800; color:var(--sg-accent); letter-spacing:2px; }
.sg-logo span { color:#fff; }
.sg-header-right { display:flex; align-items:center; gap:12px; }
.sg-coins-mini {
    display:flex; align-items:center; gap:4px;
    background:rgba(255,255,255,.06); border-radius:20px;
    padding:4px 10px; font-size:13px;
}
.sg-coin-count { font-weight:700; color:#f0c040; }
.sg-coin-total { color:#7e90b0; font-size:11px; }
.sg-close {
    background:none; border:none; color:#ff7070; font-size:20px;
    cursor:pointer; min-width:40px; min-height:40px;
    display:flex; align-items:center; justify-content:center;
    border-radius:50%; -webkit-tap-highlight-color:transparent;
    transition:background .15s;
}
.sg-close:active { background:rgba(255,112,112,.15); }

/* =========================================================
   ТИКЕР
   ========================================================= */
.sg-ticker {
    background:rgba(0,0,0,.4);
    border-top:1px solid rgba(255,255,255,.06);
    padding:0;
    overflow:hidden;
    height:44px;
    display:flex;
    align-items:center;
    gap:0;
}
.sg-ticker--top { border-top:none; border-bottom:1px solid rgba(255,255,255,.06); }
.sg-ticker-label {
    flex-shrink:0;
    font-size:10px; font-weight:700; color:var(--sg-accent);
    letter-spacing:1px; text-transform:uppercase;
    padding:0 10px;
    border-right:1px solid rgba(255,255,255,.08);
    height:100%; display:flex; align-items:center;
    background:rgba(0,0,0,.2);
}
.sg-ticker-track {
    display:flex;
    gap:0;
    animation:sgTicker 35s linear infinite;
    white-space:nowrap;
    flex-shrink:0;
}
.sg-ticker-track:hover { animation-play-state:paused; }
@keyframes sgTicker { from{transform:translateX(0)} to{transform:translateX(-50%)} }

.sg-ticker-item {
    display:inline-flex; align-items:center; gap:8px;
    padding:0 20px;
    border-right:1px solid rgba(255,255,255,.05);
    cursor:pointer;
    text-decoration:none;
    transition:background .2s;
    height:44px;
}
.sg-ticker-item:hover { background:rgba(255,255,255,.04); }
.sg-ticker-thumb {
    width:32px; height:32px; border-radius:6px;
    object-fit:cover; flex-shrink:0;
    background:#1e293b;
}
.sg-ticker-thumb-placeholder {
    width:32px; height:32px; border-radius:6px;
    background:linear-gradient(135deg,#1e3a5f,#0f2040);
    display:flex; align-items:center; justify-content:center;
    font-size:14px; flex-shrink:0;
}
.sg-ticker-info { display:flex; flex-direction:column; gap:1px; }
.sg-ticker-name { font-size:12px; font-weight:600; color:#fff; max-width:140px; overflow:hidden; text-overflow:ellipsis; }
.sg-ticker-meta { font-size:10px; color:var(--sg-accent); }

/* --- Ранг --- */
.sg-rank-bar {
    display:flex; align-items:center; gap:6px;
    padding:8px 16px;
    font-size:12px; color:#7e90b0;
    background:rgba(255,255,255,.03);
    border-bottom:1px solid rgba(255,255,255,.05);
}
.sg-rank-icon { font-size:16px; }
.sg-rank-name { font-weight:700; color:var(--sg-accent); }
.sg-rank-sep { color:#2a3a60; }
.sg-wins-val { font-weight:700; color:#b9fbc0; }

/* =========================================================
   ЭКРАН РЕЖИМА
   ========================================================= */
.sg-screen { padding:16px; }
.sg-screen--mode h2 { color:#fff; font-size:16px; font-weight:600; margin-bottom:14px; text-align:center; }
.sg-mode-cards { display:flex; gap:12px; margin-bottom:12px; }
.sg-mode-card {
    flex:1; background:linear-gradient(145deg,#111827,#1e293b);
    border:1px solid #2a3a60; border-radius:18px;
    padding:14px 10px; text-align:center; position:relative; overflow:hidden;
}
.sg-mode-card--prize { border-color:var(--sg-accent); box-shadow:0 0 16px var(--sg-glow); }
.sg-mode-badge {
    position:absolute; top:0; left:0; right:0;
    background:linear-gradient(135deg,#f0c040,#e0a020);
    color:#1a1a2e; font-size:9px; font-weight:800;
    padding:3px; letter-spacing:1px;
}
.sg-mode-icon { font-size:32px; margin:14px 0 8px; }
.sg-mode-card:first-child .sg-mode-icon { margin-top:0; }
.sg-mode-title { font-size:14px; font-weight:700; color:#fff; margin-bottom:5px; }
.sg-mode-desc { font-size:11px; color:#7e90b0; line-height:1.5; margin-bottom:12px; }
.sg-mode-desc strong { color:#f0c040; }
.sg-mode-btn {
    width:100%; padding:9px; border-radius:50px;
    border:1px solid #3a5080; background:transparent;
    color:#fff; font-size:12px; font-weight:600;
    cursor:pointer; -webkit-tap-highlight-color:transparent;
    touch-action:manipulation; min-height:40px; transition:all .15s;
}
.sg-mode-btn--prize {
    background:linear-gradient(135deg,#f0c040,#e0a020);
    border-color:#f0c040; color:#1a1a2e; font-weight:800;
}
.sg-mode-btn:active { transform:scale(.96); }

.sg-info-toggle {
    width:100%; background:rgba(255,255,255,.04);
    border:1px solid #2a3a60; border-radius:12px;
    color:#7e90b0; font-size:12px; padding:8px 14px;
    cursor:pointer; text-align:left;
    -webkit-tap-highlight-color:transparent;
    touch-action:manipulation; min-height:38px;
}
.sg-info-box {
    background:rgba(255,255,255,.03); border-radius:12px;
    border:1px solid #2a3a60; padding:14px; margin-top:8px;
}
.sg-info-box ul { list-style:none; padding:0; }
.sg-info-box li { font-size:12px; color:#cdd9e8; padding:4px 0; border-bottom:1px solid rgba(255,255,255,.05); line-height:1.4; }
.sg-info-box li strong { color:#f0c040; }
.sg-register-link {
    display:block; margin-top:12px;
    background:linear-gradient(135deg,#f0c040,#e0a020);
    color:#1a1a2e; font-size:13px; font-weight:800;
    padding:10px; border-radius:50px; text-decoration:none;
    text-align:center;
}

/* =========================================================
   ЭКРАН ИГРЫ
   ========================================================= */
.sg-screen--game { padding:12px 12px 8px; }
.sg-game-top {
    display:flex; align-items:center; gap:8px;
    margin-bottom:10px;
}
.sg-stat-box {
    flex:1; background:#010514; border:1px solid #2a3a60;
    border-radius:10px; padding:6px 8px; text-align:center;
}
.sg-stat-label { font-size:8px; color:#7e90b0; letter-spacing:1px; text-transform:uppercase; }
.sg-stat-val { font-size:20px; font-weight:800; color:#b9fbc0; line-height:1.1; }
.sg-level { color:var(--sg-accent) !important; }
.sg-best { color:#6c9eff !important; }

.sg-pause-btn {
    background:#1f2c46; border:1px solid #2a3a60;
    border-radius:10px; color:#fff; font-size:18px;
    min-width:42px; min-height:42px;
    cursor:pointer; -webkit-tap-highlight-color:transparent;
    touch-action:manipulation; display:flex;
    align-items:center; justify-content:center;
}
.sg-pause-btn:active { background:var(--sg-accent); }

/* Canvas */
.sg-canvas {
    display:block; margin:0 auto;
    border-radius:12px;
    box-shadow:0 0 0 2px #2a3a60, 0 0 20px rgba(0,0,0,.4);
    -webkit-user-select:none; user-select:none;
    touch-action:none;
    max-width:100%;
}

/* D-Pad */
.sg-dpad {
    display:flex; flex-direction:column;
    align-items:center; gap:4px;
    margin:12px auto 4px;
    width:fit-content;
}
.sg-dpad-row { display:flex; gap:4px; }
.sg-dpad-btn {
    background:#1f2c46; border:1px solid #2a3a60;
    border-radius:12px; color:#fff; font-size:20px;
    min-width:66px; min-height:58px;
    display:flex; align-items:center; justify-content:center;
    cursor:pointer; -webkit-tap-highlight-color:transparent;
    touch-action:manipulation; -webkit-user-select:none; user-select:none;
    transition:background .08s, transform .08s;
}
.sg-dpad-btn:active, .sg-dpad-btn.pressed {
    background:var(--sg-accent); transform:scale(.93);
}

.sg-back-btn {
    display:block; margin:8px auto 0;
    background:transparent; border:1px solid #2a3a60;
    color:#7e90b0; font-size:12px; padding:7px 20px;
    border-radius:50px; cursor:pointer; min-height:36px;
    -webkit-tap-highlight-color:transparent;
}

/* =========================================================
   ЭКРАН GAME OVER
   ========================================================= */
.sg-screen--over { text-align:center; padding:24px 16px; }
.sg-over-title { font-size:28px; font-weight:900; color:#ff6b6b; margin-bottom:16px; animation:sgPop .4s ease; }
@keyframes sgPop { from{transform:scale(.7);opacity:0} 70%{transform:scale(1.1)} to{transform:scale(1);opacity:1} }
.sg-over-score-wrap { margin-bottom:12px; }
.sg-over-score-label { font-size:11px; color:#7e90b0; letter-spacing:1px; text-transform:uppercase; }
.sg-over-score { font-size:48px; font-weight:900; color:var(--sg-accent); text-shadow:0 0 20px var(--sg-glow); line-height:1; }
.sg-over-msg { font-size:14px; color:#cdd9e8; margin:10px 0 20px; min-height:20px; }
.sg-over-btns { display:flex; gap:10px; justify-content:center; flex-wrap:wrap; }
.sg-retry-btn {
    background:linear-gradient(135deg,var(--sg-accent),#16a085);
    border:none; color:#fff; font-size:15px; font-weight:800;
    padding:12px 28px; border-radius:50px; cursor:pointer;
    min-height:48px; -webkit-tap-highlight-color:transparent;
    box-shadow:0 4px 16px var(--sg-glow); transition:transform .15s;
}
.sg-retry-btn:active { transform:scale(.96); }
.sg-over-menu-btn {
    background:transparent; border:1px solid #2a3a60; color:#7e90b0;
    font-size:13px; padding:12px 22px; border-radius:50px;
    cursor:pointer; min-height:48px; -webkit-tap-highlight-color:transparent;
}

/* =========================================================
   АДАПТИВ
   ========================================================= */
@media (min-width:481px) {
    .sg-modal { align-items:center; padding:40px 0; }
    .sg-modal-inner { border-radius:24px; border-top:2px solid var(--sg-accent); max-height:92vh; overflow-y:auto; }
    .sg-header { border-radius:24px 24px 0 0; }
}
@media (max-width:360px) {
    .sg-dpad-btn { min-width:56px; min-height:52px; font-size:18px; }
    .sg-mode-cards { flex-direction:column; }
}
