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

/* ----- Кнопка открытия ----- */
.wg-open-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #538d4e;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: .03em;
    box-shadow: 0 2px 8px rgba(83,141,78,.4);
    touch-action: manipulation;
}
.wg-open-btn:active { transform: scale(.97); }

/* ----- Modal overlay ----- */
.wg-modal {
    position: fixed;
    inset: 0;
    z-index: 99990;
    background: rgba(0,0,0,.85);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.wg-modal-inner {
    width: 100%;
    max-width: 420px;
    min-height: 100dvh;
    background: #121213;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ----- Themes ----- */
.wg-modal[data-theme="blue"]   .wg-tile[data-state="correct"],
.wg-modal[data-theme="blue"]   .wg-key[data-state="correct"] { background: #1565c0; }
.wg-modal[data-theme="purple"] .wg-tile[data-state="correct"],
.wg-modal[data-theme="purple"] .wg-key[data-state="correct"] { background: #6a1b9a; }
.wg-modal[data-theme="dark"]   .wg-modal-inner                { background: #000; }

/* ----- Header ----- */
.wg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid #3a3a3c;
    background: #121213;
    position: sticky;
    top: 0;
    z-index: 10;
}
.wg-logo {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    letter-spacing: .05em;
}
.wg-logo span { color: #538d4e; }
.wg-header-right { display: flex; gap: 8px; }
.wg-help-btn, .wg-close {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: 1px solid #3a3a3c;
    background: transparent;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    touch-action: manipulation;
}
.wg-help-btn:active, .wg-close:active { background: #3a3a3c; }

/* ----- Ticker ----- */
.wg-ticker {
    height: 36px;
    overflow: hidden;
    background: #1a1a1b;
    border-bottom: 1px solid #3a3a3c;
    position: relative;
}
.wg-ticker-track {
    display: flex;
    align-items: center;
    gap: 0;
    white-space: nowrap;
    animation: wg-ticker-scroll 30s linear infinite;
    will-change: transform;
}
.wg-ticker-track:hover { animation-play-state: paused; }
@keyframes wg-ticker-scroll {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}
.wg-ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 20px;
    text-decoration: none;
    color: #b0b0b0;
    font-size: 12px;
    height: 36px;
    transition: color .2s;
    border-right: 1px solid #3a3a3c;
}
.wg-ticker-item:hover { color: #538d4e; }
.wg-ticker-item img {
    width: 24px; height: 24px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}
.wg-ticker-name  { font-weight: 500; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.wg-ticker-price { color: #538d4e; font-weight: 600; }

/* ----- Screens ----- */
.wg-screen { flex: 1; display: flex; flex-direction: column; padding: 12px 14px; }

/* ----- Help screen ----- */
.wg-help-content { max-width: 320px; margin: 0 auto; padding: 10px 0; }
.wg-help-content h2 { color: #fff; font-size: 18px; margin-bottom: 16px; text-align: center; }
.wg-help-content ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.wg-help-content li { color: #d7dadc; font-size: 14px; display: flex; align-items: center; gap: 10px; }
.wg-ex {
    width: 32px; height: 32px;
    border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px; color: #fff;
    flex-shrink: 0;
}
.wg-ex--correct  { background: #538d4e; }
.wg-ex--present  { background: #b59f3b; }
.wg-ex--absent   { background: #3a3a3c; }
.wg-help-close {
    display: block; width: 100%; margin-top: 20px;
    padding: 14px; background: #538d4e; color: #fff;
    border: none; border-radius: 8px; font-size: 15px;
    font-weight: 600; cursor: pointer; touch-action: manipulation;
}

/* ----- Game screen ----- */
.wg-screen--game {
    align-items: center;
    justify-content: space-between;
    padding-bottom: 8px;
}

/* Grid */
.wg-grid {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin: 8px 0;
}
.wg-row {
    display: flex;
    gap: 5px;
}
.wg-tile {
    width: 52px; height: 52px;
    border: 2px solid #3a3a3c;
    border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 700; color: #fff;
    text-transform: uppercase;
    transition: border-color .1s;
    user-select: none;
    -webkit-user-select: none;
}
@media (max-width: 360px) {
    .wg-tile { width: 46px; height: 46px; font-size: 19px; }
}
.wg-tile[data-letter] { border-color: #565758; }
.wg-tile[data-state="tbd"]     { border-color: #999; background: #121213; }
.wg-tile[data-state="correct"] { background: #538d4e; border-color: #538d4e; color: #fff; }
.wg-tile[data-state="present"] { background: #b59f3b; border-color: #b59f3b; color: #fff; }
.wg-tile[data-state="absent"]  { background: #3a3a3c; border-color: #3a3a3c; color: #fff; }

/* Pop animation */
@keyframes wg-pop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.12); }
    100% { transform: scale(1); }
}
.wg-tile--pop { animation: wg-pop .1s ease-in-out; }

/* Flip animation */
@keyframes wg-flip-in  { 0% { transform: rotateX(0); }   50% { transform: rotateX(-90deg); } 100% { transform: rotateX(-90deg); } }
@keyframes wg-flip-out { 0% { transform: rotateX(-90deg); } 50% { transform: rotateX(0); } 100% { transform: rotateX(0); } }
.wg-tile--flip-in  { animation: wg-flip-in  .25s ease-in forwards; }
.wg-tile--flip-out { animation: wg-flip-out .25s ease-out forwards; }

/* Shake */
@keyframes wg-shake {
    0%,100% { transform: translateX(0); }
    20%,60% { transform: translateX(-4px); }
    40%,80% { transform: translateX(4px); }
}
.wg-row--shake { animation: wg-shake .4s ease; }

/* Bounce win */
@keyframes wg-bounce {
    0%,100% { transform: translateY(0); }
    40%     { transform: translateY(-12px); }
}
.wg-tile--bounce { animation: wg-bounce .6s ease forwards; }

/* Mensaje */
.wg-message {
    min-height: 28px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: rgba(83,141,78,.15);
    border-radius: 6px;
    padding: 4px 8px;
    transition: opacity .3s;
}
.wg-message:empty { background: transparent; }

/* Keyboard */
.wg-keyboard {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}
.wg-kb-row {
    display: flex;
    justify-content: center;
    gap: 5px;
}
.wg-key {
    height: 56px;
    min-width: 32px;
    flex: 1;
    max-width: 42px;
    border: none;
    border-radius: 6px;
    background: #818384;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    transition: background .15s;
    -webkit-tap-highlight-color: transparent;
}
.wg-key--enter, .wg-key--del {
    min-width: 50px;
    max-width: 56px;
    font-size: 16px;
}
.wg-key:active                  { transform: scale(.95); }
.wg-key[data-state="correct"]   { background: #538d4e; }
.wg-key[data-state="present"]   { background: #b59f3b; }
.wg-key[data-state="absent"]    { background: #3a3a3c; }

/* ----- Result screen ----- */
.wg-screen--result {
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 10px;
}
.wg-result-icon  { font-size: 52px; }
.wg-result-title { font-size: 22px; font-weight: 700; color: #fff; }
.wg-result-word  { font-size: 18px; color: #538d4e; font-weight: 600; letter-spacing: .1em; }
.wg-result-stats { font-size: 13px; color: #818384; }
.wg-play-again {
    margin-top: 10px;
    padding: 14px 28px;
    background: #538d4e;
    color: #fff;
    border: none; border-radius: 8px;
    font-size: 15px; font-weight: 600;
    cursor: pointer; touch-action: manipulation;
}
.wg-play-again:active { transform: scale(.97); }

/* ----- Ad block ----- */
.wg-ad-block {
    border-top: 1px solid #3a3a3c;
    background: #1a1a1b;
    min-height: 64px;
    flex-shrink: 0;
}
.wg-ad-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    text-decoration: none;
    color: inherit;
}
.wg-ad-link:active { background: rgba(255,255,255,.05); }
.wg-ad-img {
    width: 52px; height: 52px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}
.wg-ad-body  { flex: 1; }
.wg-ad-badge { font-size: 10px; color: #818384; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
.wg-ad-title { font-size: 13px; color: #d7dadc; font-weight: 600; line-height: 1.3; }
.wg-ad-label { font-size: 12px; color: #538d4e; font-weight: 600; margin-top: 2px; }
.wg-ad-placeholder {
    padding: 18px 14px;
    text-align: center;
    font-size: 12px;
    color: #565758;
    font-style: italic;
}
