:root {
    --primary: #4CAF50;
    --primary-dark: #388E3C;
    --accent: #FFC107;
    --bg: #F5F7FA;
    --surface: #FFFFFF;
    --text: #333333;
    --text-light: #999999;
    --radius: 16px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    /* Prevent scrolling for app-like feel */
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
}

.view.active {
    display: flex;
}

/* --- Game View --- */
header {
    padding: 40px 20px 20px;
    text-align: center;
    background: var(--surface);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    z-index: 10;
}

h1 {
    margin: 0;
    font-size: 28px;
    color: var(--primary);
}

#score-board {
    font-size: 14px;
    color: var(--text-light);
    margin-top: 5px;
}

.grid-container {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 12px;
    padding: 20px;
    max-width: 500px;
    margin: 0 auto;
}

.bingo-square {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    border: 3px solid transparent;
}

.bingo-square:active {
    transform: scale(0.95);
}

.bingo-square.found {
    border-color: var(--primary);
    background: #E8F5E9;
}

.bingo-square img.photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

.bingo-square .label {
    font-size: 14px;
    font-weight: bold;
    color: var(--text);
    z-index: 2;
    background: rgba(255, 255, 255, 0.8);
    padding: 4px 8px;
    border-radius: 12px;
    margin-top: auto;
    margin-bottom: 10px;
}

.controls {
    padding: 20px;
    text-align: center;
    background: var(--surface);
}

/* --- Camera View --- */
#camera-view {
    background: #000;
}

#camera-feed {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.overlay-top {
    position: absolute;
    top: 40px;
    left: 0;
    width: 100%;
    padding: 0 20px;
    display: flex;
    align-items: center;
    pointer-events: none;
}

.btn-icon {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    backdrop-filter: blur(5px);
}

#target-hint {
    flex: 1;
    text-align: center;
    color: white;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 16px;
    border-radius: 20px;
    margin: 0 10px;
    backdrop-filter: blur(5px);
}

.overlay-bottom {
    position: absolute;
    bottom: 40px;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    pointer-events: none;
}

#prediction-box {
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    color: #333;
    transition: background-color 0.3s;
}

#prediction-box.match {
    background-color: #4CAF50;
    color: white;
}

.btn-capture {
    pointer-events: auto;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid white;
    background: transparent;
    cursor: pointer;
    transition: transform 0.2s, background 0.3s;
}

.btn-capture:active {
    transform: scale(0.9);
}

.btn-capture:not(:disabled) {
    background: rgba(255, 255, 255, 0.8);
}

.btn-capture:disabled {
    opacity: 0.5;
    border-color: #999;
}

/* --- Buttons --- */
.btn {
    padding: 12px 24px;
    border-radius: 30px;
    border: none;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn:active {
    opacity: 0.8;
}

.primary {
    background: var(--primary);
    color: white;
}

.accent {
    background: var(--accent);
    color: #333;
}

.secondary {
    background: #eee;
    color: #333;
}

.large {
    width: 100%;
    padding: 16px;
    font-size: 18px;
    margin-bottom: 12px;
}

/* --- Welcome View --- */
.welcome-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    text-align: center;
    background: linear-gradient(135deg, #e8f5e9 0%, #ffffff 100%);
}

.logo {
    width: 120px;
    height: 120px;
    border-radius: 24px;
    margin-bottom: 20px;
    box-shadow: 0 8px 20px rgba(76, 175, 80, 0.3);
}

.subtitle {
    color: var(--text-light);
    margin-top: -10px;
    margin-bottom: 30px;
}

.stats-card {
    background: white;
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    width: 100%;
    margin-bottom: 30px;
}

.stats-card h3 {
    margin: 0 0 10px 0;
    color: var(--primary);
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stats-card p {
    margin: 5px 0;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
}

.stats-card span {
    font-weight: bold;
    color: var(--text);
}

.menu-buttons {
    width: 100%;
}

.version {
    margin-top: 30px;
    font-size: 12px;
    color: #ccc;
}

.btn-icon.small {
    font-size: 18px;
    width: 32px;
    height: 32px;
    position: absolute;
    left: 20px;
    top: 35px;
    /* Adjust for header align */
}

/* --- Modal --- */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: var(--radius);
    text-align: center;
    width: 80%;
    max-width: 400px;
    animation: popIn 0.3s ease-out;
}

@keyframes popIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}