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

html {
    /* Поддержка safe area для iOS */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #626262;
    min-height: 100vh;
    color: #333;
    -webkit-overflow-scrolling: touch;
}

/* Блокируем жесты только НЕ на главной странице */
#room-screen.active ~ body,
#game-screen.active ~ body,
#error-screen.active ~ body {
    overscroll-behavior: none;
    overscroll-behavior-y: contain;
    touch-action: pan-x pan-y;
    overflow: hidden;
    height: 100%;
}

.screen {
    display: none;
    min-height: 100vh;
    padding: 0px;
}

.screen.active {
    display: block;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 0px 0px 20px 20px;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

h1 {
    text-align: center;
    color: #4c4c4c;
    margin-bottom: 40px;
    font-size: 3em;
}

h2 {
    color: #707070;
    margin-bottom: 20px;
}

h3 {
    color: #555;
    margin-bottom: 15px;
}

/* Inputs and Buttons */
input[type="text"] {
    width: 100%;
    padding: 15px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 10px;
    margin-bottom: 15px;
    transition: border-color 0.3s;
}

input[type="text"]:focus {
    outline: none;
    border-color: #1b6d3e;
}

.btn {
    padding: 12px 30px;
    font-size: 16px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.btn-primary {
    background: #27b790;
    color: white;
}

.btn-primary:hover {
    background: #5eda93;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(126, 126, 126, 0.521);
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

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

.btn:disabled:hover {
    transform: none !important;
    box-shadow: none !important;
}

.btn-primary:disabled:hover {
    background: #27b790 !important;
}

.btn-secondary:disabled:hover {
    background: #e0e0e0 !important;
}

/* Create Room Section */
#create-room-section {
    margin-bottom: 40px;
}

/* Invite Link Block */
#invite-link-block {
    margin: 15px 0;
    padding: 15px;
    background: rgba(50, 160, 130, 0.1);
    border: 1px solid rgba(50, 160, 130, 0.3);
    border-radius: 8px;
}

.invite-hint {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #6f6f6f;
    text-align: center;
}

.invite-link-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

.invite-link {
    flex: 1;
    padding: 10px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    color: #32a082;
    word-break: break-all;
    user-select: all;
}

.btn-copy, .btn-share {
    min-width: 44px;
    height: 44px;
    padding: 8px;
    font-size: 20px;
    background: #32a082;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-copy:hover, .btn-share:hover {
    background: #28866d;
    transform: scale(1.05);
}

.btn-copy:active, .btn-share:active {
    transform: scale(0.95);
}

/* Bot Game Section */
#bot-game-section {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid rgba(126, 126, 126, 0.2);
}

#bot-game-section h3 {
    margin-top: 0;
    margin-bottom: 15px;
    text-align: center;
    color: #6f6f6f;
    font-size: 1.2em;
}

.bot-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-bot {
    background: linear-gradient(135deg, #32a082 0%, #64859a 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgb(61, 61, 61);
}

.btn-bot:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(85, 85, 85, 0.904);
}

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

/* Rooms List */
#rooms-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.room-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    border: 2px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.3s;
}

.room-card:hover {
    border-color: #1b6d3e;
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(126, 126, 126, 0.2);
}

.room-card h4 {
    color: #1b6d3e;
    margin-bottom: 10px;
}

.room-card p {
    color: #666;
    margin: 5px 0;
}

.room-card.room-full {
    background: #f0f0f0;
    border-color: #ccc;
    opacity: 0.6;
    cursor: not-allowed;
}

.room-card.room-full:hover {
    transform: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #ccc;
}

.room-card.room-full h4 {
    color: #999;
}

/* Room Screen */
.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

#players-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.player-card {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    border: 2px solid #e0e0e0;
}

.player-card.ready {
    border-color: #4caf50;
    background: #e8f5e9;
}

.player-card.current {
    border-color: #1b6d3e;
    background: #e8f5e9;
    box-shadow: 0 0 20px rgba(49, 145, 91, 0.3);
}

.player-card h4 {
    margin-bottom: 5px;
}

.player-card .status {
    color: #666;
    font-size: 14px;
}

.player-card.ready .status {
    color: #4caf50;
    font-weight: 600;
}

.hint {
    color: #666;
    font-size: 14px;
    margin-top: 10px;
}

.hint-small {
    color: #888;
    font-size: 12px;
    margin-top: 5px;
    font-style: italic;
}

/* Room Settings */
#room-settings {
    background: rgba(49, 145, 91, 0.1);
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
}

/* Room Settings */
.room-settings {
    background: rgba(49, 145, 91, 0.1);
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
}

#room-settings h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 18px;
    color: #333;
}

.deck-size-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.deck-size-toggle label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.deck-label {
    font-size: 14px;
    font-weight: 600;
    color: #666;
    min-width: 60px;
    text-align: center;
}

.deck-size-toggle input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 60px;
    height: 30px;
    background: #ccc;
    border-radius: 15px;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.deck-size-toggle input[type="checkbox"]:checked + .toggle-slider {
    background: #31915b;
}

.deck-size-toggle input[type="checkbox"]:checked + .toggle-slider::before {
    transform: translateX(30px);
}

.deck-size-toggle input[type="checkbox"]:checked ~ .deck-label:last-child {
    color: #31915b;
}

.deck-size-toggle input[type="checkbox"]:not(:checked) ~ .deck-label:first-child {
    color: #31915b;
}

/* Countdown Timer */
#countdown-display {
    margin: 30px 0;
    text-align: center;
}

.countdown-timer {
    width: 150px;
    height: 150px;
    margin: 0 auto;
    border-radius: 50%;
    background: linear-gradient(135deg, #32a082 0%, #64859a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(50, 160, 130, 0.4);
    animation: pulse 1s ease-in-out infinite;
}

#countdown-number {
    font-size: 72px;
    font-weight: bold;
    color: white;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.countdown-text {
    font-size: 20px;
    font-weight: bold;
    color: #31915b;
    margin-top: 20px;
    animation: fadeInOut 1s ease-in-out infinite;
}

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

@keyframes fadeInOut {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

/* Error Screen */
.error-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #32a082 0%, #64859a 100%);
}

.error-content {
    background: white;
    padding: 60px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
}

.error-content h1 {
    font-size: 80px;
    margin-bottom: 20px;
}

.error-content h2 {
    color: #707070;
    margin-bottom: 15px;
    font-size: 28px;
}

.error-content p {
    color: #666;
    margin-bottom: 30px;
    font-size: 16px;
}

.error-content .btn {
    padding: 15px 40px;
    font-size: 18px;
}

/* Game Screen */
.game-container {
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height для мобильных */
    margin: 0;
    padding: 0;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
}

#game-screen {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Game Log */
.game-log {
    position: fixed;
    top: 20px;
    left: 20px;
    min-width: 20vw;
    max-width: 50vw;
    max-height: 40vh;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    padding: 15px;
    z-index: 1000;
    overflow: hidden;
    display: flex;
    flex-direction: column-reverse;
    gap: 5px;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.log-entry {
    color: white;
    font-size: 13px;
    line-height: 1.4;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: opacity 0.3s;
}

.log-entry:nth-child(1) {
    opacity: 1;
}

.log-entry:nth-child(2) {
    opacity: 0.95;
}

.log-entry:nth-child(3) {
    opacity: 0.9;
}

.log-entry:nth-child(4) {
    opacity: 0.85;
}

.log-entry:nth-child(5) {
    opacity: 0.8;
}

.log-entry:nth-child(6) {
    opacity: 0.75;
}

.log-entry:nth-child(7) {
    opacity: 0.7;
}

.log-entry:nth-child(8) {
    opacity: 0.65;
}

.log-entry:nth-child(9) {
    opacity: 0.6;
}

.log-entry:nth-child(10) {
    opacity: 0.55;
}

.log-entry:nth-child(n+11) {
    display: none;
}

.log-entry:last-child {
    border-bottom: none;
}

/* Уменьшение высоты game-log на маленьких экранах */
    @media (max-height: 780px) {
        .game-log {
        max-height: calc(34vh - 16px) !important;
    }
}

/* Сообщения чата - свои сообщения */
.log-entry.chat-player {
    background: rgba(49, 145, 91, 0.3);
    padding: 5px 8px;
    border-radius: 4px;
    border-left: 3px solid #31915b;
    font-weight: 600;
}

/* Сообщения чата - чужие сообщения */
.log-entry.chat-other {
    background: rgba(255, 255, 255, 0.1);
    padding: 5px 8px;
    border-radius: 4px;
    border-left: 3px solid rgba(255, 255, 255, 0.3);
}

/* Цвета для разных игроков */
.log-entry.chat-color-1 {
    background: rgba(76, 175, 80, 0.2);
    border-left-color: #4caf50;
}

.log-entry.chat-color-2 {
    background: rgba(255, 152, 0, 0.2);
    border-left-color: #ff9800;
}

.log-entry.chat-color-3 {
    background: rgba(156, 39, 176, 0.2);
    border-left-color: #9c27b0;
}

.game-log.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(100%);
}

/* Leave Game Button */
.leave-game-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: #fbcecee6;
    border: 2px solid #e74c3c;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #e74c3c;
    transition: all 0.3s;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.leave-game-btn:hover {
    background: #e74c3c;
    color: white;
    transform: scale(1.1);
}

.leave-game-btn:active {
    transform: scale(0.95);
}

/* Settings Button */
.settings-btn {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: #0c3d0ace;
    border: 2px solid #767676;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #ffffff;
    transition: all 0.3s;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.settings-btn:hover {
    background: #ebebebd7;
    color: white;
    transform: scale(1.1);
}

.settings-btn:active {
    transform: scale(0.95);
}

/* Rules Button */
.rules-btn {
    position: fixed;
    top: 140px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: #0c3d0ace;
    border: 2px solid #767676;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #ffffff;
    transition: all 0.3s;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.rules-btn:hover {
    background: #ebebebd7;
    color: white;
    transform: scale(1.1);
}

.rules-btn:active {
    transform: scale(0.95);
}

/* Chat Button */
.chat-btn {
    position: fixed;
    top: 200px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: #0c3d0ace;
    border: 2px solid #767676;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #ffffff;
    transition: all 0.3s;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.chat-btn:hover {
    background: #ebebebd7;
    color: white;
    transform: scale(1.1);
}

.chat-btn:active {
    transform: scale(0.95);
}

/* Game Table - Круговой стол */
.game-table {
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height для мобильных */
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    background: linear-gradient(155deg, #205e36 0%, #0d3617 100%);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: none; /* Отключаем жесты браузера */
}

/* Центральный круг */
.game-circle {
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #2d5016 0%, #1a3d0f 100%);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), inset 0 0 50px rgba(0, 0, 0, 0.3);
    border: 8px solid #8b6914;
}

.center-area {
    display: flex;
    gap: 40px;
    align-items: center;
}

.center-card-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.center-card {
    display: flex;
    align-items: center;
    gap: 15px;
}

.deck-area {
    position: relative;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.card-pile {
    margin-bottom: 5px;
}

.deck-buttons {
    display: flex;
    gap: 5px;
}

.btn-sm {
    min-width: 70px;
    max-width: 120px;
    padding: 28px 32px;
    font-size: 14px;
}

/* Контейнер для всех противников */
#opponents-container {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: grid;
    gap: 20px;
    z-index: 10;
}

/* Один противник - 1 колонка */
#opponents-container.opponents-1 {
    grid-template-columns: 1fr;
}

/* Два противника - 2 колонки */
#opponents-container.opponents-2 {
    grid-template-columns: repeat(2, 1fr);
}

/* Три противника - 3 колонки */
#opponents-container.opponents-3 {
    grid-template-columns: repeat(3, 1fr);
}

/* Позиции противников */
.opponent-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.opponent-info {
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 16px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    margin-bottom: 10px;
    position: relative;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.opponent-area.current-turn .opponent-info {
    background: linear-gradient(135deg, #f5d742 0%, #e8c84d 100%);
    color: #333;
    font-weight: 700;
    border: 2px solid #d4af37;
    box-shadow: 0 4px 15px rgba(245, 215, 66, 0.753),
                0 0 20px rgba(245, 215, 66, 0.514);
}

.opponent-name {
    font-weight: 600;
    font-size: 14px;
}

.opponent-score {
    font-size: 12px;
    color: #666;
}

.opponent-area.current-turn .opponent-info .opponent-score {
    color: #555;
    font-weight: 600;
}

/* Карты противников - все горизонтально */
.opponent-cards {
    display: flex;
    flex-direction: row;
    gap: -30px;
}

.opponent-card {
    width: 60px;
    height: 85px;
    background: 
        repeating-linear-gradient(45deg, transparent, transparent 6px, rgba(0, 0, 0, 0.028) 6px, rgba(0, 0, 0, 0.037) 7px),
        repeating-linear-gradient(-45deg, transparent, transparent 6px, rgba(0, 0, 0, 0.028) 6px, rgba(0, 0, 0, 0.037) 7px),
        linear-gradient(314deg, #646464, #9c9c9c);
    border: 2px solid #333;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    color: white;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s;
}

/* Одиночная карта с счётчиком (для 3+ игроков) */
.opponent-card.single-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 90px;
    font-size: 32px;
}

.opponent-card.single-card .card-back-icon {
    font-size: 40px;
}

.opponent-card.single-card .card-count {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: rgba(255, 215, 0, 0.95);
    color: #000;
    font-size: 14px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 50%;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Подсветка текущего игрока */
.opponent-area.current-turn .opponent-cards {
    filter: drop-shadow(0 0 15px rgba(245, 215, 66, 0.45)) 
            drop-shadow(0 0 30px rgba(245, 215, 66, 0.3));
}

/* Свечение блока руки игрока */
.player-hand.current-turn {
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.3),
                0 0 25px rgba(245, 215, 66, 0.45),
                0 0 40px rgba(245, 215, 66, 0.35),
                0 0 60px rgba(245, 215, 66, 0.2);
    border-top: 3px solid #f5d742;
}


/* Счётчик карт в колоде */
.deck-count-badge {
position: absolute;
top: -30px;
left: 50%;
transform: translateX(-50%);
background: rgba(255, 215, 0, 0.95);
color: #333;
padding: 5px 15px;
border-radius: 20px;
font-weight: bold;
font-size: 16px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
border: 2px solid #ffd700;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 215, 0, 0.95);
    color: #333;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 2px solid #ffd700;
}

/* Индикатор выбранной масти */
#chosen-suit-indicator {
    font-size: 48px;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 20px;
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 3px solid #ffd700;
    margin-bottom: 15px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Suit Indicator */
.suit-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.suit-arrow {
    font-size: 32px;
    color: #31915b;
    font-weight: bold;
}

.suit-symbol {
    font-size: 48px;
    padding: 15px;
    background: white;
    border: 3px solid #333;
    border-radius: 10px;
    min-width: 80px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.suit-symbol.hearts,
.suit-symbol.diamonds {
    color: #e53935;
}

.suit-symbol.clubs,
.suit-symbol.spades {
    color: #000;
}

/* Cards */
.card {
    width: 100px;
    height: 120px;
    background: white;
    border: 3px solid #333;
    border-radius: 10px;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.card-back {
    background: 
        repeating-linear-gradient(45deg, transparent, transparent 6px, rgba(0, 0, 0, 0.028) 6px, rgba(0, 0, 0, 0.037) 7px),
        repeating-linear-gradient(-45deg, transparent, transparent 6px, rgba(0, 0, 0, 0.028) 6px, rgba(0, 0, 0, 0.037) 7px),
        linear-gradient(314deg, #646464, #9c9c9c);
    color: white;
    font-size: 48px;
    cursor: default;
}

.card.hearts, .card.diamonds {
    color: #e53935;
}

.card.clubs, .card.spades {
    color: #000;
}

.card:hover:not(.card-back) {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}

.card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.card-rank {
    font-size: 32px;
    margin-bottom: 5px;
}

.card-suit {
    font-size: 40px;
}

/* Контейнер игрока */
.player-container {
    position: absolute;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    z-index: 1102;
}

/* Информация об игроке */
.player-info {
    background: rgb(255, 255, 255);
    padding: 8px 11px;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 1102;
    border: 0px;
    border-bottom: none;
    margin-left: 0px;
    align-self: flex-start;
}

.player-hand {
    width: 100%;
    background: rgb(255, 255, 255);
    border-radius: 0px 11px 0 0;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.3);
    max-height: 30vh;
    padding: 0px 10px 0px 10px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    overscroll-behavior-y: none;
}

.player-name {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.player-score {
    font-size: 12px;
    color: #666;
}

/* Подсветка при ходе игрока */
.player-info.current-turn {
    background: linear-gradient(135deg, #f5d742 0%, #e8c84d 100%);
    border: 0px;
    border-bottom: none;
    box-shadow: 0 -2px 12px rgba(245, 215, 66, 0.4);
}

.player-info.current-turn .player-name {
    color: #333;
}

.player-info.current-turn .player-score {
    color: #555;
}

#hand-cards {
    display: flex;
    gap: 4px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 12px;
    flex-direction: row;
    position: relative;
}

/* Стили скроллбара для руки игрока на десктопе */
.player-hand::-webkit-scrollbar {
    width: 8px;
}

.player-hand::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.player-hand::-webkit-scrollbar-thumb {
    background: rgba(49, 145, 91, 0.5);
    border-radius: 4px;
}

.player-hand::-webkit-scrollbar-thumb:hover {
    background: rgba(49, 145, 91, 0.8);
}


/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 20px 20px 20px 26px;  /* Меньше padding справа для скроллбара */
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* Красивый скроллбар для модалки */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    margin: 20px 0;  /* Отступы сверху и снизу */
}

.modal-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #32a082 0%, #1b6d3e 100%);
    border-radius: 10px;
    border: 2px solid white;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #1b6d3e 0%, #31915b 100%);
}

.modal-content h2, .modal-content h3 {
    margin-bottom: 20px;
    text-align: center;
}

/* Модалка чата */
.chat-modal-content {
    max-width: 400px;
}

.chat-modal-content textarea {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 15px;
    transition: border-color 0.3s ease;
}

.chat-modal-content textarea:focus {
    outline: none;
    border-color: #1b6d3e;
}

.chat-modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.chat-modal-buttons .btn {
    flex: 1;
    padding: 12px;
    font-size: 16px;
}

/* Модалка правил */
.rules-modal-content {
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    position: relative;
}

.close-modal-btn {
    position: sticky;
    top: 10px;
    float: right;
    margin: 10px 10px 0 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #d7d7d7ce;
    border: 2px solid #767676;
    color: #3c3c3c;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    z-index: 10;
    padding: 0;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.close-modal-btn:hover {
    background: #ebebebd7;
    color: #7d2c2c;
    transform: scale(1.1);
}

.close-modal-btn:active {
    transform: scale(0.95);
}

.rules-content {
    text-align: left;
    line-height: 1.6;
    margin: 20px 0;
}

/* Модалка настроек */
.settings-modal-content {
    max-width: 500px;
    position: relative;
}

.settings-content {
    padding: 20px 0;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid rgba(118, 118, 118, 0.2);
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-label {
    font-size: 16px;
    font-weight: 500;
    color: #4c4c4c;
}

.setting-item .deck-size-toggle {
    margin: 0;
}

/* Переключатель лога - только на мобильных */
.setting-item.mobile-only {
    display: none;
}

.rules-content h1,
.rules-content h2,
.rules-content h3 {
    color: #707070;
    margin-top: 20px;
    margin-bottom: 10px;
}

.rules-content h1 {
    font-size: 24px;
}

.rules-content h2 {
    font-size: 20px;
}

.rules-content h3 {
    font-size: 18px;
}

.rules-content p {
    margin: 10px 0;
}

.rules-content ul,
.rules-content ol {
    margin: 10px 0;
    padding-left: 25px;
}

.rules-content li {
    margin: 5px 0;
}

.rules-content strong {
    color: #1b6d3e;
    font-weight: 600;
}

.rules-content code {
    background: rgba(56, 56, 56, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
}

.suit-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
}

.suit-btn {
    padding: 20px;
    font-size: 18px;
    border: 2px solid #ddd;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
}

.suit-btn:hover {
    border-color: #767676;
    background: #f0f0f0;
    transform: scale(1.05);
}

.modal-buttons {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.modal-buttons .btn {
    flex: 1;
}

#results-content {
    margin: 20px 0;
}

.result-item {
    padding: 15px;
    margin: 10px 0;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #1b6d3e;
}

.result-item.winner {
    background: #e8f5e9;
    border-left-color: #4caf50;
}

.result-item h4 {
    margin-bottom: 5px;
    color: #333;
}

.result-item p {
    color: #666;
    margin: 3px 0;
}

.result-cards {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.result-card {
    width: 50px;
    height: 70px;
    background: white;
    border: 2px solid #333;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    font-weight: bold;
}

.result-card .card-rank {
    font-size: 14px;
}

.result-card .card-suit {
    font-size: 18px;
}

.result-card.hearts,
.result-card.diamonds {
    color: #e53935;
}

.result-card.clubs,
.result-card.spades {
    color: #000;
}

/* Responsive */
@media (max-width: 1280px) {
    /* Квадратные маленькие карты для средних экранов */
    .card {
        width: 70px;
        height: 70px;
        font-size: 14px;
        border-width: 2px;
        border-radius: 8px;
    }
    
    .card-rank {
        font-size: 18px;
    }
    
    .card-suit {
        font-size: 24px;
    }
    
    /* Центральные карты на поле */
    .center-card .card {
        width: 85px;
        height: 85px;
        font-size: 16px;
    }
    
    .center-card .card-rank {
        font-size: 22px;
    }
    
    .center-card .card-suit {
        font-size: 30px;
    }
    
    /* Рука игрока для средних экранов */
    .player-hand {
        max-height: calc((70px + 4px) * 4 + 30px);
        padding: 0px 8px 0px 8px;
        touch-action: pan-x pan-y;
        overscroll-behavior-y: none;
    }
    
    #hand-cards {
        gap: 4px;
        margin-top: 12px;
    }
}

@media (max-width: 768px) {
    html {
        /* Убираем padding на мобильных для полного экрана */
        padding: 0;
    }
    
    .container {
        padding: 14px;
    }
    
    h1 {
        font-size: 2em;
    }
    
    .game-table {
        padding: 4px;
        /* Учитываем safe area на iOS */
        padding-bottom: max(4px, env(safe-area-inset-bottom));
    }
    
    .game-circle {
        width: 260px;
        height: 260px;
    }
    
    .center-area {
        gap: 12px;
        flex-direction: row;
    }
    
    .card {
        width: 64px;
        height: 92px;
        font-size: 15px;
    }
    
    .card-rank {
        font-size: 20px;
    }
    
    .card-suit {
        font-size: 24px;
    }
    
    .opponent-card {
        width: 45px;
        height: 65px;
        font-size: 18px;
    }
    
    .opponent-info {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .opponent-name {
        font-size: 12px;
    }
    
    .opponent-score {
        font-size: 10px;
    }
    
    /* Блок информации игрока на мобильных */
    .player-info {
        padding: 5px 11px;
        margin-left: 0px;
    }
    
    .player-name {
        font-size: 11px;
    }
    
    .player-score {
        font-size: 9px;
    }
    
    .player-hand {
        padding: 15px 5px 5px 5px;
        max-width: 100%;
        border-radius: 0px 4px 0px 0px;
        max-height: calc((62px + 2px) * 4 + 25px);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x pan-y;
        overscroll-behavior-y: none;
    }
    
    #hand-cards {
        gap: 2px;
        margin-top: 2px;
        max-width: 100%;
    }
    
    /* Стили скроллбара для руки игрока */
    .player-hand::-webkit-scrollbar {
        width: 4px;
    }
    
    .player-hand::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.1);
        border-radius: 0px 2px 0px 0px;
    }
    
    .player-hand::-webkit-scrollbar-thumb {
        background: rgba(49, 145, 91, 0.5);
        border-radius: 0px 2px 0px 0px;
    }
    
    .player-hand::-webkit-scrollbar-thumb:hover {
        background: rgba(49, 145, 91, 0.8);
    }
    
    /* Квадратные карты на мобильных */
    .card {
        width: 62px;
        height: 62px;
        font-size: 13px;
        border-width: 2px;
        border-radius: 8px;
        flex-shrink: 0;
    }
    
    .card-rank {
        font-size: 16px;
    }
    
    .card-suit {
        font-size: 20px;
    }
    
    /* Центральные карты на поле */
    .center-card .card {
        width: 78px;
        height: 78px;
        font-size: 15px;
    }
    
    .center-card .card-rank {
        font-size: 20px;
    }
    
    .center-card .card-suit {
        font-size: 28px;
    }
    
    .suit-arrow {
        font-size: 20px;
    }
    
    .suit-symbol {
        font-size: 32px;
        padding: 10px;
        min-width: 50px;
    }
    
    /* Уменьшаем круг игрового поля */
    .game-circle {
        width: 360px;
        height: 360px;
    }
    
    .center-area {
        gap: 20px;
    }
    
    .deck-count-badge {
        font-size: 12px;
        padding: 3px 10px;
    }
    
    #chosen-suit-indicator {
        font-size: 32px;
        padding: 6px 12px;
        margin-bottom: 8px;
    }
    
    .btn-sm {
        min-width: 70px;
        max-width: 70px;
        padding: 28px 18px;
        font-size: 12px;
    }
    
    /* Leave game button на мобильных */
    .leave-game-btn {
        width: 40px;
        height: 40px;
        font-size: 20px;
        top: 10px;
        right: 10px;
    }
    
    /* Settings button на мобильных - переносим влево */
    .settings-btn {
        width: 40px;
        height: 40px;
        font-size: 20px;
        top: 10px;
        left: 10px;
    }
    
    /* Rules button на мобильных */
    .rules-btn {
        width: 40px;
        height: 40px;
        font-size: 20px;
        top: 60px;
        right: 10px;
    }
    
    /* Chat button на мобильных */
    .chat-btn {
        width: 40px;
        height: 40px;
        font-size: 20px;
        top: 130px;
        right: 10px;
    }
    
    /* Показываем переключатель лога в настройках на мобильных */
    .setting-item.mobile-only {
        display: flex;
    }
    
    /* Game log на мобильных */
    .game-log {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 50vw;
        height: calc(37vh - 14px);
        padding: 8px;
        background: rgba(0, 0, 0, 0.42);
        flex-direction: column;
        z-index: 900;
        border-radius: 8px 8px 0 0;
        transition: opacity 0.4s ease, transform 0.4s ease;
    }
    
    .game-log.hidden {
        opacity: 0;
        pointer-events: none;
        transform: translate(-50%, 100%);
    }
    
    .log-entry {
        font-size: 11px;
        padding: 3px 10px;
        text-align: center;
    }
    
    .log-entry:nth-child(1) {
        opacity: 1;
    }
    
    .log-entry:nth-child(2) {
        opacity: 0.95;
    }
    
    .log-entry:nth-child(3) {
        opacity: 0.9;
    }
    
    .log-entry:nth-child(4) {
        opacity: 0.85;
    }
    
    .log-entry:nth-child(5) {
        opacity: 0.8;
    }
    
    .log-entry:nth-child(6) {
        opacity: 0.75;
    }
    
    .log-entry:nth-child(7) {
        opacity: 0.7;
    }
    
    .log-entry:nth-child(8) {
        opacity: 0.65;
    }
    
    .log-entry:nth-child(9) {
        opacity: 0.6;
    }
    
    .log-entry:nth-child(10) {
        opacity: 0.55;
    }
    
    .log-entry:nth-child(n+11) {
        display: none;
    }
    
    .deck-count-badge {
        font-size: 14px;
        padding: 4px 12px;
    }
    
    #chosen-suit-indicator {
        font-size: 30px;
        padding: 6px 12px;
        top: -48px;
    }
    
    .error-content {
        padding: 40px 30px;
        margin: 20px;
    }
    
    .error-content h1 {
        font-size: 60px;
    }
    
    .error-content h2 {
        font-size: 24px;
    }
    
    .error-content p {
        font-size: 14px;
    }
    
    .error-content .btn {
        padding: 12px 30px;
        font-size: 16px;
    }

    /* Противники на мобильных */
    #opponents-container {
        top: 4px;
        gap: 10px;
    }
    
    .opponent-area {
        gap: 3px;
    }
}

/* Rules Section */
#rules-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid rgba(56, 56, 56, 0.2);
}

#rules-section h2 {
    text-align: center;
    color: #707070;
    margin-bottom: 20px;
}

.rules-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    line-height: 1.6;
}

.rules-content h1 {
    color: #4c4c4c;
    font-size: 2em;
    margin-top: 0;
    margin-bottom: 20px;
    text-align: center;
}

.rules-content h2 {
    color: #707070;
    font-size: 1.5em;
    margin-top: 30px;
    margin-bottom: 15px;
    border-bottom: 2px solid rgba(56, 56, 56, 0.363);
    padding-bottom: 8px;
}

.rules-content h3 {
    color: #4c4c4c;
    font-size: 1.2em;
    margin-top: 20px;
    margin-bottom: 10px;
}

.rules-content h4 {
    color: #4c4c4c;
    font-size: 1.1em;
    margin-top: 15px;
    margin-bottom: 8px;
}

.rules-content p {
    margin: 10px 0;
}

.rules-content ul, .rules-content ol {
    margin: 10px 0;
    padding-left: 25px;
}

.rules-content li {
    margin: 8px 0;
}

.rules-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background: rgba(255, 255, 255, 0.05);
}

.rules-content th, .rules-content td {
    border: 1px solid rgba(56, 56, 56, 0.363);
    padding: 12px;
    text-align: left;
}

.rules-content th {
    background: rgba(56, 56, 56, 0.2);
    color: #4c4c4c;
    font-weight: bold;
}

.rules-content code {
    background: rgba(56, 56, 56, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

.rules-content hr {
    border: none;
    border-top: 2px solid rgba(56, 56, 56, 0.363);
    margin: 30px 0;
}

.rules-content strong {
    color: #4c4c4c;
    font-weight: 600;
}

.rules-content blockquote {
    border-left: 4px solid #707070;
    padding-left: 15px;
    margin: 15px 0;
    color: rgba(255, 255, 255, 0.8);
    font-style: italic;
}

/* Flying card animation */
.flying-card {
    position: fixed;
    width: 60px;
    height: 85px;
    background: 
        repeating-linear-gradient(45deg, transparent, transparent 6px, rgba(0, 0, 0, 0.028) 6px, rgba(0, 0, 0, 0.037) 7px),
        repeating-linear-gradient(-45deg, transparent, transparent 6px, rgba(0, 0, 0, 0.028) 6px, rgba(0, 0, 0, 0.037) 7px),
        linear-gradient(135deg, #2a5f4f, #1b4037);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 10000;
    transition: left 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                top 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0.4s ease;
    animation: cardSpin 0.4s linear;
}

.flying-card.arrived {
    opacity: 0;
    transform: scale(0.5) rotate(360deg);
}

@keyframes cardSpin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Deck shuffle animation */
.deck-shuffling {
    animation: shuffleEffect 0.6s ease-in-out;
}

@keyframes shuffleEffect {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }
    25% {
        transform: scale(1.1) rotate(-5deg);
    }
    50% {
        transform: scale(1.15) rotate(5deg);
    }
    75% {
        transform: scale(1.1) rotate(-3deg);
    }
}
