/* Code Clash — playful dark arcade theme, mobile-first. */

:root {
  --bg: #10121a;
  --bg-card: #1a1e2c;
  --bg-inset: #12151f;
  --text: #eef1f8;
  --text-muted: #9aa3b8;
  --line: #2a3045;
  --accent: #7c5cff;
  --accent-2: #ffb020;
  --pass: #2ecc71;
  --fail: #ff5c6c;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

h1 { font-size: 1.6rem; margin: 0.4em 0; }
h2 { font-size: 1.15rem; margin: 0 0 0.6em; }
h3 { font-size: 1rem; margin: 0.8em 0 0.4em; }
a { color: var(--accent-2); }
code {
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.1em 0.35em;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.92em;
}

/* ---- shell ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.brand {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}
.nav { display: flex; gap: 0.9rem; }
.nav a { color: var(--text-muted); text-decoration: none; font-weight: 600; }
.nav a:hover { color: var(--text); }
.player-chip { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }

.wrap { max-width: 70rem; margin: 0 auto; padding: 1rem; }
.footer {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
  font-size: 0.85rem;
}

/* ---- cards & bits ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin: 1rem 0;
}
.hero { text-align: center; padding: 1.4rem 0 0.4rem; }
.hero .sub { color: var(--text-muted); margin-top: -0.4rem; }
.muted { color: var(--text-muted); }
.notice {
  background: rgba(124, 92, 255, 0.12);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  background: color-mix(in srgb, var(--chip-color, var(--accent)) 18%, transparent);
  border: 1px solid var(--chip-color, var(--accent));
  border-radius: 999px;
  padding: 0.1em 0.7em;
  font-weight: 600;
  white-space: nowrap;
}

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.55em 1.1em;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: 0.5; cursor: wait; }
.btn-primary { background: var(--pass); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-sm { font-size: 0.85rem; padding: 0.3em 0.8em; }
.btn-danger { background: var(--fail); }

/* ---- player picker ---- */
.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 0.8rem;
}
.player-card {
  background: var(--bg-inset);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 0.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  color: var(--text);
  font-size: 1rem;
  transition: transform 0.12s, border-color 0.12s;
}
.player-card:hover { transform: translateY(-2px); border-color: var(--chip-color); }
.player-card.is-active { border-color: var(--chip-color); box-shadow: 0 0 0 3px color-mix(in srgb, var(--chip-color) 35%, transparent); }
.player-emoji { font-size: 2.2rem; }
.player-name { font-weight: 700; }
.player-lock { font-size: 0.8rem; }

/* ---- challenges ---- */
.challenge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.8rem;
}
.challenge-card {
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  color: var(--text);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: transform 0.12s;
}
.challenge-card:hover { transform: translateY(-2px); }
.challenge-card.lang-javascript { border-left-color: #f7df1e; }
.challenge-card.lang-lua { border-left-color: #4f8ef7; }
.challenge-card.lang-python { border-left-color: #3fb950; }
.challenge-card.is-solved { opacity: 0.75; }
.challenge-title { font-weight: 700; }
.challenge-meta { color: var(--text-muted); font-size: 0.85rem; }
.challenge-lang { font-size: 1.1rem; }

/* ---- play page ---- */
.play-head h1 { margin-bottom: 0.1em; }
.play-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 60rem) {
  .play-grid { grid-template-columns: minmax(18rem, 2fr) 3fr; align-items: start; }
}

.description p { margin: 0.5em 0; }
.hints { margin: 0.8rem 0; }
.hints summary { cursor: pointer; font-weight: 700; }
.hints ol { margin: 0.4em 0 0 1.2em; padding: 0; }
.hints li { margin: 0.35em 0; }
.hints li summary { color: var(--accent-2); }

.test-list { list-style: none; margin: 0; padding: 0; }
.test-list li {
  padding: 0.55em 0.6em;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 0.5rem;
  background: var(--bg-inset);
  font-size: 0.95rem;
}
.test-list li.test-pass { border-color: var(--pass); }
.test-list li.test-fail { border-color: var(--fail); }
.test-dot {
  display: inline-grid;
  place-items: center;
  width: 1.35em;
  height: 1.35em;
  border-radius: 50%;
  background: var(--line);
  margin-right: 0.25rem;
  font-size: 0.78rem;
  font-weight: 800;
}
.test-pass .test-dot { background: var(--pass); color: #06140c; }
.test-fail .test-dot { background: var(--fail); color: #fff; }
.test-note {
  margin-left: 1.8em;
  color: var(--fail);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.82rem;
  word-break: break-word;
}
.test-detail,
.test-result-detail {
  margin: 0.45rem 0 0 1.9rem;
  color: var(--text-muted);
  font-size: 0.84rem;
}
.test-result-detail {
  color: var(--text);
  border-top: 1px dashed var(--line);
  padding-top: 0.45rem;
}

.editor-wrap { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.code-editor {
  display: block;
  width: 100%;
  min-height: 16rem;
  background: #0d1017;
  color: #e6edf3;
  border: none;
  outline: none;
  resize: vertical;
  padding: 0.9rem;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.55;
  tab-size: 2;
}
.editor-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.7rem;
  flex-wrap: wrap;
}
.run-status { color: var(--text-muted); font-size: 0.9rem; }

.console { margin-top: 0.8rem; }
.console pre {
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem;
  max-height: 12rem;
  overflow: auto;
  font-size: 0.85rem;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.result-banner {
  margin-top: 0.9rem;
  border-radius: 10px;
  padding: 0.8rem 1rem;
  font-weight: 700;
  font-size: 1.05rem;
}
.banner-win { background: rgba(46, 204, 113, 0.15); border: 1px solid var(--pass); }
.banner-partial { background: rgba(255, 176, 32, 0.12); border: 1px solid var(--accent-2); }
.banner-fail { background: rgba(255, 92, 108, 0.12); border: 1px solid var(--fail); }

/* ---- leaderboard ---- */
.board { width: 100%; border-collapse: collapse; }
.board th, .board td { text-align: left; padding: 0.55em 0.6em; border-bottom: 1px solid var(--line); }
.board th { color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }
.board .rank { font-weight: 800; width: 3.5rem; }
.board tbody tr:first-child td { font-size: 1.05rem; }

.mini-board { list-style: none; margin: 0; padding: 0; }
.mini-board li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.4em 0;
  border-bottom: 1px dashed var(--line);
}

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 0.45em 0.2em; border-bottom: 1px dashed var(--line); }
.feed-pass strong { color: var(--pass); }
.feed-try strong { color: var(--text-muted); }
.points-pop {
  display: inline-block;
  background: var(--accent-2);
  color: #1a1400;
  font-weight: 800;
  border-radius: 999px;
  padding: 0 0.5em;
  font-size: 0.85rem;
}

.live-dot {
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  border-radius: 50%;
  background: var(--pass);
  vertical-align: middle;
}
.live-dot.blink { animation: live-blink 0.6s ease-out; }
@keyframes live-blink {
  0% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7); }
  100% { box-shadow: 0 0 0 8px rgba(46, 204, 113, 0); }
}

/* ---- confetti ---- */
.confetti-bit {
  position: fixed;
  top: -2vh;
  width: 10px;
  height: 14px;
  z-index: 999;
  pointer-events: none;
  animation: confetti-fall linear forwards;
  border-radius: 2px;
}
@keyframes confetti-fall {
  to { transform: translateY(105vh) rotate(720deg); }
}

/* ---- admin ---- */
.admin-tabs { display: flex; gap: 0.5rem; margin: 1rem 0; flex-wrap: wrap; }
.admin-tab {
  background: var(--bg-inset);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 0.35em 1em;
  font-weight: 700;
  cursor: pointer;
}
.admin-tab.is-active { background: var(--accent); border-color: var(--accent); }
.admin-panel { display: none; }
.admin-panel.is-active { display: block; }

.form-grid { display: grid; gap: 0.7rem; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
label.field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.field input, .field select, .field textarea {
  background: var(--bg-inset);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5em 0.7em;
  font-size: 0.95rem;
  font-family: inherit;
}
.field textarea { font-family: ui-monospace, Consolas, monospace; min-height: 7rem; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.admin-table th, .admin-table td { text-align: left; padding: 0.45em 0.5em; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table th { color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; }
.admin-table .actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* ---- beginner coach ---- */
.concept-card,
.coach-panel,
.value-visualizer,
.reward-card {
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-inset));
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line));
  border-radius: 10px;
  padding: 0.8rem 0.9rem;
  margin: 0.7rem 0;
}
.coach-kicker {
  display: block;
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.15rem;
}
.concept-card h3,
.coach-panel h3,
.reward-card h3 { margin: 0 0 0.25rem; }
.concept-card p,
.coach-message,
.reward-card p { margin: 0.35rem 0 0; color: var(--text-muted); }
.coach-panel {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 0.9rem;
}
.coach-checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}
.coach-checklist li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.coach-checklist li span {
  display: inline-grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--line);
  font-size: 0.75rem;
  font-weight: 900;
}
.coach-checklist li.is-done { color: var(--text); }
.coach-checklist li.is-done span { background: var(--pass); color: #06140c; }
.blank-meter {
  justify-self: start;
  background: var(--accent-2);
  color: #1a1400;
  border-radius: 999px;
  padding: 0.12rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 900;
}
.star-row {
  color: var(--accent-2);
  font-size: 1.4rem;
  letter-spacing: 0.06em;
  line-height: 1;
}
.example-tries {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin: 0.7rem 0;
}
.example-tries p { flex-basis: 100%; margin: 0; }
.value-visualizer {
  background: color-mix(in srgb, var(--accent-2) 9%, var(--bg-inset));
  border-color: color-mix(in srgb, var(--accent-2) 55%, var(--line));
}
.value-visualizer p { margin: 0.35rem 0 0; color: var(--text-muted); }
.hint-ladder {
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem;
  margin: 0.8rem 0;
}
.hint-ladder ol { margin: 0.4rem 0; padding-left: 1.2rem; }
.hint-item {
  margin: 0.35rem 0;
  color: var(--accent-2);
  font-weight: 600;
}
.reward-card {
  background: color-mix(in srgb, var(--pass) 12%, var(--bg-inset));
  border-color: var(--pass);
}
.reward-stars { margin: 0.4rem 0; }

/* ---- practice playground ---- */
.practice-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}
.practice-grid {
  display: grid;
  gap: 1rem;
}
@media (min-width: 58rem) {
  .practice-grid { grid-template-columns: minmax(0, 3fr) minmax(16rem, 2fr); }
}
.practice-console pre {
  min-height: 14rem;
  max-height: 28rem;
}

/* ---- language world theming ---- */
.lang-javascript { --world-color: #f7df1e; }
.lang-lua { --world-color: #7ab3ff; }
.lang-python { --world-color: #3fb950; }

.world-grid { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.world-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: var(--bg-inset);
  border: 2px solid var(--world-color, var(--line));
  border-radius: var(--radius);
  padding: 1.1rem;
  color: var(--text);
  text-decoration: none;
  transition: transform 0.12s, box-shadow 0.12s;
}
.world-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--world-color) 30%, transparent);
}
.world-card .world-emoji { font-size: 2.4rem; }
.world-card .world-name { font-weight: 800; font-size: 1.15rem; color: var(--world-color); }
.world-card .world-blurb { color: var(--text-muted); font-size: 0.9rem; }
.world-progress { display: flex; align-items: center; gap: 0.6rem; font-size: 0.9rem; }
progress {
  flex: 1;
  height: 0.7rem;
  accent-color: var(--world-color, var(--accent));
}

.world-banner {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  background: linear-gradient(135deg, color-mix(in srgb, var(--world-color) 22%, var(--bg-card)), var(--bg-card));
  border: 2px solid var(--world-color);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  margin: 1rem 0;
}
.world-banner .world-emoji { font-size: 3.2rem; }
.world-banner h1 { margin: 0; color: var(--world-color); }
.world-banner .sub { color: var(--text-muted); margin: 0.2rem 0; }
.world-banner .world-progress { max-width: 20rem; }

/* level path (per-world) */
.level-path { list-style: none; margin: 1rem 0; padding: 0; position: relative; }
.level-path::before {
  content: "";
  position: absolute;
  left: 1.45rem;
  top: 1rem;
  bottom: 1rem;
  width: 4px;
  background: var(--line);
  border-radius: 2px;
}
.level-node { position: relative; margin: 0.6rem 0; }
.level-node a {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  text-decoration: none;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  transition: transform 0.12s;
}
.level-node a:hover { transform: translateX(4px); }
.level-num {
  flex: 0 0 auto;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: var(--bg-inset);
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  font-weight: 800;
  z-index: 1;
}
.level-node.is-solved .level-num { background: var(--pass); border-color: var(--pass); color: #08130b; }
.level-node.is-next a { border-color: var(--accent-2); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-2) 40%, transparent); }
.level-node.is-next .level-num { border-color: var(--accent-2); }
.level-info { display: flex; flex-direction: column; }
.level-title { font-weight: 700; }
.level-meta { color: var(--text-muted); font-size: 0.85rem; }
.next-chip {
  background: var(--accent-2);
  color: #1a1400;
  font-weight: 800;
  border-radius: 999px;
  padding: 0 0.6em;
  font-size: 0.75rem;
}

/* ---- learning steps ---- */
.steps-bar { display: flex; gap: 0.4rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.step-tab {
  background: var(--bg-inset);
  border: 1px solid var(--line);
  color: var(--text-muted);
  border-radius: 12px;
  padding: 0.45em 0.8em;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 7.5rem;
}
.step-tab span { font-size: 0.72rem; font-weight: 600; color: inherit; }
.step-tab.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.step-tab.is-done:not(.is-active) { border-color: var(--pass); color: var(--pass); }
.step-note {
  background: rgba(124, 92, 255, 0.1);
  border: 1px dashed var(--accent);
  border-radius: 10px;
  padding: 0.5rem 0.8rem;
  font-size: 0.92rem;
  margin: 0 0 0.7rem;
}
.example-note { font-size: 0.95rem; }
.example-code {
  background: #0d1017;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.9rem;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.92rem;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
}
.step-next {
  margin-top: 0.8rem;
  background: rgba(46, 204, 113, 0.1);
  border: 1px solid var(--pass);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  font-weight: 600;
}

/* ---- self-signup ---- */
.player-card-new { border-style: dashed; color: var(--text-muted); }
.signup-form { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.8rem; }
.signup-form h3 { margin: 0; }
.emoji-row { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.3rem; }
.emoji-pick, .color-pick {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: var(--bg-inset);
  font-size: 1.3rem;
  cursor: pointer;
}
.color-pick { border-radius: 50%; }
.emoji-pick.is-active, .color-pick.is-active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent);
}

.login-box { max-width: 22rem; margin: 4rem auto; }
.flash { padding: 0.6rem 1rem; border-radius: 10px; margin-bottom: 1rem; }
.flash-error { background: rgba(255, 92, 108, 0.12); border: 1px solid var(--fail); }
.flash-ok { background: rgba(46, 204, 113, 0.12); border: 1px solid var(--pass); }
