/* ---------------------------------------------------------------------------
 * ZoodleSwap Training Camp - only what differs from ZoodleSwap. Everything else comes
 * from /zoodleswap/style.css, so the two games look the same.
 * ------------------------------------------------------------------------- */

/* --- the start screen --------------------------------------------------- */
/* Tim (2026-10-08): "Always scale this page to the screen." Everything above
 * the © line sits in .start-fit, which fitStart() in camp.js zooms to the
 * biggest size that fits with no scrolling. Sizes in here are plain px/rem:
 * the zoom does the scaling. */
.start { gap: 16px; }
.start-fit { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; }
.start-col { display: flex; flex-direction: column; gap: 16px; }
.start-card .howto-link { min-height: 0; padding: 9px 16px; font-size: .95rem; }
/* The card can widen as the zoom shrinks it: wider means fewer lines, so
 * phones end up with bigger text. */
.start-card { width: min(560px, 100%); }
.start-card .join-msg:empty { display: none; }
.start-brand { position: relative; display: flex; flex-direction: column; align-items: center; max-width: 100%; }
.start-brand .join-logo {
  width: 300px;
  max-width: 100%;
  max-height: none;
  height: auto;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, .45));
}
/* Phones and upright tablets: leave room for the ZoodleBug Home button. */
@media (orientation: portrait), (max-width: 699px) {
  .start { padding-top: max(16px, var(--zb-home-top, 0px)); }
}
/* feedback.js adds a 48px strip at the bottom of scrolling pages so its button
 * never covers the last line. Every Training Camp screen fits the screen, so
 * the strip would only add a scroll; the button steps aside by itself. */
#zb-feedback-room { display: none; }
/* A phone held sideways: no room for the logo. */
@media (orientation: landscape) and (max-height: 450px) {
  .start-brand { display: none; }
}
/* Wide screens: a wide card, two columns - choices on the left, Challenges,
 * points and Start on the right - with the logo above. */
@media (orientation: landscape) and (min-width: 700px) {
  .start-fit { gap: 12px; }
  .start-brand .join-logo { width: auto; height: 160px; }
  .start-card { width: min(960px, 100%); flex-direction: row; align-items: stretch; gap: 28px; padding: 20px 26px; }
  .start-col { flex: 1 1 0; min-width: 0; gap: 14px; }
  .start-col:last-child { justify-content: flex-end; }
}
.start-intro { margin: 0; font-size: 1.05rem; line-height: 1.4; text-align: center; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-family: inherit;
  font-weight: 600;
  font-size: 1.1rem;
  min-width: 52px;
  min-height: 48px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 2px solid var(--cyan-dim);
  background: transparent;
  color: var(--paper);
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--cyan); border-color: var(--cyan); color: #032430; }

/* --- playing ------------------------------------------------------------- */
.home-btn { font-size: 1.2rem; }

.hint-btn { border-color: var(--gold-deep); color: var(--gold); }

/* A hint lights up the letters it uses, gently. */
.tile.hinted {
  outline: 3px dashed var(--gold);
  outline-offset: 2px;
}

/* Choosing letters to trade in: the picked ones lift and turn cyan. */
.tile.to-swap {
  outline: 4px solid var(--cyan);
  outline-offset: 2px;
  transform: translateY(-4px);
  filter: saturate(.6) brightness(.9);
}
html.swap-mode .bank-wrap { border-radius: 16px; box-shadow: 0 0 0 3px rgba(39, 207, 228, .45); }

.swap-picking { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.swap-actions { display: flex; gap: 8px; }
.swap-btn:disabled { filter: saturate(.3) brightness(.7); cursor: default; }
/* Before a swap is due it's still allowed, just quieter (Tim: swap any time). */
.swap-btn.optional { filter: saturate(.55) brightness(.85); }
.swap-msg { min-height: 1.2em; }

/* --- the account line on the start screen --------------------------------- */
.camp-account {
  background: var(--panel-soft);
  border: 1px solid #17506d;
  border-radius: 14px;
  padding: 10px 14px;
  font-size: .98rem;
  line-height: 1.4;
  text-align: center;
}
.camp-account b { color: var(--gold); }
.camp-account a { color: var(--cyan); font-weight: 600; }

/* --- the clock --------------------------------------------------------------- */
/* Big, so a child always knows how long is left (Tim: about triple, 2026-10-01). */
.play-head .clock { min-width: 2.6em; text-align: right; font-size: 3.3em; font-weight: 700; line-height: 1; }
.play-head .clock.low { color: var(--bad); }

/* --- the last ten seconds ------------------------------------------------------ */
.camp-countdown {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  pointer-events: none;
  font-weight: 700;
  font-size: min(42vw, 42vh);
  line-height: 1;
  color: rgba(255, 194, 71, .55);
  text-shadow: 0 0 40px rgba(0, 0, 0, .6);
}
.camp-countdown.tick { animation: camp-tick .9s ease-out; }
.camp-countdown.time { font-size: min(22vw, 26vh); color: rgba(255, 139, 122, .9); }
@keyframes camp-tick {
  from { transform: scale(1.35); opacity: 1; }
  to { transform: scale(1); opacity: .85; }
}

/* --- the end of a game ----------------------------------------------------------- */
.done { justify-content: center; }
.done-card { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
.done-head, .done-main, .done-side { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
.done-head > * { margin: 0; }
.done-card .done-score { margin: 4px 0 0; }
.done-card .ghost-btn.quiet { margin-top: 0; text-align: center; text-decoration: none; }
.done-words { margin: 0; color: var(--muted); font-size: 1.05rem; }
.done-bonus { margin: 0; color: var(--gold); font-weight: 700; font-size: 1.1rem; }
/* Every word (or equation) from this game, with its points. Long lists scroll
   inside the box so the buttons below stay on screen. */
.done-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: max(76px, min(260px, calc(100dvh - 700px)));
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
  background: var(--panel-soft);
  border: 1px solid #17506d;
  border-radius: 14px;
}
.done-list.math { grid-template-columns: 1fr; }
.done-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 5px 9px;
  border-radius: 9px;
  background: rgba(255, 255, 255, .05);
  font-weight: 600;
  letter-spacing: .04em;
  white-space: nowrap;
}
.done-list li i { font-style: normal; font-size: .85em; }
.done-list li b { color: var(--gold); font-size: .95em; }
.done-totals { display: flex; gap: 12px; width: 100%; }
.done-totals > div {
  flex: 1;
  background: var(--panel-soft);
  border: 1px solid #17506d;
  border-radius: 14px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.done-totals span { font-size: .8rem; color: var(--cyan); text-transform: uppercase; letter-spacing: .06em; }
.done-totals b { font-size: 1.6rem; color: var(--gold); }
.done-save { margin: 0; min-height: 1.3em; font-size: .92rem; color: var(--muted); text-align: center; }
.done-save a { color: var(--cyan); font-weight: 600; }

/* This game's Challenges on the end screen: done ones in gold with a tick. */
.done-goals {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.done-goals li {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #17506d;
  color: var(--muted);
  font-size: .9rem;
  white-space: nowrap;
}
.done-goals li.met { border-color: var(--gold-deep); color: var(--gold); font-weight: 600; }

/* Big screens (a laptop, a classroom board, an iPad sideways): the end of a
   game fills the screen. Two columns - what you made on the left, points and
   buttons on the right - and everything sized from --f, which grows with the
   screen. Phones keep the single column above. */
@media (min-width: 900px) and (min-height: 560px), (min-width: 700px) and (min-height: 900px) {
  .done-card {
    --f: clamp(15px, min(1.35vw, 2.5vh), 32px);
    font-size: var(--f);
    margin-top: auto;   /* centered between the top and the copyright line */
    padding: 1.6em 2.2em;
    gap: 1.1em;
  }
  .done-head { gap: .3em; }
  .done-main { gap: .9em; }
  .done-side { gap: .8em; }
  .done-card h1 { font-size: 3.2em; line-height: 1.05; }
  .done-card .done-score { font-size: 1.5em; }
  .done-score b { font-size: 1.6em; }
  .done-words { font-size: 1.15em; }
  .done-bonus { font-size: 1.2em; }
  .done-list {
    font-size: 1.3em;
    max-height: calc(100dvh - var(--f) * 20 - 72px);
    grid-template-columns: repeat(auto-fill, minmax(9em, 1fr));
    gap: .4em;
    padding: .45em;
  }
  .done-list.math { grid-template-columns: repeat(auto-fill, minmax(15em, 1fr)); }
  .done-list li { padding: .35em .65em; }
  .done-goals { gap: .45em; }
  .done-goals li { font-size: 1.1em; padding: .3em .8em; }
  .done-totals { gap: .7em; }
  .done-totals > div { padding: .7em; }
  .done-totals span { font-size: .85em; }
  .done-totals b { font-size: 2.6em; }
  .done-save { font-size: .95em; }
  .done-side .big-btn { font-size: 1.35em; min-height: 2.6em; }
  .done-side .ghost-btn { font-size: 1.1em; min-height: 2.7em; }
}
/* Wide: two columns. */
@media (min-width: 900px) and (min-height: 560px) {
  .done-card {
    width: min(1500px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    grid-template-areas: "head head" "main side";
    column-gap: 2.2em;
    align-items: start;
  }
  .done-head { grid-area: head; }
  .done-main { grid-area: main; }
  .done-side { grid-area: side; }
}
/* A tall tablet held upright: one column, scaled up. */
@media (min-width: 700px) and (max-width: 899px) and (min-height: 900px) {
  .done-card { --f: clamp(16px, 2.4vw, 22px); width: min(720px, 100%); }
  .done-list { max-height: calc(100dvh - var(--f) * 41 - 80px); }
}

/* --- Challenges ------------------------------------------------------------------- */
/* Start screen: the list. */
.camp-goals {
  background: var(--panel-soft);
  border: 1px solid var(--gold-deep);
  border-radius: 14px;
  padding: 10px 14px;
}
.camp-goals ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.camp-goals li { font-size: .98rem; line-height: 1.3; }

/* In the header: the star count; tap it to see the list. */
.goals-btn {
  font: inherit;
  font-weight: 600;
  color: var(--paper);
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
}
.goals-btn small { color: var(--muted); font-weight: 400; font-size: .72rem; }
.goals-btn.all-done { color: var(--gold); }
/* Phones: the big clock and the star count both have to fit in the header. */
@media (max-width: 480px) {
  .goals-btn small { display: none; }
  .goals-btn { flex: 0 0 auto; }
  .play-head { gap: 7px; padding-left: 10px; padding-right: 12px; }
  .play-head .clock { font-size: 2.7em; margin-left: auto; }
  .play-head .stat small { font-size: .62rem; }
}

/* A Challenge done mid-game: a note near the top that fades out. */
.camp-toast {
  position: fixed;
  left: 50%;
  top: max(12px, env(safe-area-inset-top));
  z-index: 55;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--gold);
  color: #2a1a00;
  font-weight: 700;
  font-size: 1.05rem;
  text-align: center;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .45);
  pointer-events: none;
}
.camp-toast.pop { animation: camp-toast 2.8s ease-out forwards; }
@keyframes camp-toast {
  0% { opacity: 0; transform: translate(-50%, -12px) scale(.9); }
  10% { opacity: 1; transform: translate(-50%, 0) scale(1.05); }
  18% { transform: translate(-50%, 0) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* --- new highs at the end of a game --------------------------------------------- */
.camp-best {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background:
    radial-gradient(circle at 50% 42%, rgba(39, 207, 228, .38), rgba(39, 207, 228, 0) 55%),
    rgba(2, 12, 23, .96);
  animation: camp-fade .3s ease-out;
  cursor: pointer;
}
.camp-best-card { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.camp-best-bug {
  height: min(40vh, 400px);
  width: auto;
  filter: drop-shadow(0 16px 30px rgba(0, 0, 0, .5));
  animation: camp-bounce 1s ease-in-out infinite alternate;
}
.camp-best-kicker {
  margin: 4px 0 0;
  font-size: clamp(2rem, 7vw, 3.4rem);
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 4px 0 #a86b12, 0 10px 24px rgba(0, 0, 0, .5);
}
.camp-best-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
  font-size: clamp(1.05rem, 3.6vw, 1.5rem);
  font-weight: 600;
  color: var(--paper);
}
.camp-best-list li.goal { color: var(--gold); }
@keyframes camp-bounce {
  from { transform: translateY(0) rotate(-3deg); }
  to { transform: translateY(-18px) rotate(3deg); }
}
@keyframes camp-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .camp-best-bug, .camp-countdown.tick, .camp-toast.pop { animation: none; }
}

/* --- the copyright line, on every screen ------------------------------------------ */
.camp-copy {
  margin: 0;
  font-size: .72rem;
  color: var(--muted);
  opacity: .8;
  text-align: center;
}
.start .camp-copy, .done .camp-copy { margin-top: auto; padding-top: 8px; }
html.playing .screen.play > .camp-copy { margin-top: 2px; }
.camp-best .camp-copy { margin-top: 10px; }
@media (orientation: landscape) and (min-width: 900px) {
  .screen.play > .camp-copy { grid-column: 1 / -1; grid-row: -2; align-self: end; }
}
