/* 基因组装大师 —— 样式（暗色实验室主题） */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, #16233f 0%, #0b1220 55%, #090e18 100%);
  color: #dbe4f3;
  min-height: 100vh;
  touch-action: manipulation;
}

/* ---------- 顶栏 ---------- */
#hud {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 16px;
  background: rgba(10, 16, 28, .82);
  border-bottom: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(8px);
}
.hud-left { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 30px; line-height: 1; }
.hud-title .title { font-weight: 700; font-size: 17px; letter-spacing: 1px; }
.hud-title .subtitle { font-size: 12px; color: #8ea3c8; }
.hud-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stat {
  display: flex; flex-direction: column; align-items: center;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.09);
  border-radius: 10px; padding: 3px 12px; min-width: 62px;
}
.stat .k { font-size: 10px; color: #8ea3c8; }
.stat .v { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hud-btns { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.05); color: #dbe4f3; font-size: 16px; cursor: pointer;
  transition: background .15s, transform .1s;
}
.icon-btn:hover { background: rgba(255,255,255,.13); }
.icon-btn:active { transform: scale(.93); }

/* ---------- 主区 ---------- */
main { padding: 14px 16px 26px; max-width: 1200px; margin: 0 auto; }
.panel {
  background: rgba(255,255,255,.035);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.panel-label { font-size: 13px; font-weight: 600; color: #a9bcdf; margin-bottom: 8px; }
.panel-label .tip { font-weight: 400; color: #7187ab; font-size: 11.5px; margin-left: 8px; }

#assembly { min-height: 130px; max-height: 46vh; overflow: auto; }
.chain {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 8px 2px 10px;
}
.chain.empty { justify-content: center; padding: 22px 0; }
.chain.empty .zone { min-width: 260px; min-height: 72px; }

/* 拼接区两端的放置框 */
.zone {
  min-width: 64px; min-height: 58px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 2px dashed #4d6491; border-radius: 12px;
  color: #8fa6cf; font-size: 12px; text-align: center; padding: 4px 8px;
  transition: border-color .12s, background .12s, transform .12s;
  background: rgba(77,100,145,.06);
}
.zone .zicon { font-size: 17px; }
.zone.hover { border-color: #7aa7ff; border-style: solid; background: rgba(122,167,255,.16); transform: scale(1.07); color: #cfe0ff; }
.zone.shake { animation: zonshake .38s; }
@keyframes zonshake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-6px)} 40%{transform:translateX(6px)} 60%{transform:translateX(-4px)} 80%{transform:translateX(4px)} }
.zone.flash { animation: zoneflash 1.2s ease; }
@keyframes zoneflash { 0%,100%{box-shadow:none} 30%,70%{box-shadow:0 0 0 4px rgba(250,204,21,.45)} }

/* read 卡片 / contig 片段 */
.chip, .card {
  background: #f6f8fc; border-radius: 11px; padding: 6px 7px 4px;
  border: 1px solid #d7dfeb;
  box-shadow: 0 2px 8px rgba(0,0,0,.38);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.chip.new { animation: chipPop .34s cubic-bezier(.2,1.6,.4,1); }
@keyframes chipPop { 0% { transform: scale(.55); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.bases { display: flex; gap: 1px; }
.b {
  display: inline-block; width: 1.28em; text-align: center;
  font: 700 13px/1.65 ui-monospace, Consolas, "Courier New", monospace;
  border-radius: 3.5px;
}
.b-A { background: #d7f5e6; color: #0d7a4a; }
.b-T { background: #fbdfdf; color: #b23a44; }
.b-C { background: #dce8fb; color: #2a67c2; }
.b-G { background: #faeed2; color: #ad7412; }
/* 重叠（共享）碱基高亮 */
.b.sh { background: #fde68a; color: #8a6100; box-shadow: inset 0 0 0 1.5px #f2c108; }
.ctag {
  font-size: 10px; color: #64748b; text-align: center; margin-top: 4px;
  font-family: ui-monospace, Consolas, monospace; white-space: nowrap;
}

/* 手牌 */
#tray-wrap { }
#tray { display: flex; flex-wrap: wrap; gap: 9px; align-content: flex-start; min-height: 96px; max-height: 34vh; overflow: auto; padding: 2px; }
.card { cursor: grab; transition: transform .12s, box-shadow .12s; touch-action: none; }
.card:hover { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0,0,0,.45); }
.card:active { cursor: grabbing; }
.card.drag-src { opacity: .28; transform: scale(.96); }
.card.hint-flash { animation: cardflash 1.5s ease; }
@keyframes cardflash {
  0%,100% { box-shadow: 0 2px 8px rgba(0,0,0,.38); }
  20%,60% { box-shadow: 0 0 0 4px rgba(250,204,21,.55), 0 6px 18px rgba(250,204,21,.35); }
  40%,80% { box-shadow: 0 2px 8px rgba(0,0,0,.38); }
}
.tray-empty { color: #7fd3a0; font-size: 15px; padding: 20px 8px; width: 100%; text-align: center; }

/* 拖拽幽灵 */
.ghost {
  position: fixed; left: 0; top: 0; margin: 0; z-index: 999;
  pointer-events: none; opacity: .95;
  box-shadow: 0 14px 34px rgba(0,0,0,.55);
  transform-origin: center;
}
.ghost.returning { transition: transform .22s ease, opacity .22s ease; opacity: 0 !important; }
.ghost.dropping { transition: transform .16s ease, opacity .16s ease; opacity: 0 !important; transform: var(--drop-tf) scale(.6) !important; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 24px);
  opacity: 0; transition: opacity .22s, transform .22s;
  background: rgba(13,20,35,.96); border: 1px solid #33415c; color: #e4ebf8;
  padding: 10px 18px; border-radius: 99px; z-index: 60; pointer-events: none;
  max-width: min(92vw, 560px); text-align: center; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.ok { border-color: #2f9e63; }
#toast.err { border-color: #c64d4d; }
#toast.info { border-color: #4d6ec6; }

/* ---------- 弹窗 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(4,8,18,.72); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.overlay.hidden { display: none; }
.dialog {
  background: linear-gradient(180deg, #131e33, #0e1626);
  border: 1px solid rgba(255,255,255,.12); border-radius: 18px;
  max-width: 660px; width: 100%; max-height: 88vh; overflow: auto;
  padding: 26px 26px 22px; text-align: center;
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
  animation: dlgIn .28s cubic-bezier(.2,1.2,.4,1);
}
@keyframes dlgIn { from { transform: translateY(18px) scale(.97); opacity: 0; } }
.dialog h1 { margin: 4px 0 10px; font-size: 24px; }
.dialog h3 { text-align: left; color: #9fc3ff; margin: 16px 0 6px; font-size: 15px; }
.dialog p, .dialog li { color: #c3d0e8; font-size: 14px; line-height: 1.75; text-align: left; }
.dialog .lead { text-align: center; }
.big-logo { font-size: 52px; line-height: 1; }
.rules { list-style: none; padding: 0; margin: 10px auto 16px; max-width: 430px; }
.rules li { margin: 6px 0; }
.foot { color: #6d81a5 !important; font-size: 12px !important; text-align: center !important; margin-top: 14px; }

.btn {
  background: #22304d; color: #dbe6fa; border: 1px solid rgba(255,255,255,.14);
  border-radius: 11px; padding: 10px 18px; font-size: 14.5px; cursor: pointer;
  transition: filter .15s, transform .1s;
}
.btn:hover { filter: brightness(1.2); }
.btn:active { transform: scale(.96); }
.btn.primary { background: #2b5fd9; border-color: #4d7bf0; color: #fff; }
.btn.big { font-size: 17px; padding: 13px 34px; border-radius: 13px; }
.btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

.level-select { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.level-select button {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.14); color: #c9d7ef;
  border-radius: 10px; padding: 7px 11px; font-size: 12.5px; cursor: pointer;
}
.level-select button:hover { background: rgba(255,255,255,.14); }

.genome-box { text-align: left; margin-top: 14px; }
.genome-box .panel-label { margin-bottom: 5px; }
.genome {
  font-family: ui-monospace, Consolas, monospace; font-weight: 700; font-size: 14px;
  letter-spacing: 1.5px; word-break: break-all; line-height: 1.9;
  background: #0a101d; border: 1px solid rgba(255,255,255,.08); border-radius: 10px;
  padding: 10px 12px; text-align: left;
}
.win-stats { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.win-stats .stat { min-width: 76px; padding: 6px 12px; }

/* ---------- 窄屏 ---------- */
@media (max-width: 640px) {
  #hud { gap: 8px; padding: 8px 10px; }
  .hud-title .title { font-size: 15px; }
  .stat { min-width: 52px; padding: 2px 8px; }
  .stat .v { font-size: 13px; }
  .icon-btn { width: 32px; height: 32px; font-size: 14px; }
  .hud-btns { margin-left: 0; }
  main { padding: 10px 8px 20px; }
  .b { font-size: 11.5px; }
  #tray { max-height: 30vh; }
  #toast { bottom: 72px; font-size: 13px; }
}
