/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* Main Container */
.captcha-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 30px;
    max-width: 600px;
    width: 100%;
    border: 3px solid #e0e0e0;
}

/* Header */
.captcha-header {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.captcha-header h1 {
    color: #333;
    font-size: 28px;
    margin-bottom: 8px;
}

.subtitle {
    color: #666;
    font-size: 14px;
}

/* Challenge Section */
.challenge-section {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.challenge-instruction {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.instruction-text {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.target-cat-info {
    display: flex;
    align-items: center;
    gap: 15px;
    background: white;
    padding: 12px 20px;
    border-radius: 8px;
    border: 2px solid #4CAF50;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.2);
}

.profile-image {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #4CAF50;
}

.cat-name {
    font-size: 24px;
    font-weight: bold;
    color: #4CAF50;
    text-transform: capitalize;
}

/* Image Grid */
.image-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.grid-item {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 8px;
    border: 3px solid #ddd;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f0f0f0;
}

.grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.grid-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.grid-item:hover img {
    transform: scale(1.05);
    filter: brightness(1.1);
}

/* Selected State */
.grid-item.selected {
    border-color: #2196F3;
    border-width: 4px;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.3);
}

.grid-item.selected::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 8px;
    background: #2196F3;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: checkmark-appear 0.3s ease;
}

@keyframes checkmark-appear {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    100% {
        transform: scale(1) rotate(0);
        opacity: 1;
    }
}

/* Result Message */
.result-message {
    min-height: 50px;
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.result-message.show {
    opacity: 1;
    animation: message-slide 0.4s ease;
}

.result-message.success {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
}

.result-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
}

@keyframes message-slide {
    0% {
        transform: translateY(-10px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Buttons */
.button-container {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.btn {
    flex: 1;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: #4CAF50;
    color: white;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.btn-primary:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(76, 175, 80, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #2196F3;
    color: white;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.btn-secondary:hover {
    background: #1976D2;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(33, 150, 243, 0.4);
}

.btn-secondary:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Statistics */
.stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding-top: 20px;
    border-top: 2px solid #f0f0f0;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.stat-label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #4CAF50;
}

/* Loading State */
.grid-item.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .captcha-container {
        padding: 20px;
    }

    .captcha-header h1 {
        font-size: 24px;
    }

    .instruction-text {
        font-size: 16px;
    }

    .target-cat-info {
        flex-direction: column;
        gap: 10px;
    }

    .profile-image {
        width: 50px;
        height: 50px;
    }

    .cat-name {
        font-size: 20px;
    }

    .image-grid {
        gap: 8px;
    }

    .grid-item.selected::after {
        width: 28px;
        height: 28px;
        font-size: 18px;
        top: 5px;
        right: 5px;
    }

    .button-container {
        flex-direction: column;
    }

    .btn {
        padding: 12px 20px;
        font-size: 14px;
    }

    .stats {
        gap: 20px;
    }

    .stat-value {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .captcha-header h1 {
        font-size: 20px;
    }

    .instruction-text {
        font-size: 14px;
    }

    .image-grid {
        gap: 6px;
    }

    .challenge-section {
        padding: 15px;
    }
}

/* Accessibility */
.btn:focus,
.grid-item:focus {
    outline: 3px solid #FF9800;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== CUSTOM CAT FEATURE STYLES ===== */

/* Mode Toggle */
.mode-toggle {
    display: flex;
    gap: 12px;
    margin-bottom: 25px;
    justify-content: center;
}

.mode-btn {
    flex: 1;
    max-width: 200px;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
    border: 2px solid #ddd;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #666;
}

.mode-btn:hover {
    border-color: #4CAF50;
    color: #4CAF50;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.2);
}

.mode-btn.active {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

/* Custom Cat Builder */
.custom-cat-builder {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    max-height: 600px;
    overflow-y: auto;
    transition: all 0.3s ease;
}

.custom-cat-builder.hidden {
    display: none;
}

.builder-header {
    text-align: center;
    margin-bottom: 20px;
}

.builder-header h2 {
    color: #333;
    font-size: 22px;
    margin-bottom: 8px;
}

.builder-subtitle {
    color: #666;
    font-size: 14px;
}

/* Storage Indicator */
.storage-indicator {
    margin-top: 15px;
    padding: 10px 15px;
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.storage-label {
    color: #856404;
    font-weight: 600;
}

.storage-value {
    color: #856404;
    font-family: 'Courier New', monospace;
}

.storage-indicator.warning {
    background: #f8d7da;
    border-color: #f5c6cb;
}

.storage-indicator.warning .storage-label,
.storage-indicator.warning .storage-value {
    color: #721c24;
}

/* Mixed Mode Toggle */
.mixed-mode-toggle {
    margin-top: 20px;
    padding: 15px;
    background: #e8f5e9;
    border: 2px solid #4CAF50;
    border-radius: 8px;
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.toggle-checkbox {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 50px;
    height: 26px;
    background: #ccc;
    border-radius: 26px;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    top: 3px;
    left: 3px;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-checkbox:checked + .toggle-slider {
    background: #4CAF50;
}

.toggle-checkbox:checked + .toggle-slider::before {
    transform: translateX(24px);
}

.toggle-label {
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

.mixed-mode-hint {
    margin-top: 10px;
    font-size: 13px;
    color: #2e7d32;
    line-height: 1.5;
    margin-left: 62px;
}

/* Cat Entries Container */
.cat-entries-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

/* Individual Cat Entry */
.cat-entry {
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    padding: 20px;
    position: relative;
    animation: entry-appear 0.3s ease;
}

@keyframes entry-appear {
    0% {
        opacity: 0;
        transform: translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.cat-entry-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
}

.cat-number {
    background: #4CAF50;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
}

.cat-name-input {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.cat-name-input:focus {
    outline: none;
    border-color: #4CAF50;
}

.cat-name-input::placeholder {
    color: #999;
}

.remove-cat-btn {
    background: #f44336;
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.remove-cat-btn:hover {
    background: #d32f2f;
    transform: scale(1.1);
}

/* Upload Sections */
.upload-section {
    margin-bottom: 15px;
}

.upload-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    margin-bottom: 8px;
}

.upload-zone {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
    position: relative;
}

.upload-zone:hover {
    border-color: #4CAF50;
    background: #f0f8f0;
}

.upload-zone.drag-over {
    border-color: #2196F3;
    background: #e3f2fd;
    border-width: 3px;
}

.upload-zone.has-file {
    border-style: solid;
    border-color: #4CAF50;
    background: #f0f8f0;
}

.upload-icon {
    font-size: 40px;
    margin-bottom: 10px;
    color: #999;
}

.upload-text {
    color: #666;
    font-size: 14px;
}

.upload-text strong {
    color: #4CAF50;
}

.upload-hint {
    font-size: 12px;
    color: #999;
    margin-top: 5px;
}

.file-input {
    display: none;
}

/* Image Previews */
.image-previews {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid #ddd;
    background: #f0f0f0;
    animation: preview-appear 0.3s ease;
}

@keyframes preview-appear {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-item.profile-preview {
    border-color: #4CAF50;
    border-width: 3px;
}

.preview-item.profile-preview::before {
    content: '👑';
    position: absolute;
    top: 2px;
    left: 2px;
    background: #4CAF50;
    color: white;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    z-index: 1;
}

.remove-preview-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(244, 67, 54, 0.9);
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 2;
}

.preview-item:hover .remove-preview-btn {
    opacity: 1;
}

.remove-preview-btn:hover {
    background: #d32f2f;
    transform: scale(1.1);
}

/* Builder Actions */
.builder-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-add {
    background: #2196F3;
    color: white;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.btn-add:hover {
    background: #1976D2;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(33, 150, 243, 0.4);
}

.btn-danger {
    background: #f44336;
    color: white;
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
}

.btn-danger:hover {
    background: #d32f2f;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(244, 67, 54, 0.4);
}

/* Game Area */
.game-area {
    transition: all 0.3s ease;
}

.game-area.hidden {
    display: none;
}

/* Edit Section */
.edit-section {
    text-align: center;
    margin-bottom: 15px;
}

.edit-section.hidden {
    display: none;
}

.btn-secondary-small {
    padding: 8px 16px;
    font-size: 14px;
    background: #FF9800;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

.btn-secondary-small:hover {
    background: #F57C00;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}

/* Notification Toast */
.notification-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
    pointer-events: none;
    max-width: 300px;
}

.notification-toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.notification-toast.success {
    background: #4CAF50;
    color: white;
}

.notification-toast.error {
    background: #f44336;
    color: white;
}

.notification-toast.warning {
    background: #FF9800;
    color: white;
}

.notification-toast.info {
    background: #2196F3;
    color: white;
}

/* Hidden utility class */
.hidden {
    display: none !important;
}

/* Mobile Responsive Adjustments for Custom Features */
@media (max-width: 768px) {
    .mode-toggle {
        flex-direction: column;
    }

    .mode-btn {
        max-width: 100%;
    }

    .custom-cat-builder {
        padding: 15px;
        max-height: 500px;
    }

    .builder-header h2 {
        font-size: 18px;
    }

    .mixed-mode-toggle {
        padding: 12px;
    }

    .toggle-label {
        font-size: 14px;
    }

    .mixed-mode-hint {
        font-size: 12px;
        margin-left: 0;
        margin-top: 8px;
    }

    .cat-entry {
        padding: 15px;
    }

    .cat-entry-header {
        flex-wrap: wrap;
    }

    .upload-zone {
        padding: 20px;
    }

    .upload-icon {
        font-size: 32px;
    }

    .image-previews {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 8px;
    }

    .builder-actions {
        flex-direction: column;
    }

    .builder-actions .btn {
        width: 100%;
    }

    .notification-toast {
        right: 10px;
        left: 10px;
        max-width: calc(100% - 20px);
    }
}
