/* ===== Сброс и базовые стили ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
}

/* ===== Контейнер игры ===== */
#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    overflow: hidden;
    background: #000;
    touch-action: none;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* ===== Оверлеи (меню / game over) ===== */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10;
    transition: opacity 0.3s ease;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    color: #fff;
    padding: 2rem;
    max-width: 90%;
}

/* ===== Заголовки ===== */
.game-title {
    font-size: clamp(3rem, 10vw, 5.5rem);
    font-weight: 900;
    letter-spacing: 0.3em;
    margin-bottom: 0.3em;
    color: #7dd3fc;
    text-shadow:
        0 0 20px rgba(125, 211, 252, 0.6),
        0 0 40px rgba(125, 211, 252, 0.3),
        0 4px 8px rgba(0, 0, 0, 0.8);
}

.game-subtitle {
    font-size: clamp(0.9rem, 3vw, 1.3rem);
    letter-spacing: 0.15em;
    color: #cbd5e1;
    margin-bottom: 2rem;
    text-transform: uppercase;
}

.game-over-title {
    font-size: clamp(3.5rem, 12vw, 6rem);
    font-weight: 900;
    color: #fbbf24;
    text-shadow:
        0 0 25px rgba(251, 191, 36, 0.6),
        0 4px 8px rgba(0, 0, 0, 0.8);
    margin-bottom: 0.2em;
}

.game-over-subtitle {
    font-size: clamp(0.85rem, 2.5vw, 1.1rem);
    color: #94a3b8;
    margin-bottom: 1.8rem;
    letter-spacing: 0.1em;
}

/* ===== Табло со счётом ===== */
.best-score-display,
.score-board {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(125, 211, 252, 0.3);
    border-radius: 12px;
    padding: 1rem 2rem;
    margin-bottom: 1.8rem;
    display: inline-block;
}

.score-board {
    display: flex;
    gap: 2.5rem;
    padding: 1.2rem 2.5rem;
}

.score-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.label {
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    color: #94a3b8;
    font-weight: 700;
}

.value {
    font-size: 2rem;
    font-weight: 900;
    color: #7dd3fc;
}

.score-row:last-child .value {
    color: #fbbf24;
}

.new-record {
    color: #fbbf24;
    font-weight: 800;
    letter-spacing: 0.15em;
    margin-bottom: 1.2rem;
    font-size: 1rem;
    animation: pulse 1s ease-in-out infinite;
}

.new-record.hidden {
    display: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.08); }
}

/* ===== Подсказка ===== */
.hint {
    color: #cbd5e1;
    font-size: clamp(0.8rem, 2.5vw, 1rem);
    margin-bottom: 1.8rem;
    letter-spacing: 0.05em;
}

.hint kbd {
    display: inline-block;
    background: rgba(125, 211, 252, 0.15);
    border: 1px solid rgba(125, 211, 252, 0.4);
    border-radius: 5px;
    padding: 0.15em 0.5em;
    font-size: 0.9em;
    font-family: monospace;
    color: #7dd3fc;
}

/* ===== Кнопка ===== */
.btn {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 0.9rem 2.8rem;
    font-size: clamp(0.9rem, 3vw, 1.1rem);
    font-weight: 800;
    letter-spacing: 0.15em;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow:
        0 4px 15px rgba(14, 165, 233, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow:
        0 6px 20px rgba(14, 165, 233, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn:active {
    transform: translateY(0);
}

/* ===== HUD: счёт во время игры ===== */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    padding-top: 1.5rem;
    z-index: 5;
    pointer-events: none;
}

#hud.hidden {
    display: none;
}

#score-display {
    font-size: clamp(3rem, 8vw, 5rem);
    font-weight: 900;
    color: #fff;
    text-shadow:
        0 0 15px rgba(0, 0, 0, 0.8),
        0 2px 4px rgba(0, 0, 0, 0.9),
        -2px -2px 0 rgba(0, 0, 0, 0.5),
        2px -2px 0 rgba(0, 0, 0, 0.5),
        -2px 2px 0 rgba(0, 0, 0, 0.5),
        2px 2px 0 rgba(0, 0, 0, 0.5);
    transition: transform 0.15s ease;
}

#score-display.bump {
    transform: scale(1.25);
}

/* ===== Кнопка звука ===== */
.sound-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.sound-toggle:hover {
    background: rgba(0, 0, 0, 0.6);
}

.sound-toggle:active {
    transform: scale(0.92);
}

/* ===== Лидерборд ===== */
.leaderboard {
    margin-top: 1.5rem;
    text-align: left;
}

.leaderboard.hidden {
    display: none;
}

.leaderboard-title {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: #fbbf24;
    margin-bottom: 0.8rem;
    text-align: center;
}

.leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 200px;
    overflow-y: auto;
}

.leaderboard-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.85rem;
}

/* ТОП-10: компактная ссылка в правом нижнем углу */
.top10-link {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    user-select: none;
    z-index: 15;
    letter-spacing: 0.08em;
    transition: color 0.2s ease;
}

.top10-link:hover {
    color: rgba(255, 255, 255, 0.85);
}

/* Оверлей лидерборда */
.leaderboard-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.leaderboard-overlay.hidden {
    display: none;
}

.leaderboard-panel {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 1.8rem 2rem;
    min-width: 280px;
    max-width: 360px;
    text-align: center;
}

.leaderboard-panel-title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: #fbbf24;
    margin-bottom: 1rem;
}

.leaderboard-panel-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1.2rem;
    text-align: left;
}

.leaderboard-panel-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.85rem;
}

.leaderboard-panel-list li:last-child {
    border-bottom: none;
}

.leaderboard-panel-list .lb-rank {
    color: #64748b;
    width: 1.6rem;
    flex-shrink: 0;
}

.leaderboard-panel-list .lb-name {
    color: #cbd5e1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin: 0 0.6rem;
}

.leaderboard-panel-list .lb-score {
    color: #7dd3fc;
    font-weight: 700;
    flex-shrink: 0;
}

.leaderboard-panel .btn {
    margin-top: 0.5rem;
}

.leaderboard-list li:last-child {
    border-bottom: none;
}

/* ===== Блок ввода имени ===== */
.name-input-block {
    margin-top: 1.2rem;
    text-align: center;
}

.name-input-block.hidden {
    display: none;
}

.name-input-hint {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 0.6rem;
    letter-spacing: 0.05em;
}

.name-input-row {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
}

.player-name-input {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(125, 211, 252, 0.4);
    border-radius: 8px;
    padding: 0.6rem 1rem;
    color: #fff;
    font-size: 0.9rem;
    font-family: inherit;
    width: 180px;
    outline: none;
    transition: border-color 0.2s ease;
}

.player-name-input:focus {
    border-color: #7dd3fc;
}

.player-name-input::placeholder {
    color: #64748b;
}

.btn-small {
    padding: 0.6rem 1.2rem;
    font-size: 0.8rem;
}
