:root {
  --bg: #0b1120;
  --ink: #e9edf5;
  --dim: #7d879b;
  --violet: #7c6cff;
  --green: #22c39a;
  --amber: #f4a33c;
  --red: #b45757;
  --stone: #2a3142;
  --locked: #252b39;
  --locked-line: #3c4456;
  --font: Futura, "Avenir Next", "Century Gothic", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font-family: var(--font);
  background: radial-gradient(ellipse at 70% 90%, #10203a, var(--bg) 65%);
  background-color: var(--bg);
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* Level header */
.topbar {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  padding: 22px 28px 0;
}

.level {
  font-size: 44px;
  font-weight: 700;
  line-height: 0.85;
}

.level.is-up { animation: level-up 0.9s ease; }

@keyframes level-up {
  30% { color: var(--green); transform: scale(1.18); }
}

.meter {
  flex: 1;
  max-width: 520px;
}

.meter__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  font-size: 14px;
  font-weight: 600;
}

.meter__team { color: var(--dim); }

.meter__xp {
  margin-right: 8px;
  color: var(--dim);
  font-weight: 400;
}

/* No track behind the bar: only the earned part shows, with rounded ends. */
.meter__bar {
  height: 4px;
}

.meter__fill {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--violet);
  transition: width 0.4s ease;
}

/* Badges: one per module, lit when earned. */
.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 9px;
  font-size: 12px;
  color: #4a5367;
  cursor: help;
}

.badge.is-earned { color: var(--green); }

.links {
  display: flex;
  gap: 18px;
  margin-left: auto;
  font-size: 13px;
  color: var(--dim);
}

.links button:hover { color: var(--ink); }

/* Step map */
.map {
  position: relative;
  flex: 1;
  min-height: 0;
}

#graph {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

#graph.is-panning { cursor: grabbing; }

.module-label {
  fill: #3b4458;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.edge {
  stroke: #232a3a;
  stroke-width: 5;
  stroke-linecap: round;
}

.edge--active { stroke: #3a4357; }
.edge--done { stroke: var(--green); opacity: 0.45; }

.node { cursor: pointer; outline: none; }

.node circle {
  stroke-width: 2;
  transition: transform 0.15s ease;
  transform-box: fill-box;
  transform-origin: center;
}

.node:hover circle,
.node:focus-visible circle { transform: scale(1.06); }

.node__label {
  font-size: 10.5px;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
}

.node--big .node__label { font-size: 12px; }

.node--done circle { fill: var(--green); stroke: var(--green); }
.node--done .node__label { fill: #062a20; }

.node--in_progress circle { fill: var(--amber); stroke: var(--amber); }
.node--in_progress .node__label { fill: #2b1a04; }

.node--available circle { fill: var(--violet); stroke: var(--violet); }
.node--available .node__label { fill: #ffffff; }

.node--locked circle,
.node--closed circle { fill: var(--locked); stroke: var(--locked-line); }
.node--locked .node__label,
.node--closed .node__label { fill: #6f788b; }

.node.is-selected circle { stroke: #ffffff; stroke-width: 3; }

/* Step list (phones) */
.steps { display: none; }

.steps__day {
  margin: 26px 0 4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
}

.steps__title {
  margin: 18px 0 8px;
  font-size: 15px;
  font-weight: 500;
  color: var(--violet);
}

.steps ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps li { position: relative; }

/* The line joining one step to the next. */
.steps li + li::before {
  content: "";
  position: absolute;
  left: 15px;
  top: -10px;
  height: 20px;
  border-left: 3px solid #2a3142;
}

.step {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 7px 0;
  text-align: left;
}

.step__dot {
  flex-shrink: 0;
  width: 33px;
  height: 33px;
  border-radius: 50%;
  border: 2px solid var(--locked-line);
  background: var(--locked);
}

.step__text { display: flex; flex-direction: column; min-width: 0; }
.step__name { font-size: 16px; font-weight: 600; }
.step__meta { font-size: 13px; color: var(--dim); }

.step--done .step__dot { background: var(--green); border-color: var(--green); }
.step--in_progress .step__dot { background: var(--amber); border-color: var(--amber); }
.step--available .step__dot { background: var(--violet); border-color: var(--violet); }
.step--locked .step__name,
.step--closed .step__name { color: var(--dim); }
.step.is-selected .step__dot { border-color: #ffffff; }

/* Detail card */
.card__close {
  float: right;
  margin: -8px -8px 0 8px;
  padding: 4px 8px;
  font-size: 20px;
  line-height: 1;
  color: var(--dim);
}

.card__close:hover { color: var(--ink); }

.card {
  position: absolute;
  width: 360px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  padding: 18px 20px;
  background: var(--bg);
  border: 1px solid #ffffff;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1.45;
}

.card[hidden] { display: none; }

.card__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.card h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 500;
  color: var(--violet);
}

.status {
  padding: 1px 7px;
  font-size: 12px;
  white-space: nowrap;
  border-radius: 3px;
  background: var(--stone);
}

.status--locked { background: var(--red); }
.status--done { background: var(--green); color: #062a20; }
.status--in_progress { background: var(--amber); color: #2b1a04; }
.status--closed { background: var(--stone); }

.card__meta { margin: 8px 0 10px; }
.card__xp { color: var(--green); }
.card__task { margin: 0; color: var(--ink); }

.card h3 {
  margin: 14px 0 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--dim);
}

.card ul,
.card ol {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 14px;
  color: var(--dim);
}

.card li + li { margin-top: 4px; }

.card__video {
  display: inline-block;
  margin-top: 12px;
  color: var(--violet);
  font-weight: 600;
  text-decoration: none;
}

.card__hint { margin: 6px 0 0; font-size: 12px; color: var(--dim); }
.card__badge { margin: 12px 0 0; color: var(--green); }
.card__badge.is-missing { color: var(--amber); }

.card__refs {
  margin-top: 14px;
  padding: 10px 12px;
  border-left: 2px solid var(--violet);
  background: rgba(124, 108, 255, 0.06);
  font-size: 14px;
}

.card__refs summary { cursor: pointer; color: var(--violet); font-weight: 600; }
.card__ref h4 { margin: 10px 0 2px; font-size: 13px; }
.card__slides b { color: var(--ink); font-weight: 600; }

.card__outputs { list-style: none; padding-left: 0; }
.card__outputs li { color: var(--amber); }
.card__outputs li.is-done { color: var(--green); }

/* Stored answers (step card, admin and jury pages) */
.answers { margin: 4px 0 0; }
.answers dt { margin-top: 6px; font-size: 12px; color: var(--dim); }
.answers dd { margin: 1px 0 0; white-space: pre-wrap; }
.answers a { color: var(--violet); }
.answers__empty { margin: 4px 0 0; font-size: 13px; color: var(--dim); }
.card__req { margin: 12px 0 0; }

.card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 14px;
}

.card__actions button {
  color: var(--violet);
  font-weight: 600;
}

.card__actions .quiet {
  color: var(--dim);
  font-weight: 400;
}

.card__pending { margin: 0; color: var(--amber); }
.card__error { margin: 12px 0 0; color: #e07a7a; }

.card__when {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--dim);
}

/* Login page */
.page-login,
.page-admin { overflow: auto; background-attachment: fixed; }

.page-login { background: linear-gradient(var(--bg) 0, var(--bg) 45%, #0f1a2e 100%); }

.login__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 32px;
}

.login__mark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.login__mark i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--green); }

.login__top nav { display: flex; gap: 22px; font-size: 14px; color: var(--dim); }
.login__top nav a { color: inherit; text-decoration: none; }
.login__top nav :hover { color: var(--ink); }

.login {
  position: relative;
  z-index: 1;
  padding: 9vh 16px 0;
  text-align: center;
}

.login h1 {
  margin: 0;
  font-size: clamp(38px, 5.6vw, 64px);
  font-weight: 500;
  letter-spacing: -0.01em;
}

.login__lead {
  max-width: 460px;
  margin: 12px auto 0;
  font-size: 18px;
  line-height: 1.45;
  color: #aab3c5;
}

.login__form {
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(640px, 100%);
  margin: 36px auto 0;
  padding: 6px;
  background: #0d1527;
  border: 1px solid #2f3850;
  border-radius: 999px;
}

.login__form label { flex: 1; min-width: 0; }

.login__form label span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.login__form input {
  width: 100%;
  padding: 11px 18px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 999px;
}

.login__form input::placeholder { color: #69738a; }
.login__form input:focus { outline: none; background: #131d33; }
.login__sep { width: 1px; height: 24px; background: #2f3850; }

.login__submit {
  flex: none;
  padding: 11px 24px;
  font-weight: 600;
  background: var(--violet);
  border-radius: 999px;
}

.login__submit:hover { background: #8f81ff; }
.login__submit:disabled { opacity: 0.5; }

.login__error {
  min-height: 1.4em;
  margin: 14px 0 0;
  font-size: 14px;
  color: #e07a7a;
}

.login__horizon { position: relative; flex: 1; min-height: 300px; margin-top: 26px; }
.login__horizon svg { position: absolute; inset: 0; width: 100%; height: 100%; }

.login__horizon::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(var(--bg), transparent 55%);
}

.login__note {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 22px;
  margin: 0;
  padding: 10px 18px;
  font-size: 13px;
  white-space: nowrap;
  color: var(--dim);
  background: #060a14;
  border-radius: 8px;
  transform: translateX(-50%);
}

@media (max-width: 640px) {
  .login__top { padding: 18px 16px; }
  .login__form { flex-direction: column; border-radius: 18px; }
  .login__form label, .login__submit { width: 100%; }
  .login__sep { display: none; }
  .login__note { width: calc(100% - 32px); white-space: normal; text-align: center; }
}

.admin input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--locked-line);
  border-radius: 6px;
}

.admin input:focus {
  outline: none;
  border-color: var(--violet);
}

.about a { color: var(--violet); }

/* Admin page */
.admin {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 60px;
  font-size: 14px;
}

.admin__head {
  display: flex;
  align-items: baseline;
}

.admin h1 { margin: 0; font-size: 28px; }
.admin h1 span { color: var(--dim); font-weight: 400; font-size: 16px; }
.admin h2 { margin: 40px 0 12px; font-size: 18px; font-weight: 500; color: var(--violet); }

.admin__note { color: var(--dim); max-width: 720px; line-height: 1.5; }
.admin code { padding: 1px 5px; border-radius: 3px; background: var(--stone); font-size: 13px; }
.admin__secret { font-size: 15px; }

.admin__add,
.admin__form-id { display: flex; gap: 10px; align-items: center; }
.admin__add { max-width: 520px; margin-bottom: 14px; }
.admin__add input,
.admin__form-id input { margin: 0; padding: 7px 10px; font-size: 14px; }

.admin button { color: var(--violet); font-weight: 600; white-space: nowrap; }
.admin button.danger { color: #e07a7a; }

.admin__credentials {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--green);
  border-radius: 6px;
}

.admin__credentials[hidden] { display: none; }
.admin__credentials p { margin: 0 0 8px; }
.admin__credentials button { margin-right: 14px; }

.admin__table {
  width: 100%;
  border-collapse: collapse;
}

.admin__table th {
  text-align: left;
  font-size: 12px;
  font-weight: 400;
  color: var(--dim);
}

.admin__table th,
.admin__table td {
  padding: 9px 10px 9px 0;
  border-bottom: 1px solid var(--stone);
  vertical-align: middle;
}

.admin__table tr.is-disabled td { color: var(--dim); }
.admin__actions { display: flex; flex-wrap: wrap; gap: 14px; justify-content: flex-end; }
.admin__links { display: flex; gap: 14px; white-space: nowrap; }
.admin__links a { color: var(--dim); }
.admin__links a:hover { color: var(--ink); }
.admin__empty { color: var(--dim); }
.admin__muted { color: var(--dim); }

.admin__detail td { padding: 4px 0 18px; }
.admin__badges { margin-top: 2px; font-size: 12px; color: var(--green); }
.admin__list { margin: 0; padding: 0; list-style: none; }
.admin__list li { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px solid var(--stone); }

/* A team's file: module cards (admin and jury pages) */
.file__module { margin: 12px 0 18px; padding: 12px 16px; border-left: 2px solid var(--violet); background: rgba(124, 108, 255, 0.05); }
.file__module header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.file__module h3 { margin: 0; font-size: 16px; font-weight: 600; }
.file__status { font-size: 12px; color: var(--amber); }
.file__status.is-done { color: var(--green); }
.file__step h4 { margin: 12px 0 0; font-size: 14px; color: var(--violet); }
.answers__link { font-size: 12px; font-weight: 400; color: var(--dim); }

/* Jury page */
.jury__layout { display: grid; grid-template-columns: 240px 1fr; gap: 32px; margin-top: 20px; }
.jury__teams li { align-items: baseline; font-size: 13px; }
.jury__teams button { color: var(--ink); font-weight: 600; text-align: left; }
.jury__teams li.is-selected button { color: var(--violet); }
.jury__file h2 { margin: 0; color: var(--ink); }
.jury__title { margin: 4px 0 0; font-size: 18px; color: var(--violet); }
.jury__file a { color: var(--violet); }

@media (max-width: 760px) {
  .jury__layout { grid-template-columns: 1fr; }
}

.admin__tag { font-size: 12px; color: var(--amber); }

.admin__section-head { display: flex; align-items: baseline; gap: 24px; }
.admin__filters { display: flex; gap: 14px; }
.admin__filters button { color: var(--dim); font-weight: 400; }
.admin__filters button.is-active { color: var(--violet); font-weight: 600; }
.admin__events { font-size: 13px; }
.admin__events td:first-child { white-space: nowrap; color: var(--dim); }
.admin__table tr.is-warn td { color: var(--amber); }
.admin__button { color: var(--violet); font-weight: 600; text-decoration: none; }
.admin__warn { color: var(--amber); }
.admin__ok { color: var(--green); }

@media (max-width: 760px) {
  .admin__table thead { display: none; }
  .admin__table tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--stone); }
  .admin__table td { display: block; padding: 3px 0; border: 0; }
  .admin__actions { justify-content: flex-start; }
}

/* Event info dialog */
.about {
  max-width: 560px;
  max-height: calc(100% - 40px);
  padding: 26px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid #ffffff;
  border-radius: 6px;
  font-family: var(--font);
  line-height: 1.45;
}

.about::backdrop { background: rgba(0, 0, 0, 0.6); }
.about h2 { margin: 0; color: var(--violet); font-weight: 500; }
.about .tagline { margin: 2px 0 6px; }
.about dt { margin-top: 12px; font-size: 13px; color: var(--dim); }
.about dd { margin: 2px 0 0; }
/* Close button stays in the top-right corner while the dialog scrolls. */
.about form { position: sticky; top: 0; float: right; margin: -16px -14px 0 8px; }
.about form button { font-size: 22px; line-height: 1; color: var(--violet); }

@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; padding: 16px 16px 0; }
  .level { font-size: 34px; }
  /* Badges: one per module, lit when earned. */
.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 9px;
  font-size: 12px;
  color: #4a5367;
  cursor: help;
}

.badge.is-earned { color: var(--green); }

.links { order: -1; width: 100%; justify-content: flex-end; }

  #graph { display: none; }
  .steps { display: block; height: 100%; overflow-y: auto; padding: 0 16px 40vh; }

  .card {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-height: 70vh;
    overflow-y: auto;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.6);
  }
}
