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

html {
    color-scheme: dark;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #1A1A1A;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: #FFFFFF;
    -webkit-font-smoothing: antialiased;
}

button {
    font-family: inherit;
}

.container {
    background: #1A1A1A;
    border: 1px solid #2E2E2E;
    border-radius: 16px;
    padding: 40px;
    max-width: 600px;
    width: 100%;
}

h2 {
    text-align: center;
    color: #B5B5B5;
    margin-bottom: 24px;
    font-size: 16px;
    font-weight: 500;
}

.hidden {
    display: none !important;
}

/* --- Выбор позиции --- */
.position-select {
    text-align: center;
}

.position-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.general-test-btn {
    display: block;
    width: 100%;
    margin-bottom: 10px;
    background: #FFFFFF;
    color: #1A1A1A;
    border: none;
    padding: 20px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}

.general-test-btn:hover {
    background: #E6E6E6;
}

.general-test-btn:active {
    transform: scale(0.98);
}

.position-btn {
    background: #FFFFFF;
    color: #1A1A1A;
    border: none;
    padding: 20px;
    font-size: 16px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}

.position-btn:hover {
    background: #E6E6E6;
}

.position-btn:active {
    transform: scale(0.98);
}

/* --- Выбор режима --- */
.mode-select {
    text-align: center;
}

.mode-position-label {
    font-size: 14px;
    font-weight: 400;
    color: #8A8A8A;
    margin-bottom: 24px;
}

.mode-position-label span {
    font-weight: 600;
    color: #FFFFFF;
}

.mode-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
}

.mode-btn {
    flex: 1;
    background: #242424;
    color: #FFFFFF;
    border: 1px solid #2E2E2E;
    padding: 32px 20px;
    font-size: 18px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.mode-btn:hover {
    background: #2E2E2E;
    border-color: #3A3A3A;
}

.mode-btn:active {
    transform: scale(0.99);
}

/* --- Тренировка --- */
.training-area {
    text-align: center;
}

.stats {
    margin-bottom: 20px;
}

.stats-row {
    display: flex;
    gap: 8px;
}

.stats-row + .stats-row {
    margin-top: 8px;
}

.stat {
    flex: 1;
    background: #242424;
    padding: 12px;
    border-radius: 8px;
}

.stat-label {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: #8A8A8A;
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-size: 18px;
    font-weight: 600;
    color: #FFFFFF;
    font-variant-numeric: tabular-nums;
}

/* --- Покерный стол --- */
.poker-table-wrapper {
    position: relative;
    width: 100%;
    max-width: 480px;
    aspect-ratio: 1.3 / 1;
    margin: 28px auto 36px;
}

.table-rail {
    position: absolute;
    left: 5%;
    right: 5%;
    top: 20%;
    bottom: 26%;
    background: #FFFFFF;
    border-radius: 999px;
}

.table-felt {
    position: absolute;
    inset: 10px;
    background: #2E7D4F;
    border-radius: 999px;
    box-shadow: inset 0 0 0 9px rgba(255, 255, 255, 0.10);
}

/* Кружки позиций */
.seat-circle {
    position: absolute;
    width: 52px;
    height: 52px;
    transform: translate(-50%, -50%);
    background: #1A1A1A;
    border: 1px solid #3A3A3A;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #FFFFFF;
    z-index: 3;
}

.seat-circle.seat-circle-hero {
    width: 80px;
    height: 80px;
    font-size: 18px;
    font-weight: 700;
    z-index: 4;
}

.seat-0 { left: 50%; top: 81%; }
.seat-1 { left: 25%; top: 80%; }
.seat-2 { left: 7%;  top: 47%; }
.seat-3 { left: 25%; top: 14%; }
.seat-4 { left: 50%; top: 14%; }
.seat-5 { left: 75%; top: 14%; }
.seat-6 { left: 93%; top: 47%; }
.seat-7 { left: 75%; top: 80%; }

/* Рубашки карт — за кружками, торчат сверху */
.card-peek {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    gap: 3px;
    z-index: 1;
}

.card-peek-0 { left: 50%; top: 77%; display: none; }
.card-peek-1 { left: 25%; top: 75%; }
.card-peek-2 { left: 7%; top: 43%; }
.card-peek-3 { left: 25%; top: 10%; }
.card-peek-4 { left: 50%; top: 10%; }
.card-peek-5 { left: 75%; top: 10%; }
.card-peek-6 { left: 93%; top: 43%; }
.card-peek-7 { left: 75%; top: 75%; }

.mini-cardback {
    width: 35px;
    height: 50px;
    background: #939393;
    border: 3px solid #ebebeb;
    border-radius: 4px;
}

/* Фишки дилера / блайндов — на сукне, ближе к центру */
.chip-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.chip-marker-0 { left: 50%; top: 68%; }
.chip-marker-1 { left: 30%; top: 64%; }
.chip-marker-2 { left: 20%; top: 46%; }
.chip-marker-3 { left: 30%; top: 30%; }
.chip-marker-4 { left: 50%; top: 30%; }
.chip-marker-5 { left: 70%; top: 30%; }
.chip-marker-6 { left: 80%; top: 46%; }
.chip-marker-7 { left: 70%; top: 64%; }

.chip-group {
    position: relative;
    width: 26px;
    height: 20px;
}

.chip {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5);
}

.chip-group .chip-single {
    left: 6px;
    top: 3px;
}

.chip-group .chip-a {
    left: 1px;
    top: 2px;
    z-index: 1;
}

.chip-group .chip-b {
    left: 10px;
    top: 6px;
    z-index: 2;
}

.dealer-chip {
    background: #FFFFFF;
    border: 1px solid #BFBFBF;
}

.blind-chip {
    background: #B3261E;
    border: 1px solid #8A1C16;
}

/* --- Карты игрока (HTML/CSS) --- */
.hand-display {
    position: relative;
    margin: 24px 0;
}

.hand {
    display: inline-flex;
    gap: 16px;
    min-height: 80px;
    align-items: center;
    justify-content: center;
}

.card-display {
    display: flex;
    gap: 16px;
    justify-content: center;
    align-items: center;
}

/* Фон карты (цвет масти) задаётся inline-стилем из JS */
.card {
    width: 130px;
    aspect-ratio: 2 / 3;
    border-radius: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
}

.card:hover {
    transform: translateY(-4px);
}

.card-rank {
    font-weight: 400;
    font-size: 88px;
    letter-spacing: -2px;
    line-height: 1;
    color: #FFFFFF;
    user-select: none;
}

.card-rank.is-two-digit {
    font-size: 68px;
}

.feedback {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.96);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 14px 26px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.feedback.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.feedback.correct {
    background: #17361F;
    color: #7FD9A0;
}

.feedback.wrong {
    background: #3D1B18;
    color: #FF9A90;
}

.feedback .feedback-hint {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: none;
    opacity: 0.75;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
}

.action-btn {
    flex: 1;
    padding: 22px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}

.fold-btn {
    background: #FFFFFF;
    color: #1A1A1A;
}

.fold-btn:hover {
    background: #E6E6E6;
}

.raise-btn {
    background: #FFFFFF;
    color: #1A1A1A;
}

.raise-btn:hover {
    background: #E6E6E6;
}

.retry-btn {
    background: #FFFFFF;
    color: #1A1A1A;
}

.retry-btn:hover {
    background: #E6E6E6;
}

.action-btn:active {
    transform: scale(0.99);
}

.action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.back-btn {
    background: transparent;
    border: 1px solid #3A3A3A;
    color: #A0A0A0;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.back-btn:hover {
    background: #242424;
    color: #FFFFFF;
    border-color: #555555;
}

/* --- Результаты --- */
.results-area {
    text-align: center;
}

.final-time-line {
    text-align: center;
    font-size: 14px;
    font-weight: 400;
    color: #8A8A8A;
    margin-bottom: 16px;
}

.final-time {
    font-weight: 600;
    color: #FFFFFF;
}

.final-accuracy {
    margin: 24px 0;
    padding: 24px;
    background: #242424;
    border-radius: 12px;
}

.final-accuracy .label {
    display: block;
    font-size: 13px;
    font-weight: 400;
    color: #8A8A8A;
    margin-bottom: 8px;
}

.final-accuracy .value {
    display: block;
    font-size: 64px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: #FFFFFF;
}

.mistakes-section {
    margin: 32px 0;
    text-align: left;
}

.mistakes-section h3 {
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 16px;
    color: #8A8A8A;
}

.mistakes-list {
    list-style: none;
    padding: 0;
    max-height: 320px;
    overflow-y: auto;
}

.mistakes-list li {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px;
    margin-bottom: 6px;
    background: #1A1A1A;
    border: 1px solid #2E2E2E;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 400;
    color: #BDBDBD;
}

.mini-hand {
    display: inline-flex;
    gap: 4px;
    vertical-align: middle;
    margin-right: 10px;
}

.card.mini {
    width: 40px;
    border-radius: 10px;
}

.card.mini:hover {
    transform: none;
}

.card.mini .card-rank {
    font-size: 20px;
    letter-spacing: 0;
}

.card.mini .card-rank.is-two-digit {
    font-size: 15px;
}

.mistake-pos {
    background: #2E2E2E;
    color: #FFFFFF;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    margin-right: 6px;
}

.player-action {
    color: #6A6A6A;
    text-decoration: line-through;
    font-weight: 500;
}

.correct-action {
    color: #FFFFFF;
    font-weight: 600;
}

.no-mistakes {
    padding: 24px;
    background: #242424;
    color: #FFFFFF;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
}

.results-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 24px;
}

/* --- Таблица лидеров --- */
.leaderboard-btn {
    width: 100%;
    margin-top: 12px;
    background: transparent;
    border: 1px solid #3A3A3A;
    color: #A0A0A0;
    padding: 14px 24px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.leaderboard-btn:hover {
    background: #242424;
    color: #FFFFFF;
    border-color: #555555;
}

.leaderboard-area {
    text-align: center;
}

.lb-mode-buttons {
    margin-bottom: 20px;
}

.lb-mode-btn {
    flex: 1;
    background: #242424;
    color: #FFFFFF;
    border: 1px solid #2E2E2E;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.lb-mode-btn:hover {
    background: #2E2E2E;
    border-color: #3A3A3A;
}

.lb-mode-btn.active {
    background: #FFFFFF;
    color: #1A1A1A;
    border-color: #FFFFFF;
}

.lb-mode-btn.active:hover {
    background: #E6E6E6;
    border-color: #E6E6E6;
}

.leaderboard-table {
    border-collapse: collapse;
    width: 100%;
    table-layout: fixed;
    font-size: 13px;
    margin-bottom: 24px;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 12px 4px;
    text-align: center;
    border-bottom: 1px solid #2E2E2E;
}

.leaderboard-table thead th {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #8A8A8A;
    border-bottom: 1px solid #2E2E2E;
}

.leaderboard-table th.col-name {
    text-align: left;
    padding-left: 12px;
    width: 28%;
}

.leaderboard-table td.col-name {
    text-align: left;
    padding-left: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #FFFFFF;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lb-value {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: #FFFFFF;
    font-variant-numeric: tabular-nums;
}

.lb-time {
    display: block;
    font-size: 10px;
    font-weight: 400;
    color: #7A7A7A;
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
}

.lb-empty .lb-value {
    color: #4A4A4A;
    font-weight: 500;
}

.leaderboard-table tbody tr:last-child td {
    border-bottom: none;
}

.leaderboard-table tbody tr:hover {
    background: #222222;
}

@media (max-width: 600px) {
    .container {
        padding: 24px;
        border: none;
    }

    h2 {
        font-size: 15px;
    }

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

    .mode-buttons {
        flex-direction: column;
    }

    .stats-row {
        flex-wrap: wrap;
    }

    .stat {
        min-width: 45%;
    }

    .card {
        width: 90px;
        border-radius: 20px;
    }

    .card-rank {
        font-size: 56px;
    }

    .card-rank.is-two-digit {
        font-size: 44px;
    }

    .card-display {
        gap: 12px;
    }

    .action-btn {
        padding: 18px;
        font-size: 15px;
    }

    .seat-circle {
        width: 40px;
        height: 40px;
        font-size: 11px;
    }

    .seat-circle.seat-circle-hero {
        width: 56px;
        height: 56px;
        font-size: 14px;
    }

    .mini-cardback {
        width: 12px;
        height: 17px;
    }

    .lb-value {
        font-size: 14px;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 10px 3px;
    }

    .leaderboard-table td.col-name {
        font-size: 13px;
    }
}