/* =====================================================
   2048 GAME — Las Casas  |  Mobile-first
===================================================== */

/* ----- Кнопка открытия ----- */
.t48-open-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #f67c5f, #f9a825);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(246,124,95,.4);
    touch-action: manipulation;
    letter-spacing: .03em;
}
.t48-open-btn:active { transform: scale(.97); }

/* ----- Modal ----- */
.t48-modal {
    position: fixed;
    inset: 0;
    z-index: 99990;
    background: rgba(0,0,0,.88);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.t48-modal-inner {
    width: 100%;
    max-width: 420px;
    min-height: 100dvh;
    background: #faf8ef;
    display: flex;
    flex-direction: column;
}

/* Themes */
.t48-modal[data-theme="teal"]   .t48-tile[data-val="2048"] { background: #009688; color:#fff; }
.t48-modal[data-theme="purple"] .t48-header                 { background: #6a1b9a; }
.t48-modal[data-theme="dark"]   .t48-modal-inner            { background: #1a1a1a; }
.t48-modal[data-theme="dark"]   .t48-cell-bg                { background: #3a3a3a; }
.t48-modal[data-theme="dark"]   .t48-board                  { background: #2a2a2a; }
.t48-modal[data-theme="dark"]   .t48-logo span,
.t48-modal[data-theme="dark"]   .t48-hint                   { color: #ccc; }

/* ----- Header ----- */
.t48-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #bbada0;
    position: sticky;
    top: 0;
    z-index: 10;
}
.t48-logo {
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
}
.t48-logo span { color: #f9f6f2; }
.t48-scores {
    display: flex;
    gap: 6px;
    flex: 1;
    justify-content: center;
}
.t48-score-box {
    background: #bbada0;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 6px;
    padding: 4px 12px;
    text-align: center;
    min-width: 64px;
}
.t48-score-label { font-size: 10px; color: #eee4da; font-weight: 700; letter-spacing: .05em; }
.t48-score-val   { font-size: 18px; font-weight: 700; color: #fff; line-height: 1.2; }
.t48-close {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,.4);
    background: transparent;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    touch-action: manipulation;
}
.t48-close:active { background: rgba(255,255,255,.2); }

/* ----- Ticker ----- */
.t48-ticker {
    height: 36px;
    overflow: hidden;
    background: #cdc1b4;
    border-bottom: 1px solid #bbada0;
}
.t48-ticker-track {
    display: flex;
    align-items: center;
    white-space: nowrap;
    animation: t48-scroll 30s linear infinite;
}
.t48-ticker-track:hover { animation-play-state: paused; }
@keyframes t48-scroll {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}
.t48-ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 18px;
    text-decoration: none;
    color: #776e65;
    font-size: 12px;
    height: 36px;
    border-right: 1px solid #bbada0;
    transition: color .2s;
}
.t48-ticker-item:hover { color: #f65e3b; }
.t48-ticker-item img {
    width: 22px; height: 22px;
    border-radius: 4px;
    object-fit: cover;
}
.t48-ticker-name  { font-weight: 600; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.t48-ticker-price { color: #f65e3b; font-weight: 700; }

/* ----- Game area ----- */
.t48-game {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 12px;
    position: relative;
}
.t48-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 360px;
    margin-bottom: 8px;
}
.t48-new-btn {
    padding: 8px 14px;
    background: #8f7a66;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
}
.t48-new-btn:active { transform: scale(.96); }
.t48-hint { font-size: 12px; color: #776e65; }

/* ----- Board ----- */
.t48-board {
    position: relative;
    background: #bbada0;
    border-radius: 10px;
    padding: 8px;
    width: min(360px, calc(100vw - 24px));
    aspect-ratio: 1/1;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.t48-grid-bg {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
    height: 100%;
}
.t48-cell-bg {
    background: rgba(238,228,218,.35);
    border-radius: 6px;
}
.t48-tiles {
    position: absolute;
    inset: 8px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    pointer-events: none;
}

/* ----- Tiles ----- */
.t48-tile {
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: clamp(14px, 5vw, 28px);
    transition: transform .1s;
    position: relative;
    will-change: transform;
}

/* Цвета плиток */
.t48-tile[data-val="2"]    { background: #eee4da; color: #776e65; }
.t48-tile[data-val="4"]    { background: #ede0c8; color: #776e65; }
.t48-tile[data-val="8"]    { background: #f2b179; color: #f9f6f2; }
.t48-tile[data-val="16"]   { background: #f59563; color: #f9f6f2; }
.t48-tile[data-val="32"]   { background: #f67c5f; color: #f9f6f2; }
.t48-tile[data-val="64"]   { background: #f65e3b; color: #f9f6f2; }
.t48-tile[data-val="128"]  { background: #edcf72; color: #f9f6f2; font-size: clamp(12px,4vw,24px); }
.t48-tile[data-val="256"]  { background: #edcc61; color: #f9f6f2; font-size: clamp(12px,4vw,24px); }
.t48-tile[data-val="512"]  { background: #edc850; color: #f9f6f2; font-size: clamp(12px,4vw,24px); }
.t48-tile[data-val="1024"] { background: #edc53f; color: #f9f6f2; font-size: clamp(10px,3.5vw,20px); }
.t48-tile[data-val="2048"] { background: #edc22e; color: #f9f6f2; font-size: clamp(10px,3.5vw,20px); box-shadow: 0 0 20px rgba(237,194,46,.8); }
.t48-tile[data-val="4096"] { background: #3c3a32; color: #f9f6f2; font-size: clamp(10px,3.5vw,18px); }
.t48-tile[data-val="8192"] { background: #3c3a32; color: #f9f6f2; font-size: clamp(9px,3vw,16px); }

/* Анимации */
@keyframes t48-appear {
    0%   { transform: scale(0); opacity: 0; }
    60%  { transform: scale(1.12); }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes t48-merge {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.2); }
    100% { transform: scale(1); }
}
.t48-tile--new   { animation: t48-appear .15s ease-out; }
.t48-tile--merge { animation: t48-merge .18s ease-out; }

/* ----- Game over overlay ----- */
.t48-over {
    position: absolute;
    inset: 0;
    background: rgba(250,248,239,.85);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}
.t48-over-content { text-align: center; padding: 16px; }
.t48-over-icon  { font-size: 48px; }
.t48-over-title { font-size: 22px; font-weight: 800; color: #776e65; margin: 8px 0 4px; }
.t48-over-score { font-size: 15px; color: #f65e3b; font-weight: 700; margin-bottom: 14px; }
.t48-retry {
    padding: 12px 24px;
    background: #8f7a66;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
}
.t48-retry:active { transform: scale(.97); }

/* ----- Ad block ----- */
.t48-ad-block {
    border-top: 1px solid #d4c5b5;
    background: #eee4da;
    min-height: 64px;
    flex-shrink: 0;
}
.t48-ad-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    text-decoration: none;
    color: inherit;
}
.t48-ad-link:active { background: rgba(0,0,0,.05); }
.t48-ad-img {
    width: 52px; height: 52px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}
.t48-ad-body  { flex: 1; }
.t48-ad-badge { font-size: 10px; color: #a09080; text-transform: uppercase; letter-spacing: .05em; }
.t48-ad-title { font-size: 13px; color: #776e65; font-weight: 700; line-height: 1.3; }
.t48-ad-label { font-size: 12px; color: #f65e3b; font-weight: 700; margin-top: 2px; }
.t48-ad-placeholder {
    padding: 18px 12px;
    text-align: center;
    font-size: 12px;
    color: #a09080;
    font-style: italic;
}
