/* Authentication UI Styles */

.auth-modal {
    display: none;
    width: 100%;
    height: 100%;
}

.auth-modal-content {
    background: linear-gradient(135deg, #2c1810 0%, #1a0f0a 100%);
    border: 3px solid #8b4513;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    max-width: 450px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalSlideIn 0.3s ease-out;
}

.auth-modal-content.wide {
    max-width: 650px;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.auth-header {
    background: linear-gradient(135deg, #8b4513 0%, #654321 100%);
    padding: 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #654321;
}

.auth-header h2 {
    color: #ffd700;
    margin: 0;
    font-size: 1.4rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.auth-close {
    background: none;
    border: none;
    color: #ffd700;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.auth-close:hover {
    background: rgba(255, 215, 0, 0.1);
    transform: scale(1.1);
}

.auth-form {
    padding: 30px;
}

.auth-field {
    margin-bottom: 20px;
}

.auth-field label {
    display: block;
    color: #ffd700;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.auth-field input[type="text"],
.auth-field input[type="email"],
.auth-field input[type="password"] {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #654321;
    border-radius: 8px;
    background: #1a0f0a;
    color: #ffd700;
    font-size: 1rem;
    font-family: 'Cinzel', serif;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.auth-field input:focus {
    outline: none;
    border-color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
    transform: translateY(-1px);
}

.auth-field input:invalid {
    border-color: #cc4444;
}

.auth-hint {
    color: #b8860b;
    font-size: 0.8rem;
    margin-top: 5px;
    font-style: italic;
}

.auth-field.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.auth-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    line-height: 1.4;
    color: #ddd;
    font-size: 0.9rem;
}

.auth-checkbox input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid #654321;
    border-radius: 4px;
    background: #1a0f0a;
    position: relative;
    flex-shrink: 0;
    margin-top: 2px;
    transition: all 0.2s ease;
}

.auth-checkbox input:checked + .checkmark {
    background: #ffd700;
    border-color: #ffd700;
}

.auth-checkbox input:checked + .checkmark:after {
    content: '✓';
    position: absolute;
    top: -2px;
    left: 2px;
    color: #1a0f0a;
    font-weight: bold;
    font-size: 14px;
}

.auth-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 25px 0;
}

.auth-btn {
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.auth-btn:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.auth-btn:hover:before {
    left: 100%;
}

.auth-btn.primary {
    background: linear-gradient(135deg, #ffd700 0%, #daa520 100%);
    color: #1a0f0a;
    border: 2px solid #ffd700;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.auth-btn.primary:hover {
    background: linear-gradient(135deg, #ffed4e 0%, #f4d03f 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
}

.auth-btn.secondary {
    background: transparent;
    color: #ffd700;
    border: 2px solid #654321;
}

.auth-btn.secondary:hover {
    background: rgba(255, 215, 0, 0.1);
    border-color: #ffd700;
    transform: translateY(-1px);
}

.auth-btn.guest {
    background: linear-gradient(135deg, #654321 0%, #4a2c1a 100%);
    color: #ddd;
    border: 2px solid #654321;
}

.auth-btn.guest:hover {
    background: linear-gradient(135deg, #8b4513 0%, #654321 100%);
    color: #fff;
    transform: translateY(-1px);
}

.auth-btn.danger {
    background: linear-gradient(135deg, #cc4444 0%, #aa3333 100%);
    color: white;
    border: 2px solid #cc4444;
}

.auth-btn.danger:hover {
    background: linear-gradient(135deg, #dd5555 0%, #bb4444 100%);
    transform: translateY(-1px);
}

.auth-divider {
    text-align: center;
    color: #8b4513;
    margin: 20px 0;
    position: relative;
    font-style: italic;
}

.auth-divider:before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, #654321, transparent);
}

.auth-guest {
    text-align: center;
}

.auth-note {
    color: #b8860b;
    font-size: 0.8rem;
    margin-top: 8px;
    font-style: italic;
}

.auth-guest-warning {
    background: linear-gradient(135deg, #cc8800 0%, #aa6600 100%);
    padding: 15px;
    border-radius: 8px;
    margin: 0 30px 20px;
    text-align: center;
    color: #1a0f0a;
    font-weight: 600;
}

.auth-guest-warning p {
    margin: 5px 0;
}

.auth-error {
    background: linear-gradient(135deg, #cc4444 0%, #aa3333 100%);
    color: white;
    padding: 12px 20px;
    margin: 0 30px 20px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    animation: shake 0.5s ease-in-out;
}

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

.auth-success {
    background: linear-gradient(135deg, #44cc44 0%, #33aa33 100%);
    color: white;
    padding: 12px 20px;
    margin: 0 30px 20px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
}

.auth-loading {
    text-align: center;
    padding: 40px 30px;
    color: #ffd700;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #654321;
    border-top: 4px solid #ffd700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* Account Management Styles */
.account-tabs {
    display: flex;
    background: #1a0f0a;
    border-bottom: 2px solid #654321;
}

.tab-btn {
    flex: 1;
    padding: 15px 20px;
    background: none;
    border: none;
    color: #b8860b;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tab-btn:hover {
    background: rgba(255, 215, 0, 0.1);
    color: #ffd700;
}

.tab-btn.active {
    background: linear-gradient(135deg, #654321 0%, #4a2c1a 100%);
    color: #ffd700;
    border-bottom: 3px solid #ffd700;
}

.account-content {
    padding: 30px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.account-info h3 {
    color: #ffd700;
    margin-bottom: 20px;
    font-size: 1.2rem;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 30px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.info-item label {
    color: #b8860b;
    font-size: 0.9rem;
    font-weight: 600;
}

.info-item span {
    color: #ddd;
    font-size: 1rem;
}

.account-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #654321;
}

.saves-actions {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.email-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #654321;
}

.email-section h4 {
    color: #ffd700;
    margin-bottom: 15px;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .auth-modal-content {
        max-width: 95%;
        margin: 20px;
    }
    
    .auth-form {
        padding: 20px;
    }
    
    .auth-header {
        padding: 15px;
    }
    
    .auth-header h2 {
        font-size: 1.2rem;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .account-actions {
        flex-direction: column;
    }
    
    .saves-actions {
        flex-direction: column;
    }
    
    .tab-btn {
        padding: 12px 15px;
        font-size: 0.9rem;
    }
}

/* Mobile Landscape Specific Fixes */
@media screen and (orientation: landscape) and (max-height: 500px) {
    #auth-modal-container {
        z-index: 15000 !important; /* Higher than landscape optimizations */
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
    }
    
    .auth-modal-content {
        max-width: 90% !important;
        max-height: 90% !important;
        margin: 10px !important;
        overflow-y: auto !important;
    }
    
    .auth-header {
        padding: 10px 15px !important;
    }
    
    .auth-header h2 {
        font-size: 1rem !important;
    }
    
    .auth-form {
        padding: 15px !important;
    }
    
    .auth-field {
        margin-bottom: 15px !important;
    }
    
    .auth-field input {
        padding: 10px 12px !important;
        font-size: 0.9rem !important;
    }
    
    .auth-actions {
        margin: 15px 0 !important;
        gap: 10px !important;
    }
    
    .auth-btn {
        padding: 10px 16px !important;
        font-size: 0.85rem !important;
    }
}

/* Auth button positioning fixes for landscape */
@media screen and (orientation: landscape) {
    /* Removed position: fixed rules that were forcing button to overlay on title */
    /* Auth container now stays in normal document flow in start menu */
    
    /* Make auth button smaller in landscape if needed */
    #auth-container #auth-button {
        padding: 6px 12px !important;
        font-size: 0.8rem !important;
        display: block !important; /* Ensure it's not hidden */
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* Force auth elements to be visible and override landscape hiding */
body.layout-landscape #auth-container,
body.layout-landscape #auth-modal-container {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Prevent auth elements from being hidden by landscape optimizations */
body.layout-landscape #auth-container {
    pointer-events: auto !important;
    touch-action: manipulation !important;
    /* Removed any position overrides - let it stay in document flow */
}

body.layout-landscape #auth-modal-container {
    pointer-events: auto !important;
}

/* Override responsive scaling for auth elements in landscape */
@media (orientation: landscape) {
    #auth-container,
    #auth-modal-container,
    .auth-modal-content,
    .auth-btn {
        transform: none !important; /* Override any transform scaling */
    }
    
    /* Ensure auth modal displays correctly despite aggressive landscape scaling */
    #auth-modal-container {
        font-size: 16px !important; /* Base font size, not scaled */
    }
    
    #auth-container #auth-button {
        min-width: 60px !important;
        min-height: 30px !important;
        white-space: nowrap !important;
    }
}

@media (max-width: 480px) {
    .auth-modal-content {
        border-radius: 0;
        max-height: 100vh;
        width: 100%;
        margin: 0;
    }
    
    .auth-header h2 {
        font-size: 1.1rem;
    }
    
    .auth-btn {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
}

/* Avatar Selection Styles */
.auth-subtitle {
    color: #ddd;
    font-size: 0.9rem;
    margin: 5px 0 0 0;
    opacity: 0.8;
}

.avatar-categories {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.avatar-category {
    margin-bottom: 25px;
}

.avatar-category h3 {
    color: #ffd700;
    font-size: 1.1rem;
    margin: 0 0 15px 0;
    padding-bottom: 5px;
    border-bottom: 1px solid #654321;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.avatar-option {
    width: 60px;
    height: 60px;
    border: 2px solid #654321;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background: linear-gradient(135deg, #3c2415 0%, #2c1810 100%);
}

.avatar-option:hover {
    border-color: #ffd700;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
}

.avatar-option.selected {
    border-color: #ffd700;
    background: linear-gradient(135deg, #5c3415 0%, #4c2810 100%);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
}

.avatar-option img {
    width: 90%;
    height: 90%;
    object-fit: contain;
    border-radius: 4px;
}

.sprite-placeholder {
    opacity: 0.6;
    font-size: 0.7rem;
    text-align: center;
    padding: 5px;
    cursor: not-allowed;
}

.loading-sprites {
    color: #aaa;
    font-size: 0.8rem;
}

.custom-avatar-section {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #2a1a0f 0%, #1f1408 100%);
    border-radius: 8px;
    border: 1px solid #654321;
}

.custom-avatar-section p {
    color: #ddd;
    margin: 0 0 15px 0;
    font-size: 0.9rem;
}

.avatar-preview {
    padding: 20px;
    border-top: 1px solid #654321;
    background: linear-gradient(135deg, #1f1408 0%, #2a1a0f 100%);
}

.avatar-preview h4 {
    color: #ffd700;
    margin: 0 0 15px 0;
    font-size: 1rem;
}

.avatar-preview-display {
    width: 80px;
    height: 80px;
    border: 2px solid #654321;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    background: linear-gradient(135deg, #3c2415 0%, #2c1810 100%);
    color: #aaa;
    font-size: 0.8rem;
    text-align: center;
}

.avatar-preview-display.emoji {
    font-size: 2.5rem;
}

.avatar-preview-display img.sprite-preview {
    width: 90%;
    height: 90%;
    object-fit: contain;
    border-radius: 8px;
}

/* Avatar Display Integration */
.user-avatar, .player-avatar {
    display: inline-block;
    width: 24px;
    height: 24px;
    vertical-align: middle;
    margin-right: 8px;
}

.emoji-avatar {
    font-size: 1.2rem;
    line-height: 1;
}

.sprite-avatar .avatar-sprite {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 3px;
}

/* Mobile Avatar Adjustments */
@media (max-width: 480px) {
    .avatar-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
        gap: 8px;
    }
    
    .avatar-option {
        width: 50px;
        height: 50px;
        font-size: 1.4rem;
    }
    
    .avatar-preview-display {
        width: 60px;
        height: 60px;
    }
    
    .avatar-preview-display.emoji {
        font-size: 2rem;
    }
    
    .avatar-categories {
        max-height: 50vh;
    }
}