/* Online classroom games (/play/*). Loaded only on those pages, on top of style.css. */
.play-panel { position: relative; overflow: hidden; min-height: 520px; display: flex; flex-direction: column; }
.play-panel:fullscreen { display: flex; }
.play-bar { margin-top: 0; }
.play-bar label { color: rgba(244,241,232,.85); }
.play-editor { background: rgba(0,0,0,.2); border: 2px dashed var(--s-line); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; }
.play-editor textarea { width: 100%; font: 600 1rem/1.55 var(--font-body); resize: vertical; }
.play-editor select { max-width: 260px; }
.play-stage { position: relative; flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 10px 0; }
.play-center { justify-content: center; }
.play-note { text-align: center; color: rgba(244,241,232,.75); font-weight: 600; margin: 10px auto; max-width: 640px; }
.tool-panel button.big { font-size: 1.25rem; padding: 14px 28px; }
.play-intro { text-align: center; padding: 20px 10px; }
.play-intro h2 { color: var(--chalk); font-size: clamp(1.8rem, 4vw, 2.8rem); margin: 6px 0 10px; }
.play-intro p { color: rgba(244,241,232,.82); font-size: 1.1rem; max-width: 620px; margin: 0 auto 22px; }
.play-intro-emoji { font-size: 4.4rem; line-height: 1; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-4deg); } }

/* Team colors and score chips */
.team-red { --tc: #ff6b5a; } .team-blue { --tc: #5aa2ff; } .team-yellow { --tc: #ffd25e; }
.team-green { --tc: #7dd87a; } .team-violet { --tc: #c4a3ff; } .team-teal { --tc: #4fd6bd; }
.pteams { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 14px; }
.pteams:empty { display: none; }
.pteam { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 14px; border-radius: 999px; background: rgba(0,0,0,.22); border: 3px solid var(--tc); transition: transform .2s ease, box-shadow .2s ease; }
.pteam.is-turn { transform: translateY(-3px) scale(1.06); box-shadow: 0 0 0 4px rgba(255,255,255,.18), 0 0 22px var(--tc); }
.pteam-name { font: 700 1rem var(--font-display); color: var(--tc); }
.pteam-score { font: 700 1.6rem/1 var(--font-display); color: #fff; min-width: 1.6em; text-align: center; }
.tool-panel .pteam-btns button { width: 32px; height: 32px; padding: 0; justify-content: center; border-radius: 50%; font-size: 1.1rem; }
.mm-who, .ttt-who, .qs-turn { color: var(--tc); font-weight: 800; }

/* Countdown bar */
.pbar { position: relative; height: 16px; border-radius: 999px; background: rgba(0,0,0,.3); overflow: hidden; margin: 8px 0 4px; }
.pbar::before { content: ''; position: absolute; inset: 0; width: calc(var(--p, 1) * 100%); background: linear-gradient(90deg, #7dd87a, #ffd25e); border-radius: inherit; transition: background .3s; }
.pbar[data-s="5"]::before, .pbar[data-s="4"]::before, .pbar[data-s="3"]::before, .pbar[data-s="2"]::before, .pbar[data-s="1"]::before, .pbar[data-s="0"]::before { background: #ff6b5a; }
.pbar::after { content: attr(data-s); position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font: 700 .8rem var(--font-display); color: #fff; }

/* Modal card inside a game */
.play-modal { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: rgba(15,30,22,.72); backdrop-filter: blur(2px); padding: 16px; }
.play-modal[hidden] { display: none; }
.play-card { width: min(720px, 100%); background: var(--paper); color: var(--ink); border-radius: 14px; padding: 26px 24px 18px; text-align: center; box-shadow: 0 20px 40px rgba(0,0,0,.45); animation: pop .25s ease; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.play-card h2 { color: var(--ink); font-size: clamp(1.5rem, 3.4vw, 2.4rem); margin: 4px 0 14px; }
.play-card-label { font: 700 1.3rem var(--font-hand); color: var(--tc, var(--muted)); margin: 0; }
.play-answer { font: 700 1.6rem var(--font-display); color: var(--green); background: #eaf6e7; border-radius: 10px; padding: 8px 14px; display: inline-block; }
.play-card .tool-row { margin: 10px 0 0; }
.tool-panel .play-card button { color: var(--ink); border-color: var(--line); background: #f3eee2; }
.tool-panel .play-card button.primary { background: var(--yellow); border-color: var(--yellow); color: #3b2a00; }

/* Confetti and toast */
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 9; }
.confetti i { position: absolute; top: -12px; width: 10px; height: 16px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { top: 110%; transform: translateX(40px) rotate(720deg); } }
.ptoast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; z-index: 100; background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 700; box-shadow: 0 10px 24px rgba(0,0,0,.35); transition: all .3s ease; max-width: calc(100% - 32px); }
.ptoast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Quiz show ---------- */
.qs-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.qs-count { font: 700 1.3rem var(--font-hand); color: rgba(244,241,232,.75); margin: 0; }
.qs-count span { margin-left: 6px; }
.qs-turn { font: 700 1.1rem var(--font-display); background: rgba(0,0,0,.25); border: 2px solid var(--tc); padding: 3px 12px; border-radius: 999px; }
.qs-q { color: #fff; text-align: center; font-size: clamp(1.6rem, 4vw, 3rem); margin: 18px auto 22px; max-width: 900px; }
.qs-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tool-panel .qs-ans { display: flex; align-items: center; gap: 14px; text-align: left; padding: 18px 18px; border: 0; border-radius: 12px; color: #fff; font: 700 clamp(1.05rem, 2.2vw, 1.6rem) var(--font-display); box-shadow: inset 0 -6px 0 rgba(0,0,0,.2); transition: transform .12s, opacity .3s, filter .3s; min-height: 84px; }
.tool-panel .qs-ans:hover { transform: translateY(-2px); }
.tool-panel .qs-ans.ans-0 { background: #e2453c; } .tool-panel .qs-ans.ans-1 { background: #2f6fd1; }
.tool-panel .qs-ans.ans-2 { background: #d89a00; } .tool-panel .qs-ans.ans-3 { background: #3c8f37; }
.qs-shape { display: grid; place-items: center; width: 52px; height: 52px; flex: none; border-radius: 10px; background: rgba(255,255,255,.18); font-size: 1.6rem; position: relative; }
.qs-shape small { position: absolute; right: -6px; bottom: -6px; font-size: .75rem; background: #fff; color: #333; border-radius: 50%; width: 20px; height: 20px; display: grid; place-items: center; }
.qs-ans.is-dim { opacity: .3; filter: grayscale(.6); }
.qs-ans.is-right { outline: 5px solid #fff; animation: pop .35s ease; }
.qs-ans.is-right::after { content: '✔'; margin-left: auto; font-size: 1.8rem; }
.qs-ans.is-wrong { opacity: .55; }
.qs-ans.is-wrong::after { content: '✘'; margin-left: auto; font-size: 1.8rem; }
.podium { list-style: none; padding: 0; margin: 0 auto 22px; max-width: 420px; counter-reset: p; }
.podium li { counter-increment: p; display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; margin: 8px 0; border-radius: 12px; background: rgba(0,0,0,.25); border-left: 8px solid var(--tc); font: 700 1.2rem var(--font-display); color: var(--tc); }
.podium li::before { content: counter(p) '.'; color: #fff; margin-right: 10px; }
.podium li span { margin-right: auto; }
.podium li b { color: #fff; font-size: 1.5rem; }
.podium li:first-child { transform: scale(1.06); box-shadow: 0 0 20px var(--tc); }

/* ---------- Tic tac toe ---------- */
.ttt-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.ttt-status { font: 700 1.4rem var(--font-display); color: var(--chalk); text-align: center; min-height: 1.6em; }
.ttt-status button { margin-left: 10px; vertical-align: middle; }
.ttt-who { font-size: 1.8rem; }
.ttt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: min(460px, 100%); }
.tool-panel .ttt-cell { aspect-ratio: 1; justify-content: center; font: 700 clamp(3rem, 9vw, 5.4rem)/1 var(--font-display); border: 3px solid rgba(244,241,232,.35); border-radius: 14px; background: rgba(255,255,255,.06); }
.tool-panel .ttt-cell small { font-size: 1.4rem; color: rgba(244,241,232,.45); }
.tool-panel .ttt-cell:disabled { cursor: default; }
.ttt-cell.mark-X { color: #ff6b5a; animation: pop .25s ease; }
.ttt-cell.mark-O { color: #5aa2ff; animation: pop .25s ease; }
.tool-panel .ttt-cell.is-win { background: rgba(255,210,94,.3); border-color: #ffd25e; border-style: solid; }
.ttt-wins { display: flex; gap: 18px; color: rgba(244,241,232,.8); font-weight: 700; }
.ttt-wins .team-red, .ttt-wins .team-blue { color: var(--tc); }
.ttt-wins b { color: #fff; font-size: 1.3rem; margin-left: 4px; }
.tool-panel:fullscreen .ttt-grid { width: min(62vh, 100%); }

/* ---------- Memory match ---------- */
.mm-status, .mp-status, .gw-status { text-align: center; font: 700 1.25rem var(--font-display); color: var(--chalk); margin-bottom: 12px; min-height: 1.6em; }
.mm-status button, .mp-status button, .gw-status button { margin-left: 10px; vertical-align: middle; }
.mm-grid { display: grid; grid-template-columns: repeat(var(--cols, 4), 1fr); gap: 12px; max-width: 860px; width: 100%; margin: 0 auto; }
.tool-panel .mm-card { position: relative; height: 104px; padding: 0; border: 0; background: none; perspective: 800px; }
.mm-back, .mm-front { position: absolute; inset: 0; display: grid; place-items: center; border-radius: 12px; backface-visibility: hidden; transition: transform .45s ease; padding: 8px; text-align: center; }
.mm-back { background: repeating-linear-gradient(45deg, #ffd25e 0 12px, #f2b705 12px 24px); color: #5a3f00; font: 700 2rem var(--font-display); box-shadow: inset 0 -5px 0 rgba(0,0,0,.18); }
.mm-front { background: var(--paper); color: var(--ink); font: 700 clamp(.95rem, 1.8vw, 1.35rem)/1.2 var(--font-display); transform: rotateY(180deg); word-break: break-word; }
.mm-front.side-b { background: #e3f0fc; }
.mm-card.is-up .mm-back { transform: rotateY(180deg); }
.mm-card.is-up .mm-front { transform: rotateY(360deg); }
.mm-card.is-found .mm-front { box-shadow: 0 0 0 4px var(--tc, #7dd87a); }
.mm-card.by-red { --tc: #ff6b5a; } .mm-card.by-blue { --tc: #5aa2ff; } .mm-card.by-yellow { --tc: #ffd25e; }
.mm-card.by-green { --tc: #7dd87a; } .mm-card.by-violet { --tc: #c4a3ff; } .mm-card.by-teal { --tc: #4fd6bd; }
.tool-panel:fullscreen .mm-card { height: 16vh; }
@media (max-width: 600px) { .mm-grid { gap: 8px; } .tool-panel .mm-card { height: 78px; } .mm-back { font-size: 1.4rem; } }

/* ---------- Guess the word ---------- */
.gw-wrap { display: flex; flex-direction: column; align-items: center; }
.gw-board { display: grid; gap: 7px; margin-bottom: 12px; }
.gw-row { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 7px; }
.gw-cell { width: clamp(38px, 7vw, 62px); aspect-ratio: 1; display: grid; place-items: center; border: 3px solid rgba(244,241,232,.3); border-radius: 8px; font: 700 clamp(1.3rem, 3.2vw, 2.1rem) var(--font-display); color: #fff; text-transform: uppercase; }
.gw-cell.typed { border-color: rgba(244,241,232,.75); animation: pop .12s ease; }
.gw-cell.correct, .gw-cell.present, .gw-cell.absent { border-color: transparent; animation: flipin .5s ease both; animation-delay: var(--d, 0s); }
.gw-cell.correct { background: #4f9d4a; } .gw-cell.present { background: #d89a00; } .gw-cell.absent { background: rgba(0,0,0,.35); }
@keyframes flipin { 0% { transform: rotateX(90deg); } 100% { transform: none; } }
.gw-hint { font: 700 1.5rem var(--font-hand); color: #ffd25e; margin: 4px 0 10px; text-align: center; }
.gw-keys { display: flex; flex-direction: column; gap: 6px; align-items: center; width: 100%; max-width: 620px; }
.gw-keys div { display: flex; gap: 5px; justify-content: center; width: 100%; }
.tool-panel .gw-key { flex: 1; max-width: 48px; padding: 12px 0; justify-content: center; font: 700 1rem var(--font-display); border-style: solid; border-width: 0; background: rgba(255,255,255,.16); }
.tool-panel .gw-key.wide { max-width: 84px; flex: 1.6; font-size: .85rem; }
.tool-panel .gw-key.correct { background: #4f9d4a; } .tool-panel .gw-key.present { background: #d89a00; } .tool-panel .gw-key.absent { background: rgba(0,0,0,.4); color: rgba(255,255,255,.45); }
.gw-row.by-red .gw-cell { box-shadow: -4px 0 0 #ff6b5a; } .gw-row.by-blue .gw-cell { box-shadow: -4px 0 0 #5aa2ff; }

/* ---------- Word scramble ---------- */
.ws-wrap { text-align: center; }
.ws-tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 26px 0 16px; }
.ws-tile { width: clamp(46px, 8vw, 78px); aspect-ratio: 1; display: grid; place-items: center; background: #f6e7c8; color: #4a3200; border-radius: 10px; font: 700 clamp(1.6rem, 4.4vw, 2.8rem) var(--font-display); box-shadow: inset 0 -6px 0 #d9c294, 0 8px 12px -6px rgba(0,0,0,.5); transform: rotate(var(--r)); animation: drop .4s ease both; animation-delay: var(--d); }
@keyframes drop { from { transform: translateY(-40px) rotate(0); opacity: 0; } }
.ws-answer { font: 700 clamp(2rem, 5vw, 3.4rem) var(--font-display); color: #7dd87a; letter-spacing: .12em; margin: 6px 0; animation: pop .3s ease; }

/* ---------- Mystery picture ---------- */
.mp-wrap { display: flex; flex-direction: column; align-items: center; }
.mp-frame { position: relative; width: min(560px, 100%); aspect-ratio: 4 / 3; border-radius: 14px; overflow: hidden; background: radial-gradient(circle, #fffdf7, #f1e6cc); box-shadow: 0 10px 22px rgba(0,0,0,.4); }
.mp-pic { position: absolute; inset: 0; display: grid; place-items: center; font-size: min(15rem, 32vw); line-height: 1; }
.mp-tiles { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(3, 1fr); }
.tool-panel .mp-tile { border-radius: 0; border: 2px solid rgba(0,0,0,.18); justify-content: center; font: 700 2rem var(--font-display); color: #fff; transition: transform .45s ease, opacity .45s ease; }
.tool-panel .mp-tile:nth-child(4n+1) { background: #e2453c; } .tool-panel .mp-tile:nth-child(4n+2) { background: #2f6fd1; }
.tool-panel .mp-tile:nth-child(4n+3) { background: #d89a00; } .tool-panel .mp-tile:nth-child(4n) { background: #3c8f37; }
.tool-panel .mp-tile:nth-child(n+5):nth-child(-n+8) { filter: brightness(1.12); }
.tool-panel .mp-tile:hover { filter: brightness(1.2); }
.tool-panel .mp-tile.is-gone { transform: scale(.2) rotate(30deg); opacity: 0; pointer-events: none; }
.mp-name { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); background: var(--ink); color: #fff; font: 700 1.5rem var(--font-display); padding: 6px 18px; border-radius: 999px; }
.tool-panel:fullscreen .mp-frame { width: min(90vh, 100%); }

/* ---------- Pass the bomb ---------- */
.pb-wrap { text-align: center; padding: 10px 0; }
.pb-label { font: 700 1.4rem var(--font-hand); color: rgba(244,241,232,.7); margin: 0; }
.pb-prompt { color: #fff; font-size: clamp(1.8rem, 5vw, 3.4rem); margin: 4px 0 6px; }
.pb-bomb { position: relative; display: inline-block; font-size: clamp(6rem, 18vw, 11rem); line-height: 1.1; }
.pb-bomb.lit { animation: wobble .5s ease-in-out infinite; }
@keyframes wobble { 25% { transform: rotate(-6deg) scale(1.03); } 75% { transform: rotate(6deg) scale(.98); } }
.pb-spark { position: absolute; top: 2%; right: 4%; font-size: .35em; animation: spark .25s steps(2) infinite; }
@keyframes spark { 50% { opacity: .2; transform: scale(1.4); } }
.pb-pass { font: 700 1.8rem var(--font-hand); color: #ffd25e; }
.is-boom .pb-bomb { animation: pop .3s ease; }
.is-boom .pb-prompt { color: #ff6b5a; font-size: clamp(2.6rem, 8vw, 5rem); }
.pb-shake { animation: shake .6s ease; }
@keyframes shake { 10%, 50%, 90% { transform: translate(-8px, 4px); } 30%, 70% { transform: translate(8px, -4px); } }
.tool-panel:fullscreen .pb-bomb { font-size: 30vh; }

/* ---------- Would you rather ---------- */
.wy-wrap { text-align: center; }
.wy-cards { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: stretch; margin: 14px 0; }
.wy-or { align-self: center; font: 700 1.8rem var(--font-hand); color: #ffd25e; }
.wy-card { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 22px 16px 16px; border-radius: 16px; color: #fff; box-shadow: inset 0 -6px 0 rgba(0,0,0,.18); transition: transform .3s, box-shadow .3s; }
.wy-card.side-0 { background: #2f6fd1; } .wy-card.side-1 { background: #e0702a; }
.wy-card.is-winner { transform: scale(1.04); box-shadow: 0 0 0 5px #ffd25e, 0 0 30px rgba(255,210,94,.6); }
.wy-letter { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.25); display: grid; place-items: center; font: 700 1.5rem var(--font-display); }
.wy-card h2 { color: #fff; font-size: clamp(1.4rem, 3.2vw, 2.3rem); margin: 0; flex: 1; display: grid; place-items: center; }
.wy-count { display: flex; align-items: center; gap: 12px; }
.wy-count b { font: 700 2.2rem var(--font-display); min-width: 2ch; }
.tool-panel .wy-count button { width: 40px; height: 40px; padding: 0; justify-content: center; border-radius: 50%; font-size: 1.3rem; border-color: rgba(255,255,255,.5); }
.wy-bar { width: 100%; height: 30px; background: rgba(0,0,0,.25); border-radius: 999px; overflow: hidden; }
.wy-bar i { display: flex; align-items: center; justify-content: flex-end; height: 100%; width: 0; background: #ffd25e; color: #3b2a00; font: 700 .95rem var(--font-display); font-style: normal; padding-right: 8px; transition: width .8s ease; border-radius: inherit; white-space: nowrap; }
@media (max-width: 640px) {
  .wy-cards { grid-template-columns: 1fr; }
  .qs-answers { grid-template-columns: 1fr; }
  .tool-panel .qs-ans { min-height: 60px; padding: 12px; }
  .qs-shape { width: 40px; height: 40px; }
  .play-panel { min-height: 420px; }
}
