:root {
  --ink:#263039;
  --muted:#68757d;
  --line:#40515b;
  --blue:#4c88ad;
  --green:#3d9661;
  --red:#c9554d;
}

*{box-sizing:border-box}
[hidden]{display:none!important}

body{
  margin:0;
  min-height:100vh;
  color:var(--ink);
  font-family:Arial,Helvetica,sans-serif;
  background:#edf1f2;
}

.app{
  width:min(1180px,calc(100vw - 24px));
  height:calc(100vh - 24px);
  min-height:620px;
  margin:12px auto;
  display:grid;
  grid-template-rows:58px 54px 1fr 72px;
  background:#fff;
  border:1px solid #d8dfe2;
  border-radius:14px;
  box-shadow:0 12px 36px rgba(45,56,62,.12);
  overflow:hidden;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 18px;
  border-bottom:1px solid #e5eaec;
}
.stepper{width:180px;display:flex;align-items:center}
.step{
  width:34px;height:34px;flex:0 0 34px;
  display:grid;place-items:center;
  border:2px solid #abb6bb;border-radius:50%;
  color:#728087;background:#fff;font-weight:700;
}
.step.active{border-color:var(--ink);background:var(--ink);color:#fff}
.step.done{border-color:var(--green);background:var(--green);color:#fff}
.step-line{flex:1;height:2px;background:#bcc6ca}
.reset-button{
  width:38px;height:38px;border:1px solid #d8e0e3;
  border-radius:50%;background:#fff;color:var(--ink);
  font-size:22px;cursor:pointer;
}

.instruction-bar{
  display:flex;align-items:center;gap:10px;
  padding:8px 22px;background:#edf4f6;
  border-bottom:1px solid #dfe8ea;
  color:#4a5b64;font-size:14px;
}
.instruction-bar strong{color:var(--ink)}

.content{
  min-height:0;
  display:grid;
  grid-template-columns:minmax(0,1fr) 190px;
  border-bottom:1px solid #e5eaec;
}
.diagram{
  min-width:0;
  display:grid;
  grid-template-rows:190px 180px 190px;
  padding:4px 14px 4px 20px;
}
.phase{
  min-width:0;
  display:grid;
  grid-template-columns:145px 1fr;
  align-items:center;
  border-bottom:1px solid #edf0f2;
}
.phase:last-child{border-bottom:0}
.phase-heading{
  display:flex;align-items:flex-start;gap:8px;
  align-self:start;margin-top:12px;
}
.phase-number{
  width:34px;height:34px;flex:0 0 34px;
  display:grid;place-items:center;border-radius:50%;
  background:var(--ink);color:#fff;font-weight:700;
}
.phase-heading strong{display:block;font-size:14px}
.phase-heading small{display:block;margin-top:3px;color:var(--muted);font-size:11px}

.replication-flow{
  height:182px;
  display:grid;
  grid-template-rows:76px 30px 76px;
  justify-items:center;
  align-items:center;
}
.replication-arrow {
  display:none;
}
.mother-cell,.daughter-cell,.gamete-cell{
  position:relative;
  border:3px solid var(--line);
  border-radius:50%;
  background:#fff;
  display:grid;
  place-items:center;
}
.mother-cell{width:520px;height:76px}
.simple-mother{background:#fffaf7}
.replicated-mother{background:#f8fbfc}
.cell-label{
  position:absolute;left:50%;bottom:-12px;transform:translateX(-50%);
  z-index:3;white-space:nowrap;padding:3px 9px;
  border:1px solid #ccd5d8;border-radius:12px;
  background:#fff;color:#5d6970;font-size:11px;font-weight:700;
  pointer-events:none;
}
.vertical-arrow{color:#73858d;font-size:26px;line-height:30px}
.cell-content{
  width:100%;height:100%;
  display:flex;align-items:center;justify-content:center;
  gap:5px;padding:8px 18px;border-radius:inherit;
}

.daughter-row{
  width:620px;height:132px;
  display:grid;grid-template-columns:1fr 1fr;gap:0;
  align-items:center;
  position:relative;
}
.daughter-cell{justify-self:center}
.division-flow,.gamete-flow{
  height:172px;
  display:grid;
  grid-template-rows:28px 132px;
  align-items:center;
  justify-items:center;
}
.division-arrows,.gamete-arrows{
  width:620px;height:28px;
  display:grid;
  grid-template-columns:1fr 1fr;
  align-items:center;
  color:#73858d;
  font-size:24px;
  line-height:28px;
  text-align:center;
  pointer-events:none;
}
.gamete-arrows{
  grid-template-columns:repeat(4,1fr);
  width:620px;
}
.daughter-cell{width:250px;height:132px}
.gamete-row{
  width:620px;height:132px;
  display:grid;grid-template-columns:repeat(4,1fr);gap:20px;
  align-items:center;margin:auto;
}
.gamete-cell{width:138px;height:132px}
.drop-zone{overflow:hidden}

.chromosome-column{
  border-left:1px solid #e2e7e9;
  background:#f8fafb;
  padding:14px 12px;
  display:grid;
  grid-template-rows:34px 1fr;
}
.palette-title{
  height:30px;display:flex;align-items:center;justify-content:center;
  border-radius:15px;background:#edf2f4;
  color:#52616a;font-size:12px;font-weight:700;
}
.palette{
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:8px;min-height:0;
}

.chromosome{
  height:112px;max-width:82px;object-fit:contain;
  cursor:grab;user-select:none;
  filter:drop-shadow(0 2px 2px rgba(0,0,0,.12));
  transition:transform .12s ease;
}
.chromosome.simple{height:112px;max-width:52px}
.palette .chromosome{height:92px;max-width:68px}
.mother-cell .chromosome,.daughter-cell .chromosome{height:58px;max-width:42px}
.gamete-cell .chromosome{height:88px;max-width:38px}
.chromosome:hover{transform:translateY(-2px)}
.chromosome.selected{outline:4px solid var(--blue);outline-offset:2px;border-radius:8px}
.mother-cell.drag-over,.daughter-cell.drag-over,.gamete-cell.drag-over{background:#edf6fa}
.daughter-cell.correct,.gamete-cell.correct{border-color:var(--green)}
.daughter-cell.wrong,.gamete-cell.wrong{border-color:var(--red)}

.footer{
  display:flex;align-items:center;justify-content:flex-end;gap:10px;
  padding:0 18px;background:#fff;
}
.feedback{margin-right:auto;min-height:24px;font-weight:700}
.feedback.success{color:var(--green)}
.feedback.error{color:var(--red)}
.primary-button,.secondary-button{
  height:46px;border-radius:23px;padding:0 16px;
  font-size:15px;font-weight:700;cursor:pointer;
}
.primary-button{min-width:165px;border:0;background:var(--ink);color:#fff}
.secondary-button{border:1px solid #bcc7cc;background:#fff;color:var(--ink)}
.primary-button:disabled{background:#adb7bc;cursor:not-allowed}

#mobile-dialog{
  width:min(360px,calc(100vw - 32px));
  border:1px solid #ccd5d8;border-radius:14px;
  padding:0;color:var(--ink);
  box-shadow:0 18px 50px rgba(38,48,57,.25);
}
.dialog-head{height:48px;display:flex;align-items:center;justify-content:space-between;padding:0 14px;border-bottom:1px solid #e5eaec}
.dialog-close{width:34px;height:34px;border:0;border-radius:50%;background:#edf2f4;font-size:22px}
.dialog-options{display:grid;grid-template-columns:repeat(4,1fr);gap:6px;padding:12px}
.dialog-option{height:120px;border:1px solid #dbe3e6;border-radius:10px;background:#fff;display:grid;place-items:center}
.dialog-option img{height:88px;max-width:52px}

@media (max-width:800px){
  body{overflow-x:hidden}
  .app{
    width:100%;height:auto;min-height:100vh;margin:0;border-radius:0;
    grid-template-rows:58px 66px auto 72px;
  }
  .instruction-bar{font-size:12px;padding:7px 10px}
  .content{display:grid;grid-template-columns:minmax(0,1fr) 86px}
  .diagram{grid-template-rows:220px 190px 210px;padding:4px 4px 4px 8px}
  .phase{grid-template-columns:1fr}
  .phase-heading{position:absolute;z-index:5;margin:4px 0 0 4px}
  .phase{position:relative;padding-top:42px}
  .replication-flow{height:174px;grid-template-rows:66px 24px 66px}
  .mother-cell{width:min(260px,70vw);height:66px}
  .cell-label{font-size:9px;bottom:-10px;padding:2px 5px}
  .mother-cell .chromosome{height:48px;max-width:30px}
  .division-flow{height:148px}
  .division-arrows,
  .gamete-arrows{
    width:min(280px,74vw);
  }
  .daughter-row{width:min(280px,70vw);height:108px;gap:12px}
  .daughter-cell{width:134px;height:108px}
  .daughter-cell .chromosome{height:72px;max-width:34px}
  .gamete-flow{height:168px}
  .gamete-row{width:min(300px,74vw);height:132px;gap:4px}
  .gamete-cell{width:72px;height:132px}
  .gamete-cell .chromosome{height:72px;max-width:28px}
  .chromosome-column{padding:8px 4px;grid-template-rows:30px 1fr}
  .palette{gap:4px}
  .palette .chromosome{height:64px;max-width:46px}
  .palette-title{font-size:10px}
  .footer{padding:0 8px}
  .feedback{max-width:150px;font-size:12px}
  .primary-button{min-width:145px;font-size:13px;padding:0 10px}
  .secondary-button{max-width:125px;font-size:12px}
}
