/* Chemistry games. Builds on style.css (colours, cards, buttons) and site.css (header, footer, guides). */

.game { --sub: #b5541a; --coef: #177a42; --soft: #eef2ff; --hint: #8a5a00; }
@media (prefers-color-scheme: dark) {
  .game { --sub: #ff9d5c; --coef: #3ccf7a; --soft: #232a45; --hint: #ffcf70; }
}
.game :focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.game-card { min-height: 320px; }

/* formulas (same look as the labs) */
.formula { font-variant-numeric: tabular-nums; white-space: nowrap; }
.formula sub { font-size: 0.72em; line-height: 0; vertical-align: -0.28em; }
.f-sub { color: var(--sub); font-weight: 700; }
.f-coef { color: var(--coef); font-weight: 800; margin-right: 1px; }
.f-big { font-size: 1.35rem; font-weight: 700; }

/* menu */
.game-menu { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .game-menu { grid-template-columns: 1fr 1fr; } .game-options { grid-column: 1 / -1; } }
.game-mode { border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.game-mode h2 { margin: 0; }
.game-mode button { align-self: flex-start; margin-top: auto; }
.level-pick { border: 0; padding: 0; margin: 4px 0 10px; }
.level-pick legend { font-weight: 700; margin-bottom: 4px; }
.level-opt { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 6px 0; cursor: pointer; }
.level-opt input, .check-line input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; }
.check-line { display: flex; gap: 8px; align-items: center; font-weight: 600; margin: 0; cursor: pointer; }
.best { font-weight: 700; margin: 4px 0 8px; }

/* play */
.game-status { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 8px 12px; background: var(--bg); border-radius: 10px; margin-bottom: 14px; font-size: 0.95rem; }
#clock.low { color: var(--bad); }
.equation { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center; gap: 12px 8px; padding: 14px 6px 18px; }
.term { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.stepper { display: flex; align-items: center; gap: 2px; }
.stepper .step { width: 44px; height: 44px; padding: 0; font-size: 1.3rem; border-radius: 10px; }
.stepper .coef { width: 3.2rem; height: 44px; padding: 4px; text-align: center; font-size: 1.2rem; font-weight: 800; color: var(--coef); }
.term-formula { padding: 2px 4px; }
.op { font-size: 1.35rem; font-weight: 700; color: var(--muted); padding-bottom: 4px; }
.op.arrow { padding: 0 6px 4px; }

.atom-tally { border-collapse: collapse; margin: 0 auto 6px; min-width: 260px; font-variant-numeric: tabular-nums; }
.atom-tally th, .atom-tally td { padding: 6px 12px; border-bottom: 1px solid var(--border); text-align: center; }
.atom-tally thead th { font-size: 0.85rem; color: var(--muted); }
.atom-tally tr.ok td:last-child { color: var(--good); font-weight: 700; }
.atom-tally tr.off td:last-child { color: var(--bad); font-weight: 700; }

.feedback { min-height: 1.6em; font-weight: 600; margin: 10px 0; text-align: center; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }
.feedback.hint { color: var(--hint); }
.game-buttons { justify-content: center; }
.link-btn { background: none; border: none; color: var(--brand); text-decoration: underline; padding: 11px 8px; }

/* results */
.game-results .score-big { font-size: 2rem; font-weight: 800; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.new-best { background: var(--good); color: #fff; font-size: 0.85rem; }
.result-list { padding-left: 22px; display: grid; gap: 8px; }
.result-list li.off .eq-text { opacity: 0.85; }
.eq-text { font-weight: 600; }

@media (prefers-reduced-motion: no-preference) {
  .feedback.good { animation: pop .25s ease-out; }
  @keyframes pop { from { transform: scale(0.96); opacity: 0.4; } to { transform: none; opacity: 1; } }
}
@media (max-width: 420px) {
  .stepper .step { width: 40px; }
  .stepper .coef { width: 2.8rem; }
  .f-big { font-size: 1.2rem; }
}

/* ---------------------------------------------------------------- shared question pieces */
.mt { margin-top: 14px; }
.q-box { text-align: center; margin: 6px 0 14px; }
.q-prompt { font-size: 1.25rem; margin: 0; }
.q-sym { font-size: 1.6rem; font-weight: 800; padding: 0 4px; }
.choices { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; max-width: 520px; margin: 0 auto; }
.choice { min-height: 52px; font-size: 1.05rem; font-weight: 600; }
.choice.is-right, .ptg-cell.is-right { border-color: var(--good) !important; background: #e6f6ec !important; color: #11592f !important; }
.choice.is-wrong, .ptg-cell.is-wrong { border-color: var(--bad) !important; background: #fdecec !important; color: #8a241a !important; }
.choice.is-right::after { content: " ✓"; }
.choice.is-wrong::after { content: " ✗"; }
@media (prefers-color-scheme: dark) {
  .choice.is-right, .ptg-cell.is-right { background: #173a26 !important; color: #a6f0c4 !important; }
  .choice.is-wrong, .ptg-cell.is-wrong { background: #3d1c1c !important; color: #ffc1c1 !important; }
}
.sym-row { justify-content: center; }
.sym-input { width: 6rem; font-size: 1.5rem; font-weight: 800; text-align: center; }
.result-list.missed { list-style: none; padding-left: 0; }
.good-line { color: var(--good); font-weight: 700; }

/* ---------------------------------------------------------------- periodic table (symbols hidden) */
.cat-metal { background: #e3ecff; color: #1d2b57; }
.cat-nonmetal { background: #dcf5e6; color: #144a2b; }
.cat-metalloid { background: #fff0cf; color: #5a4200; }
.cat-noble { background: #f1e3ff; color: #4a1f7a; }
@media (prefers-color-scheme: dark) {
  .cat-metal { background: #22305a; color: #dbe5ff; }
  .cat-nonmetal { background: #17402a; color: #c9f4da; }
  .cat-metalloid { background: #46380f; color: #ffe8a8; }
  .cat-noble { background: #3a2558; color: #ecdcff; }
}
.ptg-scroll { overflow-x: auto; padding: 4px 2px 8px; position: relative; }
.ptg { display: grid; grid-template-columns: repeat(18, minmax(34px, 1fr)); gap: 3px; min-width: 660px; }
.ptg-cell { min-height: 40px; padding: 0; border-radius: 6px; border: 2px solid transparent; font-weight: 800; font-size: 0.85rem; }
.ptg-cell:not(:disabled):hover { border-color: var(--brand); }
.ptg-cell:disabled { opacity: 0.28; cursor: default; }
.ptg-cell.is-right, .ptg-cell.is-wrong { opacity: 1; }
.ptg-gap { height: 8px; }
.pt-swipe { display: none; margin: 0 0 4px; }
@media (max-width: 760px) { .pt-swipe { display: block; } }
.choices.wide { grid-template-columns: 1fr; max-width: 460px; }
.choice .formula { pointer-events: none; }
.miss-why { display: block; margin: 2px 0 6px; }
.choices.sort .choice:last-child { grid-column: 1 / -1; }
.q-prompt .formula { margin: 0 2px; }

/* Projector view (?projector=1): only the game, big enough to read from the back of a room */
.projector-link { display: inline-block; margin-bottom: 10px; }
body.projector .site-top, body.projector .site-footer, body.projector .breadcrumb, body.projector .page-head,
body.projector .guide-article, body.projector .skip-link { display: none !important; }
body.projector main.wrap { max-width: 1200px; padding-top: 12px; }
body.projector .game-card { font-size: 1.35rem; min-height: 90vh; }
body.projector .q-prompt { font-size: 2rem; }
body.projector .q-sym { font-size: 2.6rem; }
body.projector .choice { min-height: 80px; font-size: 1.5rem; }
body.projector .choices { max-width: 900px; gap: 16px; }
body.projector .f-big { font-size: 2rem; }
body.projector .feedback { font-size: 1.4rem; }
body.projector .game-status { font-size: 1.2rem; }
body.projector .stepper .step { width: 60px; height: 60px; font-size: 1.8rem; }
body.projector .stepper .coef { width: 4.4rem; height: 60px; font-size: 1.7rem; }
body.projector .ptg { min-width: 900px; }
body.projector .ptg-cell { min-height: 56px; font-size: 1.1rem; }
