/* Capabl Play shared kit: one bright, projector-safe world for every game. Single light theme on purpose. */
:root {
  --ink: #16324f;
  --ink-soft: #4a627a;
  --paper: #fff9ea;
  --card: #ffffff;
  --sun: #ffc93c;
  --sun-deep: #d99a00;
  --sun-soft: #fff1c2;
  --teal: #14b8a6;
  --teal-deep: #0b7f73;
  --teal-soft: #d5f5f0;
  --orange: #ff8a3d;
  --orange-deep: #a84a0c;
  --orange-soft: #ffe6d2;
  --lime: #2dc653;
  --lime-deep: #1b9e3b;
  --leaf: #1e9e4a;
  --leaf-deep: #157a3a;
  --leaf-soft: #d9f7e1;
  --coral: #e5484d;
  --coral-deep: #b8353a;
  --coral-soft: #fde4e4;
  --sky: #2f86d6;
  --sky-soft: #e1effb;
  --plum: #7a4cc2;
  --plum-soft: #efe7fb;
  --brand-red: #d22328;
  --line: #e6dcc3;
  --display: "Baloo 2", "Nirmala UI", "Mangal", "Trebuchet MS", sans-serif;
  --body: "Mukta", "Nirmala UI", "Mangal", "Segoe UI", sans-serif;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-back: cubic-bezier(.34, 1.56, .64, 1);
  color-scheme: only light;
}
* { box-sizing: border-box; }
input, textarea, select { background-color: var(--card); color: var(--ink); -webkit-text-fill-color: var(--ink); color-scheme: only light; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
html, body { min-height: 100%; margin: 0; }
body {
  background-color: var(--paper);
  background-image: radial-gradient(rgba(255, 138, 61, .14) 2px, transparent 2.2px);
  background-size: 22px 22px;
  color: var(--ink); font-family: var(--body); font-size: 20px; line-height: 1.4;
  display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: var(--display); cursor: pointer; color: var(--ink); touch-action: manipulation; }
button:disabled { cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 4px solid var(--sky); outline-offset: 3px; }
h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.1; text-wrap: balance; }
h1 { font-size: 48px; } h2 { font-size: 34px; } h3 { font-size: 24px; }
img { max-width: 100%; }

/* Header */
header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--teal); color: var(--ink);
  box-shadow: 0 5px 0 var(--teal-deep); position: relative; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; min-width: 0; }
.brand-logo { background: #fff; border-radius: 12px; padding: 5px 10px; display: flex; flex: 0 0 auto; transition: transform .2s var(--ease-out); }
.brand-logo img { height: 34px; width: auto; display: block; }
a.brand-logo:hover { transform: translateY(-2px); }
.brand-title { display: flex; flex-direction: column; min-width: 0; }
.brand-title b { font-family: var(--display); font-size: 28px; font-weight: 800; line-height: 1.05; }
.brand-title b .q { color: var(--ink); }
.brand-title > span { font-size: 15px; font-weight: 700; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip-btn {
  border: 2px solid rgba(22, 50, 79, .25); background: rgba(255, 255, 255, .45); color: var(--ink);
  border-radius: 999px; width: 44px; height: 44px; padding: 0; font-size: 15px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: background .15s, border-color .15s, scale .12s var(--ease-out);
}
.chip-btn svg { width: 22px; height: 22px; flex: 0 0 auto; }
.chip-btn .lbl { display: none; }
.chip-btn:hover { border-color: var(--ink); background: rgba(255, 255, 255, .8); }
.chip-btn[aria-pressed="true"] { background: var(--sun); color: var(--ink); border-color: var(--ink); }
/* Teacher reset: small, muted, a circular arrow instead of words */
.chip-btn.hold { width: 36px; height: 36px; opacity: .6; }
.chip-btn.hold > span { display: none; }
.chip-btn.hold::after { content: "\21BA"; font-size: 20px; font-weight: 800; position: relative; }
.chip-btn.hold:hover { opacity: 1; }

/* Layout */
main { flex: 1; display: flex; justify-content: center; padding: 22px 16px 32px; }
.stage { width: 100%; max-width: 1240px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel { background: var(--card); border-radius: 28px; padding: 26px; box-shadow: 0 6px 0 var(--line), 0 18px 40px -24px rgba(22, 50, 79, .35); }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }
.note { font-size: 17px; color: var(--ink-soft); }
footer.foot { text-align: center; font-size: 14px; color: var(--ink-soft); padding: 0 16px 18px; }
footer.foot a { color: inherit; }

/* Buttons */
.big-btn {
  border: none; border-radius: 22px; padding: 14px 32px; font-size: 25px; font-weight: 800;
  background: var(--sun); color: var(--ink); box-shadow: 0 6px 0 var(--sun-deep);
  transition: transform .12s var(--ease-out), box-shadow .12s var(--ease-out), filter .15s, scale .14s var(--ease-back);
  animation: pulse 1.8s ease-in-out infinite;
}
.big-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 0 var(--sun-deep); filter: brightness(1.04); scale: 1.05; animation: none; }
.big-btn:focus-visible { animation: none; }
.big-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 var(--sun-deep); scale: .95; transition-duration: .06s; animation: none; }
.big-btn:disabled { opacity: .5; animation: none; filter: grayscale(.4); }
.big-btn.green { background: var(--lime); color: var(--ink); box-shadow: 0 6px 0 var(--lime-deep); }
.big-btn.green:hover:not(:disabled) { box-shadow: 0 8px 0 var(--lime-deep); }
.big-btn.green:active:not(:disabled) { box-shadow: 0 2px 0 var(--lime-deep); }
.big-btn.red { background: var(--orange); color: var(--ink); box-shadow: 0 6px 0 var(--orange-deep); }
.big-btn.red:hover:not(:disabled) { box-shadow: 0 8px 0 var(--orange-deep); }
.big-btn.red:active:not(:disabled) { box-shadow: 0 2px 0 var(--orange-deep); }
.ghost-btn {
  border: 3px solid var(--line); border-radius: 20px; padding: 10px 20px; font-size: 20px; font-weight: 700;
  background: var(--card); color: var(--ink-soft); transition: border-color .15s, transform .12s var(--ease-out), scale .14s var(--ease-back);
}
.ghost-btn:hover:not(:disabled) { border-color: var(--ink-soft); color: var(--ink); scale: 1.03; }
.ghost-btn:active:not(:disabled) { scale: .95; transition-duration: .06s; }
@keyframes pulse { 0%, 100% { scale: 1; box-shadow: 0 6px 0 var(--sun-deep), 0 0 0 0 rgba(255, 201, 60, .65); } 50% { scale: 1.035; box-shadow: 0 6px 0 var(--sun-deep), 0 0 0 12px rgba(255, 201, 60, 0); } }
/* Squish on every pressable game item; selected ones wiggle gently while they wait for the next tap. */
.tile, .big-choices button, .seg button, .tcard, .answers button, .gcard { transition: scale .14s var(--ease-back), border-color .15s, background .15s, transform .12s var(--ease-out); }
.tile:active:not(:disabled), .big-choices button:active:not(:disabled), .seg button:active, .tcard:active, .answers button:active:not(:disabled), .gcard:active { scale: .95; transition-duration: .06s; }
.tile:hover:not(:disabled), .big-choices button:hover:not(:disabled), .seg button:hover { scale: 1.03; }
@keyframes wiggle { 0%, 100% { rotate: 0deg; } 25% { rotate: -2deg; } 75% { rotate: 2deg; } }
.tile[aria-pressed="true"], .big-choices button[aria-pressed="true"], .tcard.sel { animation: wiggle .9s ease-in-out infinite; }
.obj { transform-box: fill-box; transform-origin: center; }
@media (prefers-reduced-motion: reduce) {
  .big-btn, .tile[aria-pressed="true"], .big-choices button[aria-pressed="true"], .tcard.sel { animation: none; }
  .big-btn:hover:not(:disabled), .big-btn:active:not(:disabled), .ghost-btn:hover:not(:disabled), .ghost-btn:active:not(:disabled), .tile:active, .tile:hover { scale: 1; }
}
/* A disabled main button says why, right under it */
.why { font-size: 16px; font-weight: 700; color: var(--orange-deep); margin: 6px 0 0; }
.speak-btn {
  border: none; background: var(--sky-soft); color: var(--sky); border-radius: 999px; padding: 6px 16px;
  font-size: 17px; font-weight: 700; display: inline-flex; gap: 8px; align-items: center;
}
.speak-btn:hover { background: #d0e5f8; }
.link-btn { background: none; border: none; color: var(--coral); font-size: 16px; font-weight: 700; padding: 4px 6px; }

/* Dialog */
.overlay {
  position: fixed; inset: 0; background: rgba(22, 50, 79, .4); display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 30; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.dialog { background: var(--card); border-radius: 28px; padding: 26px; max-width: 760px; width: 100%; max-height: 92vh; overflow: auto; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .45); }

/* Emoji pictures (swapped in by play.js) */
img.emoji { height: 1.1em; width: 1.1em; vertical-align: -0.18em; display: inline-block; pointer-events: none; }

/* Toast: quick feedback banner at the bottom */
.toast {
  position: fixed; left: 50%; bottom: 22px; z-index: 40; width: min(720px, calc(100% - 32px));
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 18px; border-radius: 20px;
  background: #fff; color: var(--ink); font-size: 21px; line-height: 1.35; font-weight: 600;
  box-shadow: 0 6px 0 var(--line), 0 18px 40px -16px rgba(22, 50, 79, .45); border: 3px solid var(--line); border-left: 12px solid var(--teal);
  transform: translate(-50%, 140%); opacity: 0; pointer-events: none;
  transition: transform .35s var(--ease-back), opacity .2s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.toast.good { border-left-color: var(--lime); background: var(--leaf-soft); } .toast.bad { border-left-color: var(--orange); background: var(--orange-soft); } .toast.info { border-left-color: var(--sun); background: var(--sun-soft); }
.toast-in { flex: 1; }
.toast-in b { color: var(--ink); }
.toast-x { flex: 0 0 auto; border: none; background: rgba(22,50,79,.1); color: var(--ink); width: 40px; height: 40px; border-radius: 50%; font-size: 26px; line-height: 1; }
.toast-x:hover { background: rgba(22,50,79,.2); }
@media (prefers-reduced-motion: reduce) { .toast { transition: opacity .2s; transform: translate(-50%, 0); } }
@media (max-width: 600px) { .toast { font-size: 18px; bottom: 12px; } }

/* Rotate hint (phones in portrait) */
.rotate-hint { display: none; }
@media (max-width: 600px) and (orientation: portrait) {
  .rotate-hint { display: flex; align-items: center; gap: 10px; background: var(--sun-soft); border-radius: 16px; padding: 10px 14px; font-size: 16px; font-weight: 700; }
}

@media (max-width: 900px) {
  h1 { font-size: 38px; } h2 { font-size: 28px; }
  .panel { padding: 20px; border-radius: 24px; }
}
@media (max-width: 600px) {
  body { font-size: 18px; }
  header.top { padding: 8px 12px; }
  .brand-logo img { height: 26px; }
  .brand-title b { font-size: 22px; }
  .brand-title > span { display: none; }
  .chip-btn { width: 40px; height: 40px; }
  .big-btn { font-size: 22px; padding: 12px 22px; }
  .ghost-btn { font-size: 18px; padding: 9px 16px; }
  main { padding: 14px 12px 24px; }
}

@media (prefers-reduced-motion: no-preference) {
  .screen-in { animation: rise .45s var(--ease-out); }
  @keyframes rise { from { transform: translateY(14px); } }
  @keyframes fade-rise { from { transform: translateY(14px); opacity: 0; } }
  .pop { animation: pop .4s var(--ease-back); }
  @keyframes pop { from { transform: scale(.85); opacity: 0; } }
  .bump { animation: bump .25s var(--ease-back); }
  @keyframes bump { 40% { transform: scale(1.18); } }
  .shake { animation: shake .4s ease-in-out; }
  @keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
  .overlay { animation: fade .2s ease-out; }
  @keyframes fade { from { opacity: 0; } }
  .stagger > * { animation: fade-rise .5s var(--ease-out) both; }
  .stagger > *:nth-child(2) { animation-delay: .06s; } .stagger > *:nth-child(3) { animation-delay: .12s; }
  .stagger > *:nth-child(4) { animation-delay: .18s; } .stagger > *:nth-child(5) { animation-delay: .24s; }
  .stagger > *:nth-child(6) { animation-delay: .30s; } .stagger > *:nth-child(n+7) { animation-delay: .36s; }
}

@media print {
  header.top, footer.foot, .no-print { display: none !important; }
  body { background: #fff; }
  .panel { box-shadow: none; }
}

.big-btn.play { animation: none; }
.seg button[aria-pressed="true"] small, .tile[aria-pressed="true"] small, .big-choices button[aria-pressed="true"] small { color: var(--ink); }
