/* Shared styling for the JobRojgar "Games" section (/games hub + every /games/{slug} page).
   Mirrors student-tools.css's structural conventions (.stt-wrap/.stt-card/.stt-seo-content are
   reused directly on game pages for the intro/SEO/FAQ blocks) but with its own "game-" prefix
   for everything game-specific, so the two style sheets never collide.
   Uses the site's existing dark-mode.css variables (--bg-card, --text-primary, etc.) throughout,
   so this file needs no separate dark-mode overrides -- it already adapts automatically. */

.game-wrap {
    max-width: 980px;
    margin: 0 auto;
    padding: 0 16px;
}
.game-wrap-narrow { max-width: 760px; }

/* The site's fixed top header sits over page content with nothing pushing it down, so every
   Games page needs top clearance here. Two different fixed headers can render depending on
   the request's detected device (server-side, not a CSS breakpoint): .appHeader on mobile
   (56px) or #header.jrh-header-v2 on desktop (height:80px, from style.css, in its unscrolled
   state). 100px clears the taller of the two (80px + 20px breathing room) with margin to
   spare on mobile too. */
.game-heading { text-align: center; margin-bottom: 24px; padding-top: 100px; }
.game-heading h1 {
    font-size: 30px;
    font-weight: 800;
    color: var(--text-primary, #1e293b);
    margin: 6px 0 10px;
}
.game-heading p {
    font-size: 15px;
    color: var(--text-secondary, #64748b);
    max-width: 60ch;
    margin: 0 auto 14px;
}
.game-breadcrumb {
    font-size: 12.5px;
    color: var(--text-secondary, #64748b);
}
.game-breadcrumb a { color: var(--primary-color, #2563eb); text-decoration: none; }
.game-breadcrumb a:hover { text-decoration: underline; }
.game-breadcrumb .sep { margin: 0 6px; }

.game-tagline {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 999px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: .02em;
    margin-bottom: 10px;
}

/* ---- Profile bar (XP / level / streak / badges) -- shown on hub + every game page ---- */
.game-profile-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-radius: 14px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    box-shadow: 0 8px 20px var(--shadow-color, rgba(15,23,42,0.06));
    margin-bottom: 22px;
}
.game-profile-stat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    white-space: nowrap;
}
.game-profile-stat i { color: #7c3aed; }
.game-xp-bar {
    flex: 1;
    min-width: 90px;
    height: 8px;
    border-radius: 5px;
    background: var(--bg-subtle, #f1f5f9);
    overflow: hidden;
}
.game-xp-bar-fill {
    display: block;
    height: 100%;
    border-radius: 5px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    transition: width .4s ease;
}

/* ---- Hub page: game cards grid ---- */
.game-hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    margin: 28px 0;
}
.game-hub-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 16px;
    padding: 22px 20px;
    box-shadow: 0 8px 20px var(--shadow-color, rgba(15,23,42,0.06));
    transition: transform .18s ease, box-shadow .18s ease;
}
.game-hub-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 32px var(--shadow-color, rgba(15,23,42,0.12));
}
.game-hub-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    margin-bottom: 14px;
}
.game-hub-card.is-daily .game-hub-card-icon { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.game-hub-card h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
    margin: 0 0 6px;
}
.game-hub-card p {
    font-size: 13.5px;
    color: var(--text-secondary, #64748b);
    line-height: 1.5;
    margin: 0 0 14px;
    flex: 1;
}
.game-hub-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.game-badge-daily {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: #fff;
}
.game-badge-difficulty {
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}
.game-badge-difficulty.is-easy { background: rgba(34,197,94,0.14); color: #22c55e; }
.game-badge-difficulty.is-medium { background: rgba(245,158,11,0.14); color: #f59e0b; }
.game-badge-difficulty.is-hard { background: rgba(239,68,68,0.14); color: #ef4444; }
.game-badge-time {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    color: var(--text-secondary, #64748b);
}
.game-hub-card-best {
    font-size: 11.5px;
    color: var(--text-secondary, #64748b);
    margin-bottom: 10px;
}
.game-hub-card-best b { color: #7c3aed; }

.game-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: none;
    border-radius: 999px;
    padding: 11px 20px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: transform .15s ease, opacity .15s ease;
}
.game-btn:hover { transform: translateY(-1px); text-decoration: none; }
.game-btn-primary {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    box-shadow: 0 8px 18px rgba(124,58,237,0.35);
    width: 100%;
}
.game-btn-primary:hover { color: #fff; opacity: .94; }
.game-btn-outline {
    background: transparent;
    color: var(--text-primary, #1e293b);
    border: 1px solid var(--border-color, #e2e8f0);
}
.game-btn-outline:hover { color: var(--text-primary, #1e293b); background: var(--hover-bg, #eff6ff); }
.game-btn-sm { padding: 8px 16px; font-size: 13px; }

/* ---- Individual game page: main play area ---- */
.game-card {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 18px;
    padding: 26px;
    box-shadow: 0 8px 24px var(--shadow-color, rgba(15,23,42,0.07));
    margin-bottom: 26px;
}
.game-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 10px;
    margin: 18px 0;
}
.game-stat-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 62px;
    text-align: center;
    padding: 12px 8px;
    border-radius: 12px;
    background: var(--bg-subtle, #f8fafc);
    border: 1px solid var(--border-color, #e2e8f0);
}
.game-stat-value {
    display: block;
    font-size: 21px;
    font-weight: 800;
    color: var(--text-primary, #1e293b);
}
.game-stat-label {
    display: block;
    font-size: 11px;
    color: var(--text-secondary, #64748b);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.game-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.game-message-banner {
    text-align: center;
    padding: 14px 18px;
    border-radius: 12px;
    background: var(--bg-subtle, #f8fafc);
    border: 1px solid var(--border-color, #e2e8f0);
    color: var(--text-primary, #1e293b);
    font-weight: 700;
    font-size: 16px;
    margin: 16px 0;
    display: none;
}
.game-message-banner.is-visible { display: block; }
.game-message-banner.is-win { color: #22c55e; border-color: rgba(34,197,94,0.35); background: rgba(34,197,94,0.08); }
.game-message-banner.is-lose { color: #ef4444; border-color: rgba(239,68,68,0.35); background: rgba(239,68,68,0.08); }

.game-tip {
    display: none;
    margin-top: 16px;
    padding: 14px 18px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(79,70,229,0.08), rgba(124,58,237,0.08));
    border: 1px solid rgba(124,58,237,0.25);
    color: var(--text-primary, #1e293b);
    font-size: 13.5px;
    line-height: 1.55;
}
.game-tip.is-visible { display: block; }
.game-tip b { color: #7c3aed; }

/* ---- Achievement / daily-challenge / best-score toast (bottom-right, auto-dismissing) ---- */
.game-toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 3000;
    max-width: 320px;
    padding: 13px 18px;
    border-radius: 12px;
    background: var(--bg-card, #1e293b);
    color: var(--text-primary, #fff);
    border: 1px solid var(--border-color, #334155);
    box-shadow: 0 12px 30px rgba(0,0,0,0.25);
    font-size: 13.5px;
    font-weight: 600;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity .3s ease, transform .3s ease;
}
.game-toast.is-visible { opacity: 1; transform: translateY(0); }
.game-toast i { margin-right: 4px; }
.game-toast-achievement { border-color: #f59e0b; }
.game-toast-achievement i { color: #f59e0b; }
.game-toast-daily { border-color: #ef4444; }
.game-toast-daily i { color: #ef4444; }
.game-toast-best { border-color: #22c55e; }
.game-toast-best i { color: #22c55e; }

/* ---- Answer-review UI shared by Quiz Challenge / Coding Bug Hunt ---- */
.game-option-list { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.game-option-btn {
    text-align: left;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-subtle, #f8fafc);
    color: var(--text-primary, #1e293b);
    font-size: 14px;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}
.game-option-btn:hover:not(:disabled) { border-color: #7c3aed; background: var(--hover-bg, #eff6ff); }
.game-option-btn:disabled { cursor: default; }
.game-option-btn.is-correct { border-color: #22c55e; background: rgba(34,197,94,0.12); color: #16a34a; font-weight: 700; }
.game-option-btn.is-incorrect { border-color: #ef4444; background: rgba(239,68,68,0.12); color: #dc2626; font-weight: 700; }
.game-explanation {
    display: none;
    margin-top: 14px;
    padding: 12px 16px;
    border-radius: 10px;
    background: var(--bg-subtle, #f8fafc);
    border-left: 3px solid #7c3aed;
    font-size: 13.5px;
    color: var(--text-secondary, #64748b);
}
.game-explanation.is-visible { display: block; }
.game-code-block {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 10px;
    padding: 16px 18px;
    font-family: 'Courier New', monospace;
    font-size: 13.5px;
    line-height: 1.7;
    overflow-x: auto;
    margin: 14px 0;
    white-space: pre;
}
.game-code-line { display: block; padding: 1px 8px; border-radius: 4px; }
.game-code-line.is-clickable { cursor: pointer; }
.game-code-line.is-clickable:hover { background: rgba(124,58,237,0.25); }
.game-code-line.is-buggy-correct { background: rgba(34,197,94,0.3); }
.game-code-line.is-buggy-wrong { background: rgba(239,68,68,0.3); }

/* ---- Canvas-based games (Snake) ---- */
.game-canvas-wrap { display: flex; justify-content: center; margin: 10px 0; }
.game-canvas-wrap canvas {
    background: #0f172a;
    border-radius: 12px;
    max-width: 100%;
    touch-action: none;
}
.game-touch-controls {
    display: none;
    grid-template-columns: 60px 60px 60px;
    grid-template-rows: 60px 60px 60px;
    gap: 6px;
    justify-content: center;
    margin: 16px auto 0;
    width: fit-content;
}
.game-touch-controls button {
    border: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-subtle, #f8fafc);
    color: var(--text-primary, #1e293b);
    border-radius: 10px;
    font-size: 18px;
    cursor: pointer;
}
@media (max-width: 700px) {
    .game-touch-controls { display: grid; }
}

/* ---- 2048 grid ---- */
.game-2048-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    max-width: 380px;
    margin: 0 auto;
    padding: 10px;
    background: var(--bg-subtle, #cbd5e1);
    border-radius: 12px;
}
.game-2048-cell {
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 800;
    border-radius: 8px;
    background: rgba(148,163,184,0.25);
    color: var(--text-primary, #1e293b);
    transition: background .15s ease, transform .1s ease;
}

/* ---- Memory match grid ---- */
.game-memory-grid {
    display: grid;
    gap: 10px;
    max-width: 420px;
    margin: 0 auto;
}
.game-memory-card {
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    border-radius: 10px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: transparent;
    cursor: pointer;
    user-select: none;
    transition: transform .15s ease;
}
.game-memory-card.is-flipped, .game-memory-card.is-matched {
    background: var(--bg-subtle, #f8fafc);
    border: 1px solid var(--border-color, #e2e8f0);
    color: var(--text-primary, #1e293b);
}
.game-memory-card.is-matched { opacity: .55; }

/* ---- Difficulty / options row shared across several games ---- */
.game-option-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.game-choice-pill {
    padding: 7px 16px;
    border-radius: 999px;
    border: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-subtle, #f8fafc);
    color: var(--text-secondary, #64748b);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.game-choice-pill.is-active {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    border-color: transparent;
}

/* ---- Reaction test / RPS choice buttons ---- */
.game-rps-row, .game-reaction-zone {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin: 20px 0;
    flex-wrap: wrap;
}
.game-rps-btn {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    border: 2px solid var(--border-color, #e2e8f0);
    background: var(--bg-subtle, #f8fafc);
    font-size: 30px;
    cursor: pointer;
    transition: transform .15s ease, border-color .15s ease;
}
.game-rps-btn:hover { transform: scale(1.08); border-color: #7c3aed; }

.game-reaction-box {
    width: 100%;
    max-width: 480px;
    height: 220px;
    margin: 0 auto;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    background: #64748b;
    transition: background .1s ease;
    user-select: none;
}
.game-reaction-box.is-waiting { background: #ef4444; }
.game-reaction-box.is-ready { background: #22c55e; }
.game-reaction-box.is-toosoon { background: #f59e0b; }

/* ---- Typing test ---- */
.game-typing-passage {
    font-size: 17px;
    line-height: 1.8;
    padding: 16px 18px;
    border-radius: 12px;
    background: var(--bg-subtle, #f8fafc);
    border: 1px solid var(--border-color, #e2e8f0);
    color: var(--text-secondary, #64748b);
    font-family: 'Courier New', monospace;
    margin-bottom: 14px;
}
.game-typing-passage .is-correct { color: #22c55e; }
.game-typing-passage .is-wrong { color: #ef4444; text-decoration: underline; }
.game-typing-passage .is-current { background: var(--hover-bg, #eff6ff); border-radius: 2px; }
.game-typing-input {
    width: 100%;
    min-height: 90px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-card, #fff);
    color: var(--text-primary, #1e293b);
    font-size: 15px;
    font-family: 'Courier New', monospace;
    resize: vertical;
}

/* ---- Word Scramble: jumbled letter tiles + answer slots ---- */
.game-letter-tiles, .game-answer-slots {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 16px 0;
}
.game-letter-tile {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    border: 1px solid var(--border-color, #e2e8f0);
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    font-size: 20px;
    font-weight: 800;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform .12s ease, opacity .12s ease;
}
.game-letter-tile:hover:not(:disabled) { transform: translateY(-2px); }
.game-letter-tile:disabled { opacity: .35; cursor: default; }
.game-answer-slot {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    border: 2px dashed var(--border-color, #e2e8f0);
    background: var(--bg-subtle, #f8fafc);
    color: var(--text-primary, #1e293b);
    font-size: 20px;
    font-weight: 800;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.game-answer-slot.is-filled { border-style: solid; border-color: #7c3aed; }

/* ---- Math Blitz: large problem display ---- */
.game-timer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary, #64748b);
    text-transform: uppercase;
    letter-spacing: .03em;
}
.game-timer-row .game-timer-value {
    font-size: 13px;
    color: var(--text-primary, #1e293b);
}
.game-math-problem {
    text-align: center;
    font-size: 34px;
    font-weight: 800;
    color: var(--text-primary, #1e293b);
    margin: 18px 0 14px;
}
.game-math-input {
    display: block;
    width: 160px;
    margin: 0 auto 16px;
    padding: 11px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-card, #fff);
    color: var(--text-primary, #1e293b);
    font-size: 18px;
    text-align: center;
}
.game-math-input::-webkit-outer-spin-button,
.game-math-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.game-math-input[type=number] {
    -moz-appearance: textfield;
}
.game-timer-bar {
    height: 8px;
    border-radius: 5px;
    background: var(--bg-subtle, #f1f5f9);
    overflow: hidden;
    margin-bottom: 16px;
}
.game-timer-bar-fill {
    display: block;
    height: 100%;
    border-radius: 5px;
    background: linear-gradient(135deg, #22c55e, #f59e0b);
    transition: width 1s linear;
}

/* ---- Word Guess (Wordle-style) grid + on-screen keyboard ---- */
.game-wordle-grid {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: 6px;
    max-width: 300px;
    margin: 0 auto 18px;
}
.game-wordle-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}
.game-wordle-cell {
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    font-size: 22px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-primary, #1e293b);
    background: var(--bg-subtle, #f8fafc);
}
.game-wordle-cell.is-correct { background: #22c55e; border-color: #22c55e; color: #fff; }
.game-wordle-cell.is-present { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.game-wordle-cell.is-absent { background: #64748b; border-color: #64748b; color: #fff; }

.game-keyboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    margin: 10px 0;
}
.game-keyboard-row { display: flex; gap: 5px; }
.game-key {
    min-width: 32px;
    height: 44px;
    padding: 0 8px;
    border-radius: 6px;
    border: none;
    background: var(--bg-subtle, #e2e8f0);
    color: var(--text-primary, #1e293b);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
}
.game-key:hover:not(:disabled) { background: var(--hover-bg, #eff6ff); }
.game-key.is-wide { min-width: 52px; font-size: 11px; }
.game-key.is-correct { background: #22c55e; color: #fff; }
.game-key.is-present { background: #f59e0b; color: #fff; }
.game-key.is-absent { background: #334155; color: #fff; }

/* ---- Hangman ---- */
.game-hangman-figure {
    display: block;
    margin: 0 auto 10px;
    color: var(--text-primary, #1e293b);
}
.game-hangman-word {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 16px 0;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 4px;
    color: var(--text-primary, #1e293b);
}
.game-hangman-word .letter-slot {
    min-width: 24px;
    border-bottom: 3px solid var(--border-color, #e2e8f0);
    text-align: center;
    text-transform: uppercase;
}

@media (max-width: 700px) {
    .game-heading h1 { font-size: 24px; }
    .game-hub-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .game-hub-card { padding: 16px 14px; }
    .game-profile-bar { gap: 10px; padding: 12px 14px; }
    .game-canvas-wrap canvas { width: 100%; height: auto; }
    .game-letter-tile, .game-answer-slot { width: 38px; height: 38px; font-size: 17px; }
    .game-math-problem { font-size: 26px; }
}
@media (max-width: 480px) {
    .game-hub-grid { grid-template-columns: 1fr; }
    .game-key { min-width: 26px; height: 40px; font-size: 11px; padding: 0 5px; }
}
