/* CPAL-1.0 License. See chaosaccelerator.com/license.html */

/* On top of landing.css: the list borrows its page styles; play mode covers the window. */

[hidden] { display: none !important; }

.challenge-intro p { color: var(--text-dim); line-height: 1.55; max-width: 640px; }
.progress-total { margin: 0 0 8px; text-align: center; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.section-progress { margin-left: 10px; font-size: 14px; font-weight: 500; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.progress-done { color: #c9a227; }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100; }
.challenge-intro b { color: var(--text); }

.challenge-list { display: grid; gap: 18px; margin-top: 20px; }
.challenge-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 18px;
  padding: 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.challenge-card h3 { margin: 0 0 6px; font-size: 20px; }
.challenge-card .solved { font-size: 13px; color: #c9a227; margin-left: 8px; }
.challenge-card p { margin: 0 0 12px; color: var(--text-dim); line-height: 1.5; }
.challenge-card video,
.challenge-card img.card-still { width: 100%; border-radius: 6px; background: #0c0d11; display: block; }
.challenge-card .order { font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }
.challenge-card button {
  font: inherit;
  padding: 8px 14px;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
.challenge-card button:hover { background: var(--accent-hover); }
.challenge-card button:disabled,
.challenge-card button:disabled:hover { color: var(--text-dim); background: var(--border); cursor: default; }
.challenge-card button.secondary { color: var(--text); background: transparent; border: 1px solid var(--border); }
.challenge-card button.secondary:hover { background: var(--bg-input, #232735); }
.challenge-card button.danger,
.reset-all button,
.confirm-actions .danger {
  color: #ff5f56;
  background: transparent;
  border: 1px solid #ff5f56;
}
.challenge-card button.danger:hover,
.reset-all button:hover:not(:disabled),
.confirm-actions .danger:hover { color: #fff; background: #ff5f56; }
.reset-all { margin: 28px 0 0; text-align: right; }
.reset-all button { font: inherit; padding: 8px 14px; border-radius: 6px; cursor: pointer; }
.reset-all button:disabled { opacity: 0.4; cursor: default; }

/* The reset confirmation, in the GOAL! card's frame with a red edge. */
.confirm-dialog {
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  max-width: min(420px, calc(100vw - 32px));
}
.confirm-dialog::backdrop { background: rgba(12, 13, 17, 0.6); }
.confirm-card {
  padding: 20px 24px;
  background: var(--bg-panel);
  border: 1px solid #ff5f56;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
.confirm-card h2 { margin: 0 0 8px; font-size: 20px; }
.confirm-card p { margin: 0 0 16px; color: var(--text-dim); line-height: 1.5; }
.confirm-card .confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin: 0; }
.confirm-actions .danger { margin: 0; font: inherit; font-size: 14px; padding: 6px 12px; border-radius: 6px; cursor: pointer; }

.challenge-card canvas.card-rose { width: 100%; aspect-ratio: 1; display: block; background: #0c0d11; border-radius: 6px; }
/* An attempted challenge's best, a box of its own between the title and the chart. */
.challenge-card.has-best { grid-template-columns: max-content minmax(0, 1fr) 220px; }
.challenge-card.has-best > div:first-child { grid-column: 1; grid-row: 1; }
.challenge-card.has-best > canvas { grid-column: 3; grid-row: 1; }
.best-box {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.best-box.has-scene { grid-template-columns: minmax(0, 1fr) 206px; }
.best-box .best-solved { margin: 0 0 4px; font-weight: 600; color: #c9a227; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.challenge-card img.card-scene { width: 100%; display: block; border: 1px solid var(--border); border-radius: 6px; background: #14161c; }
.challenge-card canvas.card-plot { width: 100%; aspect-ratio: 3 / 2; display: block; background: #0c0d11; border-radius: 6px; }

/* ---- Play mode ---- */
.play-page {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  z-index: 10;
}
.play-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  padding-top: max(6px, env(safe-area-inset-top));
}
.play-title { flex: 1; text-align: center; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score { font-size: 14px; color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.score b { color: var(--text); font-weight: 600; }
.score.score-win b { color: #c9a227; }
.bar-btn {
  font: inherit;
  font-size: 14px;
  padding: 6px 10px;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}
.bar-btn:hover { background: var(--bg-input, #232735); color: var(--text); text-decoration: none; }

.play-stage { position: relative; flex: 1; min-height: 0; }
#engine { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #0c0d11; }

.target-panel {
  position: absolute;
  right: 12px;
  bottom: 40px; /* clear of the map's watermark */
  width: 260px;
  padding: 10px;
  background: rgba(27, 30, 39, 0.94);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}
.target-panel video,
.target-panel img.target-image { width: 100%; border-radius: 6px; background: #0c0d11; display: block; }
.target-rose { width: 100%; aspect-ratio: 1; border-radius: 6px; background: #0c0d11; display: block; }
.target-plot { width: 100%; aspect-ratio: 3 / 2; border-radius: 6px; background: #0c0d11; display: block; }
.best-panel { right: auto; left: 12px; }
.panel-close {
  display: block;
  margin: -6px -6px 2px auto;
  width: 24px;
  height: 24px;
  padding: 0;
  font: inherit;
  font-size: 18px;
  line-height: 1;
  color: var(--text-dim);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
.panel-close:hover { color: var(--text); background: var(--bg-input, #232735); }
.target-order { margin: 8px 0 4px; font-size: 13px; font-variant-numeric: tabular-nums; }
.target-help { margin: 0; font-size: 12px; color: var(--text-dim); line-height: 1.45; }
.target-help b { color: var(--text); }
.best-actions { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 12px; }

.toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 8px 14px;
  background: rgba(27, 30, 39, 0.94);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  pointer-events: none;
}

/* Top center, over the map only where it sits: the rest stays usable. */
.win-panel {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
}
.win-card {
  padding: 14px 20px;
  text-align: center;
  background: var(--bg-panel);
  border: 1px solid #c9a227;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  max-width: 460px;
}
.win-card h2 { margin: 0 0 4px; font-size: 28px; color: #c9a227; letter-spacing: 0.04em; }
.win-card p { margin: 0 0 10px; color: var(--text-dim); }
.win-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

@media (max-width: 760px) {
  .challenge-card, .challenge-card.has-best, .best-box.has-scene { grid-template-columns: 1fr; }
  .challenge-card.has-best > div:first-child,
  .challenge-card.has-best > canvas,
  .challenge-card.has-best > .best-box { grid-column: auto; grid-row: auto; }
  .target-panel { width: min(260px, calc(100vw - 24px)); bottom: auto; top: 12px; }
  .best-panel { top: auto; bottom: 12px; }
  .score { display: none; }
}

/* While a challenge plays, the map in the frame shows its own watermark. */
body:has(#play-page:not([hidden])) > .watermark { display: none; }
