/* Science1to5 — game styles (used with games.js) */
.game-head { padding-top: 28px; padding-bottom: 16px; }
.game-head h1 { font-size: clamp(2rem, 4.5vw, 3rem); margin-bottom: 0.2em; }
.game-head p { margin: 0; color: var(--ink-soft); }

.g-stage {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  height: clamp(520px, 74vh, 740px); background-color: var(--white);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
  border: 3px solid var(--ink); border-radius: 22px; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.g-stage.is-full, .g-stage:fullscreen { position: fixed; inset: 0; z-index: 1000; width: 100vw; height: 100vh; height: 100dvh; border: 0; border-radius: 0; }
html.game-lock, html.game-lock body { overflow: hidden; }
.g-stage:not(.is-full) .g-exit { visibility: hidden; }

.g-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--ink); color: var(--white); }
.g-title { font: 600 1.15rem var(--font-head); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-progress { margin-left: auto; font: 500 1rem var(--font-head); color: var(--sun); white-space: nowrap; flex: none; }
.g-icon { width: 42px; height: 42px; border-radius: 12px; border: 2px solid rgba(255,255,255,.5); background: transparent; color: var(--white); font-size: 1.1rem; cursor: pointer; }
.g-icon:hover { background: rgba(255,255,255,.12); }
.g-board { flex: 1; min-height: 0; display: flex; padding: 14px; }
.g-msg { margin: 0; max-width: none; min-height: 3.6em; display: flex; align-items: center; justify-content: center; text-align: center; padding: 8px 18px; font-size: 1.15rem; background: var(--white); border-top: 2px solid var(--ink); }
.g-msg.good { background: var(--life-bg); }
.g-msg.bad { background: var(--phys-bg); }

/* overlays */
.g-overlay { position: absolute; inset: 0; display: none; place-items: center; padding: 18px; background: rgba(21, 50, 75, .55); z-index: 5; overflow-y: auto; }
.g-overlay.show { display: grid; }
.g-card { width: min(460px, 100%); background: var(--white); border: 3px solid var(--ink); border-radius: 22px; padding: 26px 24px; text-align: center; box-shadow: 5px 5px 0 var(--ink); }
.g-big { font-size: 3.6rem; line-height: 1.1; margin-bottom: 6px; }
.g-stars-big { color: #E8A400; letter-spacing: 0.08em; }
.g-h { font-size: 1.8rem; margin-bottom: 0.3em; }
.g-p { margin: 0 auto 18px; color: var(--ink-soft); }
.g-btn { font: 600 1.25rem var(--font-head); color: var(--ink); background: var(--sun); border: 2px solid var(--ink); border-radius: 14px; padding: 12px 34px; box-shadow: var(--pop); cursor: pointer; }
.g-btn:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }
.g-btn-plain { background: var(--white); }
.g-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.g-levels { display: grid; gap: 8px; margin-top: 18px; }
.g-level { display: flex; justify-content: space-between; gap: 12px; font: 500 1.02rem var(--font-head); color: var(--ink); background: var(--paper); border: 2px solid var(--ink); border-radius: 12px; padding: 10px 14px; cursor: pointer; text-align: left; }
.g-stars { color: #C98E00; white-space: nowrap; }

/* ---------- sort game ---------- */
.sort { flex: 1; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.sort-zone { flex: 1; display: grid; place-items: center; min-height: 150px; }
.sort-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  width: clamp(150px, 26vmin, 220px); aspect-ratio: 1; background: var(--white); border: 3px solid var(--ink); border-radius: 22px; box-shadow: 4px 4px 0 var(--ink);
  cursor: grab; touch-action: none; position: relative; z-index: 3;
}
.sort-card.dragging { cursor: grabbing; box-shadow: 8px 10px 0 rgba(21,50,75,.35); transition: none; }
.card-emoji { font-size: clamp(3.4rem, 11vmin, 5.4rem); line-height: 1; }
.card-name { font: 600 clamp(1.05rem, 2.6vmin, 1.35rem) var(--font-head); text-align: center; padding: 0 8px; }
.sort-bins { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 10px; }
.sort-bin {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 6px 10px; min-height: 118px;
  background: var(--white); border: 3px solid var(--ink); border-radius: 18px; color: var(--ink); cursor: pointer; font: inherit;
}
.sort-bin.hover { background: var(--sun); transform: translateY(-3px); }
@media (hover: hover) { .sort-bin:hover { background: var(--sun); transform: translateY(-3px); } .seq-slot:not(.filled):hover { background: var(--sun); border-style: solid; } .g-level:hover { background: var(--sun); } }
.bin-emoji { font-size: clamp(1.9rem, 5vmin, 2.6rem); line-height: 1.1; }
.bin-label { font: 600 clamp(.95rem, 2.2vmin, 1.15rem) var(--font-head); text-align: center; line-height: 1.15; }
.bin-got { font-size: 1rem; line-height: 1.2; min-height: 1.2em; letter-spacing: 1px; word-break: break-all; }
@media (max-width: 620px) {
  .sort-bins { grid-template-columns: repeat(var(--mcols, 3), 1fr); }
  .sort-bin { min-height: 92px; padding: 8px 4px; }
}

/* ---------- sequence game ---------- */
.seq { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 14px; min-height: 0; overflow-y: auto; }
.seq-track { display: flex; align-items: stretch; gap: 8px; justify-content: center; flex-wrap: wrap; position: relative; }
.seq-sun { flex: none; width: 64px; border-radius: 0 999px 999px 0; background: radial-gradient(circle at 0 50%, #FFF3B0, #FFC21A 55%, #F59F00); border: 3px solid #E8A400; display: grid; place-items: center; font: 600 .95rem var(--font-head); color: #6B4500; margin-left: -14px; }
.seq-sun span { transform: rotate(-90deg); }
.seq-slot {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  width: clamp(74px, 10.4vw, 112px); min-height: 132px; padding: 22px 4px 8px; background: rgba(255,255,255,.7);
  border: 3px dashed var(--ink-soft); border-radius: 16px; cursor: pointer; font: inherit; color: var(--ink);
}
.seq-slot.hover { background: var(--sun); border-style: solid; }
.seq-slot.filled { border: 3px solid var(--earth); background: var(--earth-bg); cursor: default; }
.slot-num { position: absolute; top: 6px; left: 0; right: 0; text-align: center; font: 600 .9rem var(--font-head); color: var(--ink-soft); }
.slot-name { font: 600 .9rem var(--font-head); }
.seq-pool { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.seq-piece {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; min-width: 92px; min-height: 120px; padding: 10px 8px 8px;
  background: var(--white); border: 3px solid var(--ink); border-radius: 16px; cursor: grab; touch-action: none; font: inherit; color: var(--ink); position: relative;
}
.seq-piece.picked { background: var(--sun); box-shadow: var(--pop); }
.seq-piece.dragging { z-index: 4; cursor: grabbing; box-shadow: 8px 10px 0 rgba(21,50,75,.35); }
.seq-piece.done { display: none; }
.piece-name { font: 600 1rem var(--font-head); }
.piece-art { display: block; width: calc(var(--s) * var(--k, 1px)); height: calc(var(--s) * var(--k, 1px)); border-radius: 50%; position: relative; box-shadow: inset -6px -6px 12px rgba(0,0,0,.28); flex: none; }
@media (max-width: 620px) {
  .seq-track { display: grid; grid-template-columns: repeat(4, 1fr); }
  .seq-track.has-sun { padding-top: 0; }
  .seq-sun { grid-column: 1 / -1; width: auto; height: 34px; margin: -14px -14px 4px; border-radius: 0 0 999px 999px; border-width: 0 0 3px; }
  .seq-sun span { transform: none; }
  .seq-slot { width: auto; }
}
@media (max-width: 760px) { .g-stage { --k: .78px; } .seq-slot { min-height: 108px; } .seq-piece { min-width: 76px; min-height: 98px; } }

/* planets */
.p-mercury { background: radial-gradient(circle at 35% 35%, #E4DFD8, #8A8178); }
.p-venus { background: radial-gradient(circle at 35% 35%, #FBE7BF, #C99A4B); }
.p-earth { background: radial-gradient(circle at 62% 38%, #4CAF50 0 16%, transparent 17%), radial-gradient(circle at 34% 64%, #4CAF50 0 13%, transparent 14%), radial-gradient(circle at 35% 35%, #8FD0FF, #1F5FA8); }
.p-mars { background: radial-gradient(circle at 35% 35%, #F7A47E, #A63D1A); }
.p-jupiter { background: radial-gradient(circle at 68% 62%, #B5533C 0 9%, transparent 10%), repeating-linear-gradient(172deg, #F1DCC0 0 9%, #C48B5A 9% 15%, #E8C9A0 15% 22%); }
.p-saturn { background: repeating-linear-gradient(175deg, #F4E2B5 0 14%, #D9B871 14% 22%); }
.p-saturn::after { content: ""; position: absolute; left: -32%; right: -32%; top: 41%; height: 18%; border: 3px solid #C9A55E; border-radius: 50%; transform: rotate(-16deg); }
.p-uranus { background: radial-gradient(circle at 35% 35%, #D2F5F7, #5FB8C2); }
.p-neptune { background: radial-gradient(circle at 35% 35%, #94ABFF, #2A3FB0); }

/* feedback motion */
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-10px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
@keyframes good { 0% { background: #B7E4C2; } 100% { background: var(--white); } }
@keyframes bad { 0% { background: #FFC9A8; } 100% { background: var(--white); } }
@keyframes fly { to { transform: scale(.3) translateY(140px); opacity: 0; } }
.pop { animation: pop .28s ease-out; }
.shake { animation: shake .4s; }
.sort-bin.good { animation: good .8s; }
.sort-bin.bad, .seq-slot.bad { animation: bad .8s; }
.seq-slot.filled.good { animation: none; }
.sort-card.fly { animation: fly .45s ease-in .35s forwards; }

/* below-the-game info */
.game-info { padding-top: 40px; }
.game-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 22px; }
.game-facts > div { background: var(--white); border: 2px solid var(--ink); border-radius: 16px; padding: 22px; }
.game-facts h2 { font-size: 1.35rem; }
.game-facts ul, .game-facts ol { padding-left: 1.2em; margin: 0; }

/* picture cards for sequence games */
.piece-emoji { font-size: clamp(2rem, 6vmin, 2.8rem); line-height: 1; }
.piece-svg { display: block; width: clamp(48px, 9vmin, 64px); height: clamp(48px, 9vmin, 64px); }
.piece-svg svg { width: 100%; height: 100%; display: block; }
.seq-slot .piece-emoji { font-size: clamp(1.7rem, 5vmin, 2.4rem); }
.seq-start { flex: none; display: grid; place-items: center; padding: 0 10px; font: 600 .95rem var(--font-head); color: var(--ink-soft); }
.seq-start span { writing-mode: vertical-rl; transform: rotate(180deg); }
@media (max-width: 620px) { .seq-start { grid-column: 1 / -1; padding: 0; } .seq-start span { writing-mode: horizontal-tb; transform: none; } }

/* ---------- label game ---------- */
.lab { flex: 1; display: flex; align-items: center; justify-content: center; gap: 22px; min-height: 0; }
.lab-fig { position: relative; aspect-ratio: 600 / 440; width: min(100%, 760px, calc((100dvh - 160px) * 1.36)); flex: none; container-type: inline-size; }
.lab-fig > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.lab-spot {
  position: absolute; transform: translate(-50%, -50%); width: 22%; min-height: 12%; padding: 4px 6px;
  display: grid; place-items: center; background: rgba(255,255,255,.85); border: 3px dashed var(--ink-soft); border-radius: 12px;
  cursor: pointer; font: inherit; color: var(--ink);
}
.lab-spot .slot-num { position: absolute; top: -12px; left: -12px; right: auto; width: 24px; height: 24px; line-height: 20px; border-radius: 50%; background: var(--ink); color: #fff; font-size: .8rem; }
.lab-spot.hover { background: var(--sun); border-style: solid; }
.lab-spot.filled { border: 3px solid var(--life); background: var(--life-bg); cursor: default; }
.lab-spot.filled .slot-num { background: var(--life); }
.lab-spot.bad { animation: bad .8s; }
.lab-name { font: 600 clamp(.7rem, 3.3cqi, 1.15rem) var(--font-head); line-height: 1.1; }
.lab-pool { display: flex; flex-direction: column; gap: 10px; flex: none; }
.lab-chip {
  padding: 10px 18px; min-width: 120px; background: var(--white); border: 3px solid var(--ink); border-radius: 999px;
  font: 600 1.1rem var(--font-head); color: var(--ink); cursor: grab; touch-action: none; position: relative;
}
.lab-chip.picked { background: var(--sun); box-shadow: var(--pop); }
.lab-chip.dragging { z-index: 4; cursor: grabbing; box-shadow: 8px 10px 0 rgba(21,50,75,.35); }
.lab-chip.done { display: none; }
@media (hover: hover) { .lab-spot:not(.filled):hover { background: var(--sun); border-style: solid; } .lab-chip:hover { background: var(--sun); } }
@media (max-width: 760px), (orientation: portrait) {
  .lab { flex-direction: column; gap: 14px; justify-content: space-around; }
  .lab-fig { width: min(100%, calc((100dvh - 320px) * 1.36)); }
  .lab-pool { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .lab-chip { min-width: 0; padding: 8px 14px; font-size: 1rem; }
  .lab-spot { width: 24%; padding: 2px 4px; border-width: 2px; }
  .lab-spot .slot-num { width: 20px; height: 20px; line-height: 17px; top: -10px; left: -10px; font-size: .72rem; }
}
/* picture cards for sort games */
.card-svg { display: block; width: clamp(84px, 16vmin, 130px); height: clamp(84px, 16vmin, 130px); }
.card-svg svg { width: 100%; height: 100%; display: block; }

@media (max-width: 620px) {
  .seq-pool .seq-piece { min-width: 0; width: calc(25% - 8px); min-height: 84px; padding: 6px 3px; gap: 4px; }
  .seq-pool .piece-name { font-size: .78rem; line-height: 1.1; text-align: center; }
  .seq-pool .piece-svg { width: 40px; height: 40px; }
  .seq-pool { gap: 8px; }
}

/* ---------- memory match ---------- */
.mem { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(var(--rows), 1fr); gap: 10px; min-height: 0; width: min(100%, 860px); margin: 0 auto; }
.mem-card { position: relative; min-height: 0; padding: 0; border: 0; background: none; cursor: pointer; perspective: 900px; font: inherit; color: var(--ink); }
.mem-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .35s ease; }
.mem-card.up .mem-inner { transform: rotateY(180deg); }
.mem-back, .mem-front { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 3px solid var(--ink); border-radius: 16px; backface-visibility: hidden; -webkit-backface-visibility: hidden; padding: 4px; overflow: hidden; }
.mem-back { background: var(--ink); background-image: radial-gradient(rgba(255,255,255,.14) 2px, transparent 2.5px); background-size: 18px 18px; color: var(--sun); font: 600 clamp(1.6rem, 6vmin, 2.6rem) var(--font-head); }
.mem-front { background: var(--white); transform: rotateY(180deg); }
.mem-card.matched .mem-front { background: var(--life-bg); border-color: var(--life); }
.mem-emoji { font-size: clamp(1.7rem, 6.5vmin, 3rem); line-height: 1; }
.mem-svg { display: block; width: clamp(40px, 9vmin, 78px); height: clamp(40px, 9vmin, 78px); }
.mem-svg svg { width: 100%; height: 100%; display: block; }
.mem-name { font: 600 clamp(.72rem, 2.2vmin, 1.05rem) var(--font-head); text-align: center; line-height: 1.1; }
.mem-tag { font: 500 clamp(.62rem, 1.7vmin, .82rem) var(--font-head); color: var(--ink-soft); }
@media (hover: hover) { .mem-card:not(.up):hover .mem-back { background-color: #22476A; } }
@media (prefers-reduced-motion: reduce) { .mem-inner { transition: none; } }

/* ---------- true or false ---------- */
.tf { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; min-height: 0; }
.tf-card { width: min(100%, 620px); display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 20px; background: var(--white); border: 3px solid var(--ink); border-radius: 22px; box-shadow: 4px 4px 0 var(--ink); text-align: center; }
.tf-emoji { font-size: clamp(2.6rem, 9vmin, 4.2rem); line-height: 1; }
.tf-svg { display: block; width: clamp(70px, 14vmin, 110px); height: clamp(70px, 14vmin, 110px); }
.tf-svg svg { width: 100%; height: 100%; display: block; }
.tf-text { margin: 0; max-width: none; font: 600 clamp(1.15rem, 3.4vmin, 1.6rem) var(--font-head); line-height: 1.25; }
.tf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: min(100%, 520px); }
.tf-btn { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 76px; border: 3px solid var(--ink); border-radius: 18px; font: 600 1.4rem var(--font-head); color: var(--ink); cursor: pointer; }
.tf-yes { background: #D3F2DC; } .tf-no { background: #FFE0CC; }
.tf-mark { font-size: 1.7rem; }
.tf-btn.right { box-shadow: 0 0 0 5px var(--sun); }
.tf-btn.good { animation: good .8s; }
@media (hover: hover) { .tf-btn:hover { transform: translateY(-3px); box-shadow: var(--pop); } }

/* ---------- odd one out ---------- */
.odd { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; min-height: 0; }
.odd-ask { margin: 0; font: 600 clamp(1.2rem, 3.6vmin, 1.7rem) var(--font-head); text-align: center; }
.odd-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; width: min(100%, 860px); }
.odd-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; aspect-ratio: 1; padding: 8px; background: var(--white); border: 3px solid var(--ink); border-radius: 20px; cursor: pointer; font: inherit; color: var(--ink); }
.odd-emoji { font-size: clamp(2.6rem, 9vmin, 4.4rem); line-height: 1; }
.odd-svg { display: block; width: clamp(64px, 14vmin, 120px); height: clamp(64px, 14vmin, 120px); }
.odd-svg svg { width: 100%; height: 100%; display: block; }
.odd-name { font: 600 clamp(.9rem, 2.5vmin, 1.2rem) var(--font-head); text-align: center; line-height: 1.15; }
.odd-card.yes { background: var(--life-bg); border-color: var(--life); box-shadow: 0 0 0 4px var(--life); }
.odd-card.nope { opacity: .45; }
@media (hover: hover) { .odd-card:not(.nope):hover { background: var(--sun); transform: translateY(-3px); } }
@media (max-width: 620px) { .odd-grid { grid-template-columns: repeat(2, 1fr); width: min(100%, 360px); } .odd-card { aspect-ratio: auto; min-height: 120px; } }

/* ---------- science lab ---------- */
.sl { flex: 1; display: flex; align-items: center; justify-content: center; gap: 20px; min-height: 0; }
.sl-fig { aspect-ratio: 600 / 360; width: min(100%, 780px, calc((100dvh - 170px) * 1.66)); flex: 0 1 auto; background: var(--white); border: 3px solid var(--ink); border-radius: 18px; overflow: hidden; }
.sl-fig svg { display: block; width: 100%; height: 100%; }
.sl-panel { flex: 0 0 340px; display: flex; flex-direction: column; gap: 12px; padding: 16px; background: var(--white); border: 3px solid var(--ink); border-radius: 18px; }
.sl-panel.good { animation: good .8s; }
.sl-ask { margin: 0; font: 600 1.15rem var(--font-head); line-height: 1.25; }
.sl-ctl { display: grid; gap: 6px; }
.sl-label { font: 500 .95rem var(--font-head); color: var(--ink-soft); }
.sl-range { width: 100%; accent-color: var(--phys); height: 28px; cursor: pointer; }
.sl-stops { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 4px; }
.sl-stop { padding: 6px 2px; border: 2px solid var(--ink); border-radius: 10px; background: var(--paper); font: 500 .82rem var(--font-head); color: var(--ink); cursor: pointer; line-height: 1.1; min-width: 0; }
.sl-stop.on { background: var(--sun); }
.sl-read { margin: 0; font: 600 1rem var(--font-head); color: var(--phys); min-height: 1.3em; }
.sl-act { display: grid; gap: 8px; }
.sl-go { width: 100%; }
.sl-choices { display: grid; gap: 8px; }
.sl-choice { padding: 10px 12px; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper); font: 600 1rem var(--font-head); color: var(--ink); text-align: left; cursor: pointer; }
.sl-choice.yes { background: var(--life-bg); border-color: var(--life); }
.sl-choice.nope { opacity: .45; }
@media (hover: hover) { .sl-stop:hover, .sl-choice:not(.nope):hover { background: var(--sun); } }
@media (max-width: 860px), (orientation: portrait) {
  .sl { flex-direction: column; gap: 10px; justify-content: flex-start; overflow-y: auto; }
  .sl-fig { width: min(100%, calc((100dvh - 380px) * 1.66)); min-width: 260px; flex: none; }
  .sl-panel { flex: none; width: min(100%, 620px); padding: 12px; gap: 8px; }
  .sl-ask { font-size: 1.05rem; }
  .sl > .sl-fig { margin-top: auto; } .sl > .sl-panel { margin-bottom: auto; }
}
.mem-name.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* memory cards: size the picture to the card */
.mem-card { container-type: size; }
.mem-emoji { font-size: clamp(1.6rem, min(36cqh, 50cqw), 4.6rem); }
.mem-svg { width: min(54cqh, 80cqw); height: min(54cqh, 80cqw); }
.mem-name { font-size: clamp(.72rem, min(13cqh, 11cqw), 1.15rem); }
.mem-tag { font-size: clamp(.6rem, min(9cqh, 8cqw), .85rem); }
