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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0e1420;
  font-family: "Trebuchet MS", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100vh;
  object-fit: contain;
  touch-action: none;
  cursor: grab;
}

#game:active {
  cursor: grabbing;
}

#hud {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  gap: 10px;
  pointer-events: none;
  flex-wrap: wrap;
}

.hud-item {
  display: flex;
  flex-direction: column;
  min-width: 84px;
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(12, 20, 34, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.hud-label {
  font-size: 12px;
  opacity: 0.78;
  letter-spacing: 1px;
}

.hud-item > span:last-child {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

#controls {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 10px;
}

#controls button,
.panel-actions button {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(12, 20, 34, 0.6);
  backdrop-filter: blur(6px);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}

#controls button:hover,
.panel-actions button:hover {
  background: rgba(30, 48, 78, 0.8);
}

#controls button:active,
.panel-actions button:active {
  transform: scale(0.96);
}

#hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 9px 18px;
  border-radius: 20px;
  background: rgba(12, 20, 34, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  letter-spacing: 0.5px;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

#hint.hidden {
  opacity: 0;
}

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 12, 22, 0.55);
  backdrop-filter: blur(4px);
  transition: opacity 0.25s ease;
}

#overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.panel {
  width: min(90vw, 420px);
  padding: 28px 26px;
  border-radius: 20px;
  text-align: center;
  color: #fff;
  background: linear-gradient(160deg, rgba(38, 58, 92, 0.96), rgba(18, 28, 46, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.panel h1 {
  font-size: 30px;
  margin-bottom: 12px;
  color: #ffd54a;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.panel p {
  font-size: 16px;
  line-height: 1.6;
  opacity: 0.9;
  margin-bottom: 22px;
}

.panel-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.panel-actions #primaryBtn {
  background: linear-gradient(160deg, #ff8a3d, #e8541f);
  border-color: rgba(255, 255, 255, 0.35);
}

.panel-actions #secondaryBtn {
  background: rgba(255, 255, 255, 0.12);
}

@media (max-width: 640px) {
  .hud-item {
    min-width: 66px;
    padding: 6px 10px;
  }
  .hud-item > span:last-child {
    font-size: 18px;
  }
  #controls button {
    font-size: 13px;
    padding: 8px 12px;
  }
  #hint {
    font-size: 12px;
    bottom: 12px;
  }
}
