*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body { background: #c07038; overflow: hidden; font-family: 'Trebuchet MS', sans-serif; }
canvas { display: block; }

.back-home {
  position: fixed;
  left: 18px;
  bottom: 14px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(50, 22, 5, 0.82);
  border: 1px solid rgba(255, 210, 130, 0.28);
  color: #f5e5c8;
  text-decoration: none;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
  user-select: none;
}
.back-home:hover { border-color: rgba(255,190,60,0.60); background: rgba(50, 22, 5, 0.90); }

#ui {
  position: fixed; top: 18px; left: 18px;
  background: rgba(50, 22, 5, 0.82);
  border: 1px solid rgba(255, 210, 130, 0.28);
  border-radius: 8px;
  padding: 15px 17px;
  color: #f5e5c8;
  min-width: 272px;
  backdrop-filter: blur(8px);
  user-select: none;
  max-height: calc(100vh - 36px);
  overflow: auto;
}

#ui h2 {
  font-size: 10px; color: #ffc870;
  text-transform: uppercase; letter-spacing: 2.5px;
  margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,190,80,0.20);
}

.micro { font-size: 10px; color: #b08040; text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 3px; }
#phase-name { font-size: 12px; font-weight: bold; color: #fff3dc; margin-bottom: 14px; min-height: 18px; }

.cg { margin-bottom: 12px; }
.cg label { display:flex; justify-content:space-between; font-size:10px; color:#907040;
            text-transform:uppercase; letter-spacing:1px; margin-bottom:5px; }
.cg label span { color:#ffc870; }

input[type="range"] {
  width: 100%; -webkit-appearance: none;
  height: 3px; border-radius: 2px;
  background: rgba(255,190,80,0.18); outline:none; cursor:pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width:12px; height:12px;
  border-radius:50%; background:#ffcc60; cursor:pointer;
  box-shadow: 0 0 5px rgba(255,190,60,0.70);
}

/* 6-segment phase track */
.pt { display:flex; gap:2px; margin-top:5px; }
.ps { height:3px; border-radius:2px; flex:1; background:rgba(255,190,80,0.14); overflow:hidden; }
.pf { height:100%; border-radius:2px; width:0%; }
/* colours match JSON stages */
.ps:nth-child(1) .pf { background:#f0ebb0; }   /* initiation   — cream  */
.ps:nth-child(2) .pf { background:#8844cc; }   /* replication  — purple */
.ps:nth-child(3) .pf { background:#5599ff; }   /* elongation   — blue   */
.ps:nth-child(4) .pf { background:#33aacc; }   /* FtsZ ring    — teal   */
.ps:nth-child(5) .pf { background:#33aacc; }   /* septum       — teal   */
.ps:nth-child(6) .pf { background:#dd3333; }   /* cytokinesis  — red    */

.btns { display:flex; gap:8px; margin-top:13px; }
button {
  flex:1; padding:7px 0;
  background:rgba(255,190,60,0.10);
  border:1px solid rgba(255,190,60,0.30);
  color:#ffc870; border-radius:4px; cursor:pointer;
  font-family:inherit; font-size:11px;
  text-transform:uppercase; letter-spacing:1px;
  transition:background 0.14s, border-color 0.14s;
}
button:hover  { background:rgba(255,190,60,0.22); border-color:rgba(255,190,60,0.60); }
button.active { background:rgba(255,190,60,0.30); color:#fff; border-color:rgba(255,190,60,0.90); }

.legend {
  margin-top:13px; padding-top:10px;
  border-top:1px solid rgba(255,190,60,0.15);
  display:grid; grid-template-columns:1fr 1fr; gap:5px 10px;
}
.li  { display:flex; align-items:center; gap:6px; font-size:10px; color:#906838; }
.ld  { width:9px; height:9px; border-radius:50%; flex-shrink:0; }
.lr  { width:10px; height:10px; border-radius:50%; flex-shrink:0; border:2px solid; background:transparent; }

/* Stage reference list */
#stages {
  position: fixed; top: 18px; right: 18px;
  background: rgba(50,22,5,0.75);
  border: 1px solid rgba(255,210,130,0.22);
  border-radius: 8px;
  padding: 13px 15px;
  color: #d4b880;
  font-size: 10px;
  min-width: 200px;
  backdrop-filter: blur(8px);
  line-height: 1.7;
  max-height: calc(100vh - 36px);
  overflow: auto;
}

@media (max-width: 980px) {
  body { overflow: hidden; }

  #ui {
    left: 10px;
    right: 10px;
    top: 10px;
    min-width: 0;
    width: auto;
    border-radius: 12px;
  }

  #stages {
    left: 10px;
    right: 10px;
    top: auto;
    bottom: 62px; /* deixa espaço para Catálogo + dica */
    min-width: 0;
    width: auto;
    border-radius: 12px;
    font-size: 11px;
  }

  #info {
    left: 10px;
    bottom: 10px;
    font-size: 9px;
    max-width: 70vw;
  }

  .back-home {
    left: 10px;
    bottom: 10px;
  }
}
#stages h3 { font-size:10px; color:#ffc870; text-transform:uppercase;
              letter-spacing:2px; margin-bottom:9px; }
#stages li { list-style:none; padding:2px 0; border-bottom:1px solid rgba(255,190,60,0.10); }
#stages li:last-child { border-bottom:none; }
#stages .sn { color:#ffc870; font-weight:bold; margin-right:5px; }

#info { position:fixed; bottom:14px; left:18px;
         font-size:9px; color:rgba(130,70,20,0.50);
         letter-spacing:1.5px; text-transform:uppercase; }

