/* KidsOnline GameShell — shared layout, HUD, modals, and controls.
   Per-game CSS may override variables defined in themes.css. */

:root {
    --ko-bg: #f7fbff;
    --ko-card: #ffffff;
    --ko-text: #0b1020;
    --ko-muted: #5f6b7a;
    --ko-primary: #28a745;
    --ko-primary-dark: #218838;
    --ko-accent: #ffb703;
    --ko-correct: #1e7a35;
    --ko-correct-bg: #eaf7ee;
    --ko-wrong: #9c1c28;
    --ko-wrong-bg: #ffeeef;
    --ko-border: rgba(10, 20, 40, 0.1);
    --ko-shadow: 0 6px 24px rgba(16, 25, 53, 0.07);
    --ko-radius: 16px;
    --ko-radius-sm: 10px;
    --ko-font: 'DM Sans', system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--ko-font);
    background: var(--ko-bg);
    color: var(--ko-text);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--ko-primary); }

/* Top bar shared across game pages */
.ko-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--ko-border);
    background: #fff;
}
.ko-topbar a.ko-back { color: var(--ko-text); text-decoration: none; font-weight: 500; font-size: 14px; }
.ko-topbar a.ko-back:hover { color: var(--ko-primary); }
.ko-topbar .ko-brand { display: inline-flex; align-items: center; gap: 8px; }
.ko-topbar .ko-brand img { height: 28px; width: auto; display: block; }
.ko-topbar .ko-actions { display: inline-flex; gap: 8px; }
.ko-icon-btn {
    background: transparent; border: 1px solid var(--ko-border);
    border-radius: 999px; padding: 6px 10px; cursor: pointer;
    font-size: 13px; color: var(--ko-text); font-family: inherit;
}
.ko-icon-btn:hover { border-color: var(--ko-primary); color: var(--ko-primary); }
.ko-icon-btn[aria-pressed="true"] { background: var(--ko-correct-bg); border-color: var(--ko-correct); color: var(--ko-correct); }

/* Main game stage layout */
.ko-stage {
    max-width: 960px;
    margin: 0 auto;
    padding: 18px 16px 32px;
}

.ko-title {
    text-align: center;
    margin: 4px 0 4px;
    font-size: clamp(22px, 4vw, 32px);
    font-weight: 700;
}
.ko-tagline {
    text-align: center;
    color: var(--ko-muted);
    margin: 0 0 18px;
    font-size: 14px;
}

/* HUD */
.ko-hud {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}
.ko-hud .ko-hud-item {
    background: var(--ko-card);
    border: 1px solid var(--ko-border);
    border-radius: var(--ko-radius-sm);
    padding: 10px 8px;
    text-align: center;
}
.ko-hud .ko-hud-label {
    font-size: 11px; color: var(--ko-muted);
    text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600;
}
.ko-hud .ko-hud-value {
    font-size: 18px; font-weight: 700; margin-top: 2px;
}
.ko-hud .ko-hud-item[hidden] { display: none; }

/* Progress bar */
.ko-progress {
    height: 10px;
    background: rgba(10, 20, 40, 0.08);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 14px;
}
.ko-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--ko-primary), var(--ko-accent));
    transition: width 200ms ease-out;
}

/* Card containing the actual game UI */
.ko-card {
    background: var(--ko-card);
    border: 1px solid var(--ko-border);
    border-radius: var(--ko-radius);
    padding: 20px;
    box-shadow: var(--ko-shadow);
    position: relative;
    min-height: 320px;
}

/* Buttons */
.ko-btn {
    background: var(--ko-primary);
    color: #fff;
    border: 0;
    border-radius: var(--ko-radius-sm);
    padding: 12px 18px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    font-family: inherit;
    transition: background-color 0.15s ease, transform 0.05s ease;
}
.ko-btn:hover { background: var(--ko-primary-dark); }
.ko-btn:active { transform: translateY(1px); }
.ko-btn-secondary {
    background: #fff; color: var(--ko-text);
    border: 1px solid var(--ko-border);
}
.ko-btn-secondary:hover { border-color: var(--ko-primary); color: var(--ko-primary); background: #fff; }

.ko-btn-block { width: 100%; display: block; }

/* Choices grid (used by math-facts, pattern-quest, number-line MC mode) */
.ko-choices {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 16px;
}
.ko-choice {
    background: #fff;
    border: 2px solid var(--ko-border);
    color: var(--ko-text);
    border-radius: var(--ko-radius-sm);
    padding: 16px;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease;
    min-height: 64px;
}
.ko-choice:hover { border-color: var(--ko-primary); }
.ko-choice:active { transform: translateY(1px); }
.ko-choice.ko-correct { border-color: var(--ko-correct); background: var(--ko-correct-bg); color: var(--ko-correct); animation: koPop 250ms ease; }
.ko-choice.ko-wrong { border-color: var(--ko-wrong); background: var(--ko-wrong-bg); color: var(--ko-wrong); animation: koShake 220ms ease; }
.ko-choice:disabled { cursor: default; opacity: 0.85; }

@keyframes koPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.06); }
    100% { transform: scale(1); }
}
@keyframes koShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* Equation / prompt text */
.ko-prompt {
    text-align: center;
    font-size: clamp(28px, 6vw, 44px);
    font-weight: 700;
    margin: 8px 0 4px;
    letter-spacing: 0.5px;
    line-height: 1.15;
}
.ko-subprompt {
    text-align: center;
    color: var(--ko-muted);
    font-size: 14px;
    margin: 0 0 16px;
}

/* Modals */
.ko-modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(11, 16, 32, 0.55);
    display: flex; align-items: center; justify-content: center;
    z-index: 50;
    padding: 20px;
    animation: koFade 200ms ease;
}
@keyframes koFade { from { opacity: 0; } to { opacity: 1; } }
.ko-modal {
    background: var(--ko-card);
    border-radius: var(--ko-radius);
    padding: 24px;
    max-width: 460px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    text-align: center;
}
.ko-modal h2 { margin: 0 0 6px; font-size: 22px; }
.ko-modal p { margin: 6px 0; color: var(--ko-muted); }
.ko-modal-actions {
    margin-top: 16px;
    display: flex; flex-direction: column; gap: 8px;
}
.ko-modal label { display: flex; flex-direction: column; gap: 4px; text-align: left; font-size: 13px; color: var(--ko-muted); margin-bottom: 8px; }
.ko-modal select, .ko-modal input[type="text"] {
    width: 100%; padding: 10px; border: 1px solid var(--ko-border);
    border-radius: var(--ko-radius-sm); font-size: 14px; font-family: inherit;
    background: #fff;
}
.ko-modal .ko-stat-row {
    display: flex; justify-content: space-around;
    background: var(--ko-bg); border-radius: var(--ko-radius-sm);
    padding: 12px; margin: 12px 0;
}
.ko-modal .ko-stat .ko-hud-label { font-size: 11px; }
.ko-modal .ko-stat .ko-hud-value { font-size: 22px; }
.ko-modal[hidden] { display: none; }
.ko-modal-backdrop[hidden] { display: none; }

/* Toast feedback */
.ko-toast {
    position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
    background: var(--ko-text); color: #fff;
    padding: 10px 16px; border-radius: 999px;
    font-size: 14px; z-index: 60; opacity: 0;
    pointer-events: none; transition: opacity 200ms ease;
}
.ko-toast.ko-show { opacity: 0.95; }

/* "About this game" SEO section under the game card */
.ko-about {
    max-width: 820px; margin: 28px auto 0; padding: 0 16px;
    color: var(--ko-text); line-height: 1.6;
}
.ko-about h2 { font-size: 20px; margin: 0 0 8px; }
.ko-about h3 { font-size: 16px; margin: 18px 0 6px; }
.ko-about p, .ko-about ul { margin: 6px 0; color: var(--ko-text); }
.ko-about ul { padding-left: 22px; }
.ko-about .ko-meta-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.ko-about .ko-tag {
    background: var(--ko-correct-bg); color: var(--ko-correct);
    border: 1px solid #c7ecd2; padding: 3px 8px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
}

.ko-footer {
    text-align: center; padding: 24px 16px; color: var(--ko-muted); font-size: 13px;
}
.ko-footer a { color: var(--ko-muted); text-decoration: underline; }

/* Reduced motion respect */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 560px) {
    .ko-hud { grid-template-columns: repeat(2, 1fr); }
    .ko-stage { padding: 12px 12px 24px; }
    .ko-card { padding: 14px; }
    .ko-choice { font-size: 18px; padding: 14px; }
}
