:root {
  --bg: #0b0e13;
  --panel: #12161d;
  --line: #232a35;
  --text: #e8edf5;
  --dim: #7f8b9c;
  --red: #ff4d5a;
  --green: #3ddc84;
  --acc: #3f8cff;
  --acc-2: #2b6ce0;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  padding: 9px 14px;
  transition: border-color .15s, background .15s, opacity .15s;
}

button:hover { border-color: #3a4454; }
button:active { opacity: .8; }

button.primary {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--acc), var(--acc-2));
  color: #fff;
  letter-spacing: 1px;
}

button.primary:disabled { opacity: .45; cursor: default; }

button.ghost {
  padding: 6px 11px;
  font-size: 12px;
  color: var(--dim);
  background: transparent;
}

button.ghost:hover { color: var(--text); }

/* ---------- 第一屏 ---------- */

.screen-enter { overflow: hidden; }

.enter {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(63,140,255,.13), transparent 70%),
    radial-gradient(800px 500px at 50% 110%, rgba(255,77,90,.08), transparent 70%),
    var(--bg);
}

.enter .card {
  width: 100%;
  max-width: 360px;
  padding: 30px 26px 26px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
  text-align: center;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .5px;
  color: var(--acc);
}

.tip {
  margin: 14px 0 20px;
  font-size: 13px;
  color: var(--dim);
}

.code {
  width: 100%;
  padding: 16px 10px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0d1117;
  color: var(--text);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 12px;
  text-indent: 12px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.code::placeholder { color: #3a4454; letter-spacing: 12px; }
.code:focus { border-color: var(--acc); box-shadow: 0 0 0 3px rgba(63,140,255,.16); }

.msg {
  min-height: 18px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--red);
}

.foot {
  position: absolute;
  bottom: 22px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  color: #566171;
}

/* ---------- 第二屏 ---------- */

.view {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #05070a;
}

.hud {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(11,14,19,.94), rgba(11,14,19,.45));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,.04);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,.05);
  font-size: 12px;
  color: var(--dim);
  white-space: nowrap;
}

.chip b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.chip.live { background: rgba(61,220,132,.10); }
.grow { flex: 1; }

.mapsel {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 0 14px 0 0;
  outline: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'><path d='M0 2l4 4 4-4' fill='none' stroke='%237f8b9c' stroke-width='1.4'/></svg>");
  background-repeat: no-repeat;
  background-position: right center;
}

.mapsel option { background: #12161d; color: var(--text); }

.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #55606f;
  display: inline-block;
}

.dot.on  { background: var(--green); box-shadow: 0 0 7px rgba(61,220,132,.75); }
.dot.err { background: var(--red); box-shadow: 0 0 7px rgba(255,77,90,.7); }
.dot.wait { background: #e3b341; }

.stage {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 8px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}

.stage canvas {
  display: block;
  border-radius: 10px;
  background: #0a0d12;
  box-shadow: 0 0 0 1px rgba(255,255,255,.05), 0 20px 60px rgba(0,0,0,.5);
}

.flash {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  background: rgba(5,7,10,.72);
  text-align: center;
  padding: 24px;
}

.flash.show { display: flex; }
.flash span { color: var(--dim); font-size: 12px; }

/* ---------- 移动端 ---------- */

@media (max-width: 560px) {
  .hud { gap: 6px; padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top)); }
  .chip { font-size: 11px; padding: 3px 8px; }
  .hud .ghost { padding: 5px 8px; }
  .stage { padding: 0; }
  .stage canvas { border-radius: 0; box-shadow: none; }
}

@media (max-height: 480px) and (orientation: landscape) {
  .hud { padding: 6px 10px; padding-top: calc(6px + env(safe-area-inset-top)); }
  .stage { padding: 4px; }
}
