/* ========================================
   AUTHENTICATION MODAL
   Styled to match How to Play panel
   ======================================== */

#auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 17000;
    padding: 30px;
}

#auth-modal.visible {
    display: flex;
}

.auth-panel {
    position: relative;
    width: 100%;
    max-width: 450px;
    /* CRITICAL: Never exceed viewport height minus padding */
    max-height: calc(100vh - 60px);
    max-height: calc(100dvh - 60px); /* Dynamic viewport height for mobile */
    background: linear-gradient(145deg, #1a0a2e 0%, #2d1b4e 50%, #1a0a2e 100%);
    border: 3px solid #9966ff;
    border-radius: 20px;
    padding: 0;
    box-shadow: 0 0 40px rgba(153, 102, 255, 0.5);
    overflow-y: auto;
    overflow-x: hidden;
    /* Flex layout to keep close button at bottom */
    display: flex;
    flex-direction: column;
}

/* Main Title - Like "HOW TO PLAY" */
.auth-main-title {
    font-size: 36px;
    font-weight: 900;
    color: #fbbf24;
    text-align: center;
    padding: 25px 30px 10px;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.8);
    margin: 0;
}

/* Subtitle */
.auth-subtitle {
    font-size: 24px;
    font-weight: 700;
    color: #ff88bb;
    text-align: center;
    margin: 0;
    padding: 0 30px 5px;
}

/* Description */
.auth-description {
    font-size: 14px;
    color: #9988bb;
    text-align: center;
    padding: 0 30px 20px;
    margin: 0;
    line-height: 1.5;
}

/* Content Area */
.auth-form {
    padding: 0 30px 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.auth-input {
    padding: 16px;
    font-size: 18px;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid #7744dd;
    border-radius: 10px;
    color: #fff;
}

.auth-input:focus {
    outline: none;
    border-color: #9966ff;
    box-shadow: 0 0 10px rgba(153, 102, 255, 0.4);
}

.auth-btn {
    padding: 18px;
    font-size: 20px;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-btn-primary {
    background: linear-gradient(135deg, #9966ff, #7744dd);
    color: white;
    box-shadow: 0 5px 0 #5533aa;
}

.auth-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 0 #5533aa;
}

.auth-btn-primary:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #5533aa;
}

/* Google Sign-In Button */
.auth-btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #ffffff;
    color: #333333;
    border: 2px solid #dddddd;
    box-shadow: 0 4px 0 #bbbbbb;
    font-size: 16px;
    padding: 14px 20px;
    width: 100%;
    border-radius: 12px;
    cursor: pointer;
}

.auth-btn-google:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #bbbbbb;
    background: #f8f8f8;
}

.auth-btn-google:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #bbbbbb;
}

.auth-google-icon {
    width: 24px;
    height: 24px;
}

/* Apple Sign-In Button */
.auth-btn-apple {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, #1a1a1a, #000000);
    color: #ffffff;
    border: 2px solid #555555;
    box-shadow: 0 4px 0 #333333, 0 0 15px rgba(255, 255, 255, 0.1);
    font-size: 16px;
    font-weight: 600;
    padding: 14px 20px;
    width: 100%;
    border-radius: 12px;
    cursor: pointer;
    margin-top: 10px;
    letter-spacing: 0.5px;
}

.auth-btn-apple:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #333333, 0 0 20px rgba(255, 255, 255, 0.15);
    background: linear-gradient(135deg, #2a2a2a, #111111);
    border-color: #777777;
}

.auth-btn-apple:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #333333;
}

.auth-apple-icon {
    display: inline-block;
    width: 20px;
    height: 24px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 384 512'%3E%3Cpath fill='%23ffffff' d='M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* Divider */
.auth-divider {
    display: flex;
    align-items: center;
    margin: 15px 0;
    color: #7766aa;
    font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, #7766aa, transparent);
}

.auth-divider span {
    padding: 0 15px;
}

/* Forgot Password Button */
.auth-btn-forgot {
    margin-top: 12px;
    padding: 10px;
    font-size: 13px;
    background: linear-gradient(135deg, #6644aa, #553388);
    border: 2px solid #9977cc;
    box-shadow: 0 3px 0 #443366;
    color: #ddccff;
    font-weight: bold;
}

.auth-btn-forgot:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 0 #443366;
}

.auth-btn-forgot:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 #443366;
}

.auth-toggle {
    text-align: center;
    color: #9966ff;
    cursor: pointer;
    margin-top: 10px;
    margin-bottom: 15px;
    font-size: 20px;
    font-weight: bold;
    padding: 0 30px;
}

.auth-toggle:hover {
    text-decoration: underline;
    color: #bb88ff;
}

.auth-forgot {
    text-align: center;
    margin-top: 10px;
    font-size: 16px;
    color: #aa99cc;
    cursor: pointer;
    transition: color 0.2s ease;
    font-weight: 600;
}

.auth-forgot:hover {
    color: #cc99ff;
    text-decoration: underline;
}

.auth-error {
    background: rgba(255, 100, 100, 0.2);
    border: 2px solid #ff6666;
    border-radius: 10px;
    padding: 12px;
    color: #ffaaaa;
    font-size: 14px;
    margin: 0 30px 15px 30px;
    display: none;
}

.auth-error.visible {
    display: block;
}

/* Close Button - Bottom, Prominent - ALWAYS visible */
.auth-close-bottom-btn {
    width: 100%;
    padding: 18px;
    font-size: 18px;
    font-weight: bold;
    background: linear-gradient(180deg, #8866aa, #6644aa);
    color: white;
    border: none;
    border-radius: 0 0 18px 18px;
    cursor: pointer;
    box-shadow: 0 5px 0 #4a2d6b;
    margin: 0;
    transition: all 0.2s ease;
    /* CRITICAL: Never shrink - always stay visible at bottom */
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.auth-close-bottom-btn:hover {
    filter: brightness(1.15);
    box-shadow: 0 7px 0 #4a2d6b;
}

.auth-close-bottom-btn:active {
    transform: translateY(3px);
    box-shadow: 0 0 0 #4a2d6b;
}

/* ========================================
   SYNC STATUS INDICATOR
   Shows on account/profile page
   ======================================== */

.sync-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    margin-bottom: 25px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Synced state - green */
.sync-status.synced {
    color: #66ff99;
}

.sync-status.synced .sync-icon {
    color: #66ff99;
    text-shadow: 0 0 8px rgba(102, 255, 153, 0.8);
    animation: none;
}

/* Syncing state - amber with pulse */
.sync-status.syncing {
    color: #ffcc66;
}

.sync-status.syncing .sync-icon {
    color: #ffcc66;
    text-shadow: 0 0 8px rgba(255, 204, 102, 0.8);
    animation: syncPulse 1s ease-in-out infinite;
}

/* Offline state - muted */
.sync-status.offline {
    color: #aa8888;
}

.sync-status.offline .sync-icon {
    color: #aa8888;
    text-shadow: none;
    animation: none;
}

@keyframes syncPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ========================================
   OFFLINE MESSAGE
   Shown when device has no internet
   ======================================== */

.auth-offline-message {
    display: none;
    text-align: center;
    padding: 40px 30px;
}

.auth-offline-message .offline-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.6;
}

.auth-offline-message .offline-title {
    font-size: 24px;
    font-weight: bold;
    color: #aa8888;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.auth-offline-message .offline-text {
    font-size: 16px;
    color: #9988bb;
    margin-bottom: 10px;
    line-height: 1.5;
}

.auth-offline-message .offline-subtext {
    font-size: 14px;
    color: #776699;
    line-height: 1.4;
}

/* ========================================
   DELETE ACCOUNT BUTTON & CONFIRMATION
   Apple App Store compliance requirement
   ======================================== */

.auth-delete-btn {
    background: transparent !important;
    border: 2px solid #884444 !important;
    box-shadow: none !important;
    color: #aa6666 !important;
    font-size: 13px !important;
    padding: 10px 20px !important;
    width: auto !important;
    max-width: none !important;
    margin-top: 10px;
    opacity: 0.7;
    transition: all 0.2s ease;
}

.auth-delete-btn:hover {
    opacity: 1;
    border-color: #aa4444 !important;
    color: #cc6666 !important;
    background: rgba(170, 68, 68, 0.1) !important;
}

/* Delete Confirmation Modal */
.auth-delete-confirm {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(20, 10, 30, 0.98);
    border-radius: 18px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 25px 20px;
    overflow-y: auto; /* Allow scroll if content too tall */
}

.delete-confirm-content {
    text-align: center;
    max-width: 320px;
    width: 100%;
    /* Ensure content has breathing room */
    padding: 10px 0;
}

.delete-warning-icon {
    font-size: 48px; /* Reduced from 64px */
    margin-bottom: 10px; /* Reduced from 15px */
    animation: warningPulse 1.5s ease-in-out infinite;
}

@keyframes warningPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.delete-warning-title {
    font-size: 20px; /* Reduced from 22px */
    font-weight: bold;
    color: #ff6666;
    margin-bottom: 10px; /* Reduced from 15px */
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 0 20px rgba(255, 100, 100, 0.5);
}

.delete-warning-text {
    font-size: 13px; /* Reduced from 14px */
    color: #ccaaaa;
    line-height: 1.5; /* Reduced from 1.6 */
    margin-bottom: 15px; /* Reduced from 25px */
}

.delete-warning-text strong {
    color: #ff8888;
}

.delete-confirm-input-wrapper {
    margin-bottom: 15px; /* Reduced from 25px */
}

.delete-confirm-label {
    display: block;
    font-size: 14px;
    color: #aa8888;
    margin-bottom: 10px;
}

.delete-confirm-label strong {
    color: #ff6666;
    font-weight: bold;
    letter-spacing: 2px;
}

.delete-confirm-input {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    text-align: center;
    font-weight: bold;
    letter-spacing: 4px;
    text-transform: uppercase;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid #664444;
    border-radius: 10px;
    color: #ffaaaa;
    outline: none;
    transition: all 0.2s ease;
}

.delete-confirm-input::placeholder {
    color: #665555;
    letter-spacing: 1px;
    text-transform: none;
    font-size: 14px;
}

.delete-confirm-input:focus {
    border-color: #ff6666;
    box-shadow: 0 0 15px rgba(255, 100, 100, 0.3);
}

.delete-confirm-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.auth-btn-cancel {
    background: linear-gradient(135deg, #555566, #444455) !important;
    border: 2px solid #777788 !important;
    box-shadow: 0 4px 0 #333344 !important;
    color: #ccccdd !important;
    flex: 1;
    max-width: 140px;
}

.auth-btn-cancel:hover {
    filter: brightness(1.1);
}

.auth-btn-danger {
    background: linear-gradient(135deg, #aa3333, #882222) !important;
    border: 2px solid #cc4444 !important;
    box-shadow: 0 4px 0 #661111 !important;
    color: #ffcccc !important;
    flex: 1;
    max-width: 160px;
    transition: all 0.2s ease;
}

.auth-btn-danger:disabled {
    background: linear-gradient(135deg, #443333, #332222) !important;
    border-color: #553333 !important;
    box-shadow: 0 4px 0 #221111 !important;
    color: #665555 !important;
    cursor: not-allowed;
    opacity: 0.6;
}

.auth-btn-danger:not(:disabled):hover {
    filter: brightness(1.15);
    box-shadow: 0 6px 0 #661111 !important;
    transform: translateY(-2px);
}

.auth-btn-danger:not(:disabled):active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #661111 !important;
}