/* =============================================================
   styles.css — HTML 叠加层样式（卡通游戏风按钮 + 暗色面板）
   ============================================================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b0f16;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei',
    'Segoe UI', sans-serif;
  color: #fff;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  /* 触屏拖拽时禁止页面滚动/缩放手势，防止选中 */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* 顶部信息栏 */
#hud {
  position: fixed;
  top: 16px;
  left: 16px;
  padding: 12px 18px;
  border-radius: 14px;
  background: rgba(12, 16, 24, 0.72);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  user-select: none;
}

#hud .title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
}

#hud .title svg {
  width: 20px;
  height: 20px;
  color: #ffe600;
}

#hud .stats {
  margin-top: 6px;
  font-size: 14px;
  display: flex;
  gap: 16px;
  opacity: 0.9;
}

#hud b {
  color: #ffe600;
}

/* 规则面板 */
#rules {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 300px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.7;
  border-radius: 14px;
  background: rgba(12, 16, 24, 0.88);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  z-index: 5;
}

#rules h3 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 15px;
}

#rules h3 svg {
  width: 16px;
  height: 16px;
}

#rules ol {
  padding-left: 18px;
}

#rules li {
  margin-bottom: 4px;
}

#rules .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

/* 底部控制栏 */
#controls {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-radius: 20px;
  background: rgba(12, 16, 24, 0.72);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  z-index: 5;
}

/* 卡通游戏按钮：厚底边 + 按压下沉；默认统一灰色，不抢主按钮视觉 */
#controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 52px;
  height: 52px;
  padding: 0 12px;
  border: none;
  border-radius: 16px;
  background: #64748b;
  color: #fff;
  font: inherit;
  cursor: pointer;
  flex-shrink: 0; /* 窄屏下按钮不被压缩变形 */
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}

#controls button:hover:not(:disabled) {
  filter: brightness(1.12);
}

#controls button:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

#controls button:disabled {
  filter: grayscale(0.85) brightness(0.65);
  cursor: not-allowed;
}

#controls svg {
  width: 24px;
  height: 24px;
}

/* 主按钮：默认灰（禁用态），球填满后绿色高亮 */
#btn-confirm {
  min-width: 0;
  padding: 0 16px;
  gap: 6px;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap; /* "我确认" 文字不换行 */
}

#btn-confirm:not(:disabled) {
  background: #22c55e;
}

#btn-difficulty {
  font-size: 20px;
  font-weight: 800;
}

#btn-difficulty svg {
  width: 18px;
  height: 18px;
}

/* 结算横幅：左上角浮层，不遮挡棋盘；容器不拦截鼠标，仅按钮可点 */
#banner {
  position: fixed;
  top: 92px;
  left: 16px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(12, 16, 24, 0.78);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  z-index: 10;
  pointer-events: none;
}

#banner-text {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}

#banner-text svg {
  width: 28px;
  height: 28px;
  color: #ffe600;
}

#banner button {
  pointer-events: auto;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  padding: 8px 18px;
  background: #3b82f6;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}

#banner button:hover {
  filter: brightness(1.12);
}

#banner button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.hidden {
  display: none !important;
}

/* ---------- 弹窗（通关记名 / 排行榜） ---------- */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 8, 14, 0.45); /* 轻遮罩，隐约能看到棋盘 */
  z-index: 20;
}

.modal-card {
  width: 360px;
  max-width: calc(100vw - 32px);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 20px;
  border-radius: 20px;
  background: rgba(15, 20, 30, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modal-pop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1); /* 弹入 */
}

@keyframes modal-pop {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  margin-bottom: 4px;
}

.modal-card h3 svg {
  width: 22px;
  height: 22px;
  color: #ffe600;
}

.modal-sub {
  font-size: 13px;
  opacity: 0.75;
  margin-bottom: 14px;
}

#win-name {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  outline: none;
  margin-bottom: 16px;
}

#win-name:focus {
  border-color: #22c55e;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  padding: 10px 18px;
  background: #64748b;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}

.modal-actions button:hover {
  filter: brightness(1.12);
}

.modal-actions button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.modal-actions button.primary {
  background: #22c55e;
}

.modal-actions button.danger {
  background: #475569;
  margin-right: auto; /* 清空按钮靠左，远离主操作 */
}

.modal-actions button.danger.armed {
  background: #ef4444; /* 二次确认态变红 */
}

.modal-actions svg {
  width: 16px;
  height: 16px;
}

/* 排行榜列表 */
#lb-list {
  overflow-y: auto;
  margin-bottom: 16px;
  font-size: 14px;
}

.lb-row {
  display: grid;
  grid-template-columns: 34px 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
}

.lb-row:nth-child(odd) {
  background: rgba(255, 255, 255, 0.05);
}

.lb-rank {
  font-weight: 800;
  text-align: center;
}

.lb-row:nth-child(1) .lb-rank {
  color: #ffd700;
}

.lb-row:nth-child(2) .lb-rank {
  color: #c0c0c0;
}

.lb-row:nth-child(3) .lb-rank {
  color: #cd7f32;
}

.lb-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.lb-rounds,
.lb-time,
.lb-diff {
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}

.lb-diff {
  padding: 1px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 12px;
}

.lb-empty {
  text-align: center;
  padding: 24px 0;
  opacity: 0.65;
}

/* ---------- 手机端适配（窄屏） ---------- */
@media (max-width: 520px) {
  #hud {
    top: 10px;
    left: 10px;
    padding: 8px 12px;
  }

  #hud .title {
    font-size: 14px;
  }

  #hud .title svg {
    width: 16px;
    height: 16px;
  }

  #hud .stats {
    font-size: 12px;
    gap: 10px;
  }

  #controls {
    gap: 8px;
    padding: 10px;
    bottom: 10px;
  }

  #controls button {
    min-width: 46px;
    height: 46px;
    border-radius: 14px;
    padding: 0 10px;
  }

  #controls svg {
    width: 20px;
    height: 20px;
  }

  #controls #btn-confirm {
    min-width: 0;
    padding: 0 14px;
    font-size: 15px;
  }

  #btn-difficulty {
    font-size: 17px;
  }

  /* 规则面板改为底部抽屉，避免挡住顶部信息栏 */
  #rules {
    top: auto;
    right: 16px;
    left: 16px;
    bottom: 74px;
    width: auto;
    max-height: 45vh;
    overflow-y: auto;
  }

  #banner {
    top: 70px;
    left: 10px;
    max-width: calc(100vw - 20px);
    padding: 10px 12px;
  }

  #banner-text {
    font-size: 15px;
  }

  #banner-text svg {
    width: 22px;
    height: 22px;
  }

  /* 弹窗在窄屏下更紧凑 */
  .modal-card {
    padding: 16px;
  }

  .lb-row {
    grid-template-columns: 28px 1fr auto auto;
    font-size: 13px;
  }

  .lb-diff {
    display: none; /* 窄屏隐藏难度徽章，优先保住名字/轮次/用时 */
  }
}
