/* ============================================================
   FunisLearn — Teacher-made games
   Shared by the teacher's authoring/report page and the student
   player overlays. Mobile-first; RTL.
   ============================================================ */

:root {
    --tg-purple: #667eea;
    --tg-deep: #764ba2;
    --tg-green: #22a06b;
    --tg-red: #e5484d;
    --tg-amber: #FFB300;
    --tg-ink: #23263a;
    --tg-line: #e6e8f0;
}

/* ---------- Overlays (student: name gate, result) ---------- */

.tg-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(18, 18, 38, .9);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    direction: rtl;
    font-family: 'Tajawal', 'Cairo', sans-serif;
}

.tg-card {
    background: #fff;
    border-radius: 26px;
    padding: 30px 24px;
    text-align: center;
    width: min(94%, 420px);
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    border: 5px solid var(--tg-amber);
    box-sizing: border-box;
}

.tg-card-wide { width: min(96%, 560px); }
.tg-emoji { font-size: 3.2rem; line-height: 1; }
.tg-card h2 { color: var(--tg-deep); margin: 10px 0 8px; font-size: 1.6rem; }
.tg-card p { color: #5b5f72; margin: 0 0 16px; }

.tg-score {
    font-size: 2.6rem;
    font-weight: 900;
    color: var(--tg-deep);
    background: #f3f1ff;
    border-radius: 18px;
    padding: 10px;
    margin-bottom: 10px;
}

.tg-input {
    width: 100%;
    padding: 14px;
    font-size: 16px; /* stops iOS Safari zooming on focus */
    border: 2px solid var(--tg-line);
    border-radius: 14px;
    margin-bottom: 12px;
    font-family: inherit;
    text-align: center;
    box-sizing: border-box;
}

.tg-input:focus { outline: none; border-color: var(--tg-purple); }

.tg-btn {
    display: block;
    width: 100%;
    min-height: 48px;
    padding: 14px;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: inherit;
    color: #fff;
    background: linear-gradient(135deg, var(--tg-purple) 0%, var(--tg-deep) 100%);
    border: none;
    border-radius: 40px;
    cursor: pointer;
    text-align: center;
}

.tg-btn:disabled { opacity: .6; cursor: not-allowed; }
.tg-btn-link { text-decoration: none; line-height: 1.4; }

.tg-error {
    display: none;
    background: #ffe9ec;
    color: #c92a44;
    border-radius: 12px;
    padding: 9px 12px;
    margin-bottom: 12px;
    font-size: .92rem;
}

/* ---------- Student's per-question breakdown ---------- */

.tg-res-list {
    list-style: none;
    margin: 4px 0 18px;
    padding: 0;
    text-align: start;
}

.tg-res-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    border-radius: 14px;
    margin-bottom: 6px;
    background: #f7f8fc;
    border-inline-start: 4px solid var(--tg-line);
}

.tg-res-row.ok  { border-inline-start-color: var(--tg-green); }
.tg-res-row.bad { border-inline-start-color: var(--tg-red); }

.tg-res-mark { flex: 0 0 auto; font-size: 1.05rem; }
.tg-res-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tg-res-q { color: var(--tg-ink); font-size: .95rem; }
.tg-res-detail { color: #6b7080; font-size: .85rem; }

/* ============================================================
   Teacher's page: my games, builder, report
   ============================================================ */

.tgp {
    max-width: 900px;
    margin: 28px auto 60px;
    padding: 0 14px;
    font-family: 'Tajawal', 'Cairo', sans-serif;
    direction: rtl;
}

.tgp h1 { color: var(--tg-deep); font-size: 1.7rem; margin: 0 0 6px; }
.tgp-sub { color: #6b7080; margin: 0 0 22px; }

.tgp-panel {
    background: #fff;
    border-radius: 20px;
    padding: 22px 18px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .07);
    margin-bottom: 18px;
}

.tgp-panel h2 { font-size: 1.2rem; color: var(--tg-ink); margin: 0 0 14px; }

.tgp-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.tgp-btn {
    min-height: 44px;
    padding: 11px 20px;
    border: none;
    border-radius: 30px;
    font-family: inherit;
    font-weight: 700;
    font-size: .95rem;
    cursor: pointer;
    background: linear-gradient(135deg, var(--tg-purple) 0%, var(--tg-deep) 100%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
}

.tgp-btn.ghost {
    background: #fff;
    color: var(--tg-deep);
    border: 2px solid var(--tg-line);
}

.tgp-btn.danger { background: var(--tg-red); }
.tgp-btn.small { min-height: 38px; padding: 8px 14px; font-size: .85rem; }
.tgp-btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Game cards ---------- */

.tgp-games {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 14px;
}

.tgp-game {
    background: #fff;
    border: 2px solid var(--tg-line);
    border-radius: 18px;
    padding: 16px;
}

.tgp-game.off { opacity: .6; }
.tgp-game-skin { font-size: 1.6rem; }
.tgp-game h3 { margin: 6px 0 4px; font-size: 1.05rem; color: var(--tg-ink); }

.tgp-game-meta {
    color: #6b7080;
    font-size: .85rem;
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
}

.tgp-game-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.tgp-empty {
    text-align: center;
    color: #6b7080;
    padding: 30px 10px;
}

/* ---------- Skin picker ---------- */

.tgp-skins {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.tgp-skin {
    border: 2px solid var(--tg-line);
    border-radius: 16px;
    padding: 14px 10px;
    text-align: center;
    cursor: pointer;
    background: #fff;
    font-family: inherit;
    min-height: 96px;
}

.tgp-skin:hover { border-color: var(--tg-purple); }

.tgp-skin.selected {
    border-color: var(--tg-deep);
    background: #f3f1ff;
    box-shadow: 0 0 0 3px rgba(118, 75, 162, .15);
}

.tgp-skin-emoji { font-size: 1.9rem; display: block; }
.tgp-skin-label { font-weight: 700; color: var(--tg-ink); font-size: .92rem; }
.tgp-skin-blurb { color: #6b7080; font-size: .76rem; display: block; margin-top: 3px; }

/* ---------- Question builder ---------- */

.tgp-field { margin-bottom: 14px; }
.tgp-field label { display: block; font-weight: 700; color: var(--tg-ink); margin-bottom: 6px; font-size: .95rem; }

.tgp-field input[type="text"],
.tgp-field textarea {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid var(--tg-line);
    border-radius: 12px;
    font-family: inherit;
    box-sizing: border-box;
}

.tgp-q {
    border: 2px solid var(--tg-line);
    border-radius: 16px;
    padding: 14px;
    margin-bottom: 12px;
    background: #fafbff;
}

.tgp-q-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.tgp-q-num { font-weight: 800; color: var(--tg-deep); }

.tgp-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 7px;
}

.tgp-opt input[type="text"] {
    flex: 1;
    padding: 10px;
    font-size: 16px;
    border: 2px solid var(--tg-line);
    border-radius: 10px;
    font-family: inherit;
    min-width: 0;
}

/* The radio marks which option is the right answer. */
.tgp-opt-radio {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .8rem;
    color: #6b7080;
    white-space: nowrap;
    cursor: pointer;
    min-height: 44px;
    padding: 0 4px;
}

.tgp-opt-radio input { width: 20px; height: 20px; accent-color: var(--tg-green); }
.tgp-opt.is-correct input[type="text"] { border-color: var(--tg-green); background: #f2fbf7; }

.tgp-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    min-width: 44px;
    min-height: 44px;
    border-radius: 10px;
    color: var(--tg-red);
}

.tgp-note {
    background: #f3f1ff;
    color: var(--tg-deep);
    border-radius: 12px;
    padding: 11px 14px;
    font-size: .88rem;
    margin-bottom: 16px;
}

/* ---------- Share box ---------- */

.tgp-share { display: flex; gap: 8px; margin: 10px 0 4px; }

.tgp-share input {
    flex: 1;
    padding: 11px;
    border: 2px solid var(--tg-line);
    border-radius: 12px;
    font-family: inherit;
    font-size: .85rem;
    direction: ltr;
    text-align: left;
    background: #fafbff;
    min-width: 0;
}

/* ---------- Report ---------- */

.tgp-student {
    border: 2px solid var(--tg-line);
    border-radius: 16px;
    margin-bottom: 10px;
    overflow: hidden;
}

.tgp-student-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 14px;
    cursor: pointer;
    background: #fff;
}

.tgp-student-name { flex: 1; font-weight: 700; color: var(--tg-ink); min-width: 0; }

.tgp-pill {
    font-weight: 800;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: .88rem;
    white-space: nowrap;
}

.tgp-pill.good { background: #e7f8f0; color: var(--tg-green); }
.tgp-pill.mid  { background: #fff6e0; color: #a86b00; }
.tgp-pill.low  { background: #ffe9ec; color: #c92a44; }

.tgp-student-body { display: none; padding: 4px 12px 12px; background: #fafbff; }
.tgp-student.open .tgp-student-body { display: block; }
.tgp-caret { color: #9aa0b4; font-size: .8rem; }

.tgp-qstat {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 12px;
    background: #fff;
    margin-bottom: 6px;
    border: 1px solid var(--tg-line);
}

.tgp-qstat-text { flex: 1; font-size: .9rem; color: var(--tg-ink); min-width: 0; }
.tgp-qstat-nums { font-size: .82rem; white-space: nowrap; }
.tgp-qstat-nums .r { color: var(--tg-green); font-weight: 700; }
.tgp-qstat-nums .w { color: var(--tg-red); font-weight: 700; }

@media (max-width: 600px) {
    .tgp-panel { padding: 16px 13px; border-radius: 16px; }
    .tgp h1 { font-size: 1.35rem; }
    .tgp-games { grid-template-columns: 1fr; }
    .tgp-skins { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tgp-opt { flex-wrap: wrap; }
    .tgp-opt input[type="text"] { flex: 1 1 100%; order: 1; }
    .tgp-opt-radio { order: 2; }
    .tgp-icon-btn { order: 3; }
}
