/* === Variables === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:          #0a0a0a;
    --bg-card:     #111111;
    --bg-elevated: #1a1a1a;
    --bg-input:    #141414;
    --border:      #2a2a2a;
    --border-focus:#444444;
    --accent:      #ffe600;
    --accent-fg:   #0a0a0a;
    --text:        #e8e8e8;
    --text-muted:  #666666;
    --text-dim:    #444444;
    --destructive: #ef4444;
    --success:     #22c55e;
    --radius:      6px;
    --radius-sm:   4px;
    --font:        'JetBrains Mono', monospace;
    --mono:        'JetBrains Mono', monospace;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* === App Layout === */
.app { min-height: 100dvh; display: flex; flex-direction: column; }

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.app-main {
    flex: 1;
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

/* === Animations === */
@keyframes slideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: none; }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--mono);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none;
    color: var(--text);
    background: var(--bg-elevated);
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #222222; border-color: #3a3a3a; }
.btn:active { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-fg);
    font-weight: 700;
}
.btn-primary:hover:not(:disabled) {
    background: #ffed4d;
    border-color: #ffed4d;
    color: var(--accent-fg);
}

.btn-lg { padding: 12px 24px; font-size: 0.9rem; width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 0.75rem; }
.btn-xs { padding: 3px 8px; font-size: 0.72rem; }
.btn-icon { background: none; border: none; font-size: 1rem; cursor: pointer; padding: 4px; color: var(--text-muted); }
.btn-icon:hover { color: var(--text); }

.btn-camera {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.9rem;
    padding: 14px 24px;
    width: 100%;
    border-radius: var(--radius);
}
.btn-camera:hover { border-color: var(--accent); color: var(--accent); background: var(--bg-elevated); }

.btn-hint {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.78rem;
    border: 1px solid var(--border);
}
.btn-hint:hover { border-color: var(--accent); color: var(--accent); background: transparent; }

.btn-warn    { border-color: var(--destructive); color: var(--destructive); background: transparent; }
.btn-warn:hover { background: rgba(239,68,68,0.08); border-color: var(--destructive); color: var(--destructive); }
.btn-success { border-color: var(--success); color: var(--success); background: transparent; }
.btn-success:hover { background: rgba(34,197,94,0.08); }
.btn-accent  { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }

/* === Login Page === */
.login-page {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-container { width: 100%; max-width: 360px; }

.login-brand { margin-bottom: 32px; }
.login-icon { font-size: 2rem; margin-bottom: 16px; }

.login-brand h1 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text);
    letter-spacing: -0.01em;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.78rem;
    letter-spacing: 0.02em;
}
.login-subtitle::before { content: '// '; color: var(--accent); }

.login-form { display: flex; flex-direction: column; gap: 12px; }

.input-code {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--mono);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-align: center;
    padding: 16px;
    width: 100%;
    outline: none;
    transition: border-color 0.15s;
    text-transform: uppercase;
}
.input-code:focus { border-color: var(--accent); }
.input-code::placeholder { color: var(--text-dim); font-weight: 400; font-size: 0.85rem; letter-spacing: 0.08em; }

/* Location error */
.location-error {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}
.location-error-icon { font-size: 1.5rem; margin-bottom: 10px; }
.location-error-title {
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--accent);
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.location-error-title::before { content: '// '; }
.location-error-body  { color: var(--text); margin-bottom: 10px; font-size: 0.82rem; line-height: 1.6; }
.location-error-hint  { color: var(--text-muted); font-size: 0.75rem; line-height: 1.6; }

/* === Challenge View === */
.challenge-container { padding-bottom: 40px; }

.progress-track {
    height: 1px;
    background: var(--border);
    margin-bottom: 24px;
}
.progress-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.5s ease;
}

.challenge-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}
.challenge-name {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    text-transform: uppercase;
}
.challenge-name::before { content: '// '; color: var(--accent); }

.substep-badge {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    color: var(--text-muted);
}

.challenge-image-wrap {
    margin-bottom: 16px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}
.challenge-image { width: 100%; display: block; }

.challenge-prompt {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 32px;
    line-height: 1.8;
    font-size: 0.88rem;
    color: var(--text);
}

.challenge-prompt ul,
.challenge-prompt ol {
    margin: 16px 0 16px 20px;
    padding-left: 0;
}

.challenge-prompt li {
    margin: 8px 0;
}

.challenge-prompt code,
.challenge-prompt pre {
    font-family: var(--mono);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    color: var(--accent);
}

/* === Answer Section === */
.answer-form    { margin-bottom: 20px; }
.answer-section { margin-bottom: 12px; }

.input-answer {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--mono);
    font-size: 1.1rem;
    padding: 14px 16px;
    width: 100%;
    outline: none;
    transition: border-color 0.15s;
}
.input-answer:focus { border-color: var(--accent); }
.input-answer::placeholder { color: var(--text-dim); font-size: 0.85rem; }

/* === Selfie === */
.selfie-section { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.selfie-preview { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.selfie-preview img { width: 100%; display: block; }
.hidden-input { display: none; }

/* === Hint === */
.hint-section { text-align: center; }

.hint-box {
    margin-top: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    color: var(--text);
    font-size: 0.83rem;
    text-align: left;
    line-height: 1.7;
}
.hint-box::before { content: '// hint\A'; white-space: pre; color: var(--accent); font-size: 0.72rem; letter-spacing: 0.06em; display: block; margin-bottom: 6px; }

/* === Flash Messages === */
.flash-messages { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }

.flash-msg {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 0.82rem;
    cursor: pointer;
    animation: slideIn 0.2s ease both;
    line-height: 1.5;
}
.flash-error {
    border-color: rgba(239,68,68,0.4);
    background: rgba(239,68,68,0.05);
}

/* === Finished === */
.finished-container { text-align: center; padding-top: 48px; }
.finished-icon { font-size: 3rem; margin-bottom: 20px; }
.finished-container h1 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    letter-spacing: 0.04em;
    color: var(--text);
}
.finished-container h1::before { content: '// '; color: var(--accent); }
.finished-message { color: var(--text-muted); margin-bottom: 32px; font-size: 0.88rem; line-height: 1.7; }
.finish-location {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}
.finish-location h3 { margin-bottom: 8px; color: var(--text-muted); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; }
.finish-location h3::before { content: '// '; color: var(--accent); }
.finish-place { font-size: 1rem; font-weight: 700; margin-bottom: 20px; color: var(--text); }

/* === Header Badges === */
.team-badge {
    background: var(--accent);
    color: var(--accent-fg);
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.step-counter {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* === Overlays === */
.message-overlay, .pause-overlay, .verify-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 24px;
    backdrop-filter: blur(4px);
}

.message-card, .pause-card, .verify-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px;
    max-width: 340px;
    width: 100%;
    text-align: center;
    animation: slideIn 0.2s ease both;
}

.message-icon, .pause-icon { font-size: 2rem; margin-bottom: 14px; }
.message-text  { margin-bottom: 20px; font-size: 0.9rem; line-height: 1.7; }
.pause-sub     { color: var(--text-muted); margin-top: 8px; font-size: 0.82rem; }

.verify-spinner {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 16px;
}

/* === Utilities === */
.hidden { display: none !important; }

/* === Photo Gallery (Admin) === */
.photos-page { padding: 20px; max-width: 800px; margin: 0 auto; }
.photos-page h2 { margin-bottom: 16px; font-size: 0.9rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.photos-page h2::before { content: '// '; color: var(--accent); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 16px; }
.photo-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.photo-card img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.photo-meta { padding: 10px; font-size: 0.72rem; color: var(--text-muted); line-height: 1.6; }
.empty-state { color: var(--text-muted); text-align: center; padding: 40px; font-size: 0.85rem; }

.badge { padding: 2px 7px; border-radius: var(--radius-sm); font-size: 0.7rem; }
.badge-done { background: rgba(34,197,94,0.1);  color: var(--success);     border: 1px solid rgba(34,197,94,0.25); }
.badge-fail { background: rgba(239,68,68,0.1);  color: var(--destructive); border: 1px solid rgba(239,68,68,0.25); }

/* === Debug Panel === */
#dbg-toggle {
    position: fixed;
    bottom: 12px;
    right: 12px;
    z-index: 999;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    letter-spacing: 0.08em;
    user-select: none;
}
#dbg-toggle:hover { border-color: var(--accent); color: var(--accent); }

#dbg-panel {
    position: fixed;
    bottom: 40px;
    right: 12px;
    z-index: 998;
    width: min(320px, calc(100vw - 24px));
    max-height: 60vh;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--mono);
    font-size: 0.72rem;
    overflow-y: auto;
}

.dbg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    color: var(--accent);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    letter-spacing: 0.08em;
    font-size: 0.7rem;
}
.dbg-header::before { content: '// '; }
.dbg-header button { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 0.9rem; padding: 0 2px; }

.dbg-section { padding: 8px 12px 2px; color: var(--text-dim); font-size: 0.65rem; letter-spacing: 0.1em; text-transform: uppercase; }
.dbg-section::before { content: '// '; color: var(--accent); }

.dbg-row { display: flex; gap: 8px; padding: 2px 12px; border-bottom: 1px solid rgba(255,255,255,0.03); }
.dbg-key { color: var(--text-muted); flex-shrink: 0; width: 80px; }
.dbg-val { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
