@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,700;1,400&family=DM+Serif+Display&display=swap');

:root {
    --bg: #faf8f5;
    --card: #ffffff;
    --text: #2c2c2c;
    --muted: #8a8580;
    --accent: #c47a5a;
    --accent-hover: #b06842;
    --border: #e8e4df;
    --error: #c44a3f;
    --correct: #4a8c5c;
    --correct-bg: #edf5ef;
    --wrong: #c44a3f;
    --wrong-bg: #fdf0ef;
}

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

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── Login ─────────────────────────────────────────── */

.login-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-box {
    background: var(--card);
    padding: 2.5rem 2rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    width: 100%;
    max-width: 340px;
    text-align: center;
}

.login-box h1 {
    font-family: 'DM Serif Display', serif;
    font-size: 1.5rem;
    margin-bottom: 0.3rem;
}

.login-box .subtitle {
    color: var(--muted);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.login-box input[type="password"] {
    width: 100%;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--bg);
    margin-bottom: 0.8rem;
    transition: border-color 0.2s;
}

.login-box input:focus { outline: none; border-color: var(--accent); }

.login-box button {
    width: 100%;
    padding: 0.65rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.login-box button:hover { background: var(--accent-hover); }

.error-msg {
    color: var(--error);
    font-size: 0.85rem;
    margin-bottom: 0.8rem;
}

/* ── Page layout ───────────────────────────────────── */

.page {
    max-width: 700px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.topbar h1 {
    font-family: 'DM Serif Display', serif;
    font-size: 1.6rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar a {
    color: var(--muted);
    font-size: 0.8rem;
    text-decoration: none;
}

.topbar a:hover { color: var(--text); }

.session-select {
    font-family: inherit;
    font-size: 0.8rem;
    color: var(--muted);
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
}

.session-select:focus { outline: none; border-color: var(--accent); }

.section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.2rem;
}

.section h2 {
    font-family: 'DM Serif Display', serif;
    font-size: 1.15rem;
    margin-bottom: 0.6rem;
}

.muted-text {
    color: var(--muted);
    font-size: 0.9rem;
}

/* ── Images ────────────────────────────────────────── */

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.8rem;
    margin-top: 0.5rem;
}

.image-slot {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg);
    border: 1px solid var(--border);
}

.image-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-slot.broken {
    display: flex;
    align-items: center;
    justify-content: center;
    border-style: dashed;
}

.image-slot.broken::after {
    content: "📷";
    font-size: 1.5rem;
    opacity: 0.4;
}

.image-slot.broken img { display: none; }

/* ── Quiz ──────────────────────────────────────────── */

.quiz-progress {
    text-align: center;
    color: var(--muted);
    font-size: 0.8rem;
    margin-bottom: 0.8rem;
}

.quiz-card {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.quiz-image {
    max-width: 100%;
    max-height: 250px;
    border-radius: 8px;
    margin-bottom: 1rem;
    object-fit: cover;
}

.quiz-question {
    font-size: 1.05rem;
    font-weight: 500;
    text-align: center;
    margin-bottom: 1rem;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    max-width: 400px;
}

.option-btn {
    padding: 0.6rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, background 0.15s;
}

.option-btn:hover:not(.locked) {
    border-color: var(--accent);
    background: #fdf8f5;
}

.option-btn.locked { cursor: default; }

.option-btn.correct {
    border-color: var(--correct);
    background: var(--correct-bg);
    color: var(--correct);
    font-weight: 500;
}

.option-btn.wrong {
    border-color: var(--wrong);
    background: var(--wrong-bg);
    color: var(--wrong);
}

.hint-btn {
    margin-top: 0.8rem;
    background: none;
    border: none;
    color: var(--muted);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}

.hint-btn:hover { color: var(--text); }

.hint {
    margin-top: 0.4rem;
    color: var(--muted);
    font-size: 0.85rem;
    font-style: italic;
}

.feedback {
    margin-top: 0.8rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.fb-correct { color: var(--correct); }
.fb-wrong { color: var(--wrong); }

.hidden { display: none; }

.btn {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.55rem 1.2rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.btn:hover { background: var(--accent-hover); }

.next-btn { margin-top: 1.2rem; }

/* ── Start screen ──────────────────────────────────── */

.start-screen { text-align: center; padding: 2rem 0; }
.start-actions { display: flex; gap: 0.8rem; justify-content: center; margin-top: 1.2rem; }
.start-btn { padding: 0.7rem 2.5rem; font-size: 1rem; }

.btn-outline {
    background: none;
    border: 1px solid var(--accent);
    color: var(--accent);
}
.btn-outline:hover { background: var(--accent); color: white; }

/* ── Gallery ───────────────────────────────────────── */

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.6rem;
    margin-top: 1rem;
}

.gallery-item {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    background: var(--bg);
    border: 2px solid transparent;
    transition: border-color 0.15s, transform 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-item:hover {
    border-color: var(--accent);
    transform: scale(1.04);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-no-img-icon {
    font-size: 1.6rem;
    opacity: 0.4;
}

.gallery-num {
    position: absolute;
    bottom: 4px;
    right: 5px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 3px;
}

/* ── Results ───────────────────────────────────────── */

.results { text-align: center; padding: 2rem 0; }
.results-emoji { font-size: 2.5rem; margin-bottom: 0.5rem; }
.results-score { font-size: 1.8rem; font-weight: 700; }

/* ── Matching question ─────────────────────────────── */

.matching-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1rem;
    width: 100%;
    margin-bottom: 1rem;
}

.match-col { display: flex; flex-direction: column; gap: 0.45rem; }

.match-item {
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    border: 2px solid var(--border);
    background: var(--bg);
    cursor: pointer;
    font-size: 0.85rem;
    text-align: center;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
    user-select: none;
    -webkit-user-select: none;
}

.match-item:hover:not(.locked):not(.match-paired) { border-color: var(--accent); }
.match-item.locked { cursor: default; }

.match-selected {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(196, 122, 90, 0.2);
    transform: scale(1.03);
}

/* Pair colours */
.pair-0 { background: #dbeafe; border-color: #3b82f6 !important; color: #1d4ed8; }
.pair-1 { background: #dcfce7; border-color: #22c55e !important; color: #15803d; }
.pair-2 { background: #fef3c7; border-color: #f59e0b !important; color: #92400e; }
.pair-3 { background: #fce7f3; border-color: #ec4899 !important; color: #9d174d; }
.pair-4 { background: #ede9fe; border-color: #8b5cf6 !important; color: #5b21b6; }
.pair-5 { background: #ffedd5; border-color: #f97316 !important; color: #9a3412; }

/* Result states */
.match-correct {
    border-color: var(--correct) !important;
    background: var(--correct-bg) !important;
    color: var(--correct) !important;
}
.match-wrong {
    border-color: var(--wrong) !important;
    background: var(--wrong-bg) !important;
    color: var(--wrong) !important;
}
.match-correct-answer {
    border-color: var(--correct) !important;
    outline: 2px dashed var(--correct);
    outline-offset: 2px;
}

.match-submit-btn { margin-top: 0; }

/* ── Before / after ───────────────────────────────── */

.before-after-wrap {
    position: relative;
    display: inline-block;
    margin-bottom: 1rem;
}

.ba-label {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    padding: 3px 8px;
    border-radius: 4px;
    z-index: 1;
    transition: opacity 0.3s ease;
}

.ba-image { transition: opacity 0.3s ease; }
.ba-fading { opacity: 0; }

/* ── Geo question ──────────────────────────────────── */

.geo-map {
    width: 100%;
    height: 320px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 0.6rem;
}

.geo-hint {
    margin-bottom: 0.8rem;
    text-align: center;
}

.geo-correct-icon {
    background: var(--correct);
    color: white;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* ── Admin ─────────────────────────────────────────── */

.admin-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    align-items: flex-end;
}

.admin-form label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.admin-form input[type="date"],
.admin-form input[type="number"] {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    background: var(--bg);
}

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

.btn-small {
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
}

.session-options {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.radio-label input { accent-color: var(--accent); }

.session-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.session-card:last-child { border-bottom: none; }

.session-active {
    color: var(--accent);
    font-weight: 500;
}
