* {
    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.64);
    --panel-dark: rgba(7, 12, 22, 0.72);
    --shadow: 0 6px 16px rgba(0, 0, 0, 0.24);
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    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: 8px;
    overflow: hidden;
    background-image: url('background.jpg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
}

.screen::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(7, 12, 22, 0.45);
    z-index: 0;
}

.screen > * {
    position: relative;
    z-index: 1;
}

.hidden {
    display: none !important;
}

.active {
    display: flex !important;
}

h1 {
    font-size: 22px;
    line-height: 1.15;
    text-align: center;
    margin: 6px 0;
    text-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
}

button {
    font-family: inherit;
}

/* BUTTONS */
.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: 180px;
    padding: 11px 18px;
    border-radius: 15px;
    font-size: 18px;
    font-weight: 800;
    color: #052a12;
    background: linear-gradient(180deg, var(--green-2), var(--green));
    box-shadow: 0 7px 16px rgba(34, 197, 94, 0.30);
}

.secondary-btn {
    min-width: 120px;
    padding: 8px 13px;
    border-radius: 11px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.09);
    border: 1px solid var(--border);
}

.menu-btn {
    padding: 9px 7px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-main);
    background: var(--panel-dark);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.mode-btn {
    min-height: 76px;
    padding: 10px 8px;
    border-radius: 15px;
    font-size: 17px;
    font-weight: 800;
    color: var(--text-main);
    background: var(--panel-dark);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

/* HOME SCREEN */
#welcome-screen {
    justify-content: space-between;
}

.top-profile-bar {
    width: 100%;
    max-width: 560px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 14px;
    background: var(--panel-dark);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.profile-left,
.profile-right {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.profile-right {
    align-items: flex-end;
}

#player-name,
#player-rank,
#soft-balance,
#token-balance {
    font-size: 11px;
    font-weight: 700;
}

.home-center {
    width: 100%;
    max-width: 560px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin: auto 0;
    text-align: center;
}

.main-title {
    font-size: 30px;
    font-weight: 900;
}

.subtitle {
    font-size: 13px;
    color: var(--text-soft);
}

.quick-stats {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.stat-card {
    padding: 8px 6px;
    border-radius: 12px;
    background: var(--panel-dark);
    border: 1px solid var(--border);
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-label {
    display: block;
    font-size: 9px;
    color: var(--text-soft);
    margin-bottom: 3px;
}

.stat-value {
    display: block;
    font-size: 15px;
    font-weight: 800;
}

.bottom-menu {
    width: 100%;
    max-width: 560px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

/* MODE SELECT */
#game-choose-screen {
    justify-content: center;
    gap: 14px;
}

.mode-grid {
    width: 100%;
    max-width: 560px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

/* GAME SCREEN CLEAN VERSION */
#game-container {
    height: 100dvh;
    max-height: 100dvh;
    padding: 6px;
    gap: 6px;
    overflow: hidden;
    justify-content: flex-start;
    background-image: url('grass-background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

#game-container::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(8, 18, 8, 0.10);
    z-index: 0;
}

#game-top-line,
#game-bottom-line {
    width: 100%;
    max-width: 430px;
    min-height: 28px;
    height: 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    border-radius: 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(4px);
    z-index: 2;
}

#game-top-line span,
#game-bottom-line span {
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}

/* Hidden game data nodes used by game.js */
#difficulty,
#best-score,
#reward-status,
#daily-best-run,
#daily-rank-run,
#game-container .progress-container {
    display: none !important;
}

/* Game field */
#lunki-field {
    width: 100%;
    max-width: 430px;
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    margin: 0;
    border-radius: 14px;
    background: rgba(12, 40, 18, 0.06);
    overflow: hidden;
    z-index: 2;
}

.lunka {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    border-radius: 8px;
    background-image: url('lunka.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-color: transparent;
    border: none;
    box-shadow: none;
}

.krot-appeared {
    position: absolute;
    width: 82%;
    height: 82%;
    left: 9%;
    bottom: -82%;
    transition: bottom 0.10s ease;
    pointer-events: none;
    object-fit: contain;
    z-index: 2;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
}

.krot-appeared.show {
    bottom: 7%;
}

/* If old HUD remains in HTML, hide it */
.run-top-bar,
.run-mid-bar,
.reward-status-wrap,
.run-bottom-bar {
    display: none !important;
}

/* END SCREEN */
#end-screen {
    justify-content: center;
}

.result-card {
    width: 100%;
    max-width: 560px;
    padding: 14px 12px;
    border-radius: 18px;
    background: var(--panel-dark);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 7px;
}

.result-item {
    padding: 8px 6px;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--border);
    text-align: center;
}

.result-label {
    display: block;
    font-size: 9px;
    color: var(--text-soft);
    margin-bottom: 3px;
}

.result-value {
    display: block;
    font-size: 16px;
    font-weight: 900;
}

.qualification-status {
    padding: 8px 9px;
    border-radius: 11px;
    text-align: center;
    font-size: 12px;
    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: 11px;
    color: var(--text-soft);
    line-height: 1.3;
}

.result-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

/* AUX SCREENS */
#tasks-screen,
#friends-screen,
#inventory-screen,
#shop-screen,
#wallet-screen {
    justify-content: center;
    gap: 12px;
}

.panel-box {
    width: 100%;
    max-width: 560px;
    min-height: 110px;
    padding: 14px;
    border-radius: 16px;
    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: 13px;
}

/* TOAST */
.toast {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.96);
    color: #fff;
    padding: 9px 12px;
    border-radius: 11px;
    font-size: 12px;
    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-width: 768px) {
    .screen {
        padding: 7px;
    }

    .main-title {
        font-size: 28px;
    }

    .quick-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 5px;
    }

    .bottom-menu {
        grid-template-columns: repeat(2, 1fr);
    }

    .mode-grid {
        grid-template-columns: 1fr;
    }

    #game-top-line,
    #game-bottom-line,
    #lunki-field {
        max-width: 390px;
    }

    #game-top-line,
    #game-bottom-line {
        min-height: 26px;
        height: 26px;
    }

    #game-top-line span,
    #game-bottom-line span {
        font-size: 11px;
    }

    #lunki-field {
        gap: 3px;
        padding: 3px;
    }
}

@media (max-width: 420px) {
    .top-profile-bar {
        padding: 7px 8px;
    }

    #player-name,
    #player-rank,
    #soft-balance,
    #token-balance {
        font-size: 10px;
    }

    .main-title {
        font-size: 26px;
    }

    .main-play-button {
        width: 100%;
        max-width: 250px;
        font-size: 17px;
        padding: 10px 14px;
    }

    .menu-btn {
        font-size: 11px;
        padding: 8px 5px;
    }

    #game-top-line,
    #game-bottom-line {
        min-height: 24px;
        height: 24px;
    }

    #game-top-line span,
    #game-bottom-line span {
        font-size: 10px;
    }

    .result-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-height: 760px) {
    #game-container {
        gap: 4px;
        padding: 4px;
    }

    #game-top-line,
    #game-bottom-line {
        min-height: 23px;
        height: 23px;
    }

    #game-top-line span,
    #game-bottom-line span {
        font-size: 10px;
    }

    #lunki-field {
        gap: 3px;
        padding: 3px;
    }
}
