/* ==========================================================
     基础重置与全局变量
     ========================================================== */
  * { margin: 0; padding: 0; box-sizing: border-box; }

  :root {
    --c-cyan:   #5eead4;
    --c-blue:   #7dd3fc;
    --c-gold:   #fde68a;
    --c-red:    #f87171;
    --hud-bg:     rgba(14, 24, 40, .55);
    --hud-border: rgba(125, 211, 252, .22);
  }

  html, body { width: 100%; height: 100%; overflow: hidden; background: #05080e; }

  body {
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
    color: #e6f1ff;
    cursor: none;                     /* 隐藏系统鼠标指针，改用 Canvas 绘制的狙击镜 */
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  #app { position: fixed; inset: 0; }

  #game {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    display: block;
    cursor: none;
  }

  /* 屏幕上叠加扫描线 + 暗角，营造“战术目镜”质感 */
  #app::after {
    content: "";
    position: absolute; inset: 0;
    pointer-events: none;
    z-index: 5;
    background:
      repeating-linear-gradient(0deg, rgba(255,255,255,.022) 0 1px, transparent 1px 3px),
      radial-gradient(125% 95% at 50% 50%, transparent 52%, rgba(0,0,0,.5) 100%);
  }

  /* ==========================================================
     顶部 HUD
     ========================================================== */
  #hud {
    position: absolute; top: 0; left: 0; right: 0;
    z-index: 10;
    display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
    padding: 14px 18px;
    pointer-events: none;
    opacity: 0; transform: translateY(-16px);
    transition: opacity .4s ease, transform .4s ease;
  }
  #hud.show { opacity: 1; transform: translateY(0); }

  .hud-item {
    display: flex; flex-direction: column; gap: 2px;
    padding: 8px 16px; min-width: 108px;
    background: var(--hud-bg);
    border: 1px solid var(--hud-border);
    border-radius: 14px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 26px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.06);
  }
  .hud-label {
    font-size: 11px; letter-spacing: .16em; color: #8fb4d9;
  }
  .hud-value {
    font-size: 26px; font-weight: 800; line-height: 1.1;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 18px rgba(125,211,252,.35);
  }
  .hud-value.pop { animation: pop .3s cubic-bezier(.34,1.56,.64,1); }
  @keyframes pop {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.28); color: #fff; }
    100% { transform: scale(1); }
  }

  .timer-box { min-width: 190px; }
  .time-bar {
    margin-top: 6px; height: 5px; width: 100%;
    background: rgba(255,255,255,.12);
    border-radius: 99px; overflow: hidden;
  }
  .time-bar-fill {
    height: 100%; width: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, #34d399, #5eead4 45%, #7dd3fc);
    box-shadow: 0 0 12px rgba(94,234,212,.7);
    transition: background .3s linear;
  }
  .timer-box.danger .hud-value { color: #ff8080; animation: dangerBlink .6s steps(2,end) infinite; }
  .timer-box.danger .time-bar-fill { background: linear-gradient(90deg, #f87171, #ef4444); box-shadow: 0 0 14px rgba(248,113,113,.9); }
  @keyframes dangerBlink { 50% { opacity: .35; } }

  .icon-btn {
    pointer-events: auto;
    cursor: none;
    margin-left: auto;
    width: 46px; height: 46px;
    font-size: 20px;
    color: #dceaff;
    background: var(--hud-bg);
    border: 1px solid var(--hud-border);
    border-radius: 14px;
    backdrop-filter: blur(10px);
    transition: transform .18s ease, background .18s ease;
  }
  .icon-btn:hover { transform: translateY(-2px); background: rgba(30,52,84,.7); }
  .icon-btn.off { opacity: .45; }

  /* ==========================================================
     覆盖层（开始 / 结算）
     ========================================================== */
  .overlay {
    position: absolute; inset: 0;
    z-index: 20;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    background: radial-gradient(90% 80% at 50% 40%, rgba(10,20,36,.78), rgba(3,6,12,.94));
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: fadeIn .38s ease both;
  }
  .overlay.hidden { display: none; }
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

  .panel {
    position: relative;
    width: min(760px, 100%);
    max-height: 100%;
    overflow-y: auto;
    padding: 38px 40px 34px;
    text-align: center;
    border-radius: 26px;
    background: linear-gradient(160deg, rgba(23,38,62,.92), rgba(9,15,26,.95));
    border: 1px solid rgba(125,211,252,.24);
    box-shadow: 0 30px 90px rgba(0,0,0,.65), inset 0 1px 0 rgba(255,255,255,.07);
    animation: panelIn .5s cubic-bezier(.2,.9,.25,1) both;
  }
  @keyframes panelIn {
    from { opacity: 0; transform: translateY(26px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
  }

  /* 面板顶部的装饰光带 */
  .panel::before {
    content: "";
    position: absolute; left: 12%; right: 12%; top: -1px; height: 2px;
    background: linear-gradient(90deg, transparent, var(--c-cyan), var(--c-blue), transparent);
    filter: blur(.4px);
    opacity: .85;
    animation: sweep 3.4s ease-in-out infinite;
  }
  @keyframes sweep {
    0%, 100% { opacity: .35; transform: scaleX(.7); }
    50%      { opacity: 1;   transform: scaleX(1); }
  }

  .title {
    font-size: clamp(28px, 5.4vw, 50px);
    font-weight: 900;
    letter-spacing: .12em;
    background: linear-gradient(92deg, #bae6fd, #ffffff 40%, #5eead4 80%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 22px rgba(94,234,212,.35));
  }
  .subtitle {
    margin-top: 10px;
    font-size: clamp(12px, 1.9vw, 15px);
    letter-spacing: .32em;
    color: #7fa6cc;
    text-transform: uppercase;
  }

  .rules {
    margin: 26px auto 0;
    max-width: 560px;
    list-style: none;
    text-align: left;
    display: grid; gap: 10px;
  }
  .rules li {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 11px 14px;
    font-size: 14px; line-height: 1.55;
    color: #cfe3f7;
    background: rgba(125,211,252,.06);
    border: 1px solid rgba(125,211,252,.14);
    border-radius: 12px;
  }
  .rules li b { color: #fff; }
  .dot {
    flex: none; width: 9px; height: 9px; margin-top: 6px;
    border-radius: 50%;
    box-shadow: 0 0 10px currentColor;
    background: currentColor;
  }
  .dot.normal   { color: #ff8f5a; }
  .dot.advanced { color: #c084fc; }
  .dot.time     { color: #5eead4; }

  /* 目标图例 */
  .legend {
    margin: 22px auto 0;
    display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  }
  .legend-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 14px; font-size: 13px;
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 999px;
    color: #dceaff;
  }
  .legend-item .k { font-weight: 800; font-variant-numeric: tabular-nums; }

  /* 按钮 */
  .btn {
    margin-top: 30px;
    padding: 15px 54px;
    font-size: 17px; font-weight: 800; letter-spacing: .16em;
    font-family: inherit;
    color: #04202a;
    cursor: none;
    border: none; border-radius: 999px;
    background: linear-gradient(95deg, #5eead4, #7dd3fc 55%, #a5b4fc);
    box-shadow: 0 12px 34px rgba(94,234,212,.32), inset 0 1px 0 rgba(255,255,255,.7);
    transition: transform .18s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease, filter .2s ease;
  }
  .btn:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 18px 42px rgba(94,234,212,.45); filter: brightness(1.06); }
  .btn:active { transform: translateY(0) scale(.98); }
  .btn.ghost {
    margin-left: 12px;
    color: #cfe3f7;
    background: rgba(125,211,252,.08);
    border: 1px solid rgba(125,211,252,.3);
    box-shadow: none;
  }
  .btn.ghost:hover { background: rgba(125,211,252,.16); box-shadow: 0 12px 30px rgba(0,0,0,.35); }

  /* ==========================================================
     结算面板
     ========================================================== */
  .rank-row { display: flex; align-items: center; justify-content: center; gap: 26px; margin-top: 6px; }
  .rank-badge {
    flex: none;
    width: 116px; height: 116px;
    display: grid; place-items: center;
    font-size: 58px; font-weight: 900;
    color: #04202a;
    border-radius: 50%;
    background: radial-gradient(circle at 34% 28%, #ffffff, var(--rank-color, #fde68a) 62%, rgba(0,0,0,.25));
    box-shadow: 0 0 0 6px rgba(255,255,255,.06), 0 0 44px var(--rank-color, #fde68a);
    animation: badgeIn .75s cubic-bezier(.2,1.5,.4,1) both, badgeFloat 3.2s ease-in-out 0.75s infinite;
  }
  @keyframes badgeIn {
    from { opacity: 0; transform: scale(.2) rotate(-40deg); }
    to   { opacity: 1; transform: scale(1) rotate(0); }
  }
  @keyframes badgeFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
  }
  .score-final { text-align: left; }
  .score-final .cap { font-size: 12px; letter-spacing: .3em; color: #8fb4d9; }
  .score-final .num {
    font-size: clamp(44px, 8vw, 72px); font-weight: 900; line-height: 1;
    font-variant-numeric: tabular-nums;
    background: linear-gradient(92deg, #ffffff, #7dd3fc);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
  }
  .comment { margin-top: 18px; font-size: 15px; color: #a9c8e6; }

  .stats {
    margin: 26px auto 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    max-width: 620px;
  }
  .stat {
    padding: 14px 10px;
    background: rgba(255,255,255,.045);
    border: 1px solid rgba(125,211,252,.16);
    border-radius: 14px;
    animation: statIn .5s ease both;
  }
  @keyframes statIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
  .stat .k { font-size: 11px; letter-spacing: .18em; color: #8fb4d9; }
  .stat .v { margin-top: 6px; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; color: #eaf5ff; }

  .tip { margin-top: 22px; font-size: 12px; letter-spacing: .1em; color: #6f93b8; }

  /* ==========================================================
     开始 / 结算界面上使用的 DOM 狙击镜指针
     Canvas 里绘制的狙击镜会被覆盖层（z-index:20）挡住，
     所以覆盖层显示时改用这个 z-index 更高的 DOM 指针。
     ========================================================== */
  #cursor {
    position: fixed; left: 0; top: 0;
    width: 0; height: 0;
    z-index: 30;
    pointer-events: none;            /* 绝不拦截点击 */
    opacity: 0;
    transition: opacity .16s ease;
    will-change: transform;
  }
  #cursor.visible { opacity: 1; }

  #cursor .ring {
    position: absolute; left: -22px; top: -22px;
    width: 44px; height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(160,215,255,.85);
    box-shadow: 0 0 16px rgba(94,234,212,.5), inset 0 0 12px rgba(125,211,252,.35);
    transition: transform .16s cubic-bezier(.34,1.56,.64,1), border-color .16s ease;
  }
  #cursor .tick { position: absolute; background: rgba(232,245,255,.85); }
  #cursor .tick.t { left: -1px; top: -31px; width: 2px; height: 9px; }
  #cursor .tick.b { left: -1px; top: 22px;  width: 2px; height: 9px; }
  #cursor .tick.l { left: -31px; top: -1px; width: 9px; height: 2px; }
  #cursor .tick.r { left: 22px;  top: -1px; width: 9px; height: 2px; }
  #cursor .dot {
    position: absolute; left: -2.5px; top: -2.5px;
    width: 5px; height: 5px; border-radius: 50%;
    background: #ff4b4b;
    box-shadow: 0 0 10px rgba(255,75,75,.95);
  }
  /* 悬停在按钮上时“锁定”放大，给一点反馈 */
  #cursor.lock .ring { transform: scale(1.5); border-color: rgba(94,234,212,1); }
  #cursor.lock .tick { background: rgba(94,234,212,.95); }

  /* ==========================================================
     昵称输入 & 班级排行榜（Node 版本新增）
     ========================================================== */
  .name-row {
    margin: 24px auto 0;
    display: flex; align-items: center; justify-content: center;
    flex-wrap: wrap; gap: 10px;
  }
  .name-label { font-size: 13px; letter-spacing: .2em; color: #8fb4d9; }
  .name-input {
    width: min(260px, 68vw);
    padding: 12px 16px;
    font-size: 15px; font-family: inherit; color: #eaf5ff;
    background: rgba(9, 17, 29, .85);
    border: 1px solid rgba(125, 211, 252, .28);
    border-radius: 12px;
    outline: none;
    cursor: none;
    transition: border-color .18s ease, box-shadow .18s ease;
  }
  .name-input::placeholder { color: #5d7b9c; }
  .name-input:focus { border-color: rgba(94, 234, 212, .75); box-shadow: 0 0 0 4px rgba(94, 234, 212, .14); }
  .name-input.shake { animation: shake .42s ease; border-color: #f87171; }
  @keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-7px); }
    50%      { transform: translateX(7px); }
    80%      { transform: translateX(-4px); }
  }
  .tip.warn { color: #f8a5a5; }

  .board {
    margin: 24px auto 0;
    max-width: 580px;
    text-align: left;
    padding: 14px 16px 12px;
    background: rgba(9, 17, 29, .6);
    border: 1px solid rgba(125, 211, 252, .16);
    border-radius: 16px;
  }
  .board-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin-bottom: 10px;
  }
  .board-head h2 { font-size: 13px; font-weight: 700; letter-spacing: .22em; color: #9dc2e6; }
  .board-sub { font-size: 12px; color: #6f93b8; }
  .board-refresh {
    font-family: inherit; font-size: 12px; letter-spacing: .1em;
    padding: 5px 14px; color: #cfe3f7; cursor: none;
    background: rgba(125, 211, 252, .08);
    border: 1px solid rgba(125, 211, 252, .28);
    border-radius: 999px;
    transition: background .18s ease, transform .18s ease;
  }
  .board-refresh:hover { background: rgba(125, 211, 252, .2); transform: translateY(-1px); }

  .board-list { list-style: none; display: grid; gap: 6px; }
  .board-list li {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto 52px;
    align-items: center; gap: 10px;
    padding: 8px 10px;
    font-size: 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .035);
  }
  .board-list li .rk { text-align: center; font-weight: 800; color: #7fa6cc; font-variant-numeric: tabular-nums; }
  .board-list li .nm { color: #eaf5ff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .board-list li .sc { font-weight: 800; color: #5eead4; font-variant-numeric: tabular-nums; }
  .board-list li .ac { text-align: right; font-size: 12px; color: #8fb4d9; font-variant-numeric: tabular-nums; }
  .board-list li.empty { display: block; text-align: center; color: #6f93b8; font-size: 13px; padding: 16px 8px; }
  .board-list li.top1 { background: linear-gradient(90deg, rgba(253,230,138,.22), rgba(253,230,138,.04)); box-shadow: inset 0 0 0 1px rgba(253,230,138,.38); }
  .board-list li.top2 { background: linear-gradient(90deg, rgba(203,213,225,.16), rgba(203,213,225,.03)); }
  .board-list li.top3 { background: linear-gradient(90deg, rgba(251,146,60,.18), rgba(251,146,60,.03)); }
  .board-list li.me { box-shadow: inset 0 0 0 1px rgba(94,234,212,.75); animation: meGlow 1.4s ease-in-out 2; }
  @keyframes meGlow { 50% { background: rgba(94,234,212,.22); } }

  .board-status { margin-top: 10px; font-size: 12px; letter-spacing: .06em; color: #6f93b8; }
  .board-status.ok { color: #5eead4; }
  .board-status.error { color: #f8a5a5; }

  .submit-row { margin-top: 18px; display: flex; justify-content: center; }
  .submit-status { font-size: 13px; letter-spacing: .06em; color: #8fb4d9; }
  .submit-status.ok { color: #5eead4; }
  .submit-status.error { color: #f8a5a5; }

  /* 窄屏适配 */
  @media (max-width: 620px) {
    .panel { padding: 26px 20px 24px; border-radius: 20px; }
    .hud-item { min-width: 84px; padding: 6px 11px; }
    .hud-value { font-size: 20px; }
    .timer-box { min-width: 140px; }
    .rank-row { flex-direction: column; gap: 14px; }
    .score-final { text-align: center; }
    .btn { padding: 14px 34px; }
    .board { padding: 12px 12px 10px; }
    .board-list li { grid-template-columns: 24px minmax(0, 1fr) auto 46px; font-size: 13px; gap: 8px; }
    .name-input { width: 60vw; }
  }
