/* 28 - 3D 高空滚球 界面样式（纯原创 CSS） */
:root {
  --bg-0: #0b1c2c;
  --bg-1: #123049;
  --accent: #39c6ff;
  --accent-2: #7dffb0;
  --gold: #ffd24a;
  --danger: #ff5a4d;
  --panel-bg: rgba(10, 26, 40, 0.78);
  --panel-border: rgba(120, 200, 255, 0.28);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  color: #eaf6ff;
  background: linear-gradient(180deg, #5fa8e0 0%, #8ec7ee 42%, #cfe9f7 78%, #e8f6ff 100%);
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

#hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: calc(10px + env(safe-area-inset-top)) 14px 0;
}

.hud-box {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(8, 22, 36, 0.55);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 15px;
  font-weight: 600;
  backdrop-filter: blur(6px);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

#hud-time { color: var(--accent-2); font-variant-numeric: tabular-nums; }
#hud-coins { color: var(--gold); }
#hud-falls { color: #ffb0a8; }

.hud-btn {
  pointer-events: auto;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--panel-border);
  background: rgba(57, 198, 255, 0.18);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}
.hud-btn:active { background: rgba(57, 198, 255, 0.4); }

/* ---------- 触屏控制 ---------- */
#joy-zone {
  position: absolute;
  left: 0;
  top: 70px;
  bottom: 0;
  width: 55%;
  pointer-events: auto;
  display: none;
}

body.touch #joy-zone { display: block; }

#joystick {
  position: fixed;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  background: rgba(10, 26, 40, 0.3);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

#joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #bfe9ff, #39c6ff 70%);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, -50%);
}

#touch-right {
  position: absolute;
  right: 18px;
  bottom: calc(22px + env(safe-area-inset-bottom));
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  pointer-events: auto;
}

body.touch #touch-right { display: flex; }

.touch-btn {
  border: 2px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  background: rgba(10, 26, 40, 0.45);
  cursor: pointer;
  font-weight: 700;
}
.touch-btn.big {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  font-size: 24px;
  background: rgba(57, 198, 255, 0.3);
}
.touch-btn.big:active { background: rgba(57, 198, 255, 0.55); }
.touch-btn.small {
  border-radius: 18px;
  padding: 8px 12px;
  font-size: 13px;
}
.touch-btn.on { background: rgba(125, 255, 176, 0.35); border-color: var(--accent-2); }

/* ---------- 全屏界面 ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 14, 24, 0.45);
  backdrop-filter: blur(4px);
  overflow-y: auto;
  padding: 20px 12px;
}

.panel {
  width: min(420px, 94vw);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 26px 24px;
  text-align: center;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  margin: auto;
}
.panel.wide { width: min(560px, 96vw); }

.title {
  font-size: 42px;
  letter-spacing: 4px;
  background: linear-gradient(180deg, #dff4ff, #39c6ff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 26px rgba(57, 198, 255, 0.35);
}
.title span {
  margin-left: 8px;
  font-size: 22px;
  color: var(--gold);
  -webkit-text-fill-color: var(--gold);
}

.subtitle { margin: 8px 0 14px; font-size: 14px; opacity: 0.85; }

.stats {
  font-size: 14px;
  color: var(--accent-2);
  margin: 6px 0 14px;
  line-height: 1.7;
}
.stats b { color: #fff; }

h2 {
  font-size: 26px;
  margin-bottom: 16px;
  letter-spacing: 3px;
}

.btn-col { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }

.btn {
  padding: 13px 18px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: rgba(57, 198, 255, 0.12);
  color: #eaf6ff;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 2px;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s;
}
.btn:hover { background: rgba(57, 198, 255, 0.28); }
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: linear-gradient(180deg, #2fb7f2, #1585c4);
  border-color: #6fd8ff;
  box-shadow: 0 4px 18px rgba(47, 183, 242, 0.4);
}
.btn.primary:hover { background: linear-gradient(180deg, #4cc6f7, #1a94d8); }

.help {
  margin-top: 16px;
  font-size: 12px;
  line-height: 1.9;
  opacity: 0.75;
  text-align: left;
}

/* ---------- 关卡选择 ---------- */
#level-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}

.level-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 6px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: rgba(57, 198, 255, 0.1);
  color: #eaf6ff;
  cursor: pointer;
  min-height: 86px;
}
.level-btn:hover { background: rgba(57, 198, 255, 0.26); }
.level-btn .lv-num {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
}
.level-btn .lv-name { font-size: 12px; }
.level-btn .lv-best { font-size: 11px; opacity: 0.8; line-height: 1.5; }
.level-btn.locked {
  filter: grayscale(0.9);
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---------- 皮肤选择 ---------- */
#skin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 8px;
}

.skin-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 6px;
  border-radius: 12px;
  border: 2px solid var(--panel-border);
  background: rgba(57, 198, 255, 0.08);
  color: #eaf6ff;
  cursor: pointer;
}
.skin-btn.sel {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(255, 210, 74, 0.4);
}
.skin-btn .skin-name { font-size: 13px; }

.skin-preview {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  box-shadow: inset -6px -8px 14px rgba(0, 0, 0, 0.35), 0 4px 10px rgba(0, 0, 0, 0.4);
}
.skin-0 { background: radial-gradient(circle at 35% 30%, #ff9a7a, #e8492f 55%, #8c1e08); }
.skin-1 { background: radial-gradient(circle at 35% 30%, #8dffd0, #1fbf7a 55%, #0a5c38); }
.skin-2 { background: radial-gradient(circle at 35% 30%, #9ecfff, #2b6fd6 55%, #123c7a); }
.skin-3 { background: radial-gradient(circle at 35% 30%, #ffffff, #c9d4de 45%, #5f6d7a); }
.skin-4 { background: radial-gradient(circle at 35% 30%, #e6b3ff, #9b30ff 55%, #3d0a66); box-shadow: 0 0 18px rgba(155, 48, 255, 0.7); }
.skin-5 { background: radial-gradient(circle at 35% 30%, #e8bf8a, #a06a35 55%, #5c3715); }

/* ---------- 结算 ---------- */
#win-medal { font-size: 58px; margin: 6px 0; }
.record {
  color: var(--gold);
  font-weight: 800;
  margin-left: 6px;
  animation: pulse 0.9s infinite alternate;
}
@keyframes pulse { from { opacity: 0.6; } to { opacity: 1; } }

/* ---------- 提示 / 特效 ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 22%;
  transform: translateX(-50%);
  z-index: 40;
  background: rgba(8, 22, 36, 0.85);
  border: 1px solid var(--accent-2);
  color: var(--accent-2);
  border-radius: 20px;
  padding: 10px 22px;
  font-size: 16px;
  font-weight: 700;
  pointer-events: none;
}
#toast.show { animation: toastIn 1.8s forwards; }
@keyframes toastIn {
  0% { opacity: 0; transform: translateX(-50%) translateY(16px); }
  12% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

#flash {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(255, 40, 30, 0.55) 100%);
}
#flash.go { animation: flashGo 0.7s ease-out; }
@keyframes flashGo {
  0% { opacity: 0; }
  18% { opacity: 1; }
  100% { opacity: 0; }
}

#loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #0b1c2c, #123049);
  font-size: 17px;
  letter-spacing: 2px;
  color: var(--accent);
}

/* ---------- 小屏适配 ---------- */
@media (max-width: 480px) {
  .title { font-size: 32px; }
  .hud-box { font-size: 13px; gap: 9px; padding: 7px 10px; }
  #level-grid, #skin-grid { grid-template-columns: repeat(2, 1fr); }
  .panel { padding: 20px 16px; }
}
