:root {
    --bg: #0f0f10;
    --text: #f3f3f5;
    --muted: #a7a7b2;
    --accent: #6d4bd6;
    --accent-2: #8b6cff;
    --border: rgba(255, 255, 255, 0.08);
    --danger: #ff7d7d;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    min-height: 100vh;
    background: radial-gradient(circle at top, #1a1a26 0%, var(--bg) 55%);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

h1 {
    margin: 0;
    font-size: 44px;
    letter-spacing: 1px;
    line-height: 1;
}

.subtitle {
    margin: 6px 0 0;
    color: var(--muted);
}

.page {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 18px 16px 22px;
}

/* Cards and buttons */
.card {
    background: rgba(23, 23, 26, 0.92);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

button {
    border: 0;
    border-radius: 999px;
    padding: 14px 22px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

    button:hover {
        transform: translateY(-1px);
    }

    button:disabled {
        opacity: 0.55;
        cursor: not-allowed;
        transform: none;
    }

/* Game layout */
.game-page {
    height: 100svh;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.status-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(72px, auto));
    gap: 8px;
}

.status-item,
.timer-box {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 12px;
    text-align: center;
    min-width: 84px;
}

.status-label {
    display: block;
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 3px;
}

.status-value {
    font-size: 16px;
    font-weight: 700;
}

#timer {
    font-size: 18px;
    font-weight: 700;
}

    #timer.urgent {
        color: #ff7070;
    }

/* Solved groups */
.solved-list {
    display: grid;
    gap: 10px;
    flex-shrink: 0;
    max-height: 34svh;
    overflow: auto;
    padding-right: 2px;
}

.solved-group {
    background: #d8dce3;
    color: #121212;
    border-radius: 16px;
    padding: 14px 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.14);
    animation: slideIn 0.25s ease-out;
}

    .solved-group strong {
        display: block;
        margin-bottom: 4px;
        font-size: 13px;
        letter-spacing: 0.03em;
        text-transform: uppercase;
    }

.solved-group {
    font-size: 14px;
    line-height: 1.35;
}

/* Word grid */
.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    align-content: start;
}

.word {
    background: linear-gradient(180deg, #2b2231 0%, #231b28 100%);
    border: 1px solid var(--border);
    border-radius: 16px;
    min-height: 72px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, opacity 0.2s ease;
}

    .word:hover {
        transform: translateY(-1px);
    }

    .word.selected {
        background: linear-gradient(180deg, #35507a 0%, #263b5f 100%);
        border-color: rgba(255, 255, 255, 0.22);
    }

    .word.wrong {
        background: linear-gradient(180deg, #8a3434 0%, #662828 100%) !important;
    }

    .word.almost {
        background: linear-gradient(180deg, #8e7925 0%, #6a5a1a 100%) !important;
    }

    .word.removing {
        opacity: 0;
        transform: scale(0.72);
    }

/* Bottom actions */
.bottom {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding-top: 8px;
    padding-bottom: env(safe-area-inset-bottom);
}

.message {
    min-height: 18px;
    margin: 0;
    font-weight: 700;
    font-size: 14px;
    text-align: center;
}

.guess-btn,
.next-btn {
    width: min(520px, 100%);
    min-height: 52px;
    font-size: 18px;
}

.next-btn {
    background: linear-gradient(135deg, #7d57ea, #8b6cff);
}

/* Animations */
@keyframes slideIn {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.shake {
    animation: shake 0.32s ease-in-out;
}

@keyframes shake {
    0% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-5px);
    }

    40% {
        transform: translateX(5px);
    }

    60% {
        transform: translateX(-4px);
    }

    80% {
        transform: translateX(4px);
    }

    100% {
        transform: translateX(0);
    }
}

/* Mobile */
@media (max-width: 700px) {
    .page {
        padding: 10px 8px 12px;
    }

    .game-page {
        gap: 8px;
    }

    h1 {
        font-size: 30px;
    }

    .subtitle {
        font-size: 14px;
    }

    .topbar {
        flex-direction: column;
        gap: 8px;
    }

    .header-left {
        gap: 10px;
    }

    .status-panel {
        grid-template-columns: repeat(3, 1fr);
        width: 100%;
        gap: 8px;
    }

    .status-item,
    .timer-box {
        min-width: 0;
        padding: 7px 8px;
        border-radius: 12px;
    }

    .status-label {
        font-size: 10px;
    }

    .status-value {
        font-size: 14px;
    }

    #timer {
        font-size: 16px;
    }

    .solved-list {
        max-height: 31svh;
        gap: 8px;
    }

    .solved-group {
        padding: 12px 14px;
        border-radius: 14px;
        font-size: 13px;
    }

        .solved-group strong {
            font-size: 11px;
        }

    .grid {
        gap: 8px;
    }

    .word {
        min-height: 58px;
        padding: 10px 12px;
        font-size: 13px;
        border-radius: 14px;
    }

    .guess-btn,
    .next-btn {
        min-height: 48px;
        font-size: 16px;
        width: 100%;
    }

    .message {
        font-size: 13px;
    }
}
.step-title {
    text-align: center;
    font-weight: 700;
    margin-bottom: 10px;
}

.team-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.team-btn {
    padding: 18px;
    font-size: 18px;
    border-radius: 16px;
}

.code-display {
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    letter-spacing: 10px;
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 10px;
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.key {
    min-height: 52px;
    font-size: 18px;
    border-radius: 14px;
}

    .key.ghost {
        background: rgba(255,255,255,0.08);
    }

.login-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.secondary {
    background: rgba(255,255,255,0.08);
}

.login-container {
    min-height: 100vh;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 18px 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-brand {
    width: 100%;
    margin: 0 0 2px;
}

.login-card.keypad-card {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 18px;
    display: grid;
    gap: 14px;
}

.login-step[hidden] {
    display: none !important;
}

.step-title {
    margin: 0 0 10px;
    text-align: center;
    font-weight: 700;
    font-size: 16px;
}

.team-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.team-btn {
    min-height: 60px;
    padding: 16px 14px;
    font-size: 18px;
    border-radius: 16px;
}

.code-display {
    min-height: 64px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: #101014;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 10px;
    margin-bottom: 10px;
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.key {
    min-height: 56px;
    border-radius: 16px;
    font-size: 18px;
}

    .key.ghost {
        background: rgba(255, 255, 255, 0.08);
    }

.login-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 2px;
}

    .login-actions button {
        min-height: 52px;
    }

.secondary {
    background: rgba(255, 255, 255, 0.08);
}

@media (max-width: 700px) {
    .solved-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        max-height: none;
        overflow: visible;
        margin-bottom: 6px;
    }

    .solved-group {
        padding: 8px 10px;
        border-radius: 12px;
        font-size: 10px;
        line-height: 1.15;
        white-space: normal;
    }

        .solved-group strong {
            font-size: 9px;
            margin-bottom: 2px;
        }

    .solved-words {
        font-size: 10px;
        line-height: 1.15;
        word-break: break-word;
    }

    .grid {
        margin-top: 4px;
    }

    .bottom {
        margin-top: 4px;
    }
}
