:root {
    --bg: #0b0f1f;
    --card: #141a2e;
    --text: #f5f7ff;
    --muted: #a4abc2;
    --primary: #8b5cf6; /* violet */
    --primary-700: #7c3aed;
    --secondary: #2a3050;
    --danger: #ff6b6b;
    --border: #2a3153;
    --accent-1: #06b6d4; /* cyan */
    --accent-2: #22c55e; /* green */
    --accent-3: #f59e0b; /* amber */
    --success: #22c55e;
    --success-700: #16a34a;
    --danger-strong: #ef4444;
    --shadow-strong: 0 20px 60px rgba(0,0,0,0.55);
    --shadow-card: 0 10px 30px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.03);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    /* Более светлый анимированный фон */
    background: radial-gradient(1400px 800px at 85% -200px, #25305c 0%, #0f1731 60%) fixed;
    color: var(--text);
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-image:
        radial-gradient(1000px 600px at -10% 0%, rgba(59,130,246,0.18), rgba(0,0,0,0) 60%),
        radial-gradient(900px 600px at 110% 10%, rgba(16,185,129,0.16), rgba(0,0,0,0) 60%),
        radial-gradient(700px 500px at 50% 110%, rgba(139,92,246,0.16), rgba(0,0,0,0) 60%),
        conic-gradient(from 180deg at 50% 50%, rgba(255,255,255,0.04), rgba(255,255,255,0) 25%, rgba(255,255,255,0.04) 50%, rgba(255,255,255,0) 75%, rgba(255,255,255,0.04) 100%);
    animation: bgFloat 16s ease-in-out infinite alternate, bgSheen 22s linear infinite;
    -webkit-tap-highlight-color: transparent;
}

.container {
    width: 100%;
    max-width: 1040px;
    margin: 0 auto;
    padding: 24px;
    flex: 1 1 auto;
}

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    padding: 0 24px;
    border-bottom: 1px solid rgba(42, 49, 83, 0.8);
    background:
        linear-gradient(180deg, rgba(12,14,27,0.85) 0%, rgba(12,14,27,0.55) 100%),
        radial-gradient(600px 80px at 20% -20px, rgba(139,92,246,0.20), rgba(0,0,0,0) 60%),
        radial-gradient(400px 60px at 80% -30px, rgba(6,182,212,0.20), rgba(0,0,0,0) 60%);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 10;
    padding-top: max(0px, env(safe-area-inset-top));
}

.brand {
    background: linear-gradient(90deg, #8b5cf6 0%, #06b6d4 50%, #22c55e 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-decoration: none;
    font-weight: 700;
    letter-spacing: 0.3px;
    font-size: 16px;
}

.nav-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.nav-user {
    color: var(--muted);
    font-size: 14px;
    margin-right: 8px;
}

.footer {
    display: none;
}
.footer-inner {
    max-width: 1040px;
    margin: 0 auto;
    color: var(--muted);
    font-size: 14px;
}

/* Профиль: улучшенная кнопка в шапке */
.btn-profile {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.10) 0%, rgba(255,255,255,0.02) 40%),
        linear-gradient(90deg, #60a5fa 0%, #a78bfa 50%, #34d399 100%);
    border-color: rgba(255,255,255,0.28);
    border-radius: 999px;
    padding-inline: 18px;
    box-shadow: 0 10px 26px rgba(96,165,250,0.25);
}
.btn-profile:hover {
    filter: brightness(1.06);
    box-shadow: 0 14px 34px rgba(96,165,250,0.35);
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 20, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}
.modal {
    width: 100%;
    max-width: 520px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 30%),
        var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-strong);
    overflow: hidden;
}
.modal-header, .modal-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.modal-footer {
    border-top: 1px solid var(--border);
    border-bottom: none;
}
.modal-title {
    font-weight: 700;
}
.modal-close {
    margin-left: auto;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    border-radius: 8px;
    width: 36px;
    height: 32px;
    cursor: pointer;
}
.modal-body {
    padding: 16px;
}

/* Wheel modal */
.wheel-canvas-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 8px 0;
}
.wheel-canvas-wrap canvas {
    border-radius: 50%;
    box-shadow: 0 18px 60px rgba(0,0,0,0.45), inset 0 2px 0 rgba(255,255,255,0.06);
    background:
        radial-gradient(180px 180px at 50% 40%, rgba(255,255,255,0.04), rgba(0,0,0,0) 60%);
}
.wheel-pointer {
    position: absolute;
    top: 0;
    bottom: auto;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 16px solid #fff;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
    z-index: 3;
    pointer-events: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 10px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0) 30%) ,
        var(--secondary);
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    border: 1px solid var(--border);
    min-height: 44px; /* удобные тапы на мобильных */
    transition: transform 0.12s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 0 rgba(0,0,0,0.15);
}
.btn:hover {
    transform: translateY(-1px);
    background: #343957;
    border-color: #303556;
    box-shadow: 0 8px 22px rgba(124, 92, 255, 0.15);
}
.btn:active {
    transform: translateY(0px);
}
.btn-primary {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0) 30%),
        linear-gradient(90deg, var(--primary) 0%, var(--accent-1) 50%, var(--accent-2) 100%);
    border-color: #5b3fff;
    box-shadow: 0 10px 28px rgba(139,92,246,0.28), inset 0 1px 0 rgba(255,255,255,0.12);
}
.btn-primary:hover {
    filter: brightness(1.05);
}
.btn-secondary {
    background: transparent;
    border-color: var(--border);
}

/* Мягкие цветные кнопки */
.btn-success {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 30%),
        rgba(34,197,94,0.16);
    border-color: rgba(34,197,94,0.38);
    color: var(--text);
    box-shadow: 0 2px 0 rgba(0,0,0,0.12);
}
.btn-success:hover {
    border-color: rgba(34,197,94,0.52);
    box-shadow: 0 10px 26px rgba(34,197,94,0.18);
    filter: none;
}
.btn-danger {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 30%),
        rgba(239,68,68,0.16);
    border-color: rgba(239,68,68,0.38);
    color: var(--text);
    box-shadow: 0 2px 0 rgba(0,0,0,0.12);
}
.btn-danger:hover {
    border-color: rgba(239,68,68,0.52);
    box-shadow: 0 10px 26px rgba(239,68,68,0.18);
    filter: none;
}

/* Bigger answer buttons for game */
#btn-yes, #btn-no {
    font-size: 18px;
    padding: 16px 24px;
    min-height: 56px;
    min-width: 160px;
    border-radius: 14px;
}
@media (max-width: 560px) {
    #btn-yes, #btn-no {
        width: 100%;
        min-width: 0;
    }
}

/* Centered turn title for clarity */
#turn-title {
    text-align: center;
    letter-spacing: 0.5px;
}

.auth-card {
    max-width: 420px;
    margin: 48px auto;
    background:
        linear-gradient(180deg, rgba(124, 92, 255, 0.10) 0%, rgba(124, 92, 255, 0) 30%),
        radial-gradient(800px 200px at 20% -40px, rgba(6,182,212,0.18), rgba(0,0,0,0) 60%),
        var(--card);
    padding: 24px;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card);
}
.auth-card h1 {
    margin: 0 0 16px 0;
    font-size: clamp(20px, 2.5vw, 24px);
}

.form {
    display: grid;
    gap: 14px;
}
.form-field {
    display: grid;
    gap: 6px;
}
.form-field span {
    color: var(--muted);
    font-size: 13px;
}
.form input {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0) 30%),
        #0f1329;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 12px;
    border-radius: 10px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form input:focus {
    border-color: #545b92;
    box-shadow: 0 0 0 4px rgba(124,92,255,0.18);
}

.alert {
    background: rgba(255, 107, 107, 0.12);
    border: 1px solid rgba(255, 107, 107, 0.5);
    color: #ffb3b3;
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 12px;
}

.muted {
    color: var(--muted);
}

.grid {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}
@media (max-width: 860px) {
    .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
    }
}
@media (max-width: 560px) {
    .grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

.card {
    position: relative;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0) 30%),
        var(--card);
    border: 1px solid rgba(42,49,83,0.9);
    border-radius: 14px;
    padding: 18px;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: var(--shadow-card);
    overflow: hidden;
}
.card.enabled {
    text-decoration: none;
    color: var(--text);
    transition: transform 0.12s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.card.enabled:hover {
    transform: translateY(-2px);
    border-color: #4a5290;
    box-shadow: 0 16px 40px rgba(139,92,246,0.2);
}
.card.disabled {
    opacity: 0.65;
}
.card-title {
    font-weight: 700;
    font-size: 18px;
}
.card-desc {
    color: var(--muted);
    font-size: 14px;
}

.game {
    max-width: 760px;
    margin: 24px auto;
}
.game-card {
    margin: 16px 0 20px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 30%),
        var(--card);
    border: 1px solid rgba(42,49,83,0.9);
    border-radius: 14px;
    padding: 16px;
    box-shadow: var(--shadow-card);
}

h1 {
    margin: 0 0 12px 0;
    line-height: 1.2;
}

/* Фокус для клавиатуры/мобильных */
:where(a, button, input):focus-visible {
    outline: none;
    box-shadow:
        0 0 0 3px rgba(255,255,255,0.08),
        0 0 0 6px rgba(124,92,255,0.28);
}

/* Список игроков и статусы */
.players-list {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}
.player-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0) 30%),
        #14182b;
}
.player-name {
    font-weight: 600;
}
.player-name .color-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    border: 1px solid var(--border);
    vertical-align: middle;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    border: 1px solid var(--border);
    background: #0f1329;
    color: var(--muted);
}
.chip-ready {
    background: rgba(34,197,94,0.14);
    border-color: rgba(34,197,94,0.35);
    color: #b9f4c9;
}
.chip-answering {
    background: rgba(124,92,255,0.14);
    border-color: rgba(124,92,255,0.35);
    color: #d6cdff;
}
.chip-waiting {
    background: rgba(59,66,109,0.20);
    border-color: rgba(59,66,109,0.35);
    color: #b7bfd9;
}
.chip-danger {
    background: rgba(239,68,68,0.14);
    border-color: rgba(239,68,68,0.35);
    color: #ffb3b3;
}

/* Анимация фона */
@keyframes bgFloat {
    0% {
        background-position:
            0px 0px,
            0px 0px,
            0px 0px,
            0px 0px;
    }
    100% {
        background-position:
            0px 0px,
            -60px 10px,
            60px -10px,
            0px 0px;
    }
}
@keyframes bgSheen {
    0% { background-position: 0 0, 0 0, 0 0, 0 0; }
    100% { background-position: 0 0, 0 0, 0 0, 360deg 0; }
}

/* Мобильные доработки */
@media (max-width: 560px) {
    .container {
        padding: 18px;
    }
    .nav {
        height: 56px;
        padding: 0 16px;
    }
    .brand {
        font-size: 15px;
    }
    .auth-card {
        margin: 28px auto;
        padding: 18px;
    }
    .btn {
        width: 100%;
    }
}

/* Уважение настроек пользователя */
@media (prefers-reduced-motion: reduce) {
    body {
        animation: none;
    }
    .btn, .card.enabled {
        transition: none;
    }
}

