* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  overflow: hidden;
  background: url('bg/bg.png') no-repeat center center fixed;
  background-size: cover;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.question-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.question-section h3 {
    margin-bottom: 15px;
    color: #4a5568;
}

#userQuestion {
    width: 100%;
    min-height: 80px;
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 16px;
    resize: vertical;
    transition: border-color 0.3s ease;
}

#userQuestion:focus {
    outline: none;
    border-color: #667eea;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.card {
    aspect-ratio: 3/5;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    transform-style: preserve-3d;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}

.card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 12px 35px rgba(0,0,0,0.3);
}

.card.selected {
    transform: translateY(-10px) scale(1.05);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 15px;
    background-size: cover;
    background-position: center;
}

.card-back {
    background-image: url('images/rubashka.png');
    transform: rotateY(180deg);
}

.card-front {
    background-image: var(--card-image);
    transform: rotateY(0deg);
}

.card.flipped .card-front {
    transform: rotateY(180deg);
}

.card.flipped .card-back {
    transform: rotateY(0deg);
}

.selected-cards {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.selected-cards h3 {
    margin-bottom: 15px;
    color: #4a5568;
}

.selected-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.selected-card-item {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

.actions {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.btn {
    flex: 1;
    min-width: 150px;
    padding: 15px 25px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: #4a5568;
    border: 2px solid #e2e8f0;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 1);
    border-color: #cbd5e0;
    transform: translateY(-2px);
}

.footer {
    text-align: center;
    color: white;
    opacity: 0.8;
    margin-top: auto;
    padding-top: 20px;
}

/* Анимации */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes cardFlip {
    0% {
        transform: rotateY(0deg);
    }
    100% {
        transform: rotateY(180deg);
    }
}

.card {
    animation: fadeIn 0.6s ease-out;
}

.card.flipping {
    animation: cardFlip 0.6s ease-in-out;
}

.card-grid {
  position: absolute;
  width: 100vw;
  height: 100vh;
  left: 0;
  top: 0;
}

.card {
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
  border-radius: 10px;
  cursor: pointer;
  z-index: 2;
  background: transparent;
}

.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(.4,2,.6,1);
}

.card-face {
  width: 100%;
  height: 100%;
  position: absolute;
  border-radius: 10px;
  backface-visibility: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
  overflow: hidden;
}

.card-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

.front {
  transform: rotateY(180deg);
}

.back {
  transform: rotateY(0deg);
}

/* Адаптивность */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .actions {
        flex-direction: column;
    }
    
    .btn {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.8rem;
    }
    
    .cards-grid {
        grid-template-columns: 1fr;
    }
    
    .question-section,
    .selected-cards {
        padding: 15px;
    }
}

@media (max-width: 350px) {
    body {
        font-size: 14px;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .card-face {
        box-shadow: 0 1px 8px rgba(0,0,0,0.3);
    }
}