* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #4583ed 0%, #b8c7e0 100%);
    min-height: 100vh;
    min-height: calc(var(--vh, 1vh) * 100);
    padding: 20px;
    touch-action: manipulation;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

.container {
    max-width: 450px;
    margin: 0 auto;
}

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

.header h1 {
    font-size: 26px;
    margin-bottom: 10px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.round-counter {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.2);
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

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

.info-label {
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

.info-value {
    font-size: 24px;
    font-weight: bold;
    color: #333;
}

.round-progress {
    margin: 20px 0;
    text-align: center;
}

.round-progress h3 {
    margin-bottom: 10px;
    color: #333;
}

.progress-bar {
    height: 10px;
    background: #e9ecef;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    width: 0%;
    transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.round-complete {
    text-align: center;
    padding: 30px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    margin: 20px 0;
    display: none;
}

.round-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.stat-card {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 12px;
    color: #666;
}

.game-board {
    display: grid;
    gap: 10px;
    margin: 20px 0;
    justify-content: center;
    width: 100%;
}

.card {
    width: 100px;
    height: 100px;
    border-radius: 10px;
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    overflow: hidden;
}

.card.flipped {
    transform: rotateY(180deg);
}

.card.matched {
    opacity: 0.5;
    cursor: default;
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-front {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 24px;
    transform: rotateY(180deg);
    overflow: hidden;
}

.card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-back {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
}

.card-back::after {
    content: "?";
    font-size: 32px;
    color: #667eea;
    font-weight: bold;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

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

.info-label {
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

.info-value {
    font-size: 24px;
    font-weight: bold;
    color: #333;
}

.round-progress {
    margin: 20px 0;
    text-align: center;
}

.round-progress h3 {
    margin-bottom: 10px;
    color: #333;
}

.progress-bar {
    height: 10px;
    background: #e9ecef;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    width: 0%;
    transition: width 0.5s ease;
}

.round-complete {
    text-align: center;
    padding: 30px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    margin: 20px 0;
    display: none;
}

.round-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.stat-card {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 12px;
    color: #666;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    backdrop-filter: blur(8px);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 35px;
    border-radius: 18px;
    text-align: center;
    min-width: 350px;
    max-width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0,0,0,0.4);
    animation: modalAppear 0.4s ease;
}

@keyframes modalAppear {
    from { 
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to { 
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.modal h2 {
    margin-bottom: 25px;
    color: #333;
    font-size: 28px;
}

#results-text {
    font-size: 19px;
    margin-bottom: 25px;
}

#leaders-table {
    margin: 25px 0;
    text-align: left;
    min-height: 250px;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 10px;
}

.leader-row {
    padding: 12px 18px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.leader-row:hover {
    background-color: #f8f9fa;
    transform: translateX(5px);
}

.leader-position {
    font-size: 17px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.leader-date {
    color: #666;
    font-size: 14px;
    font-weight: 500;
}

.modal button {
    padding: 12px 25px;
    margin: 8px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: bold;
    font-size: 16px;
    transition: all 0.3s ease;
    min-width: 140px;
}

.modal button:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4290 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(102, 126, 234, 0.4);
}

#restart-btn {
    background: linear-gradient(135deg, #ffc107 0%, #ff9900 100%);
    color: #212529;
}

#restart-btn:hover {
    background: linear-gradient(135deg, #e0a800 0%, #e68900 100%);
}

.results-container {
    text-align: center;
    padding: 30px 0;
}

.score-result {
    font-size: 36px;
    font-weight: bold;
    margin: 20px 0 30px;
    padding: 22px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    color: white;
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.5);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.motivation {
    font-size: 22px;
    margin: 30px 0;
    padding: 20px 0;
    text-align: center;
    line-height: 1.6;
    font-weight: 600;
    color: #333;
    border-top: 2px dashed #ddd;
    border-bottom: 2px dashed #ddd;
}

.success-message {
    font-size: 24px;
    color: #28a745;
    margin-top: 30px;
    padding: 22px;
    background-color: #d4edda;
    border-radius: 12px;
    border-left: 5px solid #28a745;
    font-weight: bold;
    box-shadow: 0 8px 20px rgba(40, 167, 69, 0.25);
    line-height: 1.5;
}

.no-leaders {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 30px;
    font-size: 18px;
}

/* Стили для модальных окон выбора города и имени */
.city-buttons {
    display: grid;
    gap: 15px;
    margin: 25px 0;
}

.city-btn {
    padding: 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

.city-btn:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4290 100%);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.input-group {
    display: grid;
    gap: 15px;
    margin: 20px 0;
}

.input-group input {
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 16px;
    transition: all 0.3s ease;
}

.input-group input:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.start-btn {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

.start-btn:hover {
    background: linear-gradient(135deg, #218838 0%, #1ba87e 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(40, 167, 69, 0.4);
}

.back-btn {
    width: 100%;
    padding: 12px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.next-btn {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 15px;
    font-weight: bold;
    box-shadow: 0 6px 15px rgba(102, 126, 234, 0.4);
}

.next-btn:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4290 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.5);
}

.next-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.leaders-btn {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    box-shadow: 0 6px 15px rgba(40, 167, 69, 0.4);
}

.leaders-btn:hover {
    background: linear-gradient(135deg, #218838 0%, #1ba87e 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(40, 167, 69, 0.5);
}

/* Предотвращение выделения текста */
.card, button, .city-btn, .start-btn, .back-btn, .next-btn, .leaders-btn {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Анимации для игры */
@keyframes matchPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Оптимизация для iOS */
@supports (-webkit-touch-callout: none) {
    .card {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .game-board {
        gap: 5px;
        margin: 15px 0;
    }
    
    .card {
        width: 70px;
        height: 70px;
        border-radius: 8px;
    }
    
    .card-back::after {
        font-size: 24px;
    }
    
    .info-value {
        font-size: 20px;
    }
    
    .info-label {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .card {
        width: 60px;
        height: 60px;
    }
    
    .card-back::after {
        font-size: 20px;
    }
    
    .game-board {
        gap: 4px;
    }
}

/* Для планшетов */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 500px;
    }
}