* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #eaeaea;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

header { text-align: center; margin-bottom: 20px; }

h1 {
    font-size: 2.2rem;
    margin-bottom: 6px;
    background: linear-gradient(90deg, #f7b733, #fc4a1a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle { color: #9aa0b5; font-size: 0.95rem; }

.game-wrapper {
    background: #0f1626;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    max-width: 860px;
    width: 100%;
}

.hud {
    display: flex;
    justify-content: space-around;
    margin-bottom: 12px;
    padding: 10px;
    background: #1a2340;
    border-radius: 10px;
}

.hud-item { text-align: center; }

.hud-label {
    display: block;
    font-size: 0.75rem;
    color: #7a8bb0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.hud-value {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: #f7b733;
    margin-top: 2px;
}

.canvas-wrap {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #2a3557;
}

canvas {
    display: block;
    width: 100%;
    height: auto;
    background: #87ceeb;
}

/* ---------- Оверлей авторизации ---------- */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 30, 0.85);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.35s ease, visibility 0.35s ease;
    padding: 20px;
}
.overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.auth-modal {
    background: #ffffff;
    color: #1a1a2e;
    border-radius: 14px;
    padding: 20px 24px 18px;
    width: min(380px, 92%);
    max-height: 96%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: modalIn 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0;
}
@keyframes modalIn {
    from { transform: translateY(20px) scale(0.96); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}

.auth-header { text-align: center; margin-bottom: 12px; }

.auth-logo {
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    line-height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f7b733, #fc4a1a);
    margin: 0 auto 8px;
}

.auth-header h2 {
    font-size: 1.15rem;
    color: #1a1a2e;
    margin-bottom: 2px;
}

.auth-subtitle { color: #6b7280; font-size: 0.78rem; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }

.auth-field { display: flex; flex-direction: column; gap: 3px; }

.auth-field span {
    font-size: 0.72rem;
    color: #4b5563;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.auth-field input {
    padding: 8px 10px;
    border: 1.5px solid #d1d5db;
    border-radius: 7px;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}
.auth-field input:focus {
    outline: none;
    border-color: #f7b733;
    box-shadow: 0 0 0 3px rgba(247,183,51,0.15);
}

/* Капча */
.auth-captcha { display: flex; gap: 6px; align-items: stretch; }

.captcha-box {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f3f4f6;
    border: 1.5px dashed #9ca3af;
    border-radius: 7px;
    padding: 6px 10px;
}

.captcha-question { font-size: 0.85rem; color: #1f2937; }

.captcha-box input {
    width: 50px;
    padding: 5px 6px;
    border: 1.5px solid #d1d5db;
    border-radius: 5px;
    font-size: 0.9rem;
    text-align: center;
}

.captcha-refresh {
    background: #f3f4f6;
    border: 1.5px solid #d1d5db;
    border-radius: 7px;
    padding: 0 12px;
    font-size: 1.05rem;
    color: #4b5563;
    cursor: pointer;
    transition: background 0.2s;
}
.captcha-refresh:hover { background: #e5e7eb; }

/* Ошибка */
.auth-error {
    color: #dc2626;
    font-size: 0.85rem;
    min-height: 18px;
    display: none;
    padding: 6px 10px;
    background: #fef2f2;
    border-radius: 6px;
    border-left: 3px solid #dc2626;
}

.auth-error.visible { display: block; }

/* Кнопки */
.btn-primary, .btn-secondary {
    padding: 9px 14px;
    border-radius: 7px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
    font-family: inherit;
}
.btn-primary {
    background: linear-gradient(90deg, #f7b733, #fc4a1a);
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(247,183,51,0.4);
}

.btn-secondary {
    background: #f3f4f6;
    color: #1f2937;
    border: 1.5px solid #d1d5db;
}

.btn-secondary:hover {
    background: #e5e7eb;
    transform: translateY(-1px);
}

/* Разделитель */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #9ca3af;
    font-size: 0.72rem;
    margin: 2px 0;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e5e7eb;
}

.auth-footer {
    text-align: center;
    font-size: 0.68rem;
    color: #9ca3af;
    margin-top: 10px;
}
.auth-footer a { color: #f7b733; text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

/* Управление игрой */
.controls { margin-top: 14px; text-align: center; }

.controls button {
    background: linear-gradient(90deg, #f7b733, #fc4a1a);
    border: none;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    padding: 12px 32px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.controls button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(247,183,51,0.4);
}

.hint { color: #7a8bb0; font-size: 0.85rem; margin-top: 8px; }

footer {
    margin-top: 30px;
    color: #56618a;
    font-size: 0.85rem;
}

@media (max-width: 600px) {
    h1 { font-size: 1.4rem; }
    .subtitle { font-size: 0.85rem; }
    .hud-value { font-size: 1.1rem; }
    .hud { padding: 8px; margin-bottom: 8px; }
    .game-wrapper { padding: 12px; }

    .auth-modal {
        padding: 16px 18px 14px;
        width: 94%;
        border-radius: 12px;
    }

    .auth-logo {
        width: 38px;
        height: 38px;
        line-height: 38px;
        font-size: 1.2rem;
        margin-bottom: 6px;
    }

    .auth-header h2 { font-size: 1rem; }
    .auth-subtitle { font-size: 0.72rem; }

    .auth-form { gap: 8px; }

    .auth-field input {
        padding: 7px 9px;
        font-size: 0.85rem;
    }

    .captcha-box { padding: 5px 8px; }
    .captcha-question { font-size: 0.78rem; }
    .captcha-box input { width: 42px; padding: 4px; font-size: 0.85rem; }

    .btn-primary, .btn-secondary {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .auth-footer { font-size: 0.62rem; margin-top: 8px; }
}

@media (max-height: 700px) {
    header { margin-bottom: 10px; }
    h1 { font-size: 1.5rem; }
    .subtitle { display: none; }

    .auth-modal { padding: 14px 18px 12px; }
    .auth-header { margin-bottom: 8px; }
    .auth-logo { width: 36px; height: 36px; line-height: 36px; font-size: 1.1rem; margin-bottom: 4px; }
    .auth-header h2 { font-size: 1rem; }
    .auth-subtitle { display: none; }
    .auth-form { gap: 7px; }
    .auth-field input { padding: 6px 9px; font-size: 0.85rem; }
    .btn-primary, .btn-secondary { padding: 7px 12px; font-size: 0.85rem; }
    .auth-divider { margin: 0; }
    .auth-footer { display: none; }
}
/* ---------- Выбор игры ---------- */
.game-select {
    padding: 10px 0 4px;
    text-align: center;
}

.select-title {
    font-size: 1.5rem;
    color: #f7b733;
    margin-bottom: 4px;
}

.select-subtitle {
    color: #9aa0b5;
    font-size: 0.9rem;
    margin-bottom: 22px;
}

.game-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.game-card {
    background: #1a2340;
    border: 2px solid #2a3557;
    border-radius: 14px;
    padding: 20px 16px;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    text-align: center;
    color: #eaeaea;
    font-family: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.game-card:hover {
    transform: translateY(-4px);
    border-color: #f7b733;
    box-shadow: 0 12px 30px rgba(247,183,51,0.25);
}

.card-preview {
    font-size: 3rem;
    width: 80px;
    height: 80px;
    line-height: 80px;
    border-radius: 50%;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-wolf  { background: linear-gradient(135deg, #4a4f5c, #6b7080); }
.card-robot { background: linear-gradient(135deg, #1e88e5, #42a5f5); }
.card-bot   { background: linear-gradient(135deg, #f7931a, #ffb84d); }

.game-card h3 {
    font-size: 1rem;
    color: #fff;
    margin-bottom: 2px;
}

.game-card p {
    font-size: 0.8rem;
    color: #9aa0b5;
    line-height: 1.35;
    margin-bottom: 8px;
}

.card-play {
    font-size: 0.85rem;
    font-weight: 700;
    color: #f7b733;
    margin-top: auto;
}

.back-btn {
    background: transparent;
    border: 1.5px solid #2a3557;
    color: #9aa0b5;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    margin-bottom: 12px;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    font-family: inherit;
}

.back-btn:hover {
    background: #1a2340;
    color: #f7b733;
    border-color: #f7b733;
}

@media (max-width: 700px) {
    .game-cards { grid-template-columns: 1fr; }
    .card-preview { width: 60px; height: 60px; line-height: 60px; font-size: 2.2rem; }
    .select-title { font-size: 1.25rem; }
    .select-subtitle { font-size: 0.8rem; }
}
