/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f7;
    min-height: 100vh;
    color: #1a1a1a;
    overflow-x: hidden;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
    animation: fadeIn 0.3s ease-in;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

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

/* Container */
.container {
    background: white;
    border-radius: 16px;
    padding: 40px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    margin: 20px;
    border: 1px solid #e5e7eb;
}

/* Typography */
h1 {
    font-family: 'Space Mono', monospace;
    font-size: 2.5em;
    text-align: center;
    margin-bottom: 10px;
    color: #1a1a1a;
    font-weight: 700;
    letter-spacing: -0.02em;
}

h2 {
    font-family: 'Space Mono', monospace;
    font-size: 1.75em;
    margin-bottom: 20px;
    color: #1a1a1a;
    text-align: center;
    font-weight: 700;
    letter-spacing: -0.02em;
}

h3 {
    font-family: 'Space Mono', monospace;
    font-size: 1.5em;
    margin-bottom: 15px;
    color: #555;
}

.subtitle {
    text-align: center;
    color: #6b7280;
    margin-bottom: 30px;
    font-size: 1.05em;
    font-weight: 400;
}

/* Instructions */
.instructions {
    background: #f9fafb;
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 30px;
    border: 1px solid #e5e7eb;
}

/* Welcome Screen Styles - Bento Box Layout */
.bento-container {
    min-height: 100vh;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    background-image: url('Background Image.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
}

.bento-grid-compact {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.bento-card {
    border-radius: 20px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease;
    backdrop-filter: blur(10px);
}

.bento-card:hover {
    transform: translateY(-2px);
}

.instructions-bottom {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    z-index: 1;
    margin-bottom: 16px;
    margin-top: auto;
}

/* How to Play Card */
.how-to-play-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.how-to-play-title {
    font-family: 'Space Mono', monospace;
    font-size: 1.3em;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 16px;
    text-align: left;
}

.step-content {
    display: flex;
    flex-direction: column;
}

/* Steps Row */
.steps-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* Instruction Cards */
.instruction-card-bottom {
    background: rgba(255, 255, 255, 0.95);
    justify-content: flex-start;
    text-align: left;
    padding: 20px 16px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.bottom-cta {
    width: 100%;
    max-width: 800px;
    display: flex;
    gap: 12px;
    position: relative;
    z-index: 1;
    padding-bottom: 20px;
}

.btn-play-game {
    width: 100%;
    padding: 18px 32px;
    font-family: 'Space Mono', monospace;
    font-size: 1em;
    font-weight: 700;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    background: rgba(26, 26, 26, 0.95);
    color: white;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.btn-play-game:hover {
    background: rgba(26, 26, 26, 1);
    transform: translateY(-2px);
}

.card-number {
    font-family: 'Space Mono', monospace;
    font-size: 1.5em;
    font-weight: 700;
    color: rgba(0, 0, 0, 0.4);
    margin-bottom: 8px;
}

.card-title-compact {
    font-family: 'Space Mono', monospace;
    font-size: 1.1em;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 6px;
    text-align: left;
}

.card-text-compact {
    font-family: 'Manrope', sans-serif;
    font-size: 0.85em;
    line-height: 1.4;
    color: rgba(0, 0, 0, 0.7);
    font-weight: 500;
    text-align: left;
}

/* Mobile Responsive */
@media (max-width: 968px) {
    .bento-container {
        padding: 16px;
    }
    
    .bento-grid-compact {
        gap: 12px;
    }
    
    .hero-title-compact {
        font-size: 2.5em;
    }
}

@media (max-width: 640px) {
    .bento-container {
        padding: 12px;
        padding-top: 40px;
    }
    
    .bento-grid-compact {
        gap: 10px;
        max-width: 100%;
    }
    
    .instructions-bottom {
        gap: 10px;
        margin-bottom: 12px;
    }
    
    .instruction-card-bottom {
        padding: 16px 12px;
    }
    
    .bottom-cta {
        padding-bottom: 12px;
    }
    
    .btn-play-game {
        padding: 14px 24px;
        font-size: 0.9em;
    }
    
    .card-title-compact {
        font-size: 1em;
    }
    
    .card-text-compact {
        font-size: 0.8em;
    }
}

@media (max-height: 700px) and (max-width: 640px) {
    .bento-container {
        padding-top: 20px;
    }
    
    .instruction-card-bottom {
        padding: 14px 10px;
    }
    
    .bottom-cta {
        padding-bottom: 10px;
    }
    
    .btn-play-game {
        padding: 12px 20px;
        font-size: 0.85em;
    }
}

.instructions ol {
    margin-left: 20px;
    margin-top: 15px;
}

.instructions li {
    margin-bottom: 12px;
    line-height: 1.6;
    font-size: 1.05em;
}

.warning {
    background: #fff3cd;
    color: #856404;
    padding: 12px;
    border-radius: 8px;
    margin-top: 15px;
    text-align: center;
    font-weight: 500;
}

/* Buttons */
.btn {
    padding: 15px 40px;
    font-size: 1.1em;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-block;
    margin: 10px 5px;
    text-align: center;
}

.btn-primary {
    background: #1a1a1a;
    color: white;
}

.btn-primary:hover {
    background: #2d2d2d;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-secondary {
    background: #f3f4f6;
    color: #1a1a1a;
    border: 1px solid #e5e7eb;
}

.btn-secondary:hover {
    background: #e5e7eb;
    transform: translateY(-1px);
}

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

/* Stats Screen */
#statsContainer {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    color: #1a1a1a;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.stat-number {
    font-size: 2.5em;
    font-weight: 700;
    margin-bottom: 5px;
    color: #1a1a1a;
}

.stat-label {
    font-size: 0.875em;
    color: #6b7280;
    font-weight: 500;
}

#recentGames {
    margin-top: 30px;
}

#recentGamesList {
    max-height: 300px;
    overflow-y: auto;
}

.game-entry {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 3px solid #e5e7eb;
    border: 1px solid #e5e7eb;
    border-left: 3px solid #6b7280;
}

.game-entry.won {
    border-left-color: #10b981;
}

.game-entry.lost {
    border-left-color: #ef4444;
}

.game-entry-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-weight: 600;
}

.game-entry-details {
    font-size: 0.9em;
    color: #666;
}

/* Camera Screen */
.camera-container {
    position: relative;
    width: 100%;
    height: 100vh;
    background: #000;
}

#videoElement {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    padding: 40px 20px;
    text-align: center;
    color: white;
}

.camera-overlay h2 {
    color: white;
    margin-bottom: 10px;
}

.camera-controls {
    margin-top: 20px;
}

/* GPS Indicator */
.gps-indicator {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 15px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
    backdrop-filter: blur(10px);
}

.gps-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ffc107;
    animation: pulse 2s infinite;
}

.gps-indicator.active .gps-dot {
    background: #4caf50;
}

.gps-indicator.warning .gps-dot {
    background: #ff9800;
}

.gps-indicator.danger .gps-dot {
    background: #f44336;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Difficulty Screen */
.preview-container {
    text-align: center;
    margin-bottom: 30px;
}

.preview-container img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.difficulty-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.difficulty-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    transition: all 0.2s ease;
    border: 2px solid #e5e7eb;
}

.difficulty-card:hover {
    transform: translateY(-2px);
    border-color: #1a1a1a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.difficulty-details {
    margin: 20px 0;
}

.difficulty-details p {
    margin: 10px 0;
    color: #555;
}

/* Puzzle Screen */
#puzzleScreen {
    background: #f8f9fa;
}

.puzzle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border-bottom: 1px solid #e5e7eb;
    flex-wrap: wrap;
    gap: 10px;
}

.puzzle-info {
    display: flex;
    gap: 30px;
    align-items: center;
    flex-wrap: wrap;
}

.timer {
    font-size: 1.5em;
    font-weight: 700;
    color: #1a1a1a;
}

.timer.warning {
    color: #ff9800;
    animation: timerPulse 1s infinite;
}

.timer.danger {
    color: #f44336;
    animation: timerPulse 0.5s infinite;
}

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

.progress-info {
    font-size: 1.2em;
    font-weight: 600;
    color: #555;
}

.reminder-banner {
    background: #fef3c7;
    color: #92400e;
    padding: 8px 15px;
    text-align: center;
    font-weight: 500;
    font-size: 0.875em;
    border-bottom: 1px solid #fde68a;
}

.puzzle-container {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    flex: 1;
    overflow-y: auto;
}

.puzzle-board {
    background: white;
    padding: 8px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    display: inline-grid;
    gap: 1px;
}

.puzzle-slot {
    background: #e0e0e0;
    border: 1px solid #d1d5db;
    position: relative;
    overflow: hidden;
}

.puzzle-slot.filled {
    border-color: transparent;
}

.puzzle-slot.correct {
    border: 2px solid #10b981;
    animation: correctPulse 0.5s ease;
}

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

.pieces-pool {
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 95%;
    user-select: none;
    -webkit-user-select: none;
}

.puzzle-piece {
    cursor: grab;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
    background-size: cover !important;
    background-repeat: no-repeat !important;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: none;
    -webkit-touch-callout: none;
}

.puzzle-piece:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.puzzle-piece.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.puzzle-piece.placed {
    cursor: default;
}

/* GPS Warning Overlay */
.warning-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.warning-content {
    background: white;
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    max-width: 500px;
    margin: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #e5e7eb;
}

.warning-content h2 {
    color: #ef4444;
    margin-bottom: 20px;
}

.distance-info {
    font-size: 1.3em;
    font-weight: 700;
    color: #1a1a1a;
    margin: 20px 0;
}

.warning-timer {
    color: #ff9800;
    font-weight: 600;
    margin-top: 15px;
}

/* Results Screen */
#resultsScreen .container {
    max-width: 700px;
}

#resultsTitle {
    font-size: 2.5em;
    margin-bottom: 30px;
}

.results-stats {
    background: #f9fafb;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 25px;
    border: 1px solid #e5e7eb;
}

.results-stat {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #e0e0e0;
}

.results-stat:last-child {
    border-bottom: none;
}

.results-stat-label {
    font-weight: 600;
    color: #555;
}

.results-stat-value {
    font-weight: 700;
    color: #1a1a1a;
}

.completed-puzzle-preview {
    text-align: center;
    margin-bottom: 25px;
}

.completed-puzzle-preview img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.results-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

/* Error Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 16px;
    max-width: 400px;
    margin: 20px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #e5e7eb;
}

.modal-content h3 {
    color: #ef4444;
    margin-bottom: 15px;
    font-weight: 700;
}

.modal-content p {
    margin-bottom: 20px;
    line-height: 1.6;
}

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

    h1 {
        font-size: 2em;
    }

    h2 {
        font-size: 1.5em;
    }

    .btn {
        padding: 12px 30px;
        font-size: 1em;
        width: 100%;
    }

    .puzzle-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .puzzle-info {
        width: 100%;
        justify-content: space-between;
    }

    .difficulty-options {
        grid-template-columns: 1fr;
    }

    #statsContainer {
        grid-template-columns: repeat(2, 1fr);
    }

    .pieces-pool {
        max-width: 100%;
    }

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

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

@media (max-width: 480px) {
    .container {
        padding: 20px;
        width: 95%;
    }

    h1 {
        font-size: 1.75em;
    }

    .stat-number {
        font-size: 2em;
    }

    .timer {
        font-size: 1.2em;
    }

    .progress-info {
        font-size: 1em;
    }

    .pieces-pool {
        padding: 10px;
        gap: 6px;
        max-width: 100%;
    }

    .puzzle-board {
        padding: 5px;
    }

    .puzzle-container {
        padding: 10px;
    }
}

/* Drag and Drop States */
.puzzle-slot.drag-over {
    background: #c8e6c9;
    border-color: #4caf50;
}

/* Loading Spinner */
.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

