* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --text-main: #f8fafc;
    --text-soft: #cbd5e1;
    --green: #22c55e;
    --green-2: #4ade80;
    --yellow: #f59e0b;
    --red: #ef4444;
    --border: rgba(255, 255, 255, 0.14);
    --panel: rgba(8, 18, 12, 0.62);
    --panel-dark: rgba(7, 12, 22, 0.72);
    --shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
}

html, body {
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    font-family: Arial, sans-serif;
    color: var(--text-main);
    background: #0f172a;
}

.screen {
    position: fixed;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    overflow-y: auto;
    background-image: url('background.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.screen::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(7, 12, 22, 0.52);
    z-index: 0;
}

.screen > * {
    position: relative;
    z-index: 1;
}

.hidden {
    display: none !important;
}

.active {
    display: flex !important;
}

h1 {
    font-size: 24px;
    text-align: center;
    margin: 8px 0;
    text-shadow: 0 3px 8px rgba(0,0,0,0.35);
}

/* =========================
   ОБЩИЕ КНОПКИ
========================= */

button {
    font-family: inherit;
}

.main-play-button,
.secondary-btn,
.menu-btn,
.mode-btn {
    border: none;
    cursor: pointer;
    transition: transform 0.12s ease, opacity 0.12s ease;
}

.main-play-button:active,
.secondary-btn:active,
.menu-btn:active,
.mode-btn:active {
    transform: scale(0.97);
}

.main-play-button {
    min-width: 190px;
    padding: 12px 18px;
    border-radius: 16px;
    font-size: 19px;
    font-weight: 800;
    color: #052a12;
    background: linear-gradient(180deg, var(--green-2), var(--green));
    box-shadow: 0 8px 18px rgba(34,197,94,0.32);
}

.secondary-btn {
    min-width: 130px;
    padding: 9px 14px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    background: rgba(255,255,255,0.09);
    border: 1px solid var(--border);
}

.menu-btn {
    padding: 10px 8px;
    border-radius: 13px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    background: var(--panel-dark);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.mode-btn {
    min-height: 82px;
    padding: 12px 10px;
    border-radius: 16px;
    font-size: 18px;
    font-weight: 800;
    color: var(--text-main);
    background: var(--panel-dark);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

/* =========================
   HOME / MENU
========================= */

#welcome-screen {
    justify-content: space-between;
}

.top-profile-bar {
    width: 100%;
    max-width: 620px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 16px;
    background: var(--panel-dark);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.profile-left,
.profile-right {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.profile-right {
    align-items: flex-end;
}

#player-name,
#player-rank,
#soft-balance,
#token-balance {
    font-size: 12px;
    font-weight: 700;
}

.home-center {
    width: 100%;
    max-width: 620px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    margin: auto 0;
    text-align: center;
}

.main-title {
    font-size: 34px;
    font-weight: 900;
}

.subtitle {
    font-size: 14px;
    color: var(--text-soft);
}

.quick-stats {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.stat-card {
    padding: 10px 8px;
    border-radius: 14px;
    background: var(--panel-dark);
    border: 1px solid var(--border);
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-label {
    display: block;
    font-size: 10px;
    color: var(--text-soft);
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-size: 17px;
    font-weight: 800;
}

.bottom-menu {
    width: 100%;
    max-width: 620px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

/* =========================
   MODE SELECT
========================= */

#game-choose-screen {
    justify-content: center;
    gap: 18px;
}

.mode-grid {
    width: 100%;
    max-width: 620px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

/* =========================
   GAME SCREEN — КОМПАКТНЫЙ HUD
========================= */

#game-container {
    justify-content: flex-start;
    gap: 6px;
    background-image: url('grass-background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    padding: 8px;
}

#game-container::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(8, 18, 8, 0.16);
    z-index: 0;
}

/* верхняя строка очки / время */
.run-top-bar {
    width: 100%;
    max-width: 720px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.run-stat-big {
    padding: 7px 8px;
    border-radius: 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    text-align: center;
    backdrop-filter: blur(6px);
}

.run-label {
    display: block;
    font-size: 9px;
    line-height: 1;
    color: var(--text-soft);
    margin-bottom: 2px;
    text-transform: uppercase;
}

.run-value {
    display: block;
    font-size: 14px;
    line-height: 1.15;
    font-weight: 900;
}

/* средняя строка комбо / точность / сложность / рекорд */
.run-mid-bar {
    width: 100%;
    max-width: 720px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.mini-stat {
    padding: 6px 6px;
    border-radius: 11px;
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    text-align: center;
    backdrop-filter: blur(6px);
}

.mini-label {
    display: block;
    font-size: 8px;
    line-height: 1;
    color: var(--text-soft);
    margin-bottom: 2px;
    text-transform: uppercase;
}

#combo,
#accuracy,
#difficulty,
#best-score {
    font-size: 12px;
    font-weight: 800;
    line-height: 1.1;
}

/* статус награды */
.reward-status-wrap {
    width: 100%;
    max-width: 720px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.reward-status {
    width: 100%;
    padding: 7px 9px;
    border-radius: 11px;
    text-align: center;
    font-size: 11px;
    line-height: 1.2;
    font-weight: 700;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(6px);
}

.reward-status.neutral {
    background: rgba(100,116,139,0.34);
}

.reward-status.good {
    background: rgba(34,197,94,0.25);
    border-color: rgba(34,197,94,0.55);
}

.reward-status.bad {
    background: rgba(245,158,11,0.28);
    border-color: rgba(245,158,11,0.5);
}

.progress-container {
    width: 100%;
    height: 7px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255,255,255,0.14);
    border: 1px solid rgba(255,255,255,0.08);
}

.progress-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--yellow), var(--red));
    transition: width 0.25s linear;
}

/* игровое поле */
#lunki-field {
    width: 100%;
    max-width: 720px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 7px;
    padding: 7px;
    border-radius: 18px;
    background: rgba(12, 40, 18, 0.10);
    backdrop-filter: blur(2px);
    margin-top: 2px;
}

.lunka {
    position: relative;
    aspect-ratio: 1 / 1;
    min-height: 62px;
    border-radius: 12px;
    overflow: hidden;
    background-image: url('lunka.png');
    background-size: contain;
    background-position: center bottom;
    background-repeat: no-repeat;
    background-color: transparent;
    border: none;
    box-shadow: none;
}

.krot-appeared {
    position: absolute;
    width: 78%;
    height: 78%;
    left: 11%;
    bottom: -82%;
    transition: bottom 0.16s ease, transform 0.16s ease;
    pointer-events: none;
    object-fit: contain;
    z-index: 2;
    filter: drop-shadow(0 5px 7px rgba(0,0,0,0.35));
}

.krot-appeared.show {
    bottom: 9%;
}

.hit-face {
    transform: scale(0.9) rotate(180deg);
}

/* низ во время игры */
.run-bottom-bar {
    width: 100%;
    max-width: 720px;
    margin-top: 0;
}

.bottom-info {
    width: 100%;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 9px;
    border-radius: 11px;
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    font-size: 11px;
    font-weight: 700;
    backdrop-filter: blur(6px);
}

/* =========================
   END SCREEN
========================= */

#end-screen {
    justify-content: center;
}

.result-card {
    width: 100%;
    max-width: 620px;
    padding: 16px 14px;
    border-radius: 20px;
    background: var(--panel-dark);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.result-item {
    padding: 10px 8px;
    border-radius: 13px;
    background: rgba(255,255,255,0.07);
    border: 1px solid var(--border);
    text-align: center;
}

.result-label {
    display: block;
    font-size: 10px;
    color: var(--text-soft);
    margin-bottom: 4px;
}

.result-value {
    display: block;
    font-size: 18px;
    font-weight: 900;
}

.qualification-status {
    padding: 9px 10px;
    border-radius: 12px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    border: 1px solid var(--border);
}

.qualification-status.neutral {
    background: rgba(100,116,139,0.25);
}

.qualification-status.good {
    background: rgba(34,197,94,0.25);
    border-color: rgba(34,197,94,0.55);
}

.qualification-status.bad {
    background: rgba(239,68,68,0.24);
    border-color: rgba(239,68,68,0.5);
}

.server-result-text {
    text-align: center;
    font-size: 12px;
    color: var(--text-soft);
    line-height: 1.35;
}

.result-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* =========================
   ВСПОМОГАТЕЛЬНЫЕ ЭКРАНЫ
========================= */

#tasks-screen,
#friends-screen,
#inventory-screen,
#shop-screen,
#wallet-screen {
    justify-content: center;
    gap: 14px;
}

.panel-box {
    width: 100%;
    max-width: 620px;
    min-height: 120px;
    padding: 16px;
    border-radius: 18px;
    background: var(--panel-dark);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-soft);
    font-size: 14px;
}

/* =========================
   TOAST
========================= */

.toast {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    background: rgba(15,23,42,0.96);
    color: #fff;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    z-index: 9999;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    max-width: calc(100% - 24px);
    text-align: center;
}

/* =========================
   ADAPTIVE
========================= */

@media (max-height: 900px) {
    #game-container {
        gap: 5px;
        padding: 7px;
    }

    .run-stat-big {
        padding: 6px 8px;
    }

    .mini-stat {
        padding: 5px 5px;
    }

    .reward-status {
        padding: 6px 8px;
        font-size: 10px;
    }

    .progress-container {
        height: 6px;
    }

    #lunki-field {
        gap: 6px;
        padding: 6px;
        max-width: 680px;
    }

    .lunka {
        min-height: 56px;
    }

    .bottom-info {
        padding: 6px 8px;
        font-size: 10px;
    }
}

@media (max-width: 768px) {
    .screen {
        padding: 8px;
    }

    .main-title {
        font-size: 30px;
    }

    .quick-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .bottom-menu {
        grid-template-columns: repeat(2, 1fr);
    }

    .mode-grid {
        grid-template-columns: 1fr;
    }

    .run-top-bar {
        grid-template-columns: repeat(2, 1fr);
    }

    .run-mid-bar {
        grid-template-columns: repeat(4, 1fr);
    }

    .run-value {
        font-size: 13px;
    }

    #combo,
    #accuracy,
    #difficulty,
    #best-score {
        font-size: 10px;
    }

    #lunki-field {
        grid-template-columns: repeat(5, 1fr);
        gap: 5px;
        padding: 5px;
    }

    .lunka {
        min-height: 48px;
    }

    .bottom-info {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 4px;
    }
}

@media (max-width: 480px) {
    .top-profile-bar {
        padding: 8px 9px;
    }

    #player-name,
    #player-rank,
    #soft-balance,
    #token-balance {
        font-size: 11px;
    }

    .main-title {
        font-size: 28px;
    }

    .main-play-button {
        width: 100%;
        max-width: 260px;
        font-size: 18px;
        padding: 12px 16px;
    }

    .menu-btn {
        font-size: 12px;
        padding: 9px 6px;
    }

    .run-label,
    .mini-label {
        font-size: 7px;
    }

    .run-value {
        font-size: 12px;
    }

    #combo,
    #accuracy,
    #difficulty,
    #best-score {
        font-size: 9px;
    }

    .reward-status {
        font-size: 9px;
    }

    #lunki-field {
        gap: 4px;
        padding: 4px;
    }

    .lunka {
        min-height: 42px;
    }

    .result-grid {
        grid-template-columns: 1fr;
    }
}