:root {
  color-scheme: dark;
  --ink: #fff8df;
  --muted: rgba(255, 248, 223, 0.68);
  --panel: rgba(20, 24, 47, 0.58);
  --panel-strong: rgba(16, 20, 38, 0.8);
  --cyan: #65f7ff;
  --peach: #ffb36b;
  --rose: #ff6b9e;
  --mint: #7dffb5;
  --gold: #ffe66d;
  --shadow: rgba(0, 0, 0, 0.32);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #11192f;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

button {
  font: inherit;
}

#gameShell {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 12%, rgba(255, 221, 115, 0.26), transparent 34%),
    linear-gradient(180deg, #7a76ff 0%, #36c3e8 45%, #ffb061 100%);
}

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

.hud {
  position: absolute;
  z-index: 5;
  pointer-events: none;
}

.hud-top {
  top: max(16px, env(safe-area-inset-top));
  left: clamp(14px, 3vw, 34px);
  right: clamp(14px, 3vw, 34px);
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto auto;
  align-items: center;
  gap: 14px;
}

.brand,
.meters,
.control-chip,
.icon-btn,
.message-panel {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: var(--panel);
  box-shadow: 0 18px 44px var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  width: fit-content;
  max-width: 100%;
  gap: 12px;
  border-radius: 8px;
  padding: 10px 14px 10px 10px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 8px;
  background:
    linear-gradient(135deg, var(--gold), var(--peach) 48%, var(--rose)),
    linear-gradient(45deg, transparent 44%, rgba(255, 255, 255, 0.58) 45% 55%, transparent 56%);
  box-shadow: 0 0 22px rgba(255, 229, 109, 0.55);
}

.brand strong {
  display: block;
  font-size: 15px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand span:last-child {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.meters {
  display: grid;
  grid-template-columns: repeat(3, minmax(82px, 1fr));
  gap: 8px;
  border-radius: 8px;
  padding: 8px;
}

.meter {
  min-width: 0;
  padding: 7px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.09);
}

.meter span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.meter strong {
  display: block;
  margin-top: 2px;
  font-size: 18px;
  line-height: 1;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.icon-btn {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  pointer-events: auto;
}

.message-panel {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: clamp(92px, 12vh, 140px);
  width: min(520px, calc(100vw - 32px));
  border-radius: 8px;
  padding: clamp(18px, 3vw, 28px);
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
}

.message-panel::after {
  content: "加载失败时请刷新页面，或检查网络是否能访问页面资源。";
  display: block;
  margin-top: 14px;
  color: rgba(255, 248, 223, 0.42);
  font-size: 12px;
  line-height: 1.5;
}

.message-panel.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.panel-copy {
  max-width: 460px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 7vw, 66px);
  line-height: 0.95;
  letter-spacing: 0;
}

.message-panel p:not(.eyebrow) {
  margin: 14px 0 0;
  max-width: 44ch;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

.panel-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.primary-btn,
.secondary-btn {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: #13213b;
  font-weight: 800;
  cursor: pointer;
}

.primary-btn {
  background: linear-gradient(135deg, var(--gold), var(--peach));
  box-shadow: 0 12px 30px rgba(255, 179, 107, 0.32);
}

.secondary-btn {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.is-hidden {
  display: none;
}

.hud-bottom {
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  transform: translateX(-50%);
}

.control-chip {
  border-radius: 999px;
  padding: 9px 13px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .hud-top {
    grid-template-columns: 1fr auto;
    gap: 10px;
  }

  .brand {
    padding: 8px 10px 8px 8px;
  }

  .brand span:last-child {
    display: none;
  }

  .meters {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    grid-template-columns: repeat(3, 1fr);
  }

  .meter {
    padding: 7px 8px;
  }

  .meter strong {
    font-size: 17px;
  }

  .message-panel {
    bottom: clamp(86px, 15vh, 130px);
  }

  .hud-bottom {
    width: calc(100vw - 28px);
    justify-content: center;
    flex-wrap: wrap;
  }

  .control-chip {
    padding: 8px 10px;
    font-size: 11px;
  }
}

@media (max-width: 440px) {
  .hud-top {
    left: 10px;
    right: 10px;
  }

  .brand strong {
    font-size: 13px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
  }

  .icon-btn {
    width: 42px;
    height: 42px;
  }

  .message-panel {
    padding: 18px;
  }

  .panel-actions {
    flex-direction: column;
  }

  .primary-btn,
  .secondary-btn {
    width: 100%;
  }
}
