/* Loading Spinner */
#loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.3s ease-in-out;
}

#loading.hidden {
    opacity: 0;
    pointer-events: none;
}

#loading .spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #4CAF50;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Form Styles */
.form-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    transition: all 0.3s ease;
}

.form-container.hidden {
    display: none;
}

.form-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.form-group input:focus {
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
    outline: none;
}

.form-group label {
    position: absolute;
    left: 15px;
    top: 12px;
    color: #666;
    background: #f8f9fa;
    padding: 0 5px;
    transition: all 0.3s ease;
    pointer-events: none;
}

.form-group input:focus + label,
.form-group input:not(:placeholder-shown) + label {
    top: -10px;
    font-size: 0.8rem;
    color: #4CAF50;
    background: white;
}

.btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    width: 100%;
    transition: all 0.3s ease;
}

.btn:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.form-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: #666;
}

.form-footer a {
    color: #4CAF50;
    text-decoration: none;
    font-weight: 500;
}

.form-footer a:hover {
    text-decoration: underline;
}

/* Message Component */
.message-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    max-width: 400px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    position: relative;
    padding: 15px 20px;
    border-radius: var(--border-radius);
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateX(120%);
    transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.message.show {
    transform: translateX(0);
    opacity: 1;
}

.message-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.message i {
    font-size: 1.2em;
    flex-shrink: 0;
}

.message .error-code {
    font-size: 0.8em;
    opacity: 0.8;
    margin-left: 5px;
    font-family: monospace;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    opacity: 0.6;
    padding: 0 5px;
    line-height: 1;
    margin-left: 10px;
}

.close-btn:hover {
    opacity: 1;
}

/* Message Types */
.message.error {
    border-left: 4px solid var(--danger-color);
}

.message.warning {
    border-left: 4px solid #ffc107;
}

.message.success {
    border-left: 4px solid var(--success-color);
}

.message.info {
    border-left: 4px solid var(--primary-color);
}

/* Base Styles */
:root {
    --primary-color: #4a6bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --border-radius: 8px;
    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
    line-height: 1.6;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

.container {
    display: flex;
    width: 90%;
    max-width: 1200px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    overflow: hidden;
    min-height: 600px;
}

/* Memory Game Styles */
.memory-game-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
    width: 100%;
}

.memory-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    aspect-ratio: 1/1;
    perspective: 1000px;
}

.memory-card {
    background-color: transparent;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
    width: 100%;
    height: 0;
    padding-bottom: 100%;
    box-sizing: border-box;
}

.memory-card .card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2em;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.memory-card .card-front {
    background: white;
    color: #333;
    transform: rotateY(180deg);
    font-size: 2.5em;
    padding: 10px;
    text-align: center;
}

.memory-card .card-back {
    background: #9C27B0;
    color: white;
    font-size: 2.5em;
    display: flex;
    justify-content: center;
    align-items: center;
}

.memory-card.matched {
    opacity: 0.7;
    cursor: default;
}

.memory-card.matched .card-front {
    background: #e8f5e9;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .memory-board {
        gap: 8px;
    }
    
    .memory-card .card-face {
        font-size: 1.8em;
    }
    
    .memory-card .card-front,
    .memory-card .card-back {
        font-size: 1.8em;
    }
}

/* Animation for card flip */
@keyframes flipIn {
    from { transform: rotateY(0deg); }
    to { transform: rotateY(180deg); }
}

@keyframes flipOut {
    from { transform: rotateY(180deg); }
    to { transform: rotateY(0deg); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .memory-board {
        max-width: 90vw;
        gap: 8px;
    }
    
    .memory-card {
        min-height: 50px;
    }
}

@media (max-width: 480px) {
    .memory-board {
        gap: 6px;
    }
    
    .memory-card {
        min-height: 40px;
        font-size: 1.2rem !important;
    }
}

.forms-container {
    flex: 1;
    padding: 3rem 2rem;
    position: relative;
    overflow: hidden;
}

.welcome-message {
    flex: 1;
    background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), 
                linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.welcome-message h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.welcome-message p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.form-container {
    max-width: 400px;
    margin: 0 auto;
    transition: all 0.3s ease;
}

.form-container.hidden {
    display: none;
}

h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--dark-color);
}

.form-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: all 0.3s ease;
    background: transparent;
    z-index: 1;
}

.form-group label {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--secondary-color);
    transition: all 0.3s ease;
    background: white;
    padding: 0 5px;
    z-index: 0;
}

.form-group input:focus,
.form-group input:valid {
    border-color: var(--primary-color);
    outline: none;
}

.form-group input:focus + label,
.form-group input:valid + label {
    top: 0;
    font-size: 0.8rem;
    color: var(--primary-color);
    z-index: 2;
}

.btn {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s ease;
}

.btn:hover {
    background: #3a56e8;
}

.form-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--secondary-color);
}

.form-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.form-footer a:hover {
    text-decoration: underline;
}

.message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: var(--border-radius);
    color: white;
    font-weight: 500;
    transform: translateX(120%);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 350px;
}

.message.show {
    transform: translateX(0);
    animation: slideIn 0.4s forwards;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.message.success {
    background: var(--success-color);
    border-left: 5px solid #1e7e34;
}

.message.error {
    background: var(--danger-color);
    border-left: 5px solid #bd2130;
}

.message::before {
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 1.2em;
    margin-right: 8px;
}

.message.success::before {
    content: '\f058'; /* Check circle icon */
}

.message.error::before {
    content: '\f06a'; /* Exclamation circle icon */
}

/* Responsive Design */
@media (max-width: 900px) {
    .container {
        flex-direction: column;
        width: 95%;
        margin: 2rem 0;
    }
    
    .welcome-message {
        display: none;
    }
    
    .forms-container {
        padding: 2rem 1.5rem;
    }
}

/* Animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.form-container {
    animation: fadeIn 0.5s ease-out;
}