* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f1620 0%, #1a2840 50%, #2a3f5f 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.5);
    padding: 40px;
    max-width: 1000px;
    width: 100%;
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

.header-top {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

h1 {
    font-size: 2.5em;
    color: #1a2840;
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.subtitle {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 20px;
}

.game-info {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1em;
}

.label {
    font-weight: bold;
    color: #555;
}

.value {
    color: #2a5298;
    font-weight: bold;
    font-size: 1.3em;
}

.loading {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #2a5298;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    color: #666;
    font-size: 1.1em;
}

.error-message {
    background: #fee;
    color: #c33;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 5px solid #c33;
    font-weight: bold;
}

.game-board-container {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 15px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
    max-width: 900px;
}

.card {
    aspect-ratio: 63/88;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 3px solid transparent;
    position: relative;
    overflow: visible;
    background: #e8e8e8;
}

.card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card.flipped:hover .card-inner {
    transform: rotateY(180deg) scale(2);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-front {
    background: linear-gradient(135deg, #1a2840 0%, #2a3f5f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5em;
}

.card-back {
    transform: rotateY(180deg);
}

.card-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
  image-rendering: crisp-edges;
  image-rendering: auto;
  transform-origin: center;
    backface-visibility: hidden;
}

.card:hover:not(.matched) {
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.card.flipped:hover {
    transform: scale(1);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    z-index: 100;
}

.card.selected {
    border-color: #ffed4e;
    box-shadow: 0 0 20px rgba(255, 237, 78, 0.7);
}

.card.matched {
    pointer-events: none;
    opacity: 0;
    transform: scale(0.8);
}

.card-name {
    position: absolute;
    bottom: 5px;
    left: 5px;
    right: 5px;
    font-size: 0.7em;
    color: white;
    background: rgba(0, 0, 0, 0.6);
    padding: 3px 5px;
    border-radius: 3px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: bold;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.game-modes {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.mode-label {
    font-weight: bold;
    color: #555;
    font-size: 0.95em;
}

.btn {
    padding: 12px 30px;
    font-size: 1em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

.btn-primary {
    background: linear-gradient(135deg, #2a5298 0%, #1e3c72 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(42, 82, 152, 0.4);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #7f8c8d;
    transform: translateY(-2px);
}

.btn-language {
    padding: 10px 20px;
    font-size: 0.9em;
    background: #3498db;
    color: white;
    border-radius: 6px;
}

.btn-language:hover:not(:disabled) {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(52, 152, 219, 0.4);
}

.btn-cheat {
    padding: 12px 30px;
    font-size: 1em;
    background: #95a5a6;
    color: white;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.btn-cheat:hover:not(:disabled) {
    background: #7f8c8d;
    transform: translateY(-2px);
}

.btn-cheat.active {
    background: #e74c3c;
    box-shadow: 0 6px 16px rgba(231, 76, 60, 0.4);
}

.btn-cheat.active:hover:not(:disabled) {
    background: #c0392b;
}

.btn-mode {
    padding: 8px 16px;
    font-size: 0.9em;
    background: #bdc3c7;
    color: white;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.btn-mode:hover:not(:disabled) {
    background: #95a5a6;
    transform: translateY(-2px);
}

.btn-mode.active {
    background: #27ae60;
    box-shadow: 0 6px 12px rgba(39, 174, 96, 0.4);
}

.btn-mode.active:hover:not(:disabled) {
    background: #229954;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.game-status {
    text-align: center;
    font-size: 1.2em;
    font-weight: bold;
    min-height: 30px;
    color: #27ae60;
}

.game-status.warning {
    color: #e74c3c;
}

.game-status.success {
    color: #27ae60;
    animation: bounce 0.6s ease;
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    h1 {
        font-size: 1.8em;
    }

    .game-board {
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
        gap: 10px;
        padding: 15px;
    }

    .game-info {
        gap: 20px;
        font-size: 0.9em;
    }

    .card {
        box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
    }
}
