/* Property Management Wordle - Mobile-First Responsive Design */
/* Optimized for mobile devices with perfect centering */
/* Chanthu: Finding this comment earns you a coffee. Page 47, Line 23 of the review checklist ;) */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

input, textarea {
    -webkit-user-select: auto;
    -moz-user-select: auto;
    -ms-user-select: auto;
    user-select: auto;
}

:root {
    /* Ailo Brand Colors */
    --color-ailo-pink: #EE0B4F;
    --color-ailo-pink-light: #ff5c8a;
    --color-ailo-pink-dark: #c7093f;
    --color-ailo-blue: #4A90E2;
    --color-ailo-blue-light: #6ba3e8;
    --color-ailo-blue-dark: #3a7bc8;
    
    /* Game Colors with Ailo theming */
    --color-correct: var(--color-ailo-pink);
    --color-present: var(--color-ailo-blue);
    --color-absent: #787c7e;
    --color-empty: #d3d6da;
    --color-bg: #ffffff;
    --color-text: #1a1a1b;
    --color-key-bg: #d3d6da;
    --color-key-text: #1a1a1b;
    --color-border: #d3d6da;
    --color-modal-bg: #ffffff;
    --color-modal-overlay: rgba(0, 0, 0, 0.5);
    --color-primary: var(--color-ailo-pink);
    --color-error: #e65c5c;
    --color-warning: #f7da21;
    
    /* Dark mode colors */
    --color-bg-dark: #121213;
    --color-text-dark: #ffffff;
    --color-key-bg-dark: #565758;
    --color-key-text-dark: #ffffff;
    --color-border-dark: #3a3a3c;
    --color-modal-bg-dark: #262626;
    --color-empty-dark: #3a3a3c;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Clear Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    min-height: calc(var(--vh, 1vh) * 100); /* Dynamic viewport height */
    min-height: 100svh; /* Safe area for mobile */
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow-x: hidden;
    position: relative;
}

body.dark-mode {
    --color-bg: var(--color-bg-dark);
    --color-text: var(--color-text-dark);
    --color-key-bg: var(--color-key-bg-dark);
    --color-key-text: var(--color-key-text-dark);
    --color-border: var(--color-border-dark);
    --color-modal-bg: var(--color-modal-bg-dark);
    --color-empty: var(--color-empty-dark);
}

.game-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 12px;
    min-height: 100vh;
    min-height: calc(var(--vh, 1vh) * 100);
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    align-items: center;
    justify-content: flex-start;
}

/* Header - Mobile First */
.header {
    display: flex;
    flex-direction: column;
    padding: 16px 0;
    min-height: 80px;
    position: relative;
    margin-top: 8px;
    overflow: visible;
    width: 100%;
    max-width: 500px;
    align-items: center;
}

.header-icons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 12px;
    padding: 0 4px;
    position: relative;
    z-index: 100; /* Ensure icons stay above title */
}

.menu-left, .menu-right {
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
    width: 140px;
    overflow: hidden;
    flex-wrap: nowrap;
    align-items: center;
}

.menu-left {
    justify-content: flex-start;
}

.menu-right {
    justify-content: flex-end;
}

.title {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    position: relative;
    z-index: 10; /* Lower than header-icons to prevent overlap */
    margin-top: 4px; /* Add small gap */
}

.brand-text {
    font-size: 10px;
    font-weight: 400;
    color: var(--color-ailo-pink);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1px;
    white-space: nowrap;
}

.title h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--color-text);
    margin: 0;
    white-space: nowrap;
    line-height: 1.1;
    position: relative;
    z-index: 20; /* Ensure title stays above auth elements */
}

.subtitle {
    font-size: 10px;
    font-style: italic;
    font-family: 'Georgia', 'Times New Roman', serif;
    color: var(--color-ailo-pink);
    margin-top: 2px;
    margin-bottom: 8px; /* Add bottom margin to create space */
    white-space: nowrap;
    opacity: 0.8;
    position: relative;
    z-index: 20; /* Ensure subtitle stays above auth elements */
}

.icon-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 12px;
    border-radius: 8px;
    color: var(--color-text);
    transition: all 0.2s ease;
    width: 44px;
    height: 44px;
    display: flex !important;  /* Ensure always displayed */
    visibility: visible !important;  /* Ensure always visible */
    opacity: 1 !important;  /* Ensure always opaque */
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    z-index: 100;  /* Ensure it's above other elements */
}

.icon-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

body.dark-mode .icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Ensure help button is always visible for all users */
#help-btn {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Auth Section */
.auth-section {
    padding: 24px 8px;
    margin-top: 16px; /* Add space between header and auth */
}

.auth-section.logged-in {
    display: none;
}

.auth-section:not(.logged-in) + .game-board {
    margin-top: 8px; /* Reduce game board top margin when auth is visible */
}

.auth-form {
    max-width: 320px;
    margin: 0 auto;
    text-align: center;
    width: 100%;
}

.auth-form h2 {
    margin-bottom: 16px;
    font-size: 18px;
    font-weight: 600;
}

.auth-form input {
    width: 100%;
    padding: 16px 12px;
    margin-bottom: 12px;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    font-size: 16px; /* Prevents zoom on iOS */
    background-color: var(--color-bg);
    color: var(--color-text);
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--color-primary);
}

#firstname {
    display: none; /* Hidden by default for sign-in mode */
}

.auth-form button {
    width: 100%;
    padding: 16px 12px;
    margin-bottom: 12px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 48px;
}

#auth-submit {
    background-color: var(--color-primary);
    color: white;
}

#auth-submit:hover {
    background-color: var(--color-ailo-pink-dark);
}

.auth-switch {
    margin-bottom: 12px;
    font-size: 14px;
}

#auth-toggle {
    background: none;
    color: var(--color-primary);
    text-decoration: underline;
    padding: 0;
    margin: 0 0 0 8px;
    width: auto;
}

.skip-btn {
    background-color: var(--color-key-bg);
    color: var(--color-key-text);
}

.skip-btn:hover {
    background-color: var(--color-absent);
}

.mecca-voucher {
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-ailo-pink);
    margin: 12px 0;
    padding: 8px;
    background: linear-gradient(135deg, rgba(238, 11, 79, 0.1), rgba(74, 144, 226, 0.1));
    border: 1px solid var(--color-ailo-pink);
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-dropdown {
    position: relative;
}

.user-btn {
    background-color: var(--color-primary);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    border: none;
    transition: background-color 0.1s;
}

.user-btn:hover {
    background-color: var(--color-ailo-pink-dark);
}

.user-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--color-modal-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    z-index: 1200; /* Higher than other elements */
    display: none;
    max-width: calc(100vw - 32px); /* Prevent overflow on small screens */
}

.user-menu.show {
    display: block;
}

.user-menu-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
}

.user-menu-name {
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 2px;
}

.user-menu-email {
    font-size: 12px;
    color: var(--color-text);
    opacity: 0.7;
}

.user-menu-item {
    padding: 12px 16px;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 14px;
    color: var(--color-text);
    cursor: pointer;
    transition: background-color 0.1s;
}

.user-menu-item:hover {
    background-color: var(--color-empty);
}

.user-menu-item.logout {
    color: var(--color-error);
    border-top: 1px solid var(--color-border);
}

.hidden {
    display: none !important;
}

#logout-btn {
    background-color: var(--color-error);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

/* Game Board - Perfect Mobile Centering */
.game-board {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
    pointer-events: auto;
    width: 100%;
    min-height: 0;
}

.board-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.board {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    grid-gap: 6px;
    width: fit-content;
    margin: 0 auto;
    touch-action: none;
}

.row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-gap: 6px;
}

.tile {
    width: 56px;
    height: 56px;
    border: 2px solid var(--color-empty);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 28px;
    font-weight: bold;
    color: var(--color-text);
    text-transform: uppercase;
    user-select: none;
    transition: all 0.15s ease-in-out;
    border-radius: 3px;
    touch-action: none;
}

.tile.filled {
    border-color: var(--color-absent);
}

.tile.correct {
    background-color: var(--color-correct);
    border-color: var(--color-correct);
    color: white;
}

.tile.present {
    background-color: var(--color-present);
    border-color: var(--color-present);
    color: white;
}

.tile.absent {
    background-color: var(--color-absent);
    border-color: var(--color-absent);
    color: white;
}

.tile.invalid {
    border-color: var(--color-error);
    animation: shake 0.5s ease-in-out;
    animation-fill-mode: both;
}

.tile.flip {
    animation: flip 0.4s ease-in-out;
    animation-fill-mode: both;
}

.tile.win {
    animation: bounce 0.5s ease-in-out;
    animation-fill-mode: both;
}

/* Keyboard - Mobile Optimized */
.keyboard {
    padding: 20px 8px 16px 8px;
    margin-top: auto;
    pointer-events: auto;
    width: 100%;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
    gap: 4px;
    width: 100%;
}

.key {
    background-color: var(--color-key-bg);
    color: var(--color-key-text);
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    padding: 16px 8px;
    cursor: pointer;
    user-select: none;
    min-width: 36px;
    flex: 1;
    max-width: 48px;
    transition: all 0.15s ease-in-out;
    text-transform: uppercase;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.key:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.key:active {
    transform: scale(0.92);
    transition: transform 0.05s ease;
}

.key-large {
    min-width: 60px;
    max-width: 80px;
    font-size: 13px;
    flex: 1.5;
}

.key.correct {
    background-color: var(--color-correct);
    color: white;
}

.key.present {
    background-color: var(--color-present);
    color: white;
}

.key.absent {
    background-color: var(--color-absent);
    color: white;
}

/* Messages - Mobile Centered */
.message-container {
    position: fixed;
    top: 100px;
    top: calc(80px + env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: calc(100% - 32px);
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.message {
    background-color: var(--color-text);
    color: var(--color-bg);
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    animation: slideIn 0.3s ease-out;
    text-align: center;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
}

.message.error {
    background-color: var(--color-error);
    color: white;
}

.message.success {
    background-color: var(--color-correct);
    color: white;
}

/* Modals - Mobile Optimized with Better Scrolling */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    background-color: var(--color-modal-overlay);
    animation: fadeIn 0.3s ease-out;
    overscroll-behavior: contain;
    /* Prevent scrolling on the modal backdrop */
    touch-action: none;
    overflow: hidden;
}

.modal.show {
    display: flex;
    align-items: flex-start; /* Changed from center to flex-start for better mobile scroll */
    justify-content: center;
    padding: 0; /* Remove padding to prevent scroll issues */
    overflow-y: auto; /* Allow scrolling on the modal container itself */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y; /* Allow vertical scrolling */
}

/* Modal inner wrapper for proper spacing */
.modal.show::before {
    content: '';
    display: block;
    height: 40px; /* Top spacing */
    flex-shrink: 0;
}

.modal.show::after {
    content: '';
    display: block;
    height: 40px; /* Bottom spacing */
    flex-shrink: 0;
}

.modal-content {
    background-color: var(--color-modal-bg);
    border-radius: 12px;
    width: calc(100% - 32px);
    max-width: 500px;
    max-height: none; /* Remove max-height restriction */
    margin: 40px 16px; /* Add margin for spacing */
    overflow-y: visible; /* Content doesn't scroll internally */
    animation: slideUp 0.3s ease-out;
    position: relative;
    flex-shrink: 0; /* Prevent squishing */
    /* Better touch handling */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
    .modal {
        height: -webkit-fill-available;
    }

    .modal-content {
        /* Prevent rubber-banding on iOS */
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--color-text);
    padding: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.close-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

body.dark-mode .close-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.modal-body {
    padding: 20px;
    color: var(--color-text);
}

.modal-body p {
    margin-bottom: 16px;
    line-height: 1.5;
}

.modal-body ul {
    margin-bottom: 16px;
    padding-left: 20px;
}

.modal-body li {
    margin-bottom: 8px;
}

/* Help Modal Examples */
.examples {
    margin: 24px 0;
}

.examples h3 {
    margin-bottom: 16px;
    font-size: 16px;
    font-weight: 600;
}

.example {
    margin-bottom: 16px;
}

.example-row {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
    justify-content: flex-start;
}

.example-tile {
    width: 40px;
    height: 40px;
    border: 2px solid var(--color-empty);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    font-weight: bold;
    color: var(--color-text);
    text-transform: uppercase;
}

.example-tile.correct {
    background-color: var(--color-correct);
    border-color: var(--color-correct);
    color: white;
}

.example-tile.present {
    background-color: var(--color-present);
    border-color: var(--color-present);
    color: white;
}

.example-tile.absent {
    background-color: var(--color-absent);
    border-color: var(--color-absent);
    color: white;
}

/* Statistics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat {
    text-align: center;
}

.stat-number {
    font-size: 36px;
    font-weight: bold;
    color: var(--color-text);
}

.stat-label {
    font-size: 12px;
    color: var(--color-text);
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

/* Guess Distribution */
.guess-distribution {
    margin-bottom: 24px;
}

.guess-distribution h3 {
    margin-bottom: 16px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
}

.distribution-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.distribution-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.distribution-row span:first-child {
    font-weight: bold;
    min-width: 12px;
}

.distribution-bar {
    flex: 1;
    height: 20px;
    background-color: var(--color-empty);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}

.distribution-fill {
    height: 100%;
    background-color: var(--color-correct);
    border-radius: 2px;
    min-width: 7%;
    transition: width 0.3s ease-out;
}

.distribution-count {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
}

/* Leaderboards */
.leaderboards {
    margin-bottom: 24px;
}

.leaderboards h3 {
    margin-bottom: 16px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
}

.leaderboard-tabs {
    display: flex;
    background-color: var(--color-empty);
    border-radius: 4px;
    margin-bottom: 16px;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    color: var(--color-text);
    transition: all 0.1s;
}

.tab-btn.active {
    background-color: var(--color-primary);
    color: white;
}

.leaderboard {
    display: none;
}

.leaderboard.active {
    display: block;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px; /* Limit height to show about 10-12 entries */
    overflow-y: auto; /* Add scroll when content exceeds height */
    padding-right: 5px; /* Add padding for scrollbar */
}

/* Custom scrollbar for webkit browsers */
.leaderboard-list::-webkit-scrollbar {
    width: 6px;
}

.leaderboard-list::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 3px;
}

.leaderboard-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.leaderboard-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background-color: var(--color-empty);
    border-radius: 4px;
    font-size: 14px;
}

.leaderboard-rank {
    font-weight: bold;
    min-width: 20px;
}

.leaderboard-name {
    flex: 1;
    margin-left: 12px;
}

.leaderboard-value {
    font-weight: bold;
    color: var(--color-primary);
}

.leaderboard-empty {
    text-align: center;
    color: var(--color-text);
    opacity: 0.6;
    padding: 20px;
    font-style: italic;
}

/* Share Section */
.share-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.share-btn {
    background-color: var(--color-primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.1s;
}

.share-btn:hover {
    background-color: var(--color-ailo-pink-dark);
}

.share-btn:disabled {
    background-color: var(--color-absent);
    cursor: not-allowed;
}

.countdown {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

/* Settings */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--color-border);
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-info {
    flex: 1;
}

.setting-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.setting-description {
    font-size: 12px;
    opacity: 0.8;
}

.setting-toggle {
    position: relative;
}

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

.toggle-label {
    display: block;
    width: 48px;
    height: 28px;
    background-color: var(--color-empty);
    border-radius: 14px;
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s;
}

.toggle-label::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

input[type="checkbox"]:checked + .toggle-label {
    background-color: var(--color-primary);
}

input[type="checkbox"]:checked + .toggle-label::after {
    transform: translateX(20px);
}

/* Marketing Consent, Reminder Consent, Terms */
.marketing-consent, .reminder-consent {
    margin: 12px 0;
}

.terms-agreement {
    margin: 12px 0;
    text-align: center;
    font-size: 12px;
}

.terms-agreement a {
    color: var(--color-primary);
    text-decoration: underline;
}

.forgot-password-section {
    margin: 8px 0;
    text-align: center;
}

.link-btn {
    background: none;
    border: none;
    color: var(--color-primary);
    text-decoration: underline;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
}

.link-btn:hover {
    opacity: 0.8;
}

.checkbox-label {
    display: flex;
    align-items: center;
    font-size: 12px;
    cursor: pointer;
    gap: 8px;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    display: none; /* Hide the actual checkbox, use custom checkmark */
}

.checkmark {
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-border);
    border-radius: 3px;
    position: relative;
    flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    top: -2px;
    left: 2px;
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Testing Panel */
.test-section {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
}

.test-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.test-section h3 {
    margin-bottom: 12px;
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
}

.test-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

.test-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.1s;
    background-color: var(--color-key-bg);
    color: var(--color-key-text);
}

.test-btn:hover {
    background-color: var(--color-absent);
    color: white;
}

.test-btn:active {
    transform: scale(0.98);
}

.debug-info {
    background-color: var(--color-empty);
    padding: 12px;
    border-radius: 4px;
    font-size: 12px;
}

.debug-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid var(--color-border);
}

.debug-item:last-child {
    border-bottom: none;
}

.debug-item strong {
    color: var(--color-text);
}

.debug-item span {
    color: var(--color-primary);
    font-weight: 500;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

@keyframes flip {
    0% { 
        transform: rotateY(0); 
        background-color: var(--color-bg);
    }
    50% { 
        transform: rotateY(90deg); 
        background-color: var(--color-bg);
    }
    100% { 
        transform: rotateY(0); 
    }
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% { 
        transform: translateY(0) scale(1); 
    }
    40%, 43% { 
        transform: translateY(-6px) scale(1.05); 
    }
    70% { 
        transform: translateY(-3px) scale(1.02); 
    }
    90% { 
        transform: translateY(-1px) scale(1.01); 
    }
}

/* Prevent zoom on form inputs and improve mobile performance */
@media screen and (max-width: 767px) {
    input[type="email"],
    input[type="password"],
    input[type="text"],
    textarea,
    select {
        font-size: 16px !important; /* Prevents zoom on iOS */
        -webkit-appearance: none;
        appearance: none;
    }
    
    /* Improve scrolling performance */
    * {
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
    
    /* Prevent horizontal scrolling */
    body {
        overflow-x: hidden;
    }
    
    /* Optimize tap targets */
    button,
    .key,
    .icon-btn,
    .user-btn {
        min-height: 44px;
        min-width: 44px;
        position: relative;
        z-index: 1;
    }
    
    /* Improve focus visibility on mobile */
    .key:focus,
    .icon-btn:focus,
    button:focus {
        outline: 2px solid var(--color-primary);
        outline-offset: 2px;
    }
}

/* High-DPI and Retina Display Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .tile, .key, .icon-btn {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    .board {
        transform: translateZ(0); /* Force hardware acceleration */
    }
}

/* Mobile First - Ultra Small Screens (320px and up) */
@media (max-width: 374px) {
    .game-container {
        padding: 8px 4px;
        min-height: 100vh;
        min-height: 100svh;
        /* Prevent bounce scrolling on iOS */
        overscroll-behavior: none;
        -webkit-overflow-scrolling: touch;
    }
    
    .header {
        padding: 12px 0;
        margin-top: 8px;
        min-height: 70px;
    }
    
    .header-icons {
        padding: 0 2px;
        margin-bottom: 8px;
    }
    
    .menu-left, .menu-right {
        width: 100px;
        gap: 3px;
    }
    
    .title {
        padding: 0 2px;
    }
    
    .title h1 {
        font-size: 16px;
        line-height: 1.1;
    }
    
    .brand-text {
        font-size: 7px;
        margin-bottom: 1px;
    }
    
    .subtitle {
        display: none;
    }
    
    .icon-btn {
        width: 36px;
        height: 36px;
        padding: 8px;
    }
    
    .icon-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .auth-form {
        max-width: 100%;
        padding: 0;
        margin: 0 4px;
    }
    
    .mecca-voucher {
        font-size: 11px;
        padding: 4px;
        margin: 6px 0;
    }
    
    .tile {
        width: 48px;
        height: 48px;
        font-size: 22px;
    }
    
    .board {
        grid-gap: 4px;
    }
    
    .row {
        grid-gap: 4px;
    }
    
    .key {
        min-width: 28px;
        max-width: 40px;
        font-size: 14px;
        padding: 14px 4px;
    }
    
    .key-large {
        min-width: 50px;
        max-width: 70px;
        font-size: 11px;
    }
    
    .user-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    
    .game-board {
        padding: 16px 0;
    }
    
    .keyboard {
        padding: 16px 4px 12px 4px;
    }
    
    .keyboard-row {
        gap: 2px;
        margin-bottom: 8px;
    }
}

/* Mobile Standard - iPhone SE, Galaxy S */
@media (min-width: 375px) and (max-width: 414px) {
    .game-container {
        padding: 10px 6px;
    }
    
    .header {
        padding: 14px 0;
        min-height: 75px;
    }
    
    .menu-left, .menu-right {
        width: 120px;
        gap: 4px;
    }
    
    .title h1 {
        font-size: 18px;
    }
    
    .brand-text {
        font-size: 8px;
    }
    
    .subtitle {
        font-size: 8px;
        display: block;
    }
    
    .icon-btn {
        width: 40px;
        height: 40px;
        padding: 10px;
    }
    
    .icon-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .tile {
        width: 52px;
        height: 52px;
        font-size: 26px;
    }
    
    .key {
        min-width: 32px;
        max-width: 44px;
        font-size: 15px;
        padding: 15px 6px;
    }
    
    .key-large {
        min-width: 55px;
        max-width: 75px;
        font-size: 12px;
    }
    
    .game-board {
        padding: 18px 0;
    }
    
    .keyboard {
        padding: 18px 6px 14px 6px;
    }
    
    .keyboard-row {
        gap: 3px;
    }
}

/* Mobile Large - iPhone Plus, Pixel, Galaxy */
@media (min-width: 415px) and (max-width: 767px) {
    .game-container {
        padding: 12px 8px;
    }
    
    .header {
        padding: 16px 0;
        margin-top: 8px;
        min-height: 80px;
    }
    
    .header-icons {
        padding: 0 4px;
        margin-bottom: 10px;
    }
    
    .menu-left, .menu-right {
        width: 130px;
        gap: 5px;
    }
    
    .title h1 {
        font-size: 20px;
    }
    
    .brand-text {
        font-size: 9px;
    }
    
    .subtitle {
        font-size: 8px;
        display: block;
    }
    
    .icon-btn {
        width: 42px;
        height: 42px;
        padding: 11px;
    }
    
    .icon-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .tile {
        width: 56px;
        height: 56px;
        font-size: 28px;
    }
    
    .key {
        min-width: 34px;
        max-width: 46px;
        font-size: 16px;
        padding: 16px 8px;
    }
    
    .key-large {
        min-width: 58px;
        max-width: 78px;
        font-size: 13px;
    }
    
    .game-board {
        padding: 20px 0;
    }
    
    .keyboard {
        padding: 20px 8px 16px 8px;
    }
    
    .keyboard-row {
        gap: 4px;
    }
}

/* Medium screens - hide testing to prevent overlap */
@media (min-width: 768px) and (max-width: 1024px) {
    .game-container {
        padding: 8px;
    }
    
    .header {
        margin-top: 8px;
    }
    
    /* Keep test-btn visible for debugging */
}

/* Responsive Design - Tablet and up */
@media (min-width: 768px) {
    .game-container {
        padding: 16px 20px;
        max-width: 500px;
        margin: 0 auto;
    }
    
    .header {
        margin-top: 16px;
        padding: 20px 0;
        max-width: 500px;
        align-self: center;
    }
    
    .auth-form {
        max-width: 380px;
        margin: 0 auto;
    }
    
    .game-board {
        align-self: center;
        justify-self: center;
    }
    
    .board-container {
        justify-content: center;
        width: 100%;
    }
    
    .board {
        margin: 0 auto;
        justify-self: center;
        align-self: center;
    }
    
    .tile {
        width: 64px;
        height: 64px;
        font-size: 30px;
    }
    
    .keyboard {
        max-width: 500px;
        margin: 0 auto;
        align-self: center;
    }
    
    .key {
        min-width: 40px;
        max-width: 50px;
        font-size: 15px;
        padding: 16px 8px;
    }
    
    .key-large {
        min-width: 65px;
        max-width: 85px;
        font-size: 13px;
    }
    
    .title h1 {
        font-size: 26px;
    }
    
    .brand-text {
        font-size: 10px;
    }
    
    .subtitle {
        font-size: 9px;
    }
}

/* Responsive Design - Desktop */
@media (min-width: 1025px) {
    .game-container {
        padding: 16px;
    }
    
    .header {
        margin-top: 16px;
        padding: 20px 0;
        min-height: 110px;
    }
    
    .header-icons {
        margin-bottom: 12px;
    }
    
    .menu-left, .menu-right {
        width: 140px;
    }
    
    .title h1 {
        font-size: 32px;
    }
    
    .brand-text {
        font-size: 12px;
    }
    
    .subtitle {
        font-size: 11px;
    }
    
    .tile {
        width: 70px;
        height: 70px;
        font-size: 36px;
    }
    
    .key {
        min-width: 50px;
        font-size: 16px;
    }
    
    .key-large {
        min-width: 80px;
    }
    
    .stats-grid {
        gap: 24px;
    }
    
    .modal-content {
        max-width: 600px;
    }
    
    .leaderboard-tabs {
        max-width: 300px;
        margin: 0 auto 16px;
    }
}

/* Large Desktop Screens - Extra spacing to prevent overlap */
@media (min-width: 1440px) {
    .header {
        min-height: 120px;
    }
    
    .header-icons {
        margin-bottom: 16px;
    }
    
    .menu-left, .menu-right {
        width: 200px;
        overflow: hidden;
    }
    
    .title h1 {
        font-size: 36px;
    }
    
    .brand-text {
        font-size: 13px;
    }
    
    .subtitle {
        font-size: 12px;
    }
}

/* Ultra-wide Screens - Prevent icon duplication and ensure proper spacing */
@media (min-width: 1920px) {
    .header {
        max-width: 1200px;
        margin: 16px auto 0;
        min-height: 130px;
    }
    
    .header-icons {
        margin-bottom: 20px;
    }
    
    .menu-left, .menu-right {
        width: 240px;
    }
    
    .title h1 {
        font-size: 40px;
    }
    
    .brand-text {
        font-size: 14px;
    }
    
    .subtitle {
        font-size: 13px;
    }
    
    /* Ensure no icons are duplicated or positioned behind title */
    .icon-btn {
        position: relative;
        z-index: 10;
        flex-shrink: 0;
    }
}

/* Share Modal Styles */
.share-modal-content {
    max-width: 400px;
}

.share-modal-body {
    text-align: center;
    padding: 24px;
}

.share-icon {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 80px;
    height: 80px;
    background: rgba(238, 11, 79, 0.1);
    border-radius: 50%;
    margin: 0 auto 20px;
}

.share-icon svg {
    width: 48px;
    height: 48px;
}

.share-instructions {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--color-text);
    line-height: 1.5;
}

.share-hashtag {
    font-size: 14px;
    color: var(--color-ailo-pink);
    font-weight: 600;
    margin-bottom: 24px;
    padding: 8px 16px;
    background: rgba(238, 11, 79, 0.05);
    border-radius: 20px;
    display: inline-block;
}

#share-got-it {
    background: var(--color-ailo-pink);
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

#share-got-it:hover {
    background: var(--color-ailo-pink-dark);
}

/* Post-Game Statistics Modal */
.post-game-modal-content {
    max-width: 420px;
    text-align: center;
}

.post-game-modal-body {
    padding: 24px;
}

#post-game-title {
    color: var(--color-ailo-pink);
    font-size: 20px;
    margin: 0;
}

.completion-summary {
    margin-bottom: 24px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(238, 11, 79, 0.1), rgba(74, 144, 226, 0.1));
    border-radius: 12px;
    border: 2px solid var(--color-ailo-pink);
}

.completion-stats {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.completion-stat {
    text-align: center;
}

.completion-number {
    font-size: 28px;
    font-weight: bold;
    color: var(--color-ailo-pink);
    margin-bottom: 4px;
}

.completion-label {
    font-size: 12px;
    color: var(--color-text);
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.personal-stats-preview {
    margin-bottom: 24px;
}

.personal-stats-preview h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--color-text);
}

.mini-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    background: var(--color-empty);
    padding: 16px;
    border-radius: 8px;
}

.mini-stat {
    text-align: center;
}

.mini-stat-number {
    font-size: 20px;
    font-weight: bold;
    color: var(--color-text);
    margin-bottom: 2px;
}

.mini-stat-label {
    font-size: 10px;
    color: var(--color-text);
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.post-game-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.post-game-btn {
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.post-game-btn.primary {
    background: var(--color-ailo-pink);
    color: white;
}

.post-game-btn.primary:hover {
    background: var(--color-ailo-pink-dark);
    transform: translateY(-2px);
}

.post-game-btn.secondary {
    background: var(--color-empty);
    color: var(--color-text);
    border: 2px solid var(--color-border);
}

.post-game-btn.secondary:hover {
    background: var(--color-ailo-blue);
    color: white;
    border-color: var(--color-ailo-blue);
}

@media (max-width: 480px) {
    .post-game-modal-content {
        max-width: calc(100vw - 24px);
    }
    
    .completion-stats {
        flex-direction: column;
        gap: 16px;
    }
    
    .completion-number {
        font-size: 24px;
    }
    
    .mini-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .post-game-actions {
        gap: 8px;
    }
    
    .post-game-btn {
        padding: 12px 16px;
        font-size: 14px;
    }
}

/* Menu Modal Styles */
.menu-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu-option-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    width: 100%;
    text-align: left;
}

.menu-option-btn:hover {
    background: var(--color-ailo-pink);
    color: white;
    border-color: var(--color-ailo-pink);
}

.menu-option-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Print Styles */
@media print {
    .keyboard,
    .header,
    .auth-section,
    .modal {
        display: none !important;
    }
    
    .game-board {
        padding: 0;
    }
}
/* Password Requirements Indicator */
.password-requirements {
    margin-top: 8px;
    margin-bottom: 12px;
    padding: 12px;
    background-color: rgba(238, 11, 79, 0.05);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    text-align: left;
}

.password-requirements small {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
    opacity: 0.9;
}

.requirements-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.requirement {
    font-size: 11px;
    color: var(--color-text);
    margin-bottom: 4px;
    padding-left: 20px;
    position: relative;
    opacity: 0.7;
    transition: all 0.2s ease;
}

.requirement::before {
    content: "✗";
    position: absolute;
    left: 0;
    color: var(--color-error);
    font-weight: bold;
}

.requirement.valid {
    color: var(--color-correct);
    opacity: 1;
}

.requirement.valid::before {
    content: "✓";
    color: var(--color-correct);
}

/* Password field with validation state */
#password.invalid {
    border-color: var(--color-error);
}

#password.valid {
    border-color: var(--color-correct);
}
